Home Technical Talk

How to reverse the specular in a shader? (Unity/Vive)



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

Sign In or Register to comment.