Jump to content

Light and Shadow


Macha

Recommended Posts

You mean you don't like code based shaders? Usually ASAD Light and ASAD Shadow shaders from SHOPS are great staring point of customizations because they already have "battery included". They are code based though...

Link to comment
Share on other sites

Hi Symek, I must say I always find it tiring to look through code, there's always so much to scroll through and backreading. Code is good to figure out algorithms, especially with nested stuff, but even then I prefer just a few equations if that's possible.

The reason I ask for a network is because I don't know the "infrastructure" of such a setup. Where do shadow shaders go? Plug them into a light? Material? Does it need this that or the other?

The algorithms I'll eventually figure out. I just want to see the "basic wiring up" of a shadow shader.

Link to comment
Share on other sites

maybe this can help you a bit

http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=19313

it's more about light shaders though and no examples, but it's kind of intuitive if you understand the principle

with the shadow shader it's almost the same as for lights but you output the value you want the surface to receive when calling shadow() function. so usually some darkening color since inside surface shaders this is usually multiplied by light color in illuminance loops

since shadow shader is run after light shadow you have computed light color (Cl) available in the shadow shader

just to keep in mind for light/shadow shaders

P is the position of the light source (it's named Surface Position in VOPs which may confuse you)

Ps is the position on the surface which is calling the shader

other are self explanatory I think

I can post some file later if I get to Houdini, if you'll still need some example ;)

Edited by anim
Link to comment
Share on other sites

Thanks, I figured out the light shaders. Looks like they get automatically called from inside an illumination loop or something, so we don't have to worry about that.

So, we just use the in and out global variables from "light" and attach the shader to a light.

The shadow one is still mysterious. It's not just a negative light by any chance?

Edited by Macha
Link to comment
Share on other sites

...Looks like they get automatically called from inside an illumination loop or something, so we don't have to worry about that...

worry? what do you mean :)

the light shaders are called by illuminance loop according to scope, they invoke light shader on each scoped light and gets Cl and L information, so you need light shader for that if you use light template object

you don't need to worry about that if you are using light object and you are just adding Shadow Shader Property to it if you need custom shadow, so if you mean that so yes, don't worry, but you still need to understand how light shader works to understand shadow shaders

yes, you can perceive shadow shader as kind of light shader ,

but keep in mind that in most surface shaders shadow shader's output color is multiplied with light shader's output color in surface shader, so look at it rather as multiplier

if in illuminance loop you are computing light intensity by (proto code, not VEX) :

max(0,Nn.Ln)*Cl*shadow()

then that shadow() function is asking shadow shader on current light(in loop) for the value (usually 0-1)

so when you in shadow shader fire single ray from Ps along to L with the length of |P-Ps| and output hit 1 or no hit 0 then you'll get basic hard shadow (you can use trace() for it or filtershadow(), fastshadow(), ...) or compute your shadow without raytracing( shadow map lookup, pointcloud lookup, volume lookup, metaball lookup ..) whatever comes to mind. Its almost the same as surface shader, just outputs color 0-1 to be used as light multiplier, that's all (or maybe not? :) I am not a shaderwriter so I may be mistaken)

You can of course do this all in surface shader, or light shader, but it's handy to have it separated

shadow/light shaders are not that different from surface shaders, you are still operating with surface position Ps and computing light intensity for it

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...