- Home /
How to make shader supporting normal maps with worldPos based UV-mapping?
So I have a mesh generated through script and it's fairly impossible to UV-map it. Instead I made a custom surface shader that samples texture from worldPos.xy|xz|yz projections, then blends them based on worldNormal and now I want the same thing for normal maps, however, if I use worldNormal I have to add "INTERNAL_DATA" to change o.Normal and I basically can't figure out how to use o.Normal with "INTERNAL_DATA" and normal map samples achieved through this function:
float3 projectXYZ (sampler2D tex, float3 pos, float3 norm, float scale, float3 tint) {
float3 scaledPos = pos / scale;
float3 blendAxes = abs(norm);
blendAxes /= blendAxes.x + blendAxes.y + blendAxes.z;
float3 xProjection = tex2D(tex, scaledPos .yz) * blendAxes.x;
float3 yProjection = tex2D(tex, scaledPos .xz) * blendAxes.y;
float3 zProjection = tex2D(tex, scaledPos .xy) * blendAxes.z;
return (xProjection + yProjection + zProjection) * tint;
}
In other words, this function samples normal map, how do I make a use of it?
Your answer
Follow this Question
Related Questions
Folded UV's results in difference in shading of normals? 0 Answers
Problem with Normal Maps 1 Answer
Surface Shader World Normal 0 Answers
Can I unpack normal / tangent / uv information in the vertex function in a surface shader? 1 Answer
How to make a conditional #pragma surface noforwardadd 1 Answer