Hey all,
I’m using a transmissive refraction grating as a material for a physical architectural model of a project of mine – I’d like to be able to visualize this effect in Blender.
Previously, I’ve seen plenty of people make shaders for reflective diffraction gratings (such as on this forum post), but I’m stumped trying to create one for a transmissive diffraction grating, especially one that produces caustics.
Is this kind of effect possible?
It will depend on how accurate do you need it to be.
If you want a precise representation of a grated glass, then you won’t get it to be realistic…
Lights in Cycles don’t carry any wavelength information, which will be the first problem, as only wavelengths in the light spectrum are diffracted.
Second, as Cycles is not a spectral renderer, finding the correct white point is extremely difficult.
The third problem is that, while reflective gratings are simpler to calculate, transmissive gratings are heavier. That will make the renders really noisy without a huge amount of sampling.
Faking the grating effect, can be done to some extend, but it will require a lot of tweaking. The speed can be slightly improved if instead of a refraction, you just use Ray_Portal shaders with faked refractions.
But even so, the white point will still be a problem and it will be difficult to calibrate the colors.
That said, here’s a fake example:
(it’s using a single grating, not the piramidal grating in your example)
I’m not too too worried about realism here - I think this is solid enough!
Though, I realize now that I’m asking for two things at once, this fulfilling one of the things.
The other thing is that I’d like to somehow reproduce the coloured shadows and caustics that light passing through a grating produces. I’m very new to blender and after trying to mess around with caustics I’m definitely lost.
If you or anybody else wants to tackle that challenge as well, by all means : P
As said above, Cycles is not suited for this kind of light interactions.
The shader above will still produce shadows and caustics, but Cycles will miss the majority of rays that could transmit energy.
Even Path Guiding and Caustics Shadow Casting won’t help that much.
If for camera rays, the required sampling needs to be at least 1k, for diffuse and glossy rays, that value will has to be exponentially higher!
Again, you could fake it even further by turning the glass into an emission for secondary rays, and replicate the inverse equation (based on the light source location) to emit specific colors at specific positions into specific directions.
This won’t be practical, since moving the light or the ‘glass’ forces a change in the shader.
I will not create such an example because is too much work for a support question, but you can look to this old example as an idea.
And just to finalize, a grating pattern such the piramidal in your example, won’t produce a very visible caustic pattern. There will be some coloration around the multiple penumbras, specially if the light is composed of just a few particular wavelengths (lasers, led, etc)… But the sum of them in the majority of the illuminated surfaces will converge to ‘white’ very quickly (unless the light source is very powerfull, very small, and very far, i.e. Sun, but even so…).