Macha Posted April 14, 2011 Share Posted April 14, 2011 Does anybody have a shader network illustrating light and shadow shaders? I want to build a custom caustic-type shadow and I'm not sure how to go about it. Quote Link to comment Share on other sites More sharing options...
symek Posted April 14, 2011 Share Posted April 14, 2011 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... Quote Link to comment Share on other sites More sharing options...
Macha Posted April 14, 2011 Author Share Posted April 14, 2011 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. Quote Link to comment Share on other sites More sharing options...
anim Posted April 15, 2011 Share Posted April 15, 2011 (edited) 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 April 15, 2011 by anim Quote Link to comment Share on other sites More sharing options...
Macha Posted April 15, 2011 Author Share Posted April 15, 2011 (edited) 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 April 15, 2011 by Macha Quote Link to comment Share on other sites More sharing options...
anim Posted April 15, 2011 Share Posted April 15, 2011 ...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 Quote Link to comment Share on other sites More sharing options...
anim Posted April 17, 2011 Share Posted April 17, 2011 ok, here is simple example file of sort of caustic type shadow in VOPs as promised notice that shadow can output color outside 0-1 range for example above 1 to make light more brighter simple_caustic_shadow.hip Quote Link to comment Share on other sites More sharing options...
anim Posted April 17, 2011 Share Posted April 17, 2011 here is the same file, but with area light it's great that shadow shaders work with area lights by default, and what I was surprised that they work with PBR too, cool, I am going to play a bit simple_caustic_shadow_area_light.hip 1 Quote Link to comment Share on other sites More sharing options...
Macha Posted April 17, 2011 Author Share Posted April 17, 2011 Thanks anim! You're always a good source of genius! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.