I sample 3 times the same texture and The UV are created with the world position.
Code sample:
.......The normals are used to lerp the textures.
float2 uvX = pos.yz;
float2 uvY = pos.zx;
float2 uvZ = pos.xy;
float4 textureX = tex2D(texSampler, uvX);
float4 textureY = tex2D(texSampler, uvY);
float4 textureZ = tex2D(texSampler, uvZ);
......
......
float maskY = smoothstep(0.5f, 0.8f, abs(normal.y));
float maskZ = smoothstep(0.5f, 0.8f, abs(normal.z));
float4 finalLerp = lerp(textureX, textureY, maskY);
finalLerp = lerp(final, textureZ, maskZ);
......
This technique is more suitable for organic materials.
Video of the hlsl shader in 3dsmax
Video of the hlsl shader in 3dsmax
No comments:
Post a Comment