@driftengine/core 4.13.2 → 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.
- package/CHANGELOG.json +27 -0
- package/README.md +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/render/backend/webgl2/renderer.d.ts +12 -0
- package/dist/render/backend/webgl2/renderer.js +47 -2
- package/dist/render/backend/webgpu/clothSetPack.js +1 -0
- package/dist/render/backend/webgpu/clothSolvePack.d.ts +5 -2
- package/dist/render/backend/webgpu/clothSolvePack.js +2 -1
- package/dist/render/backend/webgpu/gpuClothSet.js +1 -1
- package/dist/render/backend/webgpu/renderer.d.ts +9 -0
- package/dist/render/backend/webgpu/renderer.js +33 -1
- package/dist/render/backend/webgpu/shaders/clothSolve.wgsl.d.ts +1 -1
- package/dist/render/backend/webgpu/shaders/clothSolve.wgsl.js +7 -5
- package/dist/render/hairLobes.d.ts +23 -0
- package/dist/render/hairLobes.js +50 -1
- package/dist/render/shaders/flat/detail.d.ts +21 -0
- package/dist/render/shaders/flat/detail.js +74 -0
- package/dist/render/shaders/flat/glassTint.d.ts +1 -1
- package/dist/render/shaders/flat/glassTint.js +1 -0
- package/dist/render/shaders/flat/hair.js +51 -25
- package/dist/render/shaders/flat/index.d.ts +5 -0
- package/dist/render/shaders/flat/index.js +3 -0
- package/dist/render/shaders/flat/main.d.ts +1 -1
- package/dist/render/shaders/flat/main.js +5 -2
- package/dist/render/shaders/flat/models.js +11 -4
- package/dist/render/shaders/generated/flat.wgsl.d.ts +144 -16
- package/dist/render/shaders/generated/flat.wgsl.js +183 -55
- package/dist/render/surfaceDetail.d.ts +79 -0
- package/dist/render/surfaceDetail.js +86 -0
- package/dist/render/surfaceTexture.d.ts +9 -0
- package/package.json +6 -6
- package/src/index.ts +2 -0
- package/src/render/backend/webgl2/renderer.ts +58 -2
- package/src/render/backend/webgpu/clothSetPack.ts +1 -0
- package/src/render/backend/webgpu/clothSolvePack.ts +6 -2
- package/src/render/backend/webgpu/gpuClothSet.ts +1 -1
- package/src/render/backend/webgpu/renderer.ts +42 -1
- package/src/render/backend/webgpu/shaders/clothSolve.wgsl.ts +7 -5
- package/src/render/hairLobes.ts +76 -1
- package/src/render/shaders/flat/detail.ts +74 -0
- package/src/render/shaders/flat/glassTint.ts +3 -1
- package/src/render/shaders/flat/hair.ts +51 -25
- package/src/render/shaders/flat/index.ts +8 -0
- package/src/render/shaders/flat/main.ts +5 -2
- package/src/render/shaders/flat/models.ts +11 -4
- package/src/render/shaders/generated/flat.wgsl.ts +183 -55
- package/src/render/surfaceDetail.ts +136 -0
- package/src/render/surfaceTexture.ts +9 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A material's tiled detail over whatever its maps made: `SurfaceMaterial.detail`, packed into
|
|
3
|
+
* `uDetail` by `surfaceDetail.ts`.
|
|
4
|
+
*
|
|
5
|
+
* **Each texel wears its own region's detail alone.** The region is read exactly from the ORM
|
|
6
|
+
* array's layer the material names, at the base coordinates, so an index is never blended with its
|
|
7
|
+
* neighbour's at a region's edge; then that region's normal map is read at its repeat and offset,
|
|
8
|
+
* turned through a frame built on the normal the base maps made — the construction a layered
|
|
9
|
+
* material lays its layers over a mesh normal with — and its occlusion multiplied into the
|
|
10
|
+
* surface's. A strength scales the detail's slopes as a layer's look does.
|
|
11
|
+
*
|
|
12
|
+
* **Read with explicit gradients**, the base coordinates' times the region's repeat, because the
|
|
13
|
+
* region is the pixel's own: a read whose level is implicit is legal only in uniform control flow
|
|
14
|
+
* (AGENTS.md 2026-08-07), and across a region's edge the repeated coordinates jump, which would
|
|
15
|
+
* read a level as coarse as the jump. The frame and the gradients are taken first, under the
|
|
16
|
+
* uniform branch that calls this.
|
|
17
|
+
*
|
|
18
|
+
* **A lit switch, `SURFACE_DETAIL`**, off until a material first asks, declared after `LAYERED` and
|
|
19
|
+
* `LAYER_LOOKS` so each keeps its id. Compiled out, its thirty-three vectors are not declared.
|
|
20
|
+
*/
|
|
21
|
+
export function detailGlsl(on: boolean): string {
|
|
22
|
+
if (!on) {
|
|
23
|
+
return /* glsl */ `
|
|
24
|
+
const bool SURFACE_DETAIL = false; // wgsl:override
|
|
25
|
+
bool detailed() { return false; }
|
|
26
|
+
void surfaceDetail(inout vec3 n, inout float occlusion, vec2 uv) {}
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
return /* glsl */ `
|
|
30
|
+
/* Whether this program lays a material's detail. Off but where one has asked: detail.ts. */
|
|
31
|
+
const bool SURFACE_DETAIL = true; // wgsl:override
|
|
32
|
+
/*
|
|
33
|
+
* Thirty-three vectors, as surfaceDetail.ts packs them: the region count (x) and the ORM array's
|
|
34
|
+
* layer holding the region map, or -1 for none (y); then two a region, the normal map's layer (x),
|
|
35
|
+
* the occlusion's or -1 (y), the normal strength (z) and the occlusion strength (w); its repeats
|
|
36
|
+
* across and down (x y) and its offset (z w).
|
|
37
|
+
*/
|
|
38
|
+
uniform vec4 uDetail[33]; // wgsl:material
|
|
39
|
+
|
|
40
|
+
bool detailed() { return uDetail[0].x > 0.0; }
|
|
41
|
+
|
|
42
|
+
/* The region a texel of the base maps is in, read exactly, held to the regions there are. */
|
|
43
|
+
int detailRegion(vec2 uv) {
|
|
44
|
+
int last = int(uDetail[0].x) - 1;
|
|
45
|
+
if (uDetail[0].y < 0.0) return 0;
|
|
46
|
+
ivec2 size = textureSize(uOrmMap, 0).xy;
|
|
47
|
+
ivec2 texel = clamp(ivec2(floor(fract(uv) * vec2(size))), ivec2(0), size - 1);
|
|
48
|
+
int region = int(texelFetch(uOrmMap, ivec3(texel, int(uDetail[0].y)), 0).r * 255.0 + 0.5);
|
|
49
|
+
return clamp(region, 0, last);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void surfaceDetail(inout vec3 n, inout float occlusion, vec2 uv) {
|
|
53
|
+
/* In uniform control flow, before anything that depends on the pixel's region. */
|
|
54
|
+
mat3 frame = tangentFrame(n, vWorldPos, uv, vTangent, vHasTangents);
|
|
55
|
+
vec2 dx = dFdx(uv);
|
|
56
|
+
vec2 dy = dFdy(uv);
|
|
57
|
+
int region = detailRegion(uv);
|
|
58
|
+
vec4 picks = uDetail[1 + region * 2];
|
|
59
|
+
vec4 place = uDetail[2 + region * 2];
|
|
60
|
+
vec2 at = uv * place.xy + place.zw;
|
|
61
|
+
vec2 gx = dx * place.xy;
|
|
62
|
+
vec2 gy = dy * place.xy;
|
|
63
|
+
vec3 d = textureGrad(uModelMap, vec3(at, picks.x), gx, gy).xyz * 2.0 - 1.0;
|
|
64
|
+
/* z rebuilt where none is stored, as the base map's is: normalMap.ts. */
|
|
65
|
+
d.z = d.z > 0.0 ? d.z : sqrt(max(0.0, 1.0 - dot(d.xy, d.xy)));
|
|
66
|
+
d = normalize(vec3(d.xy * picks.z, max(d.z, 1e-4)));
|
|
67
|
+
n = normalize(frame * d);
|
|
68
|
+
if (picks.y >= 0.0) {
|
|
69
|
+
float held = textureGrad(uModelMap, vec3(at, picks.y), gx, gy).r;
|
|
70
|
+
occlusion *= mix(1.0, held, picks.w);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
@@ -40,7 +40,8 @@ export type LitSwitch =
|
|
|
40
40
|
| 'WORLD_UVS'
|
|
41
41
|
| 'MOVING_SUN'
|
|
42
42
|
| 'LAYERED'
|
|
43
|
-
| 'LAYER_LOOKS'
|
|
43
|
+
| 'LAYER_LOOKS'
|
|
44
|
+
| 'SURFACE_DETAIL';
|
|
44
45
|
|
|
45
46
|
/** Every switch off: what a renderer starts from before its profile and its content say otherwise. */
|
|
46
47
|
export function noLitSwitches(): Record<LitSwitch, boolean> {
|
|
@@ -57,6 +58,7 @@ export function noLitSwitches(): Record<LitSwitch, boolean> {
|
|
|
57
58
|
MOVING_SUN: false,
|
|
58
59
|
LAYERED: false,
|
|
59
60
|
LAYER_LOOKS: false,
|
|
61
|
+
SURFACE_DETAIL: false,
|
|
60
62
|
};
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -4,29 +4,35 @@
|
|
|
4
4
|
* receives, and every term to a finite answer where the geometry degenerates.
|
|
5
5
|
*
|
|
6
6
|
* **The strand is the tangent, root to tip.** The model map's green turns each strand's tilt by up
|
|
7
|
-
* to half of it either way (0.5 is none) and its blue is occlusion, which
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* to half of it either way (0.5 is none) and its blue is occlusion, which light from every side
|
|
8
|
+
* takes and the lamps do not — their shadows are theirs to cast. The red is not read: a colour from
|
|
9
|
+
* root to tip is the albedo map's to carry.
|
|
10
10
|
*
|
|
11
|
-
* **
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* **Light from every side** — the sky, the probes, DriftLight — goes through the lobes rather than
|
|
12
|
+
* past them: they are evaluated once, for a light along the eye flattened across the strand, every
|
|
13
|
+
* lobe widened by \`HAIR_AREA\` as a source that large would widen it, and their sum taken as the
|
|
14
|
+
* share of that light the strand returns (\`hairIndirect\`). That is how a real-time hair model
|
|
15
|
+
* stands one direction in for the sphere: a strand returns most toward the eye what arrives from
|
|
16
|
+
* the eye's side of it, and the R and TRT lobes are what make a fibre gold rather than a wash of
|
|
17
|
+
* its scatter. The environment's reflection leaves hair out, because R already took its share.
|
|
18
|
+
*
|
|
19
|
+
* **What it gives up**: light from behind. The direction stands for the eye's side only, so there
|
|
20
|
+
* is no transmitted lobe in it, and a head of hair lit from behind by an open sky shows no rim
|
|
21
|
+
* from the sky; the lamps carry one. And the share is one direction's, not the sphere's integral,
|
|
22
|
+
* so it moves with the eye as the lobes do rather than holding still as an average would. **What
|
|
23
|
+
* would make it wrong** is hair seen mostly against its light, a head against a bright window,
|
|
24
|
+
* whose sky arrives through the strands rather than off them and wants the transmitted lobe back.
|
|
16
25
|
*/
|
|
17
|
-
import { HAIR_F0, HAIR_MIN_BETA
|
|
26
|
+
import { HAIR_AREA, HAIR_F0, HAIR_MIN_BETA } from '../../hairLobes.ts';
|
|
18
27
|
|
|
19
28
|
export const HAIR_GLSL = /* glsl */ `
|
|
20
29
|
const float HAIR_F0 = ${HAIR_F0.toFixed(9)};
|
|
21
30
|
const float HAIR_MIN_BETA = ${HAIR_MIN_BETA.toFixed(3)};
|
|
22
|
-
const float
|
|
31
|
+
const float HAIR_AREA = ${HAIR_AREA.toFixed(3)};
|
|
23
32
|
|
|
24
|
-
/* This texel's tilt, gathered
|
|
33
|
+
/* This texel's tilt, and the share of light from every side it returns: gathered with the surface. */
|
|
25
34
|
float hShift;
|
|
26
|
-
|
|
27
|
-
void hairSurface() {
|
|
28
|
-
hShift = uModelParams[0].x * (0.5 + mMap.g);
|
|
29
|
-
}
|
|
35
|
+
vec3 hAround;
|
|
30
36
|
|
|
31
37
|
/** A longitudinal lobe: a normalised Gaussian of width \`beta\` at \`x\` from its centre. */
|
|
32
38
|
float hairLongitudinal(float beta, float x) {
|
|
@@ -38,14 +44,18 @@ float hairFresnel(float cosine) {
|
|
|
38
44
|
return HAIR_F0 + (1.0 - HAIR_F0) * c * c * c * c * c;
|
|
39
45
|
}
|
|
40
46
|
|
|
41
|
-
/** The normal turned toward the eye across the strand: the scatter's and
|
|
47
|
+
/** The normal turned toward the eye across the strand: the scatter's, and light from every side's. */
|
|
42
48
|
vec3 hairAcross() {
|
|
43
49
|
vec3 across = mToEye - mTangent * dot(mTangent, mToEye);
|
|
44
50
|
float length2 = dot(across, across);
|
|
45
51
|
return length2 > 1e-8 ? across * inversesqrt(length2) : mNormal;
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
/**
|
|
55
|
+
* The lobes for light arriving along \`l\`, into \`mSpecular\` and \`mDiffuse\`: every lobe widened by
|
|
56
|
+
* \`grow\` radians, and the transmitted one scaled by \`backlit\`.
|
|
57
|
+
*/
|
|
58
|
+
void hairLobes(vec3 l, float grow, float backlit) {
|
|
49
59
|
vec3 t = mTangent;
|
|
50
60
|
float sinI = clamp(dot(t, l), -1.0, 1.0);
|
|
51
61
|
float sinO = clamp(dot(t, mToEye), -1.0, 1.0);
|
|
@@ -56,7 +66,6 @@ void hairLight(vec3 l, float sourceRadius, float dist) {
|
|
|
56
66
|
float cosPhi = dot(lp, vp) * inversesqrt(dot(lp, lp) * dot(vp, vp) + 1e-4);
|
|
57
67
|
float cosHalfPhi = sqrt(clamp(0.5 + 0.5 * cosPhi, 0.0, 1.0));
|
|
58
68
|
float beta = max(mRoughness * mRoughness, HAIR_MIN_BETA);
|
|
59
|
-
float grow = sourceRadius / max(2.0 * dist, 1e-3);
|
|
60
69
|
float x = sinI + sinO;
|
|
61
70
|
|
|
62
71
|
float r = hairLongitudinal(beta + grow, x + 2.0 * hShift) * 0.25 * cosHalfPhi
|
|
@@ -66,7 +75,7 @@ void hairLight(vec3 l, float sourceRadius, float dist) {
|
|
|
66
75
|
float h = cosHalfPhi * (1.0 + a * (0.6 - 0.8 * cosPhi));
|
|
67
76
|
float fTT = hairFresnel(cosD * sqrt(clamp(1.0 - h * h, 0.0, 1.0)));
|
|
68
77
|
float tt = hairLongitudinal(0.5 * beta + grow, x - hShift) * exp(-3.65 * cosPhi - 3.98)
|
|
69
|
-
* (1.0 - fTT) * (1.0 - fTT) *
|
|
78
|
+
* (1.0 - fTT) * (1.0 - fTT) * backlit;
|
|
70
79
|
float ttPower = 0.5 * sqrt(clamp(1.0 - h * h * a * a, 0.0, 1.0)) / cosD;
|
|
71
80
|
|
|
72
81
|
float fTRT = hairFresnel(0.5 * cosD);
|
|
@@ -81,6 +90,11 @@ void hairLight(vec3 l, float sourceRadius, float dist) {
|
|
|
81
90
|
mDiffuse = sqrt(mAlbedo) * uModelParams[0].y * mix(wrapped, 1.0 - abs(sinI), 0.33);
|
|
82
91
|
}
|
|
83
92
|
|
|
93
|
+
/** A lamp, or the sun at no size: widened by the angle it subtends, as \`sphereLobe\` takes it. */
|
|
94
|
+
void hairLight(vec3 l, float sourceRadius, float dist) {
|
|
95
|
+
hairLobes(l, sourceRadius / max(2.0 * dist, 1e-3), uModelParams[0].z);
|
|
96
|
+
}
|
|
97
|
+
|
|
84
98
|
/**
|
|
85
99
|
* A shadow on the scatter: light that reaches a strand in another's shadow has passed through
|
|
86
100
|
* hair to get there, so a penumbra deepens toward the fibre's own hue.
|
|
@@ -90,13 +104,25 @@ vec3 hairShade(float shadow) {
|
|
|
90
104
|
return shadow * pow(max(hue, vec3(1e-4)), vec3(1.0 - shadow));
|
|
91
105
|
}
|
|
92
106
|
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
107
|
+
/**
|
|
108
|
+
* The share of light from every side a strand returns: the lobes for a light along the eye
|
|
109
|
+
* flattened across the strand, unshadowed, with nothing from behind and every lobe widened by
|
|
110
|
+
* \`HAIR_AREA\`, twice their sum and at most all of it. Twice, in this engine's units, because the
|
|
111
|
+
* lobes are per unit irradiance and the scatter's half is then exactly \`HAIR_SCATTER_SPHERE\`, its
|
|
112
|
+
* own average over the sphere: \`hairLobes.ts\` says why, and holds the arithmetic to it.
|
|
113
|
+
*/
|
|
114
|
+
vec3 hairIndirect() {
|
|
115
|
+
hairLobes(hairAcross(), HAIR_AREA, 0.0);
|
|
116
|
+
return min(vec3(1.0), 2.0 * (mSpecular + mDiffuse));
|
|
96
117
|
}
|
|
97
118
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
119
|
+
void hairSurface() {
|
|
120
|
+
hShift = uModelParams[0].x * (0.5 + mMap.g);
|
|
121
|
+
hAround = hairIndirect();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Light from every side, through the lobes, under the map's occlusion. */
|
|
125
|
+
vec3 hairAround(vec3 light) {
|
|
126
|
+
return hAround * (mMap.b * light);
|
|
101
127
|
}
|
|
102
128
|
`;
|
|
@@ -24,6 +24,7 @@ import { overlayGlsl } from './overlay.ts';
|
|
|
24
24
|
import { reflectionSurfaceGlsl } from './reflectionSurface.ts';
|
|
25
25
|
import { worldUvGlsl } from './worldUv.ts';
|
|
26
26
|
import { movingSunGlsl } from './movingSun.ts';
|
|
27
|
+
import { detailGlsl } from './detail.ts';
|
|
27
28
|
import { layeredGlsl } from './layered.ts';
|
|
28
29
|
import { MAP_READS_GLSL } from './mapReads.ts';
|
|
29
30
|
import { CHANNEL_BEND, LIT_CHANNEL_ATTRIBUTE } from '../vertexChannel.ts';
|
|
@@ -539,6 +540,11 @@ export interface FlatShaderOptions {
|
|
|
539
540
|
* \`uLayerLooks\` and all. True when absent; nothing without \`layered\`. See \`layerLooksGlsl\`.
|
|
540
541
|
*/
|
|
541
542
|
readonly layerLooks?: boolean;
|
|
543
|
+
/**
|
|
544
|
+
* Whether it lays a material's tiled detail over its maps, \`uDetail\` and all
|
|
545
|
+
* (\`SurfaceMaterial.detail\`). True when absent. See \`detailGlsl\`.
|
|
546
|
+
*/
|
|
547
|
+
readonly surfaceDetail?: boolean;
|
|
542
548
|
/**
|
|
543
549
|
* How many point lights this build declares room for. `MAX_POINT_LIGHTS` when absent.
|
|
544
550
|
*
|
|
@@ -692,6 +698,8 @@ export function flatFrag(options: FlatShaderOptions): string {
|
|
|
692
698
|
worldUvGlsl(options.worldUvs ?? true),
|
|
693
699
|
/* After the projection, so its switch takes the next id; the normal map below calls it. */
|
|
694
700
|
layeredGlsl(options.layered ?? true, options.layerLooks ?? true),
|
|
701
|
+
/* After the layers, so its switch takes the next id; main calls it. See detail.ts. */
|
|
702
|
+
detailGlsl(options.surfaceDetail ?? true),
|
|
695
703
|
/* Where each map is read, after both of the ways it can be read otherwise. See mapReads.ts. */
|
|
696
704
|
MAP_READS_GLSL,
|
|
697
705
|
/* After the frame and the projection it calls, unconditional for the same reason as the
|
|
@@ -227,6 +227,8 @@ export const MAIN_GLSL = `void main() {
|
|
|
227
227
|
if (uNormalStrength > 0.0) n = normalMapped(n, surfaceAt, frameAt, frameTangents);
|
|
228
228
|
/* A draw's wrinkles, by region, over whatever the map made: overlay.ts. */
|
|
229
229
|
if (SURFACE_OVERLAY) n = overlayWrinkle(n, unmapped, surfaceAt.xy);
|
|
230
|
+
/* The material's tiled detail over whatever the maps made, and its occlusion: detail.ts. */
|
|
231
|
+
if (SURFACE_DETAIL && detailed()) surfaceDetail(n, ormOcclusion, surfaceAt.xy);
|
|
230
232
|
|
|
231
233
|
/*
|
|
232
234
|
* Microscopic relief: the surface's own texture, as a turn of the normal rather than a change
|
|
@@ -693,8 +695,9 @@ export const MAIN_GLSL = `void main() {
|
|
|
693
695
|
* branch it did not take before.
|
|
694
696
|
*/
|
|
695
697
|
/* A model reflects its environment whatever the pass asked of the standard model: see
|
|
696
|
-
modelReflectance. On the switches alone, so the derivatives
|
|
697
|
-
|
|
698
|
+
modelReflectance. Hair takes none: modelReflects. On the switches alone, so the derivatives
|
|
699
|
+
below stay in uniform flow. */
|
|
700
|
+
if ((uEnvironmentDials.y > 0.0 || uMaterialFlags.y != 0 || modelled) && modelReflects()) {
|
|
698
701
|
vec3 toEye = normalize(uCameraPos - vWorldPos);
|
|
699
702
|
vec3 mirrored = reflect(-toEye, modelled ? modelReflectNormal(n) : n);
|
|
700
703
|
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
|
|
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
|
|
@@ -95,6 +95,15 @@ bool modelSeesBehind() {
|
|
|
95
95
|
return false;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Whether the environment's reflection reaches this surface: every model's but hair's, whose share
|
|
100
|
+
* of it is in its light from every side (hair.ts).
|
|
101
|
+
*/
|
|
102
|
+
bool modelReflects() {
|
|
103
|
+
if (MODEL_HAIR) return false;
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
|
|
98
107
|
/* The surface a model shades, gathered once in main before any light reaches it. */
|
|
99
108
|
vec3 mNormal;
|
|
100
109
|
vec3 mToEye;
|
|
@@ -285,7 +294,6 @@ vec3 modelIrradiance(vec3 irradiance) {
|
|
|
285
294
|
/** The normal the environment is reflected about: the surface's own, but for a stretched lobe. */
|
|
286
295
|
vec3 modelReflectNormal(vec3 n) {
|
|
287
296
|
if (MODEL_ANISOTROPIC) return anisotropicReflectNormal(n);
|
|
288
|
-
if (MODEL_HAIR) return hairAcross();
|
|
289
297
|
return n;
|
|
290
298
|
}
|
|
291
299
|
|
|
@@ -361,7 +369,6 @@ vec3 modelDiffuseOut(vec3 diffuse, float fog) {
|
|
|
361
369
|
* what the standard model would.
|
|
362
370
|
*/
|
|
363
371
|
float modelReflectance(float standard) {
|
|
364
|
-
if (MODEL_HAIR) return hairReflectance();
|
|
365
372
|
if (MODEL_SKIN) return skinReflectance();
|
|
366
373
|
if (MODEL_EYE) return eyeReflectance();
|
|
367
374
|
return standard;
|