IRCSS

Triplanar Mapping in Shader

Aug 4th, 2019
657
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  float4 Triplanar(sampler2D Texture, float Tiling, float3 offset, float3 Pos, float3 Normals) {
  2.     float4 albedoX = tex2D(Texture, Pos.zy*Tiling + offset.zy);
  3.     float4 albedoY = tex2D(Texture, Pos.xz*Tiling + offset.xz);
  4.     float4 albedoZ = tex2D(Texture, Pos.xy*Tiling + offset.xy);
  5.  
  6.     float3 triW = abs(Normals);
  7.     triW /= (triW.x + triW.y + triW.z);
  8.     return albedoX * triW.x + albedoY * triW.y + albedoZ * triW.z;
  9.    }
RAW Paste Data