Light Direction issue

Node-based Shader Editor

Light Direction issue

Postby Frenk.1999.98K » Mon Jan 21, 2019 12:25 am

Hi, it's me again.. :D
I'm creating my Custom Lighting for the ocean, and I'm trying to get the light to reflect on the water, but I can't quite figure out how to get the light direction right..

These are the nodes I'm using
Image
Which results in this
Image
And looks like this applied to the ocean
Image
And result also in this (from another angle)
Image
Which looks like this, when applied to the ocean
Image
Now, the light reflection looks right, but the direction of the reflection is not, as it should look like it's coming from the sun..
I'll try to explain better the current situation and scene setup, with the following "diagram"/top-view
Image

I tried to play a bit with the nodes but I can't get it to reflect from the right direction.

Also, another thing that I'm having a lot of trouble with lately, is that if I animate a texture's UV, either by panning or by just adding a value to the original UV (i.e. Time), the texture gets more and more pixelated as it goes faster. :? I really hope you can help me out on this one as well.

Thank you in advance!
Frenk.1999.98K
 
Posts: 11
Joined: Mon Jan 14, 2019 4:55 pm

Re: Light Direction issue

Postby Frenk.1999.98K » Mon Jan 21, 2019 3:13 pm

After some time I came up with this other version of the nodes
Image
Which made the situation better, but as you can see, the light has still a visible offset...
Image
I also noticed that by blending two normals together, the light has a higher offset and gets also significantly brighter...
Image
Now I'm even more confused..

Can I somehow clamp the dot value, or maybe clamp the normal, for the brightness?
Frenk.1999.98K
 
Posts: 11
Joined: Mon Jan 14, 2019 4:55 pm

Re: Light Direction issue

Postby Amplify_Borba » Thu Jan 24, 2019 3:25 pm

Hey there! You could use the Saturate or the Clamp node, although the Saturate is most commonly used for this type of situations where you need to limit a value's range to 0 - 1.

Regarding the Custom Lighting setup, I'm afraid I can't be of much help, I'd suggest looking into Unity's own Built-in shaders to investigate how they set it up.
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

Re: Light Direction issue

Postby Frenk.1999.98K » Fri Jan 25, 2019 2:28 am

Alright, thank you, I'll look them up!
Also, the clamp helped out a lot, but then I found that a remap worked better...

I still have the pixelated problem, though...

Still wave normal
Image
Fast moving wave normal
Image
I've never seen this happen before, and I really don't know how to fix it, or either what would be causing it... :?
Frenk.1999.98K
 
Posts: 11
Joined: Mon Jan 14, 2019 4:55 pm

Re: Light Direction issue

Postby Amplify_Borba » Fri Jan 25, 2019 2:47 pm

I'm not entirely sure of what could be causing that, but I'll be happy to take a quick look at your setup as you might've come across an issue. If possible, please send us a simple sample over to [email protected] so that we can run some tests on our side.
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

Re: Light Direction issue

Postby Frenk.1999.98K » Fri Jan 25, 2019 8:51 pm

Alright, I've just sent an email with a simple unity package, with which you'll be able to recreate the issue.
Frenk.1999.98K
 
Posts: 11
Joined: Mon Jan 14, 2019 4:55 pm

Re: Light Direction issue

Postby Frenk.1999.98K » Sat Jan 26, 2019 7:07 pm

Alright, after some research I found it's a thing of its own, in unity itself...

Let me explain better:
If you pan the image as you would normally do, it will result in the image getting more and more pixelated as it goes faster.
If instead you pan the image but keep the offset between 0 and 1, the panning won't result in a pixelated image.

To fix it from your side, you could add an option on the 'Panner' node, that when enabled, it subtracts the floored offset to the offset itself, before adding it to the output UVs...

Here is an example of how to simulate it with normal nodes
Image

Edit:
I had to do it for each axis and check if it was positive or negative, to decide if I had to subtract or not..
Otherwise it was snappy here and there..
Frenk.1999.98K
 
Posts: 11
Joined: Mon Jan 14, 2019 4:55 pm

Re: Light Direction issue

Postby Amplify_Borba » Mon Jan 28, 2019 10:42 am

Thank you for sharing your findings with us!

We've ran some tests on our side and concluded that the issue is due to precision issues that originate from using Unity's timer, so the viable solution would be for you to implement your own timer through script and feed its data into the shader as a property.

Your proposed solution seems to also be able to deal with the issue at hand and, although it would likely be useful for some users that could come across a similar issue, we can't add it as an option to the Panner node as it's more of a workaround for a specific issue rather than a proper solution such as the one suggested above.

Please let us know if you have any further questions or come across any other issues.
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

Re: Light Direction issue

Postby Frenk.1999.98K » Tue Jan 29, 2019 9:00 am

Alright, thank you for the info, I didn't realise the time was the issue.
I'll Implement my own then, as suggested.

Thank you again for all the help, have a nice day!
Frenk.1999.98K
 
Posts: 11
Joined: Mon Jan 14, 2019 4:55 pm

Re: Light Direction issue

Postby Amplify_Borba » Tue Jan 29, 2019 9:24 am

No problem, happy to help!

Please let us know if you come across any further question or issues.
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 11 guests