jonklein Posted February 4, 2019 Share Posted February 4, 2019 Hello! I'm working on a custom toon shader. As a basis I want to use the lambert lighting model as described in the tutorial embedded below. To test this I created a very simple scene with a sphere placed at the origin, a point light and a material with the material builder applied to the sphere (see image below). Now, here's the problem: The shading of the sphere is incorrect as soon as the point light has negative coordinates. It seems as if the surface_global's P and N are expressed in a different space compared to the point light's position. This happend with Mantra as well as Redshift (where I used the same setup as in the video below, apart from getting the light's position through a constant and channel references). Am I wrong to assume that P is the world position of the current point being shaded and N is it's normalised normal? Is this the wrong way to get the light position into the shader? I spent some time testing and searching on the internet but I couldn't find anything that clarified these quesitons sufficiently for me. custom_lambert.hipnc Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted February 4, 2019 Share Posted February 4, 2019 (edited) Hi Jonas, I attached a simple scene that does shading based on the dot product of the surface normal and the normalized light direction. It includes a SOP-variant in VEX and a VOP-shader. Also Yancy Lindquist recently published an extensive tutorial on shading concepts: If all you want is a lambertian toon shader you can also watch mine: light_angle.hip Edited February 4, 2019 by konstantin magnus Quote Link to comment Share on other sites More sharing options...
jonklein Posted February 4, 2019 Author Share Posted February 4, 2019 (edited) Thank's Konstantin, those ressources are incredibly helpful! Now I got it to work. The basic problem was that I had to get the light's position into the material builder not via a constant but as a parameter. That is where your approach differed from what I was working with. However, to get it to work properly I also had to invert the z-coordinate. Edited February 4, 2019 by jonklein Quote Link to comment Share on other sites More sharing options...
st4 Posted February 7, 2020 Share Posted February 7, 2020 hi @jonklein how did you end up getting the light position to be read in the material i am trying to follow this: i was trying read light position using global variable but it is not reading? i move the light around but it doesnt recognize it 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.