bx-1480-shaderexp #76
|
@ -54,10 +54,12 @@ const m_onBeforeCompile = (shader) => {
|
|||
|
||||
// Изменяем вершинный шейдер
|
||||
shader.vertexShader = `
|
||||
varying float vDistance;
|
||||
${shader.vertexShader}
|
||||
`.replace(
|
||||
`#include <begin_vertex>`,
|
||||
`#include <begin_vertex>
|
||||
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 <normal_fragment_begin>
|
||||
|
||||
// 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 <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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue