-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
Closed
Labels
Description
clipping_planes_pars_vertex.glsl uses this coding pattern
#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )
varying vec3 vViewPosition;
#endif
In other words, declare viewViewPosition -- but not if it has been predeclared.
These material-dependent chunks become problematic when creating new materials, because it can lead to variable redeclaration conflicts if it is not known if the variable has been previously declared. For example:
#if SOME_CONDITION
varying vec3 vViewPosition;
#endif
...
//from clipping_planes_pars_vertex
#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )
varying vec3 vViewPosition;
#endif
As the number of materials increases, figuring out how to modify the chunks to avoid a potential redeclaration is too tedious.
Would the following coding pattern be acceptable? To be used only when needed.
varying vec3 vViewPosition;
#define VVIEWPOSITION
...
//rewrite of clipping_planes_pars_vertex
#if NUM_CLIPPING_PLANES > 0 && ! defined( VVIEWPOSITION )
varying vec3 vViewPosition;
#endif
Or, is there a better solution to decouple the material types from the Chunks?