Hey everyone! I am new to programming shaders, and I have an issue when making triplanar textures.
What I am doing is to implement the shader graph in this video as ShaderLab.
Iridescent Bubble Shader - Advanced Materials - Episode 19 (youtube.com)
Everything works fine except the triplanar node. I have followed the official document of triplanar nodes to implement a function for it. But my code still doesn’t work. Triplanar Node | Shader Graph | 6.9.2 (unity3d.com)
Here’s my function:
float4 SampleTriplanarTexture(float3 worldPos, float3 worldNormal, sampler2D tex, float Tile, float blend)
{
float3 Node_UV = worldPos * Tile;
float3 Node_Blend = pow(abs(worldNormal), blend);
Node_Blend /= dot(Node_Blend, 1.0);
float4 Node_X = tex2D(tex, Node_UV.zy);
float4 Node_Y = tex2D(tex, Node_UV.xz);
float4 Node_Z = tex2D(tex, Node_UV.xy);
return Node_X * Node_Blend.x + Node_Y * Node_Blend.y + Node_Z * Node_Blend.z;
}
Where I plug in worldPos and worldNormal with the world position and normal of each fragment.
It would be appreciated if anyone has done something with triplanar shader code and provide some insights!
Thanks!