Skip to content

Commit 7ba9147

Browse files
authored
Examples: Fix shader code in BasicNode. (mrdoob#21818)
1 parent 415f35b commit 7ba9147

File tree

1 file changed

+10
-36
lines changed

1 file changed

+10
-36
lines changed

examples/jsm/nodes/materials/nodes/BasicNode.js

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,18 @@ class BasicNode extends Node {
1919

2020
const position = this.position ? this.position.analyzeAndFlow( builder, 'v3', { cache: 'position' } ) : undefined;
2121

22-
builder.addParsCode( /* glsl */`
23-
varying vec3 vViewPosition;
24-
25-
#ifndef FLAT_SHADED
26-
27-
varying vec3 vNormal;
28-
29-
#endif`
30-
);
3122

3223
const output = [
3324
'#include <beginnormal_vertex>',
34-
'#include <defaultnormal_vertex>',
35-
36-
'#ifndef FLAT_SHADED', // Normal computed with derivatives when FLAT_SHADED
37-
38-
' vNormal = normalize( transformedNormal );',
25+
'#include <morphnormal_vertex>',
26+
'#include <skinnormal_vertex>',
27+
'#include <defaultnormal_vertex>'
28+
];
3929

40-
'#endif',
30+
output.push(
31+
'#include <begin_vertex>'
4132

42-
'#include <begin_vertex>',
43-
];
33+
);
4434

4535
if ( position ) {
4636

@@ -55,14 +45,11 @@ class BasicNode extends Node {
5545
'#include <morphtarget_vertex>',
5646
'#include <skinning_vertex>',
5747
'#include <project_vertex>',
58-
'#include <fog_vertex>',
5948
'#include <logdepthbuf_vertex>',
60-
'#include <clipping_planes_vertex>',
61-
62-
' vViewPosition = - mvPosition.xyz;',
6349

6450
'#include <worldpos_vertex>',
65-
'#include <shadowmap_vertex>'
51+
'#include <clipping_planes_vertex>',
52+
'#include <fog_vertex>',
6653
);
6754

6855
code = output.join( '\n' );
@@ -82,21 +69,8 @@ class BasicNode extends Node {
8269

8370
builder.requires.transparent = alpha !== undefined;
8471

85-
builder.addParsCode( /* glsl */`
86-
varying vec3 vViewPosition;
87-
88-
#ifndef FLAT_SHADED
89-
90-
varying vec3 vNormal;
91-
92-
#endif`
93-
);
94-
9572
const output = [
96-
// add before: prevent undeclared normal
97-
'#include <normal_fragment_begin>',
98-
99-
color.code,
73+
color.code
10074
];
10175

10276
if ( mask ) {

0 commit comments

Comments
 (0)