I've followed PQs tutorial on GI and I'm afraid I don't understand how light- and shadow shaders really work. If there is a dedicated section in the manual which you think can help me with that please redirect me, I couldn't find anything (even the Help on Light-Template has no mention of shaders, although they are clearly part of the node).
So I create a random spotlight but there is of course no GI in the scene. But when I create a separate Light Template - which, according to the manual, is just a “Light Skeleton” - and give the latter a light shader of type VEX GI, all geometry gets GI.
I can vaguely guess that a Light Template with a GI shader does actually not affect other lights, but plays the special role of lighting up areas where it deems GI takes place. The GI shader makes the Light Template behave not like a “normal lght” but calculates lighting (and shadowing - how is this distinguished?) on it's complete own.
That makes me assume that a light shader can make a light do virtually anything - given how exotic a GI light works. Then I look into a regular light to figure out what kind of light shader these use but all I find is circles and cones in its SOP net?
I don't get it.
What appears even less understandable to me is how Light (shaders) and Surfaces (shaders) play together. I've also watched the tutorial on shading and I get the point that a surface shader is queried for every pixel, given inclination and normal as its input and expecting a diffuse color as output.
My best guess is that the render engine obtains all lights in a scene, merges the information into a resulting ray which is then passed on to the surface shader. But how would work this together with GI? Does GI have a explicit inclination/ray?
These are just a few questions, I hope I could at least convey my confusion on this topic.
Thanks :roll:
How do light/shadow shaders work?
9454 4 2- ManDay
- Member
- 40 posts
- Joined: May 2010
- Offline
- tamte
- Member
- 8539 posts
- Joined: July 2007
- Offline
here is my understanding, i am not a serious light shader writer, but i've made some:
surface shader can call light shaders if it needs that information, it can use Illuminance Loop VOP or any of the lighting models for that
then inside the loop it calls lights (light shaders) according the light mask one by one
it's sending some information like P or N to the light shader
then light shader can use that info to calculate Color and L vector (which is direction from surface point to light)
then back in Surface shader those 2 variables are used to calculate shading
for example:
many surface shading models will give you value of 1 if surface normal(N) is parallel to direction to light (L)
then they multiply it with light color(intensity)
in case of GI light shader it takes P and N from surface (called Ps, N in light shader) then it uses this info to calculate occlusion/irradiance calling the came occlusion()/irradiance() function you can use in surface shaders.
As a result you'll get color value which is sent as light color (Cl) back to surface shader
since Cl already contains complete shading you need to avoid shading in the surface shader so you can send N as L back to shader
(using the knowledge that if N=L (or is parallel) then most surface shader lighting models will result in 1 * Cl and therefore only Cl which is what GI light needs)
i hope it is understandable from what i've written
i am still learning these things so please someone correct me if i am wrong
i have avoided going into too much detail (like normalization of N or other things to make it less confusing as an example)
there is a few light/shadow shaders in Mantra Light (Shadow) TAB menu
you can place them, right-click, choose Type Properties…, Code Tab
there you can see shader code
surface shader can call light shaders if it needs that information, it can use Illuminance Loop VOP or any of the lighting models for that
then inside the loop it calls lights (light shaders) according the light mask one by one
it's sending some information like P or N to the light shader
then light shader can use that info to calculate Color and L vector (which is direction from surface point to light)
then back in Surface shader those 2 variables are used to calculate shading
for example:
many surface shading models will give you value of 1 if surface normal(N) is parallel to direction to light (L)
then they multiply it with light color(intensity)
in case of GI light shader it takes P and N from surface (called Ps, N in light shader) then it uses this info to calculate occlusion/irradiance calling the came occlusion()/irradiance() function you can use in surface shaders.
As a result you'll get color value which is sent as light color (Cl) back to surface shader
since Cl already contains complete shading you need to avoid shading in the surface shader so you can send N as L back to shader
(using the knowledge that if N=L (or is parallel) then most surface shader lighting models will result in 1 * Cl and therefore only Cl which is what GI light needs)
i hope it is understandable from what i've written
i am still learning these things so please someone correct me if i am wrong
i have avoided going into too much detail (like normalization of N or other things to make it less confusing as an example)
there is a few light/shadow shaders in Mantra Light (Shadow) TAB menu
you can place them, right-click, choose Type Properties…, Code Tab
there you can see shader code
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- kursad
- Member
- 88 posts
- Joined: March 2010
- Offline
There is a Mantra master class video from Sidefx. It explains some very basics of Mantra, might be helpful to you to see how Mantra handles various calls
Masterclass: Rendering With Mantra
http://www.sidefx.com/index.php?option=com_content&task=view&id=1414&Itemid=259 [sidefx.com]
It would be nice to have more technical Mantra videos from Sidefx on the other hand. Mantra is very appealing.
Masterclass: Rendering With Mantra
http://www.sidefx.com/index.php?option=com_content&task=view&id=1414&Itemid=259 [sidefx.com]
It would be nice to have more technical Mantra videos from Sidefx on the other hand. Mantra is very appealing.
- mathmad
- Member
- 30 posts
- Joined: July 2009
- Offline
- tamte
- Member
- 8539 posts
- Joined: July 2007
- Offline
-
- Quick Links