diff options
| author | prospanclaudebot <[email protected]> | 2026-07-10 22:50:12 +0000 |
|---|---|---|
| committer | prospanclaudebot <[email protected]> | 2026-07-10 22:50:12 +0000 |
| commit | 82be5d249c394460081370f1d033a93f32ced492 (patch) | |
| tree | 23685897d117f6ab4e334f2bfe17e5b656ef2c86 /serve | |
| parent | 61c14c061c896a93f3300f5ed59b43c8e9b45190 (diff) | |
| download | planeta-zhopa-82be5d249c394460081370f1d033a93f32ced492.tar.gz planeta-zhopa-82be5d249c394460081370f1d033a93f32ced492.zip | |
gfx: блум + хром-аберрация + цветокор + виньетка в фулскрин-проходе (по L выключается)
Diffstat (limited to 'serve')
| -rw-r--r-- | serve/index.html | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/serve/index.html b/serve/index.html index a1a7c1b..f8ce0f2 100644 --- a/serve/index.html +++ b/serve/index.html @@ -1657,12 +1657,20 @@ const _sunWorld = new THREE.Vector3(); let rtScene = new THREE.WebGLRenderTarget(innerWidth, innerHeight); const grScene = new THREE.Scene(), grCam = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1); const grMat = new THREE.ShaderMaterial({ - uniforms: { tScene: { value: null }, sunPos: { value: new THREE.Vector2(0.5, 0.8) }, intensity: { value: 0.0 } }, + uniforms: { tScene: { value: null }, sunPos: { value: new THREE.Vector2(0.5, 0.8) }, intensity: { value: 0.0 }, res: { value: new THREE.Vector2(innerWidth, innerHeight) } }, vertexShader: 'varying vec2 vUv; void main(){ vUv=uv; gl_Position=vec4(position,1.0); }', - fragmentShader: 'varying vec2 vUv; uniform sampler2D tScene; uniform vec2 sunPos; uniform float intensity;' + - 'void main(){ vec3 col=texture2D(tScene,vUv).rgb; vec2 stp=(sunPos-vUv)/40.0; vec2 uv=vUv; float dec=1.0; vec3 sh=vec3(0.0);' + - 'for(int i=0;i<40;i++){ uv+=stp; vec3 s=texture2D(tScene,uv).rgb; float b=max(s.r,max(s.g,s.b)); sh+=s*smoothstep(0.68,1.0,b)*dec; dec*=0.955; }' + - 'sh/=40.0; gl_FragColor=vec4(col+sh*intensity*vec3(1.05,0.98,0.82),1.0); }' + fragmentShader: 'varying vec2 vUv; uniform sampler2D tScene; uniform vec2 sunPos; uniform float intensity; uniform vec2 res;' + + 'vec3 bp(vec2 u){ vec3 s=texture2D(tScene,u).rgb; float b=max(s.r,max(s.g,s.b)); return s*smoothstep(0.62,1.05,b); }' + + 'void main(){ vec2 uv=vUv; vec2 d=uv-0.5; vec2 tx=1.0/res; float ca=0.0018; vec3 col;' + + 'col.r=texture2D(tScene,uv+d*ca).r; col.g=texture2D(tScene,uv).g; col.b=texture2D(tScene,uv-d*ca).b;' + + 'vec2 stp=(sunPos-uv)/40.0; vec2 gv=uv; float dec=1.0; vec3 sh=vec3(0.0);' + + 'for(int i=0;i<40;i++){ gv+=stp; vec3 s=texture2D(tScene,gv).rgb; float b=max(s.r,max(s.g,s.b)); sh+=s*smoothstep(0.68,1.0,b)*dec; dec*=0.955; }' + + 'sh/=40.0; col+=sh*intensity*vec3(1.05,0.98,0.82);' + + 'vec3 bl=vec3(0.0); for(int i=0;i<8;i++){ float a=float(i)*0.7853982; vec2 o=vec2(cos(a),sin(a)); bl+=bp(uv+o*tx*3.5); bl+=bp(uv+o*tx*8.0)*0.55; }' + + 'col+=bl*0.052;' + + 'col=(col-0.5)*1.07+0.5; float l=dot(col,vec3(0.299,0.587,0.114)); col=mix(vec3(l),col,1.16); col*=vec3(1.02,1.0,0.985);' + + 'float vig=1.0-smoothstep(0.35,1.2,length(d)*1.35); col*=mix(0.80,1.0,vig);' + + 'gl_FragColor=vec4(max(col,0.0),1.0); }' }); grScene.add(new THREE.Mesh(new THREE.PlaneGeometry(2, 2), grMat)); const _sunProj = new THREE.Vector3(); @@ -2067,6 +2075,7 @@ function tick(now) { _sunWorld.copy(sunDir).multiplyScalar(1150).add(camera.position); // sun world pos -> screen for god rays _sunProj.copy(_sunWorld).project(camera); grMat.uniforms.sunPos.value.set(_sunProj.x * 0.5 + 0.5, _sunProj.y * 0.5 + 0.5); + grMat.uniforms.res.value.set(innerWidth, innerHeight); grMat.uniforms.intensity.value = (_sunProj.z < 1) ? 0.55 : 0.0; renderer.setRenderTarget(rtScene); renderer.render(scene, camera); renderer.setRenderTarget(null); grMat.uniforms.tScene.value = rtScene.texture; |
