Getting ready to decode normal.

This commit is contained in:
David Williams
2014-05-29 19:34:43 +02:00
parent e40eb6d762
commit a6a1c4dbb7
2 changed files with 6 additions and 2 deletions

View File

@ -11,9 +11,9 @@ void main()
{
// Again, for the purposes of these examples we cannot be sure that per-vertex normals are provided. A sensible fallback
// is to use this little trick to compute per-fragment flat-shaded normals from the world positions using derivative operations.
vec3 normal = normalize(cross(dFdy(worldPosition.xyz), dFdx(worldPosition.xyz)));
//vec3 normal = normalize(cross(dFdy(worldPosition.xyz), dFdx(worldPosition.xyz)));
// We are just using the normal as the output color, and making it lighter so it looks a bit nicer.
// Obviously a real shader would also do texuring, lighting, or whatever is required for the application.
outputColor = vec4(abs(normal) * 0.5 + vec3(0.5, 0.5, 0.5), 1.0);
outputColor = vec4(abs(worldNormal.xyz) * 0.5 + vec3(0.5, 0.5, 0.5), 1.0);
}