- Home /
Question by
djweinbaum · Mar 31, 2017 at 02:42 PM ·
shadermathshaderlabshader writingsurface shader
Project UVs from arbitrary direction vector in shader
I'd like to draw a moon disc in a skybox shader, but I don't know how to sample the texture so the moon shows up in the correct position in the sky. I have a perfectly spherical skybox mesh. The following kind of works (no idea how or why) but the moon gets distorted toward the z directions.
float2 moonUV = (IN.worldPos - _MoonDirection.xyz).xy * .002;
half4 moon = tex2D(_MoonDiffuse, moonUV);
o.Normal = UnpackNormal(tex2D(_MoonNormal, IN.uv2_MoonDiffuse));
c = lerp(c, moon, moon.a);
Can anyone point me in the right direction?
Comment
Your answer
Follow this Question
Related Questions
Shader - What is float3.xy? 1 Answer
Scene Depth Node, find depth value from x/y position of camera frame 1 Answer
How can I add Color property To This Shader 1 Answer
Surface shader changing z value 0 Answers
viewDir changes with o.Normal 1 Answer