Strange CG Behaviour

Hi guys,

I encountered some really strange errors today from my CG program in my Surface Shader.
Here’s what I mean:

Works.

o.Albedo = tex2D(_WaterBase, i.uv_WaterBase).rgb;
o.Alpha = 1;

Works.

o.Albedo = 1;
o.Alpha = i.uv_WaterBase.r;

Does not work.

o.Albedo = tex2D(_WaterBase, i.uv_WaterBase).rgb;
o.Alpha = i.uv_WaterBase.r;

The first one uses the texture coords to determine color, and has a constant alpha.
The second one uses the texture coords to determine alpha, and has a constant color.
The third one tries to use the texture coords to determine both color AND alpha,
but it ends up being completely transparent.

Also, I can’t use the isnan function. Even when I call isnan(1.0), it says there is no
matching overloaded function found!

This is all very frustrating. Could someone please lend a hand?

Can you post full shader that has those problems?

About the isnan - what is the exact error you’re getting? And does it go away if you add “#pragma exclude_renderers gles” to the shader? It might be that we did not add support for this function to the GLSL cross-compiler. FYI, not all GPUs support full IEEE floats, so relying on NaNs, denormals other funky things might not work depending on the GPU.

Thank you, Aras. It’s solved now. Turns out the sample tiling factor was the problem. :slight_smile: