Get light position from within material shader possible?

   5022   4   1
User Avatar
Member
2 posts
Joined: Aug. 2010
Offline
Hi,

I'm trying to create a simple phong shader (practice) but it seems that light information is inaccessible from within mat shader. I tried global variable node with light selected but that only worked within light shader node.
I know there's a lighting model node available to compose but is there anyway to access lights or other /obj information from within material shader?
User Avatar
Member
1390 posts
Joined: July 2005
Offline
You need to export P from within light shader, then use limport() inside illuminance loop of your surface shader.
User Avatar
Member
9384 posts
Joined: July 2007
Offline
no need for export import P

just inside illuminance Loop create Global Variables VOP
and add P and L variables with Add VOP
you'll get position of the currently processed light in camera space
if you need it in world space append Transform VOP and change space from current to world

but for recreating phong shader you don't need light position because you already have L variable which is vector from currently shaded point to light
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
1390 posts
Joined: July 2005
Offline
tamte
no need for export import P

True. Missed that, as I've been recently in that subject of passing various light's stuff to shaders. Thanks tamte!
User Avatar
Member
2 posts
Joined: Aug. 2010
Offline
I'm surprise that global variable node is actually context sensitive!
Thanks a lot!!
  • Quick Links