Skip to content

Commit 012cf0e

Browse files
authored
Added vertex tangent support (#22264)
1 parent dceadef commit 012cf0e

File tree

4 files changed

+48
-8
lines changed

4 files changed

+48
-8
lines changed

src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ varying vec3 vViewPosition;
55
66
varying vec3 vNormal;
77
8-
#endif
8+
#ifdef USE_TANGENT
9+
10+
varying vec3 vTangent;
11+
varying vec3 vBitangent;
912
13+
#endif
14+
15+
#endif
1016
1117
struct BlinnPhongMaterial {
1218

src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ varying vec3 vViewPosition;
55
66
varying vec3 vNormal;
77
8-
#endif
8+
#ifdef USE_TANGENT
9+
10+
varying vec3 vTangent;
11+
varying vec3 vBitangent;
912
13+
#endif
14+
15+
#endif
1016
1117
struct ToonMaterial {
1218

src/renderers/shaders/ShaderLib/meshphong_vert.glsl.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ varying vec3 vViewPosition;
77
88
varying vec3 vNormal;
99
10+
#ifdef USE_TANGENT
11+
12+
varying vec3 vTangent;
13+
varying vec3 vBitangent;
14+
15+
#endif
16+
1017
#endif
1118
1219
#include <common>
@@ -34,11 +41,18 @@ void main() {
3441
#include <skinnormal_vertex>
3542
#include <defaultnormal_vertex>
3643
37-
#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED
44+
#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED
3845
39-
vNormal = normalize( transformedNormal );
46+
vNormal = normalize( transformedNormal );
4047
41-
#endif
48+
#ifdef USE_TANGENT
49+
50+
vTangent = normalize( transformedTangent );
51+
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
52+
53+
#endif
54+
55+
#endif
4256
4357
#include <begin_vertex>
4458
#include <morphtarget_vertex>

src/renderers/shaders/ShaderLib/meshtoon_vert.glsl.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ varying vec3 vViewPosition;
77
88
varying vec3 vNormal;
99
10+
#ifdef USE_TANGENT
11+
12+
varying vec3 vTangent;
13+
varying vec3 vBitangent;
14+
15+
#endif
16+
1017
#endif
1118
1219
#include <common>
@@ -33,11 +40,18 @@ void main() {
3340
#include <skinnormal_vertex>
3441
#include <defaultnormal_vertex>
3542
36-
#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED
43+
#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED
3744
38-
vNormal = normalize( transformedNormal );
45+
vNormal = normalize( transformedNormal );
3946
40-
#endif
47+
#ifdef USE_TANGENT
48+
49+
vTangent = normalize( transformedTangent );
50+
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
51+
52+
#endif
53+
54+
#endif
4155
4256
#include <begin_vertex>
4357
#include <morphtarget_vertex>

0 commit comments

Comments
 (0)