I am creating a PixelShader
in which I only want to render specific pixels based on a condition. In this case, the condition is “time“. Each Vertex
in my object has a float
value representing a point in time; on my controlling form I have a TrackBar
control which is locked to the minimum and maximum points of time in my object. This allows me to view only the vertices that are “alive” at the specified point in time. The pixel shader I came up with is rather straight-forward:
float4 PSMain(PixelShaderInput input) : SV_Target { float4 result = 0; if (!IgnoreTime) { if (input.Time <= CurrentTime) result = input.Diffuse; } return result; }
The property IgnoreTime
is set on the ObjectBuffer
while the CurrentTime
is set in a standalone (later to be expanded) TimeBuffer
. Again, these are straight-forward so I know they aren’t the issue.
I believe either a value is incorrect, or the shader isn’t doing what I think it’s doing. I have stepped through the C#
side and all of the values are lining up properly; when I update the TimeBuffer
, it reflects the TrackBar
value, and when I update the ObjectBuffer
it reflects the IgnoreTime
property on the object which is set to false
. When I create the object, I properly assign the correct time values to each Vertex
. I am unable to step through the shader code and so I am confused as to what is going on.
Questions
The way I’ve written the shader, I believe it is setting up a completely transparent color, then if the current object shouldn’t ignore time, and the time for the current pixel is less than or equal to the current time in the buffer, then set the result to the specified color instead; finally, return the result. Seems simple enough, but the object doesn’t render to the screen at all (unless it’s always completely transparent).
- Is there something I am forgetting to do here?
- Is the
HLSL
code doing what I believe it to be doing?