Question by
Corey Cole · Jun 06, 2016 at 07:22 PM ·
error messageshader programmingfloating point
Floating point error message in shader
I'm using a 3rd party shader. I don't notice any issues in the Unity editor (although I probably didn't open a scene that uses the shader). This code compiles cleanly for OSX, but gave an error message - "unknown variable 'f'" - at the line "float avg = (orgCol.r + orgCol.g + orgCol.b)/3f;" when I compiled for Windows 64-bit.
Changing the "3f" to "3.0f" eliminated the compilation error. All the documentation I've seen suggests that 3f is legal floating point scalar syntax. Has anyone else seen this issue?
//Our Fragment Shader
fixed4 frag (v2f i) : COLOR{
fixed4 orgCol = tex2D(_MainTex, i.uv); //Get the orginal rendered color
//Make changes on the color
float avg = (orgCol.r + orgCol.g + orgCol.b)/3f;
fixed4 col = fixed4(avg, avg, avg, 1);
return col;
}
Comment
Needing to specify the decimal place in floats become a thing when DX11 came out, I think.