World Position - Rotating objects "rotates" lighting?

Node-based Shader Editor

World Position - Rotating objects "rotates" lighting?

Postby Vess » Fri Aug 31, 2018 3:34 pm

So I've been having this issue with one of my more complex shaders, but it turns out, the most basic World Position shader is also having this issue. I'm still new to shaders and ASE, so i'm probably doing something wrong...

I'm trying to make a World Position shader to be able to have multiple sections of a level connect to one another without worrying of the texture tiling together properly. I noticed that sometimes the normal seemed inverted or the light not matching the direction it's emanating from. Rotating an object is making the lights direction change, while the texture itself stays put.

I've checked with debug and everything is static and not moving (even the normal) but whenever i remove debug and test it all together, the rotation of the object is affecting the direction of the light.

Here's the shader: Image
and here's a gif of it: Image

What I'm trying to get with this, is that the texture tiles together and light is not affected by the objects rotation.

Any help is appreciated :)

P.S.: Don't mind the normal, i just used something that made this effect much more apparent.
Vess
 
Posts: 2
Joined: Fri Aug 31, 2018 3:20 pm

Re: World Position - Rotating objects "rotates" lighting?

Postby Amplify_Borba » Fri Aug 31, 2018 4:47 pm

Hello, thank you for getting in touch and for your support!

This is a tricky situation, and the issue with the current setup is that when you rotate the object, the position of its vertices is being altered in world space, so the value of the world position that is passed to the UV's is different.

One possible, although not perfect solution to prevent the mesh's rotation from affecting the UV's would be as follows:

Image

We're using the Scale and Offset nodes to center the UV's pivot for performing the necessary operations, then reverting it before passing the data to the Texture Sample's UV input. Since we're using a 3D plane that is being rotated on the Y axis, we're using the X and Z values for transforming the vector and forcing Y to 0 to prevent any stretching.

Do note that this is meant to be a starting point for developing a more robust solution.

I'm also sharing the shader file, for your convenience:
RotationExample.zip
(1.6 KiB) Downloaded 194 times


Please let me know if this helps, thanks!
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: World Position - Rotating objects "rotates" lighting?

Postby Vess » Fri Aug 31, 2018 5:40 pm

Hey Amplify_Borba,

Thanks for the reply. I remade it and i also downloaded your example. Unfortunately it's still "rotating" the light. I also updated my plugin to the latest (i saw there were fixes for World Position) but that didn't resolve it either.

even when i turn off lights in my scene, i can still see it "rotating" the lights. I tried playing around with Vertex Position, but still haven't yielded the result I'm seeking :C

Sorry, I'm still very new to all this, so I may be misunderstanding the issue.
Vess
 
Posts: 2
Joined: Fri Aug 31, 2018 3:20 pm

Re: World Position - Rotating objects "rotates" lighting?

Postby Ricardo Teixeira » Mon Sep 03, 2018 11:19 am

Vess wrote:Hey Amplify_Borba,

Thanks for the reply. I remade it and i also downloaded your example. Unfortunately it's still "rotating" the light. I also updated my plugin to the latest (i saw there were fixes for World Position) but that didn't resolve it either.

even when i turn off lights in my scene, i can still see it "rotating" the lights. I tried playing around with Vertex Position, but still haven't yielded the result I'm seeking :C

Sorry, I'm still very new to all this, so I may be misunderstanding the issue.


Hello there,

I'm afraid that's the expected result, you would need additional work to prevent normal related issues as we do with our Triplanar node(source code included).

Apologies for the inconvenience.
Sales & 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
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 69 guests