anotherTunnelMessToWorkWith

This commit is contained in:
Marco
2024-02-23 11:28:00 +01:00
parent 8d8f7aacf6
commit 26fd76c2a1
57 changed files with 1320 additions and 112 deletions

View File

@@ -1,36 +1,106 @@
// Input varying representing the texture coordinates
varying vec2 vUv;
uniform float time;
uniform sampler2D u_texture;
// https://www.shadertoy.com/view/4djSRW
float hash12(vec2 p){
vec3 p3 = fract(vec3(p.xyx) * .1031);
// Time variable for animation
uniform float time;
uniform sampler2D u_texture; // Texture samplers for the two textures
uniform sampler2D u_texture2; // Texture samplers for the two textures
uniform float transparency1; // Transparencies (opacities) for the two textures
uniform float transparency2; // Transparencies (opacities) for the two textures
uniform vec2 scale; // UV coordinates scaling
uniform vec2 offset; // UV coordinates offset
uniform float rotation; // Rotation angle for UV coordinates
uniform float turbulence; // Turbulence factor for UV coordinates distortion
uniform float colorOffset; // Offset for color modification
uniform float brightness; // Brightness adjustment
uniform float distortionFactorX; // Distortion factor along the X-axis
uniform float repeatX; // Texture repeat along the X-axis
uniform float repeatY; // Texture repeat along the Y-axis
uniform float aspectRatioCorrection; // Correction factor for texture aspect ratio
uniform float distortionFactorY; // Distortion factor along the Y-axis
uniform float waveSpeed; // Speed of the waving effect
uniform float globalScale; // Global scaling factor for UV coordinates
uniform float twist; // Twist factor for UV coordinates
uniform float waveFrequency; // Frequency of the waving effect
uniform float depthFactor; // Depth modulation factor for waving effect
uniform float glowIntensity; // Intensity of the glow effect
uniform float pulseSpeed; // Speed of the pulsation effect
uniform float colorR; // R color components for tinting
uniform float colorG; // G color components for tinting
uniform float colorB; // B color components for tinting
// Hash function for generating pseudo-random numbers
float hash12(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}
void main() {
// Get the texture coordinates
vec2 uv = vUv;
uv.x *= 3.142596;
// Apply scaling to the UV coordinates
uv *= scale;
const float numbers = 9.0;
// Apply rotation to the UV coordinates
uv = vec2(
uv.x * cos(rotation) - uv.y * sin(rotation),
uv.x * sin(rotation) + uv.y * cos(rotation)
);
vec2 repeat = vec2(6.0, 12.0);
// Apply offset to the UV coordinates
uv += offset;
vec2 cell = (uv * repeat);
// Apply turbulence to the UV coordinates
uv += turbulence * sin(time * 0.1) * vec2(hash12(uv), hash12(uv * 2.0));
cell.x *= numbers;
cell = floor(cell);
// Apply color offset to UV coordinates
uv += colorOffset;
float rand = 100.0 * hash12(cell);
// Adjust UV coordinates to account for the aspect ratio of the texture
uv *= vec2(aspectRatioCorrection, 1.0);
float offset = mod(floor(time + rand), numbers) / numbers;
uv = fract(uv * repeat);
uv.x = fract(uv.x + offset);
// Encourage wrapping by using the fract function on the UV coordinates
uv = fract(uv);
vec4 color = texture2D(u_texture, uv);
// Sample colors from the two textures
vec4 color1 = texture2D(u_texture, uv);
vec4 color2 = texture2D(u_texture2, uv);
color -= 0.05 * vec4(vec3(rand), 1.0);
gl_FragColor = color;
}
// Multiply texture colors by their respective transparencies (opacities)
color1 *= vec4(1.0, 1.0, 1.0, transparency1);
color2 *= vec4(1.0, 1.0, 1.0, transparency2);
// Example: This wil render the first texture on 100% and the second texture will be on top
// vec4 finalColor = mix(color1 * transparency1, vec4(0.0), transparency2) + color2 * transparency2;
// Same as before but swapped layers
// vec4 finalColor = mix(color2 * transparency2, vec4(0.0), transparency1) + color1 * transparency1;
vec4 finalColor;
if (transparency1 >= 0.0) {
finalColor = mix(color1 * transparency1, vec4(0.0), transparency2) + color2 * transparency2;
} else if (transparency2 >= 0.0) {
finalColor = mix(color2 * transparency2, vec4(0.0), transparency1) + color1 * transparency1;
}
// Modify finalColor based on brightness
finalColor.rgb *= brightness;
// Pulsation effect
float pulse = 0.5 + 0.5 * sin(time * pulseSpeed);
finalColor.rgb += pulse * glowIntensity;
// Waving effect
float wave = sin(time * waveSpeed + uv.y * waveFrequency);
uv.x += wave * depthFactor;
finalColor.rgb += wave * depthFactor;
// Set the final color as the output
gl_FragColor = finalColor;
}

View File

@@ -0,0 +1,35 @@
varying vec2 vUv;
uniform sampler2D u_texture;
// https://www.shadertoy.com/view/4djSRW
float hash12(vec2 p){
vec3 p3 = fract(vec3(p.xyx) * .1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}
void main() {
vec2 uv = vUv;
const float numbers = 9.0;
vec2 repeat = vec2(6.0, 12.0);
vec2 cell = floor(uv * repeat * numbers);
float rand = 100.0 * hash12(cell);
float grid = mod(cell.x + cell.y, 2.0); // Grid pattern
// Create holes by checking the hash value
float holeThreshold = 0.2;
float hole = step(holeThreshold, hash12(cell + vec2(rand)));
vec4 color = texture2D(u_texture, uv);
// Apply the grid pattern and holes
color.rgb *= mix(1.0, 0.8, grid); // Darken the grid cells
color.rgb *= hole; // Make holes transparent
gl_FragColor = color;
}

View File

@@ -0,0 +1,12 @@
varying vec2 vUv;
uniform float time;
void main() {
vUv = uv;
// Adjust the scale factor based on your desired appearance
float scale = 0.5; // Adjust as needed
vUv.y *= scale;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}

View File

@@ -0,0 +1,7 @@
varying vec2 vUv;
uniform sampler2D u_texture;
void main() {
vec4 color = texture2D(u_texture, vUv);
gl_FragColor = color;
}

View File

@@ -0,0 +1,25 @@
varying vec2 vUv;
uniform sampler2D u_texture;
// https://www.shadertoy.com/view/4djSRW
float hash12(vec2 p){
vec3 p3 = fract(vec3(p.xyx) * .1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}
void main() {
vec2 uv = vUv;
const float numbers = 9.0;
vec2 repeat = vec2(1.0, 1.0);
vec2 cell = floor(uv * repeat * numbers);
float rand = 100.0 * hash12(cell);
vec4 color = texture2D(u_texture, uv);
gl_FragColor = color;
}

View File

@@ -1,9 +1,16 @@
// vertex.glsl
varying vec2 vUv;
uniform float time;
uniform float distortionFactorX;
uniform float distortionFactorY; // Added uniform for Y-axis distortion
void main() {
vUv = uv;
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
// Apply distortion to the X and Y coordinates
float distortedX = position.x + sin(position.y * distortionFactorX) * 0.2;
float distortedY = position.y + cos(position.x * distortionFactorY) * 0.2;
gl_Position = projectionMatrix * modelViewMatrix * vec4(distortedX, distortedY, position.z, 1.0);
}