Skip to content

Commit

Permalink
chore: update ThreeJS to v160 and fix custom shaders to make them wor…
Browse files Browse the repository at this point in the history
…k with this version [PT-186622948]
  • Loading branch information
pjanik committed Jan 3, 2024
1 parent 17dae1f commit 6501478
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/tectonic-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"screenfull": "^6.0.2",
"seedrandom": "^3.0.5",
"shutterbug": "^1.5.0",
"three": "0.151.0",
"three": "^0.160.0",
"timeseries-analysis": "^1.0.12",
"uuid": "^9.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Slightly modified Phong shader taken from THREE.ShaderLib:
// https://github.com/mrdoob/three.js/blob/b398bc410bd161a88e8087898eb66639f03762be/src/renderers/shaders/ShaderLib/meshphong.glsl.js
// https://github.com/mrdoob/three.js/blob/d04539a76736ff500cae883d6a38b3dd8643c548/src/renderers/shaders/ShaderLib/meshphong.glsl.js
// It supports alpha channel in color attribute (vec4 is used instead of vec3) + a few custom features like
// hiding vertices, colormap texture, and so on. Custom code is always enclosed in // --- CUSTOM comment.

Expand Down Expand Up @@ -32,6 +32,7 @@ uniform float opacity;
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
Expand Down Expand Up @@ -59,7 +60,6 @@ uniform float opacity;

// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)


vec2 dHdxy_fwd() {

vec2 dSTdx = dFdx( vBumpMapUv );
Expand All @@ -75,8 +75,9 @@ uniform float opacity;

vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {

vec3 vSigmaX = dFdx( surf_pos.xyz );
vec3 vSigmaY = dFdy( surf_pos.xyz );
// normalize is done to ensure that the bump map looks the same regardless of the texture's scale
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
vec3 vN = surf_norm; // normalized

vec3 R1 = cross( vSigmaY, vN );
Expand All @@ -101,7 +102,7 @@ void main() {

#include <clipping_planes_fragment>

vec4 diffuseColor = vec4( diffuse, opacity );
vec4 diffuseColor = vec4( diffuse, opacity );
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;

Expand Down Expand Up @@ -143,6 +144,7 @@ void main() {

#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
Expand All @@ -160,9 +162,9 @@ void main() {
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;

#include <envmap_fragment>
#include <output_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Slightly modified Phong shader taken from THREE.ShaderLib.
// https://github.com/mrdoob/three.js/blob/b398bc410bd161a88e8087898eb66639f03762be/src/renderers/shaders/ShaderLib/meshphong.glsl.js
// https://github.com/mrdoob/three.js/blob/d04539a76736ff500cae883d6a38b3dd8643c548/src/renderers/shaders/ShaderLib/meshphong.glsl.js
// It supports alpha channel in color attribute (vec4 is used instead of vec3) + a few custom features like
// hiding vertices, colormap texture, and so on. Custom code is always enclosed in // --- CUSTOM comment.

Expand All @@ -23,6 +23,7 @@ flat out int vPatternIdx;
varying vec3 vViewPosition;

#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
Expand All @@ -44,9 +45,10 @@ void main() {
vPatternIdx = patternIdx;
// ---

#include <uv_vertex>
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>

#include <beginnormal_vertex>
#include <morphnormal_vertex>
Expand Down

0 comments on commit 6501478

Please sign in to comment.