#Wind Shader Graph Glitch

1 messages · Page 1 of 1 (latest)

short lark
#

My wind shader graph causes sprites to jitter when the player moves near them.

This happens regardless of whether or not the camera is moving.
The only solution I’ve found is having the sprite with the wind shader and player on different layers. (I need them both on the same layer for sorting) Any help/advice would be much appreciated.

Attached is a sample of this happening, the wind shader, and my camera settings.

granite field
#

I can't see any reason the player would affect the jitter in any way.
Maybe the jitter happens regardless, and you just don't notice it when there's no player around/point of reference?

#

Unless the affected objects are parented to the player or move relative to it via code or something.

hearty river
#

I can imagine it has to do with atlasing and the object space, but not enitrely sure why changing the layering would fix that issue.

short lark
short lark
short lark
#

Through further experimenting I found that the player doesn't even need to be moving either simply existing in the world is enough for the shadergraph to break, here's some footage of that with me toggling the player on and off

short lark
# shell turtle Is this in Play mode?

Yes! I also just figured out that turning off the player's animator seems to cause the shadergraph to work as well I'm wondering if it has something to do with the squash and stretch animation I apply to the player sprite still not sure how that is impacting the shadergraph though

shell turtle
#

Which editor version

short lark
#

2022.3.42f1

shell turtle
#

That version of URP does use dynamic sprite batching, and I can't imagine what else it could be related to

short lark
#

Removing the squash and stretch animation from the player seemed to have fixed it

#

I have no idea how

shell turtle
#

Before that could also swap to deformation using world space

#

If the error persists there it would point away from it being a dynamic batching issue
But then it'd be even less certain

short lark
#

Hmmm alright I'll look into these two methods thanks again for your response the second method uses the same tutorial as the one I used so hopefully I'll be able to get some headway with it!

shell turtle
short lark
shell turtle
#

As dynamic sprite batching is not used in modern URPs so there's no need to avoid object space

short lark
#

Remy's Method #2 World-Aligned Local UV:
So I was able to revert the UV's back to basic UV nodes and changed the input of the object's position to this block that was posted on Remy's tutorial. At first it seemed like it didn't work but when I changed the comparison node to "Equal" it actually seemed closer to what I was looking for (albeit sprites are now out of position and their size is wrong).

It's closer but still a bit messy. I've adjusted the comparison to every option aside from "Equal" and it seems to just make the sprites spazz out aside from "LessOrEqual"

short lark
shell turtle
short lark
#

So since the shadergraph was built with object space in mind I suppose I'm a bit lost as to how I could adjust the object position/scale to match the use of the world aligned local uv position

shell turtle
#

@short lark Oh, one more thing
You're using the Time node, which keeps running while the editor/application is open, so it can run into floating point inaccuracy issues

#

That's what the jitter looks like, as gradient noise at very high UV values gets "crunchy"

#

But it typically happens when you're also multiplying the Time, and it shouldn't be related to dynamic batching

short lark
shell turtle
#

I'd recommend Frac as a test but I'm not sure if it actually fixes that issue so it might not be too empirical
Then again, it might fix it

short lark
#

Hmmm it's a bit hard to tell with how short the loop is but I think the jitter is gone while using frac, going to try and run a custom time next

shell turtle
short lark
shell turtle
short lark
#

Success! Seems like setting a custom time was all that was needed to stop the jittering nice prediction and thank you again for your help! I noticed that it looks like it needs to be called on every object though (the bushes in the background don't have any scripts on them so they aren't effected by wind despite still having the shader) the shader is a child of a parent so I'm going to have to find a way to set it so it impacts all of them like the time node had

shell turtle
#

Something like Shader.SetGlobalFloat, and the property needs to be not "exposed" in SG

short lark
#

Ohhh alright let me try and adjust that, fingers crossed I sort of have been overlooking this little visual bug would be awesome to finally be rid of it

shell turtle
#

Why the player sprite or its animation affects it defies my reason

#

Artstyle is nice btw sparkleclassic

short lark
#

Thank you so much! And it looks like you hit it on the money, all the sprites are getting updated now and it only needs one call from a single fixed update script. Thank you so much for your help so glad to have this nipped for good lolol!!

shell turtle
#

Awesome! UnityChanCheer

short lark
short lark
#

still not 100% but having half of the sprites update the custom time through script and having the other half rely on a global variable update seems to reduce the sprite jittering a decent amount, still pops in every now and again but not as much... going to classify this as semi-solved not perfect but satisfied enough with how it seems to have panned out