diff --git a/utils/material.ts b/utils/material.ts index 55bb7c4..dd46b84 100644 --- a/utils/material.ts +++ b/utils/material.ts @@ -54,10 +54,12 @@ const m_onBeforeCompile = (shader) => { // Изменяем вершинный шейдер shader.vertexShader = ` + varying float vDistance; ${shader.vertexShader} `.replace( `#include `, `#include + vDistance = length(position ` ); @@ -66,6 +68,7 @@ const m_onBeforeCompile = (shader) => { uniform vec2 u_resolution; uniform vec2 u_mouse; uniform float u_time; + varying float vDistance; float random (in float x) { return fract(sin(x)*1e4); } @@ -108,7 +111,7 @@ const m_onBeforeCompile = (shader) => { #include // vec2 normal_st = gl_FragCoord.xy/vec2(u_resolution); - vec2 normal_st = gl_PointCoord.xy/vec2(u_resolution); + vec2 normal_st = vec2(vDistance, vDistance)/vec2(u_resolution); vec3 normal_pos = vec3(normal_st*5.0,1.0*0.5); vec3 normal_noise = vec3(noise(normal_pos)); @@ -120,7 +123,7 @@ const m_onBeforeCompile = (shader) => { `#include `, `#include - vec2 st = gl_FragCoord.xy/vec2(u_resolution); + vec2 st = vDistance/vec2(u_resolution); vec3 pos = vec3(st*5.0,1.0*0.5);