hlsl – Color pixel based on condition?

I'm creating a PixelShader in which I only want to render specific pixels based on a condition. In this case, the condition is "hour". Every Vertex in my object has a float value that represents a point in time; in my control form I have a Tracking bar control that is locked to the minimum and maximum points of time in my object. This allows me to see only the vertices that are "live"At the specified point in time, the pixel shader I came up with is quite simple:

float4 PSMain (input PixelShaderInput): SV_Target {
float4 result = 0;
if (IgnoreTime) {
if (HasTexture && input.TextureUV[0] ! = -9999)
result = Texture0.Sample (Sampler, input.TextureUV);
plus
result = input.Diffuse;
}
else {
if (input.Time <= CurrentTime) {
if (HasTexture && input.TextureUV[0] ! = -9999)
result = Texture0.Sample (Sampler, input.TextureUV);
plus
result = input.Diffuse;
}
plus
result = float4 (0, 1, 0, 1);
}

return result
}

The property IgnoreTime is established in the ObjectBuffer while the Current time is established independently (later to expand) TimeBuffer. Again, these are simple, so I know they are not the problem.

I think either a value is wrong, or the shader is not doing what I think he is doing. I have crossed the DO# side and all the values ​​are aligned correctly; when I update the TimeBufferreflects the Tracking bar value, and when I update the ObjectBuffer reflects the IgnoreTime property in the object that is set in false. When I create the object, I correctly assign the correct time values ​​to each one Vertex. I can not go through the shading code and, therefore, I am confused about what is happening.


To update

I decided to continue analyzing the problem and changed the color back to green in case the pixel was not rendered. The object is now displayed in solid green regardless of the position in the Tracking bar control. I think this may be a problem between In t Y float, but since float can accept easily In t I do not see why that would be a problem.

  • I tried to convert to In t; This did nothing.

Questions

The way I've written the shader, I think it's setting up a completely transparent color, then if the current object should not ignore the time, and the time for the current pixel is less than or equal to the current time in the buffer, then set the result in the specified color instead; Finally, return the result. It seems simple enough, but the object is not represented on the screen (unless it is always completely transparent).

  • Is there something I'm forgetting to do here?
  • Is the HLSL Code doing what I think it is doing?