退役(零视觉影响: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 案不变
138 lines
3.1 KiB
JavaScript
138 lines
3.1 KiB
JavaScript
import {
|
|
UniformsLib,
|
|
UniformsUtils,
|
|
Matrix4
|
|
} from 'three';
|
|
|
|
/**
|
|
* @module VelocityShader
|
|
* @three_import import { VelocityShader } from 'three/addons/shaders/VelocityShader.js';
|
|
*/
|
|
|
|
/**
|
|
* Mesh velocity shader by @bhouston.
|
|
*
|
|
* @constant
|
|
* @type {ShaderMaterial~Shader}
|
|
*/
|
|
const VelocityShader = {
|
|
|
|
name: 'VelocityShader',
|
|
|
|
uniforms: UniformsUtils.merge( [
|
|
UniformsLib.common,
|
|
UniformsLib.displacementmap,
|
|
{
|
|
modelMatrixPrev: { value: new Matrix4() },
|
|
currentProjectionViewMatrix: { value: new Matrix4() },
|
|
previousProjectionViewMatrix: { value: new Matrix4() }
|
|
}
|
|
] ),
|
|
|
|
vertexShader: /* glsl */`
|
|
#define NORMAL
|
|
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
|
|
varying vec3 vViewPosition;
|
|
|
|
#endif
|
|
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
|
|
uniform mat4 previousProjectionViewMatrix;
|
|
uniform mat4 currentProjectionViewMatrix;
|
|
|
|
uniform mat4 modelMatrixPrev;
|
|
|
|
varying vec4 clipPositionCurrent;
|
|
varying vec4 clipPositionPrevious;
|
|
|
|
void main() {
|
|
|
|
|
|
#include <uv_vertex>
|
|
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
|
|
#ifdef USE_SKINNING
|
|
|
|
vec4 mvPosition = modelViewMatrix * skinned;
|
|
clipPositionCurrent = currentProjectionViewMatrix * modelMatrix * skinned;
|
|
clipPositionPrevious = previousProjectionViewMatrix * modelMatrixPrev * skinned;
|
|
|
|
#else
|
|
|
|
vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );
|
|
clipPositionCurrent = currentProjectionViewMatrix * modelMatrix * vec4( transformed, 1.0 );
|
|
clipPositionPrevious = previousProjectionViewMatrix * modelMatrixPrev * vec4( transformed, 1.0 );
|
|
|
|
#endif
|
|
|
|
gl_Position = projectionMatrix * mvPosition;
|
|
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
}
|
|
`,
|
|
fragmentShader: /* glsl */`
|
|
#define NORMAL
|
|
|
|
uniform float opacity;
|
|
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
|
|
varying vec4 clipPositionCurrent;
|
|
varying vec4 clipPositionPrevious;
|
|
|
|
void main() {
|
|
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
diffuseColor.a = opacity;
|
|
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
|
|
vec2 ndcPositionCurrent = clipPositionCurrent.xy/clipPositionCurrent.w;
|
|
vec2 ndcPositionPrevious = clipPositionPrevious.xy/clipPositionPrevious.w;
|
|
vec2 vel = ( ndcPositionCurrent - ndcPositionPrevious ) * 0.5;
|
|
vel = vel * 0.5 + 0.5;
|
|
vec2 v1 = packDepthToRG(vel.x);
|
|
vec2 v2 = packDepthToRG(vel.y);
|
|
gl_FragColor = vec4(v1.x, v1.y, v2.x, v2.y);
|
|
|
|
#include <logdepthbuf_fragment>
|
|
|
|
}
|
|
|
|
`
|
|
};
|
|
|
|
export { VelocityShader };
|