I have been testing out the built in lightweight pipeline and the shader graph and dont seem to be able to get sprites to play well with the system.
Putting my shader graph shader on a sprite renderer gives this message:
“Material does not have a _MainTex texture property”
Adding a _MainTex property to the graph via the blackboard only adds it as an internal name to the graph, which doesn’t help. I have made a script that forces the _maintex keyword on and applies a texture to maintex, but because it isn’t linked up in the shadergraph to master output, it doesnt do anything.
Am I missing something here, Is there a way to get this working? It seems like it should be as simple as naming a blackboard property to _MainTex.
Hi, I am very interested on this topic too. I manager to get rid of the warning: “Material does not have a _MainTex texture property” but could not render the sprite properly. Here I show a screenshot of the material applied to a sprite and to a cube next to it (black spots on top of white).
Is there a way to do this properly or it is still a feature in development? Thank you!
Finally I managed to make it work, although I still need to hack the way to get the _MainTex naming. This is the solution to have a material working with a SpriteRenderer: Feedback Wanted: Shader Graph page-12#post-3462968. And, in order to get the _MainTex what I do is select the shader graph in the explorer, then go to the Inspector in debug mode and change the name there. The problem is that every time you save the shader from the shader graph the naming will be regenerated and you will need to change it again manually. Finally, I had to set SpriteRenderer mode to Tiled or Sliced, Simple didn’t work.
This is already possible since v2.0.x of shader graph, but this is only for Unity 2018 so if you have 2018.1 the newer versions of LWRP/HDRP and shader graph won’t show up. Some changes needed to be made C++ side and that happened in 2018.2 so this is why it’s not in 2018.1.
Yes, it actually looks like setting the reference to _MainTex works in 2018.2.0f2. I can only get it to work with PBR though. Trying to compile the graph with Unlit gives me the error
redefinition of '_MainTex'
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()```
For getting the color, I tried with both _Color and _RendererColor as these are the two colors in the default Sprite shader. Unfortunately, no luck getting them to work.
Yeah Unlit doesn’t work with _MainTex atm, should see a little performance bump when it does work though.
And remember on your PBR’s plug the texture alpha of the texture to both the master Alpha and master AlphaClipThreshold, it will reduce pixel overdraw. You may need to run it through a multiply node first to fine tune the edges.
I am really loving the the shader graph so far. I have made a 2d fog that blends the texture with a fog color based on a sprites world y and world z (or layer order). So fog sits low on the ground and gets thicker the further back it goes.
Everything you see in this scene apart from the water and the pink ball are powered by a single shader. All of the sprites are imported in as white, their color is determined by the shader.
I even added in a day night cycle that has <1% framerate impact as its just color lerping on a timer.
Here is the same scene at dawn:
The background sprites are preblurred and just placeholder for testing. The only PP is fast mdoe bloom from the LWRP.
I’m a little confused about what I’m experiencing with respect to using a Shader Graph shader in a screen-space canvas. I’ve set up the shader pretty much as everyone else has described:
I can see the images in the Scene view, but they don’t show up in the Game View. The images appear in the game view if I remove the material from them, but as soon as I apply the material they disappear from the game view. Is this just the way things work with HDRP and shader graph shaders in the UI? I’m using 2018.3 and HDRP 4.10.