summaryrefslogtreecommitdiff
path: root/serve
diff options
context:
space:
mode:
authorprospanclaudebot <[email protected]>2026-07-10 23:10:11 +0000
committerprospanclaudebot <[email protected]>2026-07-10 23:10:11 +0000
commit6eaa49b191466f6a52d3fd004dcd9d87e1ac41b3 (patch)
treecfe671d75fc7e2543d8ae9628cbc05d12550e7af /serve
parent3326bb2b3af9f3a2f9252564a99ea0cfbc42b574 (diff)
downloadplaneta-zhopa-6eaa49b191466f6a52d3fd004dcd9d87e1ac41b3.tar.gz
planeta-zhopa-6eaa49b191466f6a52d3fd004dcd9d87e1ac41b3.zip
вода: процедурная roughness + пена во фрагменте (убрал последнюю baked-текстуру); земля: цвет-детейл
Diffstat (limited to 'serve')
-rw-r--r--serve/index.html30
1 files changed, 18 insertions, 12 deletions
diff --git a/serve/index.html b/serve/index.html
index 72bd3e6..f419d35 100644
--- a/serve/index.html
+++ b/serve/index.html
@@ -1268,6 +1268,7 @@ terrainMat.onBeforeCompile = (sh) => {
'float h21T(vec2 p){ return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453); }\n' +
'float vnT(vec2 p){ vec2 i=floor(p),f=fract(p); f=f*f*(3.0-2.0*f); return mix(mix(h21T(i),h21T(i+vec2(1.0,0.0)),f.x),mix(h21T(i+vec2(0.0,1.0)),h21T(i+vec2(1.0,1.0)),f.x),f.y); }\n' +
'float fbmT(vec2 p){ float a=0.5,s=0.0; for(int i=0;i<4;i++){ s+=a*vnT(p); p=p*2.03+17.1; a*=0.5; } return s; }\n')
+ .replace('#include <color_fragment>', '#include <color_fragment>\n diffuseColor.rgb *= 0.82 + 0.34*fbmT(vWPosT.xz*0.6);')
.replace('#include <roughnessmap_fragment>', '#include <roughnessmap_fragment>\n roughnessFactor *= 0.5 + 0.65*fbmT(vWPosT.xz*0.32);')
.replace('#include <normal_fragment_maps>', '#include <normal_fragment_maps>\n' +
' { float hh=fbmT(vWPosT.xz*0.34); vec2 dH=vec2(dFdx(hh),dFdy(hh))*15.0;' +
@@ -1282,19 +1283,24 @@ scene.add(terrain);
// glossy WATER in the low areas — roughness also varies (calm/rippled patches), never a perfect uniform mirror
const WATER_Y = MAP.waterY;
const waterTime = { value: 0 };
-const waterMat = new THREE.MeshStandardMaterial({ color: MAP.water, roughness: 1.0, metalness: 0.0, roughnessMap: roughTex(0.05, 0.04, 0.28), transparent: true, opacity: 0.9, polygonOffset: true, polygonOffsetFactor: -2, polygonOffsetUnits: -2 });
-waterMat.onBeforeCompile = (sh) => { // fractal-sine waves: displaces the surface + ripples the normal (so LTC/reflections shimmer)
+const waterMat = new THREE.MeshStandardMaterial({ color: MAP.water, roughness: 0.2, metalness: 0.0, transparent: true, opacity: 0.9, polygonOffset: true, polygonOffsetFactor: -2, polygonOffsetUnits: -2 });
+waterMat.onBeforeCompile = (sh) => { // гёрстнер-волны (vertex) + процедурная roughness/пена (fragment) — БЕЗ запечённых текстур
sh.uniforms.uTime = waterTime;
- const wfn = 'uniform float uTime;\n' +
- 'float oceanH(vec2 p){ float h=0.0,A=1.25,L=95.0; vec2 d=vec2(1.0,0.28);' +
- ' for(int i=0;i<6;i++){ vec2 dd=normalize(d); float k=6.2831853/L; float c=sqrt(9.8/k); h+=A*sin(dot(dd,p)*k+uTime*c*0.14); A*=0.62; L*=0.62; d=vec2(d.x*0.6-d.y*0.8,d.x*0.8+d.y*0.6); } return h; }\n' +
- 'vec3 oceanG(vec2 p){ vec3 o=vec3(0.0); float A=1.7,L=95.0; vec2 d=vec2(1.0,0.28);' +
- ' for(int i=0;i<6;i++){ vec2 dd=normalize(d); float k=6.2831853/L; float c=sqrt(9.8/k); float f=dot(dd,p)*k+uTime*c*0.14; float Q=0.6/(k*A*6.0); o.x+=Q*A*dd.x*cos(f); o.y+=Q*A*dd.y*cos(f); o.z+=A*sin(f); A*=0.62; L*=0.62; d=vec2(d.x*0.6-d.y*0.8,d.x*0.8+d.y*0.6); } return o; }\n';
- sh.vertexShader = wfn + sh.vertexShader;
- sh.vertexShader = sh.vertexShader.replace('#include <beginnormal_vertex>',
- '#include <beginnormal_vertex>\n float e=1.6; float wx=oceanH(position.xy+vec2(e,0.0))-oceanH(position.xy-vec2(e,0.0)); float wy=oceanH(position.xy+vec2(0.0,e))-oceanH(position.xy-vec2(0.0,e)); objectNormal=normalize(vec3(-wx,-wy,2.0*e));');
- sh.vertexShader = sh.vertexShader.replace('#include <begin_vertex>',
- '#include <begin_vertex>\n vec3 og=oceanG(position.xy); transformed.x+=og.x; transformed.y+=og.y; transformed.z+=og.z;');
+ const vfn = 'uniform float uTime;\nvarying float vWH; varying vec2 vWXZ;\n' +
+ 'float oceanH(vec2 p){ float h=0.0,A=1.7,L=95.0; vec2 d=vec2(1.0,0.28); for(int i=0;i<6;i++){ vec2 dd=normalize(d); float k=6.2831853/L; float c=sqrt(9.8/k); h+=A*sin(dot(dd,p)*k+uTime*c*0.14); A*=0.62; L*=0.62; d=vec2(d.x*0.6-d.y*0.8,d.x*0.8+d.y*0.6); } return h; }\n' +
+ 'vec3 oceanG(vec2 p){ vec3 o=vec3(0.0); float A=1.7,L=95.0; vec2 d=vec2(1.0,0.28); for(int i=0;i<6;i++){ vec2 dd=normalize(d); float k=6.2831853/L; float c=sqrt(9.8/k); float f=dot(dd,p)*k+uTime*c*0.14; float Q=0.6/(k*A*6.0); o.x+=Q*A*dd.x*cos(f); o.y+=Q*A*dd.y*cos(f); o.z+=A*sin(f); A*=0.62; L*=0.62; d=vec2(d.x*0.6-d.y*0.8,d.x*0.8+d.y*0.6); } return o; }\n';
+ sh.vertexShader = sh.vertexShader
+ .replace('#include <common>', '#include <common>\n' + vfn)
+ .replace('#include <beginnormal_vertex>', '#include <beginnormal_vertex>\n float e=1.6; float wx=oceanH(position.xy+vec2(e,0.0))-oceanH(position.xy-vec2(e,0.0)); float wy=oceanH(position.xy+vec2(0.0,e))-oceanH(position.xy-vec2(0.0,e)); objectNormal=normalize(vec3(-wx,-wy,2.0*e));')
+ .replace('#include <begin_vertex>', '#include <begin_vertex>\n vec3 og=oceanG(position.xy); transformed.x+=og.x; transformed.y+=og.y; transformed.z+=og.z; vWH=og.z; vWXZ=position.xy;');
+ const ffn = 'uniform float uTime;\nvarying float vWH; varying vec2 vWXZ;\n' +
+ 'float wh21(vec2 p){ return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453); }\n' +
+ 'float wvn(vec2 p){ vec2 i=floor(p),f=fract(p); f=f*f*(3.0-2.0*f); return mix(mix(wh21(i),wh21(i+vec2(1.0,0.0)),f.x),mix(wh21(i+vec2(0.0,1.0)),wh21(i+vec2(1.0,1.0)),f.x),f.y); }\n' +
+ 'float wfbm(vec2 p){ float a=0.5,s=0.0; for(int i=0;i<4;i++){ s+=a*wvn(p); p=p*2.03+9.1; a*=0.5; } return s; }\n';
+ sh.fragmentShader = sh.fragmentShader
+ .replace('#include <common>', '#include <common>\n' + ffn)
+ .replace('#include <color_fragment>', '#include <color_fragment>\n float wn=wfbm(vWXZ*0.12+uTime*0.03); float foam=smoothstep(2.1,3.6,vWH+wn*1.4); diffuseColor.rgb=mix(diffuseColor.rgb, vec3(0.82,0.9,0.96), foam*0.6);')
+ .replace('#include <roughnessmap_fragment>', '#include <roughnessmap_fragment>\n roughnessFactor = clamp(mix(0.08,0.5,wn) + foam*0.5, 0.03, 1.0);');
};
const water = new THREE.Mesh(new THREE.PlaneGeometry(TERR * 2, TERR * 2, 110, 110), waterMat);
water.rotation.x = -Math.PI / 2; water.position.y = WATER_Y; scene.add(water);