- Home /
How to get surface shaders to work in URP?
When coding shaders into my Unity project (2019.4 using URP) I get the magenta error shader anytime that I use surface shaders. No errors are reported in the Console. How do I get surface shaders to work with URP? Is there anyway to use surface shaders and shader graph?
Sorry for the newb question, and thank you in advance!
Answer by xibanya · Oct 09, 2020 at 04:24 AM
Basically, there isn't actually any such thing as a surface shader! There are only vertex and fragment shaders! A surface shader is actually a frag shader with all the the standard lighting calculations handled behind the scenes (because they're very long and it would be annoying to copy and paste them into every single lit shader you wanted to make.)
So if you want to port a surface shader over to the URP, take the surface shader part and put it in a lit frag shader. If you want to see what that might look like, if you look at a surface shader in a standard render pipeline project in the inspector, you'll see a button that says Show Generated Code. Click that and then have a look at the result (warning, it'll be a very long file because it will contain every single keyword variation!) You'll see how the surface function is actually integrated into a lit frag shader.
Answer by edmondkeroro · Apr 07 at 07:02 PM
Try to use Mobile/Particles/xxx.shader to replace surfaceshader_VC