Shader Graph with Tilemaps (and Sprites)
Hi, I was hoping that I could put shaders on Tilemaps for various effects. Such as making an ocean tile wobble a little (with UV distortions?) or get lava to bloom, perhaps even to see if it's possible to stretch out and loop a single big ground texture over several squares of a tilemap object to make the looping texture more seamless and simple to deal with.
But I've struggled with something as basic as getting a sprites-default kind of shader to work. It's mostly since I'm unsure what to do and have a hard time to find help online.
However I finally got something that looks like it's working fine, with normal sprites. But applying this to a tilemap makes my Editor crash, or turn the tilemap invisible. Perhaps a bit optimistic, does anyone have any advice what I could do or look for help for desired results? What is the bare minimum needed to make tilemaps simply display correctly with Shader Graphs?
Answer by r59q · Aug 09, 2020 at 09:26 PM
This is an old question, however I just so happened to run into the same problem. I am using Unity 2020.1.1.
Firstly create a shader. In project : Create -> Shader -> 2D Renderer -> Sprite Lit Graph (I think all graph types work).
Add a Texture2D property, and make sure the reference is "_MainTex". If it's not it won't work.
Pass the property through a Sample Texture 2D node and into the Sprite Lit Master node.
Create a new material.
Add the shader to the newly created material.
Now create the Tilemap, which is going to utilize the shader.
Add the material to the Tilemap Renderer component, which is generated alongside the Tilemap.
Now you can modify the shader and the correct sprite should be displayed, because you referenced the Texture2D property as '_MainTex'.
Your answer
Follow this Question
Related Questions
Unity 2018.1.2f1 doesn't apply textures to material if I use HDRenderPipeline. 0 Answers
Shader Graph Transparent Texture Problem HELP! 3 Answers
Need help to combine shaders, is this possible? 0 Answers
Why are there speckles on my texture? 0 Answers
How to remove the transparency of the grass ? (with terrain tool) 0 Answers