Hi guys no less about shaders than i do coding so yikes. I s it possible to expand the standard shader to include effect such as rim lighting and more to the point increase the amount of textures that can be applied. Right now you can apply secondary maps but can it be made that you can have third 4th maps etc?
If possible what would be the drawbacks i know that secondary maps are more expensive would third and fourth be even more expensive or the same as secondary.
This is what surface shaders are for, though it’s important to know if you’re trying to do blend 4 sets of textures using the full standard setup you might start running out of texture samples
Thx for the reply bgolus so the standard shader is a surface shader? (sorry don’t know much at all and even less about shaders shaders). Im just looking for another texture and normal slot don’t need the height/ao etc for the extra textures i don’t think. So how do i go about it can i just duplicate the code that sets up the secondary textures or is it more involved?
When you say run out of texture samples what do you mean by that?
Thx
There are essentially 3 kinds of shaders in Unity, surface shaders, fixed function shaders, and vertex & fragment shaders.
Vertex & fragment shaders have every part of the shader written out in them. These are as close to what the GPU needs as you’ll want to write. see below*
Surface shaders are a Unity thing and are shorter functions that are used to generate full vertex & fragment shaders. Surface functions let you supply the basic material inputs, like albedo, normal map, smoothness, etc. and choose a lighting model and Unity does all the hard work of making the “real” shader for you. The standard and standard specular shaders are vertex fragment shaders, but the Standard lighting model is available as an option for surface shaders. If you make a new surface shader in Unity it’ll default to using the standard lighting model.
Fixed function shaders are how shaders used to be written 10+ years ago when GPUs first started being used. Unity doesn’t actually support fixed function shaders anymore, but instead these too are translated into vertex & fragment shaders.
Read this, yes all 5 parts.
- Unity’s vertex & fragment shaders aren’t actually the last form of the shader. Unity’s shaders are written using HLSL and Unity’s own ShaderLab shader layout which then gets translated into the various languages needed by other platforms. OpenGL GLSL for Mac, and Linux, OpenGLES GLSL for Mobile, Metal for iOS, PLSL for PS4 & Vita, HLSL for PC, as well as various versions for for each language like DirectX 9 vs DirectX 11 vs DirectX 12, or OpenGL ES 2.0 vs 3.1, etc. Almost every platform needs a slightly different or completely different format and this is one of the major powers of Unity is it’s ability to translate shaders into all of these. You can write code specific to each platform on your own, but it’s rare you need to do that. To add confusion this isn’t even the final form of these shaders as they need to be compiled into forms for each specific GPU, but that’s usually handled outside of Unity by drivers or platform specific compilers that take the HLSL / GLSL code and make this “final” form. I put quotes on that final because drivers will often take that “final” form and modify it again for various reason.