General Shader Questions
While we wait for the presentation from the shader workshop to be cleaned up and made available I have a question; and we might as well start a general thread.
How do you declare a cubemap in a Unity3D shader script and apply it to the scene?
I know @Chippit talked about it in the workshop but I don't think he went into detail.
How do you declare a cubemap in a Unity3D shader script and apply it to the scene?
I know @Chippit talked about it in the workshop but I don't think he went into detail.
Comments
Then you need to add a vector to your v2f (or whatever you call it) struct. This contains the lookup vector you use for getting which pixel in your cubemap you want to use.
Depending on what you want to do with it, how you work out your reflNormal may change. If you're using your cubemap as reflection, then you're looking up the cubemap by thinking of it as a vector that goes from your eye/camera, bounces off of a surface (i.e. is reflected about the surface's normal), and leaves to hit the cubemap somewhere. You'd therefore use something like:
(There are actually some pretty huge possibilities here, depending on how math-y you want to get. You can rotate the reflNormal over time to get the cubemap to rotate. You could treat the cubemap as light, for gorgeous image-based lighting. And those are just the more "standard" things.)
For looking up the cubemap, you use something like:
texCUBE seems to expect world space coordinates, so make sure that when you're working out what your reflNormal is, you're giving it the view direction and normal in world space.
Why does it seem to be so hard to find information on shaders?
http://docs.unity3d.com/Manual/SL-BuiltinValues.html