Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2cd0e007e4 | |||
| 9c86ecc338 |
@@ -452,11 +452,18 @@ function GlassModel({
|
|||||||
// Scene-texture FBO: render layer 0 (background + stickers) at half res.
|
// Scene-texture FBO: render layer 0 (background + stickers) at half res.
|
||||||
// Same as the original GlassSystem: one shared pass, camera mask forced to
|
// Same as the original GlassSystem: one shared pass, camera mask forced to
|
||||||
// layer 0 so glass meshes (layer 10) are excluded from their own refraction.
|
// layer 0 so glass meshes (layer 10) are excluded from their own refraction.
|
||||||
|
// ⚠ type: HalfFloatType —— 原版 sb() 工厂创建的所有 RT 均为 HalfFloat
|
||||||
|
// (4d3f3b68 @200877: {minFilter,magFilter,type:HalfFloatType,...})。
|
||||||
|
// UnsignedByte 的默认 RT 会让折射纹理的暗部量化/截断,Dark 主题下
|
||||||
|
// Hard-Light 着色的底色因此偏灰(模型"发透明感"而非饱和蓝)。
|
||||||
const fbo = useMemo(() => {
|
const fbo = useMemo(() => {
|
||||||
const dpr = gl.getPixelRatio();
|
const dpr = gl.getPixelRatio();
|
||||||
const w = Math.max(2, Math.floor((size.width * dpr) / 2));
|
const w = Math.max(2, Math.floor((size.width * dpr) / 2));
|
||||||
const h = Math.max(2, Math.floor((size.height * dpr) / 2));
|
const h = Math.max(2, Math.floor((size.height * dpr) / 2));
|
||||||
const target = new THREE.WebGLRenderTarget(w, h, {
|
const target = new THREE.WebGLRenderTarget(w, h, {
|
||||||
|
minFilter: THREE.LinearFilter,
|
||||||
|
magFilter: THREE.LinearFilter,
|
||||||
|
type: THREE.HalfFloatType,
|
||||||
stencilBuffer: false,
|
stencilBuffer: false,
|
||||||
depthBuffer: true,
|
depthBuffer: true,
|
||||||
samples: 0,
|
samples: 0,
|
||||||
@@ -523,44 +530,59 @@ function GlassModel({
|
|||||||
// flips. Per-model tingColor overrides: m[0]/m[1] light A/B,
|
// flips. Per-model tingColor overrides: m[0]/m[1] light A/B,
|
||||||
// m[2]/m[3] dark A/B, missing entries fall back to the theme defaults.
|
// m[2]/m[3] dark A/B, missing entries fall back to the theme defaults.
|
||||||
const isDark = useResolvedTheme() === "dark";
|
const isDark = useResolvedTheme() === "dark";
|
||||||
|
// ⚠ R3F 对 ShaderMaterial 的 `uniforms` prop 做的是「按键浅合并」:
|
||||||
|
// material.uniforms 是独立容器,标量按值拷贝、Vector4/Texture 共享引用,
|
||||||
|
// 且仅在 prop 引用变化时重新合并。材质创建后再改 memo 对象,标量
|
||||||
|
// (uDark、brightness、thickness alpha、loop…)永远到不了 GPU —— Dark
|
||||||
|
// 主题下 uDark 卡在 0、参数卡在 light 值,模型因此失色。原版所有
|
||||||
|
// apply 都写 T.current.uniforms(材质 ref);这里同样穿透到材质,
|
||||||
|
// 材质未挂载时回落到 memo(创建时会被拷贝进去),并以 mergedGeometry
|
||||||
|
// 作为「材质已存在」信号重跑(原版靠 tintYRange Y 的变化触发同一效果)。
|
||||||
|
const matUniforms = () =>
|
||||||
|
(materialRef.current?.uniforms ?? uniforms) as typeof uniforms;
|
||||||
// 原版移动端钳制 loop(apply effect: t=O?Math.min(B.loop,2):B.loop)——
|
// 原版移动端钳制 loop(apply effect: t=O?Math.min(B.loop,2):B.loop)——
|
||||||
// 折射采样少一轮,色散/亮度观感随设备宽度变化;桌面 3、移动 2。
|
// 折射采样少一轮,色散/亮度观感随设备宽度变化;桌面 3、移动 2。
|
||||||
const loop = isMobile ? Math.min(LIGHT_PARAMS.loop, 2) : LIGHT_PARAMS.loop;
|
const loop = isMobile ? Math.min(LIGHT_PARAMS.loop, 2) : LIGHT_PARAMS.loop;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
uniforms.uLoop.value = loop;
|
const u = matUniforms();
|
||||||
uniforms.uRgbRefraction.value = +(loop <= 3);
|
u.uLoop.value = loop;
|
||||||
}, [loop, uniforms]);
|
u.uRgbRefraction.value = +(loop <= 3);
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [loop, uniforms, mergedGeometry]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const u = matUniforms();
|
||||||
const P = isDark ? DARK_PARAMS : LIGHT_PARAMS;
|
const P = isDark ? DARK_PARAMS : LIGHT_PARAMS;
|
||||||
uniforms.uShininess.value = P.shininess;
|
u.uShininess.value = P.shininess;
|
||||||
uniforms.uDiffuseness.value = P.diffuseness;
|
u.uDiffuseness.value = P.diffuseness;
|
||||||
uniforms.uFresnelPower.value = P.fresnelPower;
|
u.uFresnelPower.value = P.fresnelPower;
|
||||||
uniforms.uFresnelStrength.value = P.fresnelStrength;
|
u.uFresnelStrength.value = P.fresnelStrength;
|
||||||
uniforms.uBrightness.value = P.brightness;
|
u.uBrightness.value = P.brightness;
|
||||||
uniforms.uContrast.value = P.contrast;
|
u.uContrast.value = P.contrast;
|
||||||
uniforms.uGamma.value = P.gamma;
|
u.uGamma.value = P.gamma;
|
||||||
uniforms.uSaturation.value = P.saturation;
|
u.uSaturation.value = P.saturation;
|
||||||
uniforms.uTintMix.value = P.tintMix;
|
u.uTintMix.value = P.tintMix;
|
||||||
uniforms.uTintThicknessMinAlpha.value = P.tintThicknessMinAlpha;
|
u.uTintThicknessMinAlpha.value = P.tintThicknessMinAlpha;
|
||||||
uniforms.uTintThicknessMaxAlpha.value = P.tintThicknessMaxAlpha;
|
u.uTintThicknessMaxAlpha.value = P.tintThicknessMaxAlpha;
|
||||||
const tintA = isDark
|
const tintA = isDark
|
||||||
? (tintColors?.[2] ?? DARK_PARAMS.tintColorA)
|
? (tintColors?.[2] ?? DARK_PARAMS.tintColorA)
|
||||||
: (tintColors?.[0] ?? LIGHT_PARAMS.tintColorA);
|
: (tintColors?.[0] ?? LIGHT_PARAMS.tintColorA);
|
||||||
const tintB = isDark
|
const tintB = isDark
|
||||||
? (tintColors?.[3] ?? DARK_PARAMS.tintColorB)
|
? (tintColors?.[3] ?? DARK_PARAMS.tintColorB)
|
||||||
: (tintColors?.[1] ?? LIGHT_PARAMS.tintColorB);
|
: (tintColors?.[1] ?? LIGHT_PARAMS.tintColorB);
|
||||||
uniforms.uTintColorA.value.copy(hexToVec4(tintA));
|
u.uTintColorA.value.copy(hexToVec4(tintA));
|
||||||
uniforms.uTintColorB.value.copy(hexToVec4(tintB));
|
u.uTintColorB.value.copy(hexToVec4(tintB));
|
||||||
uniforms.uDark.value = isDark ? 1 : 0;
|
u.uDark.value = isDark ? 1 : 0;
|
||||||
}, [isDark, tintColors, uniforms]);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [isDark, tintColors, uniforms, mergedGeometry]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const drawingBufferSize = gl.getDrawingBufferSize(new THREE.Vector2());
|
const drawingBufferSize = gl.getDrawingBufferSize(new THREE.Vector2());
|
||||||
uniforms.uScreenResolutionPx.value.set(
|
matUniforms().uScreenResolutionPx.value.set(
|
||||||
drawingBufferSize.x,
|
drawingBufferSize.x,
|
||||||
drawingBufferSize.y
|
drawingBufferSize.y
|
||||||
);
|
);
|
||||||
}, [gl, size, uniforms]);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [gl, size, uniforms, mergedGeometry]);
|
||||||
|
|
||||||
// Float bob: desktop only in the original (floatingMotion && !isMobileWidth)
|
// Float bob: desktop only in the original (floatingMotion && !isMobileWidth)
|
||||||
const floatEnabled = floating && !isMobile;
|
const floatEnabled = floating && !isMobile;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { useFrame, useThree } from "@react-three/fiber";
|
|||||||
import { EffectComposer } from "@react-three/postprocessing";
|
import { EffectComposer } from "@react-three/postprocessing";
|
||||||
import { UnsignedByteType, Vector2 } from "three";
|
import { UnsignedByteType, Vector2 } from "three";
|
||||||
import { usePointer } from "@/lib/pointer";
|
import { usePointer } from "@/lib/pointer";
|
||||||
|
import { useResolvedTheme } from "@/lib/shellMedia";
|
||||||
import { scrollBus } from "@/lib/scrollBus";
|
import { scrollBus } from "@/lib/scrollBus";
|
||||||
import {
|
import {
|
||||||
FluidPushPass,
|
FluidPushPass,
|
||||||
@@ -30,10 +31,15 @@ import {
|
|||||||
* lime trail acts as a pointer indicator over the dot curtain
|
* lime trail acts as a pointer indicator over the dot curtain
|
||||||
* - params: starRays 6, intensity .7, threshold .99, streakScale
|
* - params: starRays 6, intensity .7, threshold .99, streakScale
|
||||||
* 8·(w/1920)·(mobile?2:1), hotspotPower 32, gate .88,
|
* 8·(w/1920)·(mobile?2:1), hotspotPower 32, gate .88,
|
||||||
* tailColorLight #ffa300
|
* tailColor 随主题: light #ffa300 / dark #1600ff(原 lensFlare 控制
|
||||||
|
* tailColorLight/tailColorDark,resolvedTheme 切换)。
|
||||||
|
* ⚠ 尾迹色叠在玻璃高光热点上:Dark 下用橙色会把模型区域的
|
||||||
|
* r/g 抬高、显得"发灰发透明"而非原版的饱和蓝。
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const BRIGHT_SOURCE_SECTIONS = ["banner", "footer"];
|
const BRIGHT_SOURCE_SECTIONS = ["banner", "footer"];
|
||||||
|
const TAIL_COLOR_LIGHT = "#ffa300";
|
||||||
|
const TAIL_COLOR_DARK = "#1600ff";
|
||||||
const clamp01 = (v: number) => Math.min(1, Math.max(0, v));
|
const clamp01 = (v: number) => Math.min(1, Math.max(0, v));
|
||||||
const sT = (e?: number) => (e === undefined ? 0 : clamp01(e > 1 ? e / 100 : e));
|
const sT = (e?: number) => (e === undefined ? 0 : clamp01(e > 1 ? e / 100 : e));
|
||||||
|
|
||||||
@@ -81,6 +87,9 @@ export function PostFX() {
|
|||||||
const { uv: pointerUv, insideRef } = usePointer();
|
const { uv: pointerUv, insideRef } = usePointer();
|
||||||
const isMobile = size.width < 1024;
|
const isMobile = size.width < 1024;
|
||||||
const reducedMotion = useReducedMotion();
|
const reducedMotion = useReducedMotion();
|
||||||
|
// 尾迹色随主题(原版: resolvedTheme → tailColorDark / tailColorLight)
|
||||||
|
const isDark = useResolvedTheme() === "dark";
|
||||||
|
const tailColor = isDark ? TAIL_COLOR_DARK : TAIL_COLOR_LIGHT;
|
||||||
|
|
||||||
const composerRef = useRef<any>(null);
|
const composerRef = useRef<any>(null);
|
||||||
|
|
||||||
@@ -95,9 +104,11 @@ export function PostFX() {
|
|||||||
streakScale: 8,
|
streakScale: 8,
|
||||||
hotspotPower: 32,
|
hotspotPower: 32,
|
||||||
gate: 0.88,
|
gate: 0.88,
|
||||||
tailColor: "#ffa300",
|
tailColor,
|
||||||
}),
|
}),
|
||||||
[]
|
// 尾迹色随主题切换时需重建材质 uniform —— tailColor 进依赖
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
[tailColor]
|
||||||
);
|
);
|
||||||
const fluidPass = useMemo(() => new FluidPushPass(), []);
|
const fluidPass = useMemo(() => new FluidPushPass(), []);
|
||||||
|
|
||||||
@@ -124,9 +135,9 @@ export function PostFX() {
|
|||||||
streakScale,
|
streakScale,
|
||||||
hotspotPower: 32,
|
hotspotPower: 32,
|
||||||
gate: 0.88,
|
gate: 0.88,
|
||||||
tailColor: "#ffa300",
|
tailColor,
|
||||||
});
|
});
|
||||||
}, [flarePass, streakScale]);
|
}, [flarePass, streakScale, tailColor]);
|
||||||
|
|
||||||
const dprRef = useRef(1);
|
const dprRef = useRef(1);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ function seed() {
|
|||||||
about_p2: "我相信工程塑造可靠的产品,设计赋予它们灵魂;",
|
about_p2: "我相信工程塑造可靠的产品,设计赋予它们灵魂;",
|
||||||
about_p2_link_label: "我的作品",
|
about_p2_link_label: "我的作品",
|
||||||
intro_prefix:
|
intro_prefix:
|
||||||
"我是北极新一,一名横跨设计与工程的全栈开发者:Web 前端与后端、Flutter 客户端、AI 应用开发都有实践,也从产品设计一路做到工程落地。工作之外,我常在 ",
|
"我是北极新一,一名横跨设计与工程的全栈开发者:Web 前端与后端、移动端、AI 应用开发都有实践,也从产品设计一路做到工程落地。工作之外,我常在 ",
|
||||||
intro_suffix: " 上记录与分享这些探索。",
|
intro_suffix: " 上记录与分享这些探索。",
|
||||||
intro_brand: "小红书",
|
intro_brand: "小红书",
|
||||||
footer_headline: "让我们|创造|一些不凡的|数字作品",
|
footer_headline: "让我们|创造|一些不凡的|数字作品",
|
||||||
|
|||||||
Reference in New Issue
Block a user