World light direction fallback

Node-based Shader Editor

World light direction fallback

Postby Kilerbomb » Mon Apr 08, 2019 2:15 am

Hello! I am working on a toon shader that needs to work in both realtime and baked lighting situations. I am using a shading ramp texture and would like to have it fall back to a fake light direction of [0,1,0] when there is no directional light present. How would I test for this? I have tried using an If node testing for a vector of [0,0,0] from the World Light Direction node but have not had any success. I should also note that I have "safe normalize" turned off in the World Light Direction node. Maybe I am thinking about this wrong, but so far I have not been able to achieve what I am looking for. Any help would be greatly appreciated!
Kilerbomb
 
Posts: 2
Joined: Sun Apr 07, 2019 11:12 pm

Re: World light direction fallback

Postby naitoookami » Mon Apr 08, 2019 6:58 pm

You were on the right track but instead of the light direction vector use light intensity. If there is a real time light in the scene, light intensity will always be greater than zero. You can get light intensity from the light color node.
naitoookami
 
Posts: 17
Joined: Tue Oct 02, 2018 5:24 pm

Re: World light direction fallback

Postby Kilerbomb » Tue Apr 09, 2019 12:07 pm

naitoookami wrote:You were on the right track but instead of the light direction vector use light intensity. If there is a real time light in the scene, light intensity will always be greater than zero. You can get light intensity from the light color node.

Hmm that seems like it would work but wouldn't point lights and spot lights also change this? Or is that all in light attenuation? Either way it does seem that I found a solution. I was using If Community since it allowed for vector3 inputs, but I believe that the "equal threshold" part was the issue. Instead, I added each axis of the light direction vector and used a Compare (A == B) node to check if the resulting value was 0. This has worked so far without issues.

I am having another problem, though. As I said earlier I need this shader to work with baked lighting as well as realtime. Since this is a "toon" style shader, I have been attempting to find a way to apply the ambient diffuse light as a flat color across my object, as the shading created from the normal direction really clashes with the toon look of the shader. Is there any way to achieve this? I have seen other shaders do it but am unsure if it is possible in amplify, or how it would be done.
Kilerbomb
 
Posts: 2
Joined: Sun Apr 07, 2019 11:12 pm

Re: World light direction fallback

Postby Amplify_Borba » Tue Apr 09, 2019 12:33 pm

Hello, there's a sample in this post that combines baked and realtime lighting through a custom lighting shader, which might be helpful.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 2 guests