Page 1 of 1

World Position - Rotating objects "rotates" lighting?

PostPosted: Fri Aug 31, 2018 3:34 pm
by Vess
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.

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

PostPosted: Fri Aug 31, 2018 4:47 pm
by Amplify_Borba
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!

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

PostPosted: Fri Aug 31, 2018 5:40 pm
by Vess
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.

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

PostPosted: Mon Sep 03, 2018 11:19 am
by Ricardo Teixeira
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.