Yesterday I find a variable _ScreenParams.x
It was strange ,though I now figure out what it means (thks to spraycanmansam).
I tried to log it out in the console .the code somehow looks like following
Properties{
.........
logVar ("used for log" , float) = 0
}
fixed4 frag(appdata_full IN) : COLOR
{
........
logVar = _ScreenParams.x;
}
}
then I put a script for logging on this gameObject
FixedUpdate( or PostRender)
{
print(renderer.material.GetFloat("logVar");
}
problem is : its always zero! like it has never been assigned. where is the problem?
Im afraid properties are strictly a one way street. You can send data to the shader from a script but you can not write into the property and send it back to the script.
Remember that multiple instances of your fragment shader will be run, one for each fragment generated by the GPU and this could be hundreds if not thousands of fragments. So the question is, if you could do this and you write into the property from the fragment shader which result out all these fragments generated would end up in the property?
There is no way to tell which is why (among many others) this is not possible.
The reason “GetFloat” exists as a function is the it is sometimes useful to find out what you have set the value to using “SetFloat”.