It doesn’t appear to be playing well with sprites from textures that are set to multiple sprite mode. The sway is suposed to be nothing ath the bottom and gradually increase to full strength at the top. From what I can tell, instead of seeing the bottom of the selected sprite as the bottom, it looks like the shader is treating the bottom of the entire multi-sprite texture as the “bottom” of the sprite.
In the example below, the tree on the left is using a sprite from the top left corner of a much larger texture in multiple sprite mode. The tree on the right is using a sprite from a texture in single sprite mode. The sway intensity has been increased to really show the problem…
alertsmalllice
Notice how the trunk of the tree on the left is swaying back and forth, but the trunk of the tree on the right is practically stationary.
Is this normal behavior for shader graphs? Is there some way I can tell it to treat the individual sprite separately from the entire texture, or do I have to split every sprite I want to add a shader to into it’s own texture?
Ok seem the problem is with making sprite atlas, once in the atlas shader become weirds (those using vertex displacement at least). I separated all images and placed them outside atlas and everything is fine now.
Is there any update on if there will be a way to use a sprite from a sprite atlas with shader graph? I would really like to avoid having to save every single sprite as a sperate file, as it would be an inconvenience for our workflow …
Sliced, Tiled of type Multiple/Atlased … Shader Graph has problems with all of those. The only type i was able to make work was Simple/Single Sprite/Texture combination. Defeats the purpose of having 9sliced or Atlased sprites completely.
I have found a reasonable workaround for this situation that allows you to use a Sprite sheet and still get the desired result.
Firstly the issue is that the shader is taking into account the entire Textures UV coordinates and not the specific sprite.
Option 1.
Like above mentioned you can remove the sprites you want to apply this shader to from the sheet into it’s own texture and lose the perfomance benefits of a sprite sheet.
Option 2.
Create a second sprite sheet for the sprites you want this shader applied to.
Align each sprite in this sheet Horizontally, where there is only one line of sprites.
Ensure each sprite is aligned to the bottom of the sheet.
Add some padding to each sprite (Optional).
This works since the shader uses the the Y UVs of Sprite sheet, which in this new sprite sheets case is the same for all sprites, this gives way to another slight issue see below notes.
Notes
If you have Sprites that vary in height by a lot (e.g Bushes/Grass vs Trees) you will need to seperate these into their own material and adjust the Shader properties
Was there ever a resolution to this?
We have encountered this issue as well and have already rather large atlases of textures done and in game, so redoing all the textures would be quite a task. is there a way to get sprite uv in shader?
I just tested today: this is still an issue at least for my test setup.
SpriteAtlas. Tilemap. The ShaderGraph is very similar to what’s in the Lost Crypt demo’s tree sway. It seems to treat it like the tree spans the whole y-direction. So when the Atlas is in a shape like this:
It sways very, very slightly relative to just the tree alone because the sprites are small and there’s extra unused atlas space above. It seems to use the Atlas’s UVs, not the sprite’s.
edit: if I quadruple the Wind Strength in Play mode only then it seems to behave like before (with no Atlas), but that’s hacky and likely will need to change every time that atlas grows.
Context:
My solution is good only if you have a sprite sheet that is divided into equal parts.
My character is in a 10 row, 10 column sprite sheet, each 36x36 pixels.
and I wanted to superimpose another texture on top of it.
Before the solution, some terminology:
UV is actually two coordinates, both between 0 and 1 so 0,0 represent one corner and 1,1 represents the other.
Since shader graph uv is for the whole sprite sheet than 0…1 => 0…360pixel (in my case)
The Solution:
The trick is to pass the UV node into a modulo node with x = 1/10 and y = 1/10 (in my case because I had a 10x10 sprites) and then to put it into a sampler UV node.
Please note:
it does not look good inside the shader graph as you will see many duplications of the texture.
However, it works in the game itself just great.
Ah, sorry if this isn’t effective but in another Brackeys video
@ 9:30 he feeds world/object space to one of the nodes (instead of UV) and it seems to correct the issue of an effect being “stretched” over multiple sprites - even though they are on a single horizontally aligned sprite sheet.
It’s the Get Started with Shader Graph - Dissolve Tutorial video.
It would be nice to get access to the “cropped” uv coordinates the sprite renderer is using when rendering a sprite located in an atlas in order to use it with other textures…