Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/core/p5.Renderer3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -1448,10 +1448,6 @@ export class Renderer3D extends Renderer {
this.scratchMat3.inverseTranspose4x4(this.states.uViewMatrix);
shader.setUniform("uCameraNormalMatrix", this.scratchMat3.mat3);
}
if (shader.uniforms.uCameraRotation) {
this.scratchMat3.inverseTranspose4x4(this.states.uViewMatrix);
shader.setUniform("uCameraRotation", this.scratchMat3.mat3);
}
shader.setUniform("uViewport", this._viewport);
}

Expand Down
4 changes: 4 additions & 0 deletions src/webgl/p5.Shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -1028,8 +1028,12 @@ class Shader {
return;
} else {
if (Array.isArray(data)) {
if (uniform._cachedData && this._renderer._arraysEqual(uniform._cachedData, data)) {
return;
}
uniform._cachedData = data.slice(0);
} else {
if (uniform._cachedData === data) return;
uniform._cachedData = data;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/webgl/shaders/lighting.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ precision highp float;
precision highp int;

uniform mat4 uViewMatrix;
uniform mat3 uCameraNormalMatrix;

uniform bool uUseLighting;

uniform mat3 uCameraRotation;
uniform int uDirectionalLightCount;
uniform vec3 uLightingDirection[5];
uniform vec3 uDirectionalDiffuseColors[5];
Expand Down Expand Up @@ -108,7 +108,7 @@ vec2 mapTextureToNormal( vec3 v ){
vec3 calculateImageDiffuse(vec3 vNormal, vec3 vViewPosition, float metallic){
// make 2 seperate builds
vec3 worldCameraPosition = vec3(0.0, 0.0, 0.0); // hardcoded world camera position
vec3 worldNormal = normalize(vNormal * uCameraRotation);
vec3 worldNormal = normalize(vNormal * uCameraNormalMatrix);
vec2 newTexCoor = mapTextureToNormal( worldNormal );
vec4 texture = TEXTURE( environmentMapDiffused, newTexCoor );
// this is to make the darker sections more dark
Expand All @@ -120,7 +120,7 @@ vec3 calculateImageSpecular(vec3 vNormal, vec3 vViewPosition, float shininess, f
vec3 worldCameraPosition = vec3(0.0, 0.0, 0.0);
vec3 worldNormal = normalize(vNormal);
vec3 lightDirection = normalize( vViewPosition - worldCameraPosition );
vec3 R = reflect(lightDirection, worldNormal) * uCameraRotation;
vec3 R = reflect(lightDirection, worldNormal) * uCameraNormalMatrix;
vec2 newTexCoor = mapTextureToNormal( R );
#ifdef WEBGL2
// In p5js the range of shininess is >= 1,
Expand Down
Loading
Loading