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

Shaders: Added new shader chunks for tangent support #22269

Merged
merged 2 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions src/renderers/shaders/ShaderChunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ import morphtarget_pars_vertex from './ShaderChunk/morphtarget_pars_vertex.glsl.
import morphtarget_vertex from './ShaderChunk/morphtarget_vertex.glsl.js';
import normal_fragment_begin from './ShaderChunk/normal_fragment_begin.glsl.js';
import normal_fragment_maps from './ShaderChunk/normal_fragment_maps.glsl.js';
import normal_pars_fragment from './ShaderChunk/normal_pars_fragment.glsl.js';
import normal_pars_vertex from './ShaderChunk/normal_pars_vertex.glsl.js';
import normal_vertex from './ShaderChunk/normal_vertex.glsl.js';
import normalmap_pars_fragment from './ShaderChunk/normalmap_pars_fragment.glsl.js';
import clearcoat_normal_fragment_begin from './ShaderChunk/clearcoat_normal_fragment_begin.glsl.js';
import clearcoat_normal_fragment_maps from './ShaderChunk/clearcoat_normal_fragment_maps.glsl.js';
Expand Down Expand Up @@ -195,6 +198,9 @@ export const ShaderChunk = {
morphtarget_vertex: morphtarget_vertex,
normal_fragment_begin: normal_fragment_begin,
normal_fragment_maps: normal_fragment_maps,
normal_pars_fragment: normal_pars_fragment,
normal_pars_vertex: normal_pars_vertex,
normal_vertex: normal_vertex,
normalmap_pars_fragment: normalmap_pars_fragment,
clearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin,
clearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
export default /* glsl */`
varying vec3 vViewPosition;

#ifndef FLAT_SHADED

varying vec3 vNormal;

#ifdef USE_TANGENT

varying vec3 vTangent;
varying vec3 vBitangent;

#endif

#endif

struct BlinnPhongMaterial {

vec3 diffuseColor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
export default /* glsl */`
varying vec3 vViewPosition;

#ifndef FLAT_SHADED

varying vec3 vNormal;

#ifdef USE_TANGENT

varying vec3 vTangent;
varying vec3 vBitangent;

#endif

#endif

struct ToonMaterial {

vec3 diffuseColor;
Expand Down
14 changes: 14 additions & 0 deletions src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default /* glsl */`
#ifndef FLAT_SHADED

varying vec3 vNormal;

#ifdef USE_TANGENT

varying vec3 vTangent;
varying vec3 vBitangent;

#endif

#endif
`;
14 changes: 14 additions & 0 deletions src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default /* glsl */`
#ifndef FLAT_SHADED

varying vec3 vNormal;

#ifdef USE_TANGENT

varying vec3 vTangent;
varying vec3 vBitangent;

#endif

#endif
`;
14 changes: 14 additions & 0 deletions src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default /* glsl */`
#ifndef FLAT_SHADED // normal is computed with derivatives when FLAT_SHADED

vNormal = normalize( transformedNormal );

#ifdef USE_TANGENT

vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );

#endif

#endif
`;
1 change: 1 addition & 0 deletions src/renderers/shaders/ShaderLib/meshphong_frag.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ uniform float opacity;
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
Expand Down
28 changes: 2 additions & 26 deletions src/renderers/shaders/ShaderLib/meshphong_vert.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,14 @@ export default /* glsl */`

varying vec3 vViewPosition;

#ifndef FLAT_SHADED

varying vec3 vNormal;

#ifdef USE_TANGENT

varying vec3 vTangent;
varying vec3 vBitangent;

#endif

#endif

#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
Expand All @@ -40,19 +28,7 @@ void main() {
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>

#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED

vNormal = normalize( transformedNormal );

#ifdef USE_TANGENT

vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );

#endif

#endif
#include <normal_vertex>

#include <begin_vertex>
#include <morphtarget_vertex>
Expand Down
1 change: 1 addition & 0 deletions src/renderers/shaders/ShaderLib/meshtoon_frag.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ uniform float opacity;
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
Expand Down
28 changes: 2 additions & 26 deletions src/renderers/shaders/ShaderLib/meshtoon_vert.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,13 @@ export default /* glsl */`

varying vec3 vViewPosition;

#ifndef FLAT_SHADED

varying vec3 vNormal;

#ifdef USE_TANGENT

varying vec3 vTangent;
varying vec3 vBitangent;

#endif

#endif

#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
Expand All @@ -39,19 +27,7 @@ void main() {
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>

#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED

vNormal = normalize( transformedNormal );

#ifdef USE_TANGENT

vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );

#endif

#endif
#include <normal_vertex>

#include <begin_vertex>
#include <morphtarget_vertex>
Expand Down