Outside VS triangle

  • kingeric1992
  • Topic Author
More
8 years 2 months ago - 8 years 2 months ago #1 by kingeric1992 Outside VS triangle was created by kingeric1992
content out of the triangle always return 0 regardless of previous input?
trying to update texture sprites in single pass but didn't work.

and how about discard; ? it also returns 0.

demo code
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;
    }    
}
Last edit: 8 years 2 months ago by kingeric1992.

Please Log in or Create an account to join the conversation.

  • crosire
More
8 years 2 months ago #2 by crosire Replied by crosire on topic Outside VS triangle
All bound rendertargets are cleared to zero before the pixelshader is executed, so this is expected.

Please Log in or Create an account to join the conversation.

  • kingeric1992
  • Topic Author
More
8 years 2 months ago #3 by kingeric1992 Replied by kingeric1992 on topic Outside VS triangle
ok.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.