New project: party stage
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
export const fireVertexShader = `
|
||||
varying vec2 vUv;
|
||||
void main() {
|
||||
vUv = uv;
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
||||
}
|
||||
`;
|
||||
|
||||
export const fireFragmentShader = `
|
||||
varying vec2 vUv;
|
||||
uniform float u_time;
|
||||
|
||||
// 2D Random function
|
||||
float random (vec2 st) {
|
||||
return fract(sin(dot(st.xy,
|
||||
vec2(12.9898,78.233)))*
|
||||
43758.5453123);
|
||||
}
|
||||
|
||||
// 2D Noise function
|
||||
float noise (in vec2 st) {
|
||||
vec2 i = floor(st);
|
||||
vec2 f = fract(st);
|
||||
|
||||
float a = random(i);
|
||||
float b = random(i + vec2(1.0, 0.0));
|
||||
float c = random(i + vec2(0.0, 1.0));
|
||||
float d = random(i + vec2(1.0, 1.0));
|
||||
|
||||
vec2 u = f*f*(3.0-2.0*f);
|
||||
return mix(a, b, u.x) +
|
||||
(c - a)* u.y * (1.0 - u.x) +
|
||||
(d - b) * u.x * u.y;
|
||||
}
|
||||
|
||||
// Fractional Brownian Motion to create more complex noise
|
||||
float fbm(in vec2 st) {
|
||||
float value = 0.0;
|
||||
float amplitude = 0.5;
|
||||
float frequency = 0.0;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
value += amplitude * noise(st);
|
||||
st *= 2.0;
|
||||
amplitude *= 0.5;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = vUv;
|
||||
float q = fbm(uv * 2.0 - vec2(0.0, u_time * 1.2));
|
||||
float r = fbm(uv * 2.0 + q + vec2(1.7, 9.2) + vec2(0.0, u_time * -0.3));
|
||||
|
||||
float fireAmount = fbm(uv * 2.0 + r + vec2(0.0, u_time * 0.15));
|
||||
|
||||
// Shape the fire to rise from the bottom
|
||||
fireAmount *= (1.0 - uv.y);
|
||||
|
||||
vec3 fireColor = mix(vec3(0.9, 0.3, 0.1), vec3(1.0, 0.9, 0.3), fireAmount);
|
||||
gl_FragColor = vec4(fireColor, fireAmount * 2.0);
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,94 @@
|
||||
export const screenVertexShader = `
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
vUv = uv;
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
||||
}
|
||||
`;
|
||||
|
||||
export const screenFragmentShader = `
|
||||
varying vec2 vUv;
|
||||
uniform sampler2D videoTexture;
|
||||
uniform float u_effect_type; // 0: none, 1: warmup, 2: powerdown
|
||||
uniform float u_effect_strength; // 0.0 to 1.0
|
||||
uniform float u_time;
|
||||
|
||||
// 2D Random function
|
||||
float random (vec2 st) {
|
||||
return fract(sin(dot(st.xy,
|
||||
vec2(12.9898,78.233)))*
|
||||
43758.5453123);
|
||||
}
|
||||
|
||||
// 2D Noise function
|
||||
float noise (vec2 st) {
|
||||
vec2 i = floor(st);
|
||||
vec2 f = fract(st);
|
||||
|
||||
float a = random(i);
|
||||
float b = random(i + vec2(1.0, 0.0));
|
||||
float c = random(i + vec2(0.0, 1.0));
|
||||
float d = random(i + vec2(1.0, 1.0));
|
||||
|
||||
vec2 u = f*f*(3.0-2.0*f);
|
||||
return mix(a, b, u.x) +
|
||||
(c - a)* u.y * (1.0 - u.x) +
|
||||
(d - b) * u.x * u.y;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 finalColor;
|
||||
|
||||
// Shimmering edge effect - ALWAYS ON
|
||||
vec4 videoColor = texture2D(videoTexture, vUv);
|
||||
|
||||
// Shimmering edge effect
|
||||
float dist = distance(vUv, vec2(0.5));
|
||||
float shimmer = noise(vUv * 20.0 + vec2(u_time * 2.0, 0.0));
|
||||
float edgeFactor = smoothstep(0.3, 0.5, dist);
|
||||
|
||||
vec3 shimmerColor = vec3(0.7, 0.8, 1.0) * shimmer * edgeFactor * 0.5;
|
||||
|
||||
vec4 baseColor = vec4(videoColor.rgb + shimmerColor, videoColor.a);
|
||||
|
||||
if (u_effect_type < 0.9) {
|
||||
// normal video
|
||||
finalColor = baseColor;
|
||||
} else if (u_effect_type < 1.9) { // "Summon Vision" (Warm-up) effect
|
||||
// This is now a multi-stage effect controlled by u_effect_strength (0.0 -> 1.0)
|
||||
float noiseVal = noise(vUv * 50.0 + vec2(0.0, u_time * -125.0));
|
||||
vec3 mistColor = vec3(0.8, 0.7, 1.0) * noiseVal;
|
||||
vec4 videoColor = texture2D(videoTexture, vUv);
|
||||
|
||||
// Stage 1: Fade in the mist (u_effect_strength: 0.0 -> 0.5)
|
||||
// The overall opacity of the surface fades from 0 to 1.
|
||||
float fadeInOpacity = smoothstep(0.0, 0.5, u_effect_strength);
|
||||
|
||||
// Stage 2: Fade out the mist to reveal the video (u_effect_strength: 0.5 -> 1.0)
|
||||
// The mix factor between mist and video goes from 0 (all mist) to 1 (all video).
|
||||
float revealMix = smoothstep(0.5, 1.0, u_effect_strength);
|
||||
|
||||
vec3 mixedColor = mix(mistColor, baseColor.rgb, revealMix);
|
||||
finalColor = vec4(mixedColor, fadeInOpacity);
|
||||
|
||||
} else { // "Vision Fades" (Power-down) effect
|
||||
// Multi-stage effect: Last frame -> fade to mist -> fade to transparent
|
||||
|
||||
float noiseVal = noise(vUv * 50.0 + vec2(0.0, u_time * 123.0));
|
||||
vec3 mistColor = vec3(0.8, 0.7, 1.0) * noiseVal;
|
||||
vec4 videoColor = texture2D(videoTexture, vUv);
|
||||
|
||||
// Stage 1: Fade in the mist over the last frame (u_effect_strength: 0.0 -> 0.5)
|
||||
float mistMix = smoothstep(0.0, 0.5, u_effect_strength);
|
||||
vec3 mixedColor = mix(baseColor.rgb, mistColor, mistMix);
|
||||
|
||||
// Stage 2: Fade out the entire surface to transparent (u_effect_strength: 0.5 -> 1.0)
|
||||
float fadeOutOpacity = smoothstep(1.0, 0.5, u_effect_strength);
|
||||
|
||||
finalColor = vec4(mixedColor, fadeOutOpacity);
|
||||
}
|
||||
|
||||
gl_FragColor = finalColor;
|
||||
}
|
||||
`;
|
||||
@@ -0,0 +1,22 @@
|
||||
import * as THREE from 'three';
|
||||
|
||||
export function applyVibrancyToMaterial(material, texture) {
|
||||
// Inject custom shader code to boost vibrancy
|
||||
material.onBeforeCompile = (shader) => {
|
||||
// Pass the texture map to the fragment shader
|
||||
shader.uniforms.vibrancyMap = { value: texture };
|
||||
|
||||
shader.fragmentShader = 'uniform sampler2D vibrancyMap;\n' + shader.fragmentShader;
|
||||
shader.fragmentShader = shader.fragmentShader.replace(
|
||||
'#include <dithering_fragment>',
|
||||
`
|
||||
#include <dithering_fragment>
|
||||
// Get the pure texture color
|
||||
vec4 texColor = texture2D(vibrancyMap, vMapUv);
|
||||
// Mix the final lit color with the pure texture color to keep it vibrant
|
||||
float vibrancy = 0.3; // 0.0 = full lighting, 1.0 = full texture color
|
||||
gl_FragColor.rgb = mix(gl_FragColor.rgb, texColor.rgb, vibrancy) + texColor.rgb * 0.2;
|
||||
`
|
||||
);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user