I'm pretty much a HLSL n00b, and what I'm trying to do is alter a global (uniform) variable inside a shader, and get the post-render value using
TVShader.GetEffectParamBoolean(string).
Apparently, I mistakenly thought that I could do this like so:
// HLSL
bool myBool = false;
float4 ps_main(PS_INPUT input) : COLOR0 {
myBool = true;
return float4(0.0f, 0.0f, 0.0f, 0.0f);
}
// C#
// ... render some stuff using shader above...
bool result = myTVShader.GetEffectParamBoolean("myBool");
... But no matter what,
result always evaluates to
false.
The same thing happens if I do this:
// HLSL
bool myBool = true;
float4 ps_main(PS_INPUT input) : COLOR0 {
myBool = true;
return float4(0.0f, 0.0f, 0.0f, 0.0f);
}
// C#
myTVShader.SetEffectParamBoolean("myBool", false);
// ... render some stuff using shader above...
bool result = myTVShader.GetEffectParamBoolean("myBool");
In other words, I'm able to get the value of
myBool only as defined during its declaration, or via
TVShader.SetEffectParamBoolean(string, bool) -- which actually seem to be effectively one and the same.
How can I pass a change to
myBool from within the pixel shader function to my C# code?