Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Morph target compatibility and new threejs version compatibility #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 27 additions & 4 deletions js/IridescentMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,39 @@ class IridescentMaterial extends THREE.ShaderMaterial {
uniforms: materialUniforms,

vertexShader: `
#include <morphtarget_pars_vertex>

varying vec3 vWorldPosition;
varying vec3 vWorldNormal;


attribute vec3 morphTarget0;
attribute vec3 morphTarget1;
attribute vec3 morphTarget2;
attribute vec3 morphTarget3;

void main() {
vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
#include <begin_vertex>
#include <morphtarget_vertex>

#ifdef USE_MORPHTARGETS

// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:
// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence)
// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting
transformed *= morphTargetBaseInfluence;
transformed += morphTarget0 * morphTargetInfluences[0];
transformed += morphTarget1 * morphTargetInfluences[1];
transformed += morphTarget2 * morphTargetInfluences[2];
transformed += morphTarget3 * morphTargetInfluences[3];

#endif

vWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz;
// normalMatrix is view space... we need world space which is okay here since we're using uniform scaling only
vec4 viewPos = modelViewMatrix * vec4(position,1.0);
vec4 viewPos = modelViewMatrix * vec4(transformed, 1.0);
vWorldNormal = mat3(modelMatrix) * normalize(normal);
gl_Position = projectionMatrix * viewPos;
}`,
}`,
fragmentShader: `
varying vec3 vWorldPosition;
varying vec3 vWorldNormal;
Expand Down
6 changes: 3 additions & 3 deletions js/ThinFilmFresnelMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ class ThinFilmFresnelMap extends THREE.DataTexture {
var g = -0.9689 * x + 1.8758 * y + 0.0415 * z;
var b = 0.0557 * x - 0.2040 * y + 1.0570 * z;

r = THREE.Math.clamp(r, 0.0, 1.0);
g = THREE.Math.clamp(g, 0.0, 1.0);
b = THREE.Math.clamp(b, 0.0, 1.0);
r = THREE.MathUtils.clamp(r, 0.0, 1.0);
g = THREE.MathUtils.clamp(g, 0.0, 1.0);
b = THREE.MathUtils.clamp(b, 0.0, 1.0);

// linear to gamma
r = Math.sqrt(r);
Expand Down
Loading