Skip to content

Commit def2568

Browse files
authored
Fix lighting basis during RTT (playcanvas#3424)
* add tbn multiplier * move
1 parent 95417a6 commit def2568

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/graphics/program-lib/chunks/TBNderivative.frag

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
uniform float tbnBasis;
2+
13
// http://www.thetenthplanet.de/archives/1180
24
void getTBN() {
35
vec2 uv = $UV;
@@ -16,6 +18,6 @@ void getTBN() {
1618

1719
// construct a scale-invariant frame
1820
float denom = max( dot(T,T), dot(B,B) );
19-
float invmax = (denom == 0.0) ? 0.0 : 1.0 / sqrt( denom );
20-
dTBN = mat3( T * invmax, -B * invmax, dVertexNormalW );
21+
float invmax = (denom == 0.0) ? 0.0 : tbnBasis / sqrt( denom );
22+
dTBN = mat3(T * invmax, -B * invmax, dVertexNormalW );
2123
}

src/scene/renderer/forward-renderer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class ForwardRenderer {
130130
this.nearClipId = scope.resolve('camera_near');
131131
this.farClipId = scope.resolve('camera_far');
132132
this.cameraParamsId = scope.resolve('camera_params');
133+
this.tbnBasis = scope.resolve('tbnBasis');
133134

134135
this.fogColorId = scope.resolve('fog_color');
135136
this.fogStartId = scope.resolve('fog_start');
@@ -456,6 +457,8 @@ class ForwardRenderer {
456457
camera.frustum.setFromMat4(viewProjMat);
457458
}
458459

460+
this.tbnBasis.setValue(target && target.flipY ? -1 : 1);
461+
459462
// Near and far clip values
460463
this.nearClipId.setValue(camera._nearClip);
461464
this.farClipId.setValue(camera._farClip);

0 commit comments

Comments
 (0)