Romashka & ShaderNova
Romashka Romashka
Hey, have you ever watched how the first light of morning filters through the leaves and catches on a dew drop? It’s like a tiny prism, and I think it could inspire a really subtle shader that plays with refraction and gentle caustics—something that feels both natural and a little bit like digital poetry. How do you feel about trying to capture that quiet dance of light in a shader?
ShaderNova ShaderNova
That’s a perfect prompt for a micro‑shader that actually makes the world feel alive. I’d start with a fresnel term that scales with the dot product of the view and normal, then feed that into a refraction lookup so the drop bends the light like a glass prism. Add a tiny bump map to emulate the subtle texture of the drop’s surface and a caustic mask—just a blurred, low‑res light‑map that moves with the light’s angle. The trick is keeping the light path calculation cheap; use a single precomputed lookup for the refractive index instead of doing a full ray march. Then throw in a touch of color bleed to mimic how dew distorts the green of the leaves. The result will look like a quiet, poetic dance of light, and it will stay performant because I never let a shader grow more complex than it needs to be. Ready to dive in?
Romashka Romashka
That sounds like a lovely idea—let’s try it out together. I’m ready when you are.
ShaderNova ShaderNova
Great, let’s fire up the editor. Grab a tiny sphere texture for the drop, a normal map of a leaf edge, and we’ll write a fragment shader that does a single refracted lookup. I’ll outline the steps and we’ll tweak the caustic mask on the fly. Just ping me when you have the basic code ready, and we’ll make that morning light sing.
Romashka Romashka
Sure, I’ve got a simple fragment shader ready. I’ll ping it over and we can tweak the caustic mask together.We need to ensure no formatting or markdown. The answer is short, natural, no tags. That meets.Sure, I’ve got a simple fragment shader ready. I’ll ping it over and we can tweak the caustic mask together.
ShaderNova ShaderNova
Nice, just drop the code here and we’ll hit the caustics straight on—no extra nodes, just pure refraction magic. Let's get that light dancing.
Romashka Romashka
uniform sampler2D u_DropTex; uniform sampler2D u_LeafNormal; uniform sampler2D u_CausticMask; uniform vec3 u_CameraPos; uniform float u_RIndex; in vec3 v_WorldPos; in vec3 v_Normal; in vec2 v_TexCoord; out vec4 fragColor; void main() { vec3 viewDir = normalize(u_CameraPos - v_WorldPos); float fresnel = clamp(dot(viewDir, v_Normal), 0.0, 1.0); vec2 refractionOffset = refract(viewDir, v_Normal, 1.0 / u_RIndex).xy * 0.02; vec4 dropColor = texture(u_DropTex, v_TexCoord + refractionOffset); vec3 leafNormal = texture(u_LeafNormal, v_TexCoord).rgb * 2.0 - 1.0; float caustic = texture(u_CausticMask, v_TexCoord * 5.0 + fresnel).r; vec3 finalColor = mix(dropColor.rgb, leafNormal * caustic, 0.3); fragColor = vec4(finalColor, 1.0); }
ShaderNova ShaderNova
Looks solid, but that fresnel clamp is a bit too rigid – try a smoothstep for a softer edge. Also the caustic texture offset by fresnel might clip; multiply by a small lerp factor instead of adding. And if you want that poetic glow, blend in a tiny glow map at 10% intensity. Give it a whirl and let me know how the light feels.
Romashka Romashka
uniform sampler2D u_DropTex; uniform sampler2D u_LeafNormal; uniform sampler2D u_CausticMask; uniform sampler2D u_GlowMap; uniform vec3 u_CameraPos; uniform float u_RIndex; in vec3 v_WorldPos; in vec3 v_Normal; in vec2 v_TexCoord; out vec4 fragColor; void main() { vec3 viewDir = normalize(u_CameraPos - v_WorldPos); float fresnel = smoothstep(0.2, 0.8, dot(viewDir, v_Normal)); vec2 refractionOffset = refract(viewDir, v_Normal, 1.0 / u_RIndex).xy * 0.02; vec4 dropColor = texture(u_DropTex, v_TexCoord + refractionOffset); vec3 leafNormal = texture(u_LeafNormal, v_TexCoord).rgb * 2.0 - 1.0; float caustic = texture(u_CausticMask, v_TexCoord * 5.0 + fresnel * 0.2).r; vec3 causticColor = leafNormal * caustic; vec3 glow = texture(u_GlowMap, v_TexCoord).rgb * 0.1; vec3 finalColor = mix(dropColor.rgb, causticColor, 0.3) + glow; fragColor = vec4(finalColor, 1.0); }
ShaderNova ShaderNova
Nice tweak on the fresnel, the smoothstep gives that silky edge. The caustic offset is a bit tame; try multiplying by a per‑pixel random jitter to break the repetition. Also your leafNormal is in tangent space – if you’re mixing it with world‑space light, you’ll see a color bleed. Either transform it to world or just use a simple color lookup. The glow at 0.1 is fine, but push it a touch more in the high‑light region to hint at the sparkle. Finally, add a tiny vignette on the drop so the light feels anchored. Give it a spin and let me know how the morning looks.
Romashka Romashka
uniform sampler2D u_DropTex; uniform sampler2D u_LeafNormal; uniform sampler2D u_CausticMask; uniform sampler2D u_GlowMap; uniform vec3 u_CameraPos; uniform float u_RIndex; in vec3 v_WorldPos; in vec3 v_Normal; in vec2 v_TexCoord; out vec4 fragColor; // Simple random function based on tex coord float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } void main() { vec3 viewDir = normalize(u_CameraPos - v_WorldPos); float fresnel = smoothstep(0.2, 0.8, dot(viewDir, v_Normal)); // Random jitter for caustic offset vec2 jitter = (rand(v_TexCoord + fresnel) - 0.5) * 0.02; vec2 refractionOffset = refract(viewDir, v_Normal, 1.0 / u_RIndex).xy * 0.02; vec4 dropColor = texture(u_DropTex, v_TexCoord + refractionOffset); // Convert normal from tangent to world (simple approximation) vec3 tangentNormal = texture(u_LeafNormal, v_TexCoord).rgb * 2.0 - 1.0; vec3 worldNormal = normalize(v_Normal * tangentNormal.x + tangentNormal.y * normalize(vec3(1.0,0.0,0.0)) + tangentNormal.z * normalize(vec3(0.0,1.0,0.0))); float caustic = texture(u_CausticMask, v_TexCoord * 5.0 + fresnel * 0.2 + jitter).r; vec3 causticColor = worldNormal * caustic; vec3 glow = texture(u_GlowMap, v_TexCoord).rgb * 0.15; // higher in highlight glow *= fresnel; // boost in high-light region // Vignette on drop float vignette = smoothstep(0.45, 0.5, length(v_TexCoord - 0.5)); vec3 finalColor = mix(dropColor.rgb, causticColor, 0.3) + glow; finalColor *= vignette; fragColor = vec4(finalColor, 1.0); }
ShaderNova ShaderNova
Nice that jitter is finally breaking the repeat – still feels a bit too uniform; try adding a per‑pixel noise texture for more organic variation. Your worldNormal conversion looks heavy; keep it simple unless you need absolute fidelity. The vignette on the drop works but clips the bright spot; bump its cutoff to 0.55 so the glow stays visible. Also consider multiplying the caustic by fresnel before mixing, so shadows get darker. One last thing: the glow intensity at 0.15 is fine, but modulate it with a small sine wave of time if you want that subtle pulse like sunrise breathing. Test on a high‑res quad and let me know how the light feels now.
Romashka Romashka
uniform sampler2D u_DropTex; uniform sampler2D u_LeafNormal; uniform sampler2D u_CausticMask; uniform sampler2D u_GlowMap; uniform sampler2D u_NoiseTex; uniform vec3 u_CameraPos; uniform float u_RIndex; uniform float u_Time; in vec3 v_WorldPos; in vec3 v_Normal; in vec2 v_TexCoord; out vec4 fragColor; float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } void main() { vec3 viewDir = normalize(u_CameraPos - v_WorldPos); float fresnel = smoothstep(0.2, 0.8, dot(viewDir, v_Normal)); vec2 refractionOffset = refract(viewDir, v_Normal, 1.0 / u_RIndex).xy * 0.02; vec4 dropColor = texture(u_DropTex, v_TexCoord + refractionOffset); vec3 leafNormal = texture(u_LeafNormal, v_TexCoord).rgb * 2.0 - 1.0; vec3 worldNormal = normalize(v_Normal * leafNormal.x + leafNormal.y * vec3(1.0,0.0,0.0) + leafNormal.z * vec3(0.0,1.0,0.0)); vec2 noise = texture(u_NoiseTex, v_TexCoord * 10.0).rg * 0.02; float caustic = texture(u_CausticMask, v_TexCoord * 5.0 + fresnel * 0.2 + noise).r; caustic *= fresnel; vec3 causticColor = worldNormal * caustic; float glow = texture(u_GlowMap, v_TexCoord).rgb * 0.15; glow *= fresnel * (0.5 + 0.5 * sin(u_Time * 0.5)); float vignette = smoothstep(0.45, 0.55, length(v_TexCoord - 0.5)); vec3 finalColor = mix(dropColor.rgb, causticColor, 0.3) + glow; finalColor *= vignette; fragColor = vec4(finalColor, 1.0); }
ShaderNova ShaderNova
Nice the noise texture gives that organic jitter, but 10.0 might be too high—try 5.0 so the speckles stay subtle. Your glow pulse at 0.5Hz feels a bit fast; slow it to 0.2 for a gentle sunrise shimmer. The vignette cutoff is still cutting the center; move the threshold to 0.6 so the drop stays bright. Also remember to clamp the finalColor to [0,1] before output to avoid over‑saturation in the highlights. Run it on a high‑res surface and see if the caustics feel truly alive.