trying to update texture sprites in single pass but didn't work.
and how about discard; ? it also returns 0.
texture2D SpriteTex { Width = 300; Height = 1; Format = R16F;};
sampler2D SpriteSampler { Texture = SpriteTex; };
void VS_Sprite(in uint id : SV_VertexID, out float4 pos : SV_Position, out float2 texcoord : TEXCOORD)
{
float2 vpos = float2(-1, 1);
vpos.y = (id == 1)? -3 : vpos.y;
vpos.x = (id == 2)? 3 : vpos.x;
vpos.x = vpos.x / 30 + (frac(RFX_timer * 0.001 / 20) * 2 - 1);
texcoord = 0.5;
pos = float4(vpos.xy, 0.0, 1.0);
}
float PS_Sprite(in float4 position : SV_Position, in float2 texcoord : TEXCOORD0) : SV_Target0
{ return 1; }
// Fullscreen Triangle Vertex Shader
void VS_PostProcess(in uint id : SV_VertexID, out float4 pos : SV_Position, out float2 texcoord : TEXCOORD)
{
texcoord.x = (id == 2) ? 2.0 : 0.0;
texcoord.y = (id == 1) ? 2.0 : 0.0;
pos = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
float PS_SpriteTest(in float4 position : SV_Position, in float2 texcoord : TEXCOORD0) : SV_Target0
{
if(texcoord.y > 0.5) discard;
return tex2D(SpriteSampler, texcoord);
}
technique Sprite < enabled = true;>
{
pass
{
VertexShader = VS_Sprite;
PixelShader = PS_Sprite;
RenderTarget = SpriteTex;
}
pass
{
VertexShader = VS_PostProcess;
PixelShader = PS_SpriteTest;
}
}