I'm trying to replicate the effect of sun hitting a window blind, and scattering in a cross-shaped pattern.
This is for Unity using a Vive headset; it's for architects to preview different kinds of window shades in VR, so it needs to be as accurate as I can make it.
I'm using Shader Forge.
I know I can use a dot product to get the reflection vector, but it's not quite the right effect. For one thing, the surface normal of the window blind is pointing towards the camera (or mostly so), so the reflection vector ends up being perpendicular.
For another thing, I need the glare to always be centered on the light. But I can't just use the light's position because it's a directional light, which means its rendered position is infinitely distant. :O
I'm thinking about refraction as possibility, but ideally the cross pattern should look like it is perturbed by the weave of the blind's fabric.
My current incomplete solution is using a Lens Flare on the light, and this mostly works OK. It has two big problems though:
1) It rotates around the at vector, which looks terrible in the Vive HMD. If you tilt your head to the right, the glare cross pattern tilts too, but the fabric does not. FML.
2) It doesn't look like it's being bumped by the weave.
Anyone have any ideas to share?
Replies
This is the material that they use:
And then they just set the light direction in the blueprint automatically so when you change the light, it'll update the material:
There is an another thing, called "custom depth" in unreal. This allows you to filter out certain objects that you want, and you can apply some post process only on those. The custom depth can help you with setting up such effects as when its behind something it looks different for example.
https://forums.unrealengine.com/showthread.php?40378-Tutorial-The-many-uses-of-Custom-Depth-in-Unreal-4
For the glare shape, I think you can simply use a specific normalmap, and distort the glare texture coordinates with that. The another thing that you could do is that you have 2 or more glare textures, a simple one and some distorted ones and you simply blend between them based on view angle.
http://fabiensanglard.net/lightScattering/index.php