Hi,
I added a '.hlsl’ file with some common functions. I also wanted to get some global parameters in there to later set them with Shader.SetGlobal method calls.
HLSL globals:
uniform float _gWaterPlaneY = 405.9467;
uniform float _gFogDistance = 4;
uniform float _gDirectSunlightMaxDepth = 160;
uniform float3 _gTurbidityColor = float3(0.0999, 0.203, 0.22);
uniform float3 _gAbsorptionColor = float3(1, 0.8, 0.7);
C# Update code:
private static readonly int WaterPlaneY = Shader.PropertyToID("_gWaterPlaneY");
private static readonly int DirectSunlightMaxDepth = Shader.PropertyToID("_gDirectSunlightMaxDepth");
private static readonly int FogDistance = Shader.PropertyToID("_gFogDistance");
private static readonly int TurbidityColor = Shader.PropertyToID("_gTurbidityColor");
private static readonly int AbsorptionColor = Shader.PropertyToID("_gAbsorptionColor");
Shader.SetGlobalFloat(WaterPlaneY, _waterPlaneY);
Shader.SetGlobalFloat(DirectSunlightMaxDepth, _directSunlightMaxDepth);
Shader.SetGlobalFloat(FogDistance, _fogDistance);
Shader.SetGlobalColor(TurbidityColor, _turbidityColor);
Shader.SetGlobalColor(AbsorptionColor, _absorptionColor);
However, only last ‘float’ parameter works, same applies with ‘float3’ params.
When I simply switch last two float params in HLSL code, then again, the last one works while the previous one that used to be the first and was working, stops working.
What the heck?