退役(零视觉影响:NEXT_PUBLIC_HERO_SCENE 从未在任何 .env* 设置): - 删 hero-scene.tsx(694行)/caption/单测/文案真源/CC0 机柜/海报帧 - R26 删除、R22 登记归零、e2e heroSceneMask 移除(无命中的假安全网) - R22 自证改可注入(夹具不再依赖生产条目) 落库(flag NEXT_PUBLIC_HERO_FIELD 样期默认关 ⇒ 基线零影响): - hero-field.tsx 三拍:噪声→增长→判断;bloom 半分辨率;DPR≤1.5 - 降级统一看结论帧(reduced-motion 定格 T_HOLD=40500 非 0) - 文案真源含承诺词正则守卫(禁帮助/赋能/提升/%/倍) - 海报帧 capture 脚本与资产同批入库(1920x864/26.9KB,可复现) - eslint 忽略 demo/**/vendor/**(vendored three 不可被 lint-staged --fix 改写) 守卫重建:R26 指向 hero-field(43260ms/3 拍合规);R22 登记 HeroField 条目 验证:tsc 0 / eslint 0 error / jest 162 套件 1906 例 / check:grammar 26+26 / check:a11y 0 违规 / 默认构建首页 DOM 冒烟 E 案不变
107 lines
2.0 KiB
JavaScript
107 lines
2.0 KiB
JavaScript
/**
|
|
* @module WaterRefractionShader
|
|
* @three_import import { WaterRefractionShader } from 'three/addons/shaders/WaterRefractionShader.js';
|
|
*/
|
|
|
|
/**
|
|
* Basic water refraction shader.
|
|
*
|
|
* @constant
|
|
* @type {ShaderMaterial~Shader}
|
|
*/
|
|
const WaterRefractionShader = {
|
|
|
|
name: 'WaterRefractionShader',
|
|
|
|
uniforms: {
|
|
|
|
'color': {
|
|
value: null
|
|
},
|
|
|
|
'time': {
|
|
value: 0
|
|
},
|
|
|
|
'tDiffuse': {
|
|
value: null
|
|
},
|
|
|
|
'tDudv': {
|
|
value: null
|
|
},
|
|
|
|
'textureMatrix': {
|
|
value: null
|
|
}
|
|
|
|
},
|
|
|
|
vertexShader: /* glsl */`
|
|
|
|
uniform mat4 textureMatrix;
|
|
|
|
varying vec2 vUv;
|
|
varying vec4 vUvRefraction;
|
|
|
|
void main() {
|
|
|
|
vUv = uv;
|
|
|
|
vUvRefraction = textureMatrix * vec4( position, 1.0 );
|
|
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
|
|
}`,
|
|
|
|
fragmentShader: /* glsl */`
|
|
|
|
uniform vec3 color;
|
|
uniform float time;
|
|
uniform sampler2D tDiffuse;
|
|
uniform sampler2D tDudv;
|
|
|
|
varying vec2 vUv;
|
|
varying vec4 vUvRefraction;
|
|
|
|
float blendOverlay( float base, float blend ) {
|
|
|
|
return( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );
|
|
|
|
}
|
|
|
|
vec3 blendOverlay( vec3 base, vec3 blend ) {
|
|
|
|
return vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ),blendOverlay( base.b, blend.b ) );
|
|
|
|
}
|
|
|
|
void main() {
|
|
|
|
float waveStrength = 0.5;
|
|
float waveSpeed = 0.03;
|
|
|
|
// simple distortion (ripple) via dudv map (see https://www.youtube.com/watch?v=6B7IF6GOu7s)
|
|
|
|
vec2 distortedUv = texture2D( tDudv, vec2( vUv.x + time * waveSpeed, vUv.y ) ).rg * waveStrength;
|
|
distortedUv = vUv.xy + vec2( distortedUv.x, distortedUv.y + time * waveSpeed );
|
|
vec2 distortion = ( texture2D( tDudv, distortedUv ).rg * 2.0 - 1.0 ) * waveStrength;
|
|
|
|
// new uv coords
|
|
|
|
vec4 uv = vec4( vUvRefraction );
|
|
uv.xy += distortion;
|
|
|
|
vec4 base = texture2DProj( tDiffuse, uv );
|
|
|
|
gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );
|
|
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
|
|
}`
|
|
|
|
};
|
|
|
|
export { WaterRefractionShader };
|