@driftengine/core 4.13.3 → 4.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -694,8 +694,9 @@ export const MAIN_GLSL = `void main() {
694
694
  * branch it did not take before.
695
695
  */
696
696
  /* A model reflects its environment whatever the pass asked of the standard model: see
697
- modelReflectance. On the switches alone, so the derivatives below stay in uniform flow. */
698
- if (uEnvironmentDials.y > 0.0 || uMaterialFlags.y != 0 || modelled) {
697
+ modelReflectance. Hair takes none: modelReflects. On the switches alone, so the derivatives
698
+ below stay in uniform flow. */
699
+ if ((uEnvironmentDials.y > 0.0 || uMaterialFlags.y != 0 || modelled) && modelReflects()) {
699
700
  vec3 toEye = normalize(uCameraPos - vWorldPos);
700
701
  vec3 mirrored = reflect(-toEye, modelled ? modelReflectNormal(n) : n);
701
702
  vec3 environment = mix(uAmbientGround, uAmbient, mirrored.y * 0.5 + 0.5);
@@ -12,8 +12,8 @@
12
12
  * **Where the models plug in.** `main` gathers the surface once (`modelSurface`), then asks at each
13
13
  * place light arrives: `modelLight` for the sun, each lamp and each rectangle, `modelAmbient` for
14
14
  * the sky and the probe's irradiance, `modelIrradiance` for DriftLight, `modelReflectNormal` and
15
- * `modelReflectance` for the environment's reflection. Each returns today's term for the standard
16
- * model, and each model's file is where its own answers are.
15
+ * `modelReflectance` for the environment's reflection, which `modelReflects` keeps from hair. Each
16
+ * returns today's term for the standard model, and each model's file is where its own answers are.
17
17
  *
18
18
  * **What a model returns from a light** is the two halves the standard terms are: a diffuse already
19
19
  * weighted by the angle of arrival, and a specular lobe in the engine's peak-normalised units (see
@@ -93,6 +93,15 @@ bool modelSeesBehind() {
93
93
  return false;
94
94
  }
95
95
 
96
+ /**
97
+ * Whether the environment's reflection reaches this surface: every model's but hair's, whose share
98
+ * of it is in its light from every side (hair.ts).
99
+ */
100
+ bool modelReflects() {
101
+ if (MODEL_HAIR) return false;
102
+ return true;
103
+ }
104
+
96
105
  /* The surface a model shades, gathered once in main before any light reaches it. */
97
106
  vec3 mNormal;
98
107
  vec3 mToEye;
@@ -282,7 +291,6 @@ vec3 modelIrradiance(vec3 irradiance) {
282
291
  /** The normal the environment is reflected about: the surface's own, but for a stretched lobe. */
283
292
  vec3 modelReflectNormal(vec3 n) {
284
293
  if (MODEL_ANISOTROPIC) return anisotropicReflectNormal(n);
285
- if (MODEL_HAIR) return hairAcross();
286
294
  return n;
287
295
  }
288
296
 
@@ -358,7 +366,6 @@ vec3 modelDiffuseOut(vec3 diffuse, float fog) {
358
366
  * what the standard model would.
359
367
  */
360
368
  float modelReflectance(float standard) {
361
- if (MODEL_HAIR) return hairReflectance();
362
369
  if (MODEL_SKIN) return skinReflectance();
363
370
  if (MODEL_EYE) return eyeReflectance();
364
371
  return standard;