Hi, I’m trying to adapt this shader from Harry Alisavakis to work with HDRP:
I’ve created a custom sky and all those requirements but I cannot get the actual shader to work.
I tried to simplify the shader to only use a gradient and nothing else but it also didn’t work.
I then tried to convert the simplified version to HLSL and to look similar to how the HDRP Gradient sky is working but keeping the math from Harrys shader. This also didn’t work and resulted in only the bottom gradient being shown.
I tried to convert and only use this part of the fragment shader from Harry:
float2 uv = float2(atan2(i.uv.x,i.uv.z) / UNITY_TWO_PI, asin(i.uv.y) / UNITY_HALF_PI);
float middleThreshold = smoothstep(0.0, 0.5 - (1.0 - _MiddleSmoothness) / 2.0, i.uv.y - _MiddleOffset);
float topThreshold = smoothstep(0.5, 1.0 - (1.0 - _TopSmoothness) / 2.0 , i.uv.y - _TopOffset);
fixed4 col = lerp(_ColorBottom, _ColorMiddle, middleThreshold);
col = lerp(col, _ColorTop, topThreshold);
My Code looks something like this when in HLSL form
float2 uv = float2(atan2(i.uv.x,i.uv.z) / TWO_PI, asin(i.uv.y) / HALF_PI);
float middleThreshold = smoothstep(0.0, 0.5 - (1.0) / 2.0, i.uv.y );
float topThreshold = smoothstep(0.5, 1.0 - (1.0) / 2.0 , i.uv.y );
float4 col = lerp(_ColorBottom, _ColorMiddle, middleThreshold);
col = lerp(col, _ColorTop, topThreshold);
return col;
Hence my question is: Does the vertex shader actually pass proper UV data for the skybox in HDRP?
I’m not really shader-savy but I’m trying to learn!
All the best,
Tim