Skip to content

Commit

Permalink
Fix ibl direction (#916)
Browse files Browse the repository at this point in the history
* refactor: fix skybox mirror problem

* fix: TextureCube is left-hand,so x need inverse (#855)

Co-authored-by: ChenMo <[email protected]>
  • Loading branch information
zhuxudong and GuoLei1990 authored Aug 3, 2022
1 parent d3e3f6e commit f1ada73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/shaderlib/extra/skybox.vs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ varying vec3 v_cubeUV;

void main() {

v_cubeUV = POSITION.xyz;
v_cubeUV = vec3( -POSITION.x, POSITION.yz );// TextureCube is left-hand,so x need inverse
gl_Position = u_mvpNoscale * vec4( POSITION, 1.0 );
gl_Position.z = gl_Position.w;

}
}
2 changes: 2 additions & 0 deletions packages/core/src/shaderlib/pbr/ibl_frag_define.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// sh need be pre-scaled in CPU.
vec3 getLightProbeIrradiance(vec3 sh[9], vec3 normal){
normal.x = -normal.x;
vec3 result = sh[0] +

sh[1] * (normal.y) +
Expand Down Expand Up @@ -51,6 +52,7 @@ vec3 getLightProbeRadiance(vec3 viewDir, vec3 normal, float roughness, int maxMI
#else

vec3 reflectVec = reflect( -viewDir, normal );
reflectVec.x = -reflectVec.x; // TextureCube is left-hand,so x need inverse

float specularMIPLevel = getSpecularMIPLevel(roughness, maxMIPLevel );

Expand Down

0 comments on commit f1ada73

Please sign in to comment.