bx-1480-shaderexp #76

Merged
ksenia_mikhailova merged 5 commits from bx-1480-shaderexp into dev 2024-10-01 11:03:26 +03:00
1 changed files with 5 additions and 2 deletions
Showing only changes of commit 219d652e71 - Show all commits

View File

@ -54,10 +54,12 @@ const m_onBeforeCompile = (shader) => {
// Изменяем вершинный шейдер // Изменяем вершинный шейдер
shader.vertexShader = ` shader.vertexShader = `
varying float vDistance;
${shader.vertexShader} ${shader.vertexShader}
`.replace( `.replace(
`#include <begin_vertex>`, `#include <begin_vertex>`,
`#include <begin_vertex> `#include <begin_vertex>
vDistance = length(position
` `
); );
@ -66,6 +68,7 @@ const m_onBeforeCompile = (shader) => {
uniform vec2 u_resolution; uniform vec2 u_resolution;
uniform vec2 u_mouse; uniform vec2 u_mouse;
uniform float u_time; uniform float u_time;
varying float vDistance;
float random (in float x) { float random (in float x) {
return fract(sin(x)*1e4); return fract(sin(x)*1e4);
} }
@ -108,7 +111,7 @@ const m_onBeforeCompile = (shader) => {
#include <normal_fragment_begin> #include <normal_fragment_begin>
// vec2 normal_st = gl_FragCoord.xy/vec2(u_resolution); // 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_pos = vec3(normal_st*5.0,1.0*0.5);
vec3 normal_noise = vec3(noise(normal_pos)); vec3 normal_noise = vec3(noise(normal_pos));
@ -120,7 +123,7 @@ const m_onBeforeCompile = (shader) => {
`#include <dithering_fragment>`, `#include <dithering_fragment>`,
`#include <dithering_fragment> `#include <dithering_fragment>
vec2 st = gl_FragCoord.xy/vec2(u_resolution); vec2 st = vDistance/vec2(u_resolution);
vec3 pos = vec3(st*5.0,1.0*0.5); vec3 pos = vec3(st*5.0,1.0*0.5);