- Home /
tangent space viewDir in a SurfaceShader
There is probably not much more I can say about that. I'm trying to get the tangent space view direction in a surface shader (in the surf() function) but I can't seem to figure out how, so after searching for a solution for quite some time I'm coming back here to ask you guys.
The last thing I got (after a few other iterations that didn't work) is this:
struct Input {
// [...]
float3 worldTangentDir : TEXCOORD0;
};
void vert (inout appdata_full v, out Input o) {
// [...]
TANGENT_SPACE_ROTATION; // create rotation matrix
o.worldTangentDir = mul( rotation, ObjSpaceViewDir( v.vertex ) );
}
void surf (Input IN, inout SurfaceOutputStandard o) {
// [...]
o.Albedo = abs(IN.worldTangentDir);
}
What I expect would be to see different colors on my mesh representing the tangent view direction (kind of like when you map the normals to the output Albedo so each pixel gets colored accordingly). But what I get is just black. Any ideas on this one?
Thanks in advance!
Your answer
Follow this Question
Related Questions
Shader - Object Depth 0 Answers
viewDir changes with o.Normal 1 Answer
Simple Shader Syntax ... or so I thought 0 Answers
Moving UV's with a shader (tiling error) 1 Answer
Fog shader 2 Answers