Error 1:
Shader error in ‘Custom/ExtrusionWithBump’: Program ‘vert_surf’, ambiguous overloaded function reference “tex2D(sampler2D, float4)” at line 22
Error 2:
Shader error in ‘Custom/ExtrusionWithBump’: Program ‘vert_surf’, maximum vs_4_0_level_9_3 sampler register index (0) exceeded - note that the target doesn’t support texture sampling intrinsics (compiling for d3d11_9x) at line 23
Error3:
Shader error in ‘Custom/ExtrusionWithBump’: Program ‘vert_surf’, cannot map expression to vs_4_0 instruction set (compiling for d3d11) at line 61
You need to change tex2D to tex2Dlod (keep float4 for uv as in the original) and add #pragma glsl #pragma target 3.0
That’s because texture fetch from vertex shader is supported from Shader Model 3 and up and because the default compilation target for opengl is ARB shaders which don’t support it either.
This of course rises the hardware requirements for the shader.
I got a problem with VTF as well but it’s not a problem with the compiling.
The shader works fine in the editor but when I build the game it will only show the default pink material. The shader code is just copied from the examples and of course I tried the glsl version with the renderer forced into OpenGL mode, but to no avail.
There is just this warning, which I can’t figure out: Shader warning in ‘Custom/VTF’: Program ‘vert_surf’, maximum vs_4_0_level_9_3 sampler register index (0) exceeded - note that the target doesn’t support texture sampling intrinsics (compiling for d3d11_9x) at line 21
Edit: Found the solution to the problem. Nothing wrong with the shader itself but the GameObject using the shader was instantiated programmatically by me and had no references to the scene. So it couldn’t be loaded. The solution: Copy the shader to the Resources folder. Guess you never learn out