Topaz & ShaderNova
Topaz Topaz
I was sketching a crystal in my sleep and saw how its facets twist the city lights—almost like a shader that sings. Do you think we could craft a glow that feels like a cut gemstone, where each ray is a little poem of light?
ShaderNova ShaderNova
Sure, but don’t expect the built‑in glossy node to do the trick—real crystals need a fresnel that spikes at the edges, a refraction map that bends light per facet, and a specular term that feels like a whispered poem. Write a small GLSL snippet that pulls each facet’s normal from a lookup texture, then use a sine‑modulated offset for the ray directions so the glow feels alive, not flat. Or bake the whole thing into a 3D texture if you want to spare the CPU. Either way, the key is letting every facet talk to the light, not just glisten.
Topaz Topaz
Ah, the facets whisper like tiny jewels, let me show you a little ritual in GLSL that makes each one sing with light. uniform sampler2D facetNormals; uniform samplerCube envMap; uniform float time; in vec3 fragPos; in vec3 viewDir; out vec4 fragColor; void main() { // Grab the normal that belongs to this fragment from the lookup texture vec2 uv = gl_FragCoord.xy / resolution.xy; vec3 facetNormal = texture(facetNormals, uv).rgb * 2.0 - 1.0; // A sharp fresnel edge, because a crystal loves a dramatic flourish float fresnel = pow(1.0 - max(dot(viewDir, facetNormal), 0.0), 5.0); // Bend the light like a prism vec3 refractDir = refract(viewDir, facetNormal, 1.0/1.5); // Add a sine‑modulated wobble so the glow feels alive float sineMod = sin(dot(refractDir, vec3(1.0, 0.0, 0.0))*10.0 + time); refractDir += sineMod * 0.05 * facetNormal; // Sample the environment map for a whispered specular poem vec3 spec = texture(envMap, refractDir).rgb * fresnel; fragColor = vec4(spec, 1.0); }
ShaderNova ShaderNova
Nice trick, but that uv hack will bleed the facets unless you pack the normals into the same resolution as your geometry. Try sampling from a 3D normal map tied to the mesh or use a screen‑space lookup if you’re doing SSAO. Also that 0.05 wobble will be drowned in the fresnel spike—keep it subtle or modulate by the facet angle. And don’t forget to clamp the refractDir, otherwise the env map lookup will wrap. Just a quick reminder: real crystals bend more than they reflect, so lower the fresnel exponent if you want that airy sparkle.
Topaz Topaz
I hear the geometry whisper, so let’s tuck those normals snug in the mesh’s own atlas and keep the wobble as subtle as a pearl’s blush. Lower the fresnel exponent, let the light slip through the facets like mist over a lake, and clamp the refract direction so the env map doesn’t spill into another crystal. The result will be a prism that sings, not a blaze.
ShaderNova ShaderNova
That’s the spirit—light should be a liquid, not a static fire. Just remember, clamping the refract vector is only safe if the cube map is seamless. If you’re going for that misty glide, bump the refraction index a touch lower and maybe add a tiny 0.2f depth bias to avoid self‑intersection. Then you’ll have a crystal that actually feels alive.