This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Build TBN using derivatives (works without explicit tangents) | |
| vec3 dp1 = dFdx(vPosition); | |
| vec3 dp2 = dFdy(vPosition); | |
| vec2 duv1 = dFdx(vUv); | |
| vec2 duv2 = dFdy(vUv); | |
| vec3 tangent = normalize( duv2.y * dp1 - duv1.y * dp2 ); | |
| vec3 bitangent = normalize( -duv2.x * dp1 + duv1.x * dp2 ); | |
| vec3 normal = normalize(vNormal); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| vec3 color = vec3(0.0); | |
| vec2 coords = vUv - vec2(0.5); // | |
| float mag = length(coords) * 2.0; // length(coords) / 0.5 | |
| mag = clamp(mag, 0.0, 1.0); | |
| float angle = atan(coords.y, coords.x); | |
| angle -= 1.57079632679; | |
| if (angle < 0.0) angle += 6.28318530718; | |
| angle /= 6.28318530718; | |
| vec4 c = texture2D(tDiffuse, vec2(angle, mag)); | |
| color = c.rgb; |