Shader problem when "Use Direct3D 11" enabled

Hello,

I’ve thought I could give adding tessellation to my shaders a try, and I turned “Use Direct3D 11” on in the Player settings.

Most of my shaders perform well, except for one shader, which is the longest of all shader including the most features.

Here is a pic of the warnings:

What can cause this? Thanks.

Could you post the relevant lines? It seems as if you’re trying to cast a float3 to a float4 in the last error.
At least, last time i ran into that error i had forgotten a , between variables which resulted to unity thinking i was passing only 3 of the 4 parameters -.-

Well, the errors on this lines make little sense, and that’s why I don’t even know what’s it about

Line 17- _ParallaxMap (“Parralax Map”, 2D) = “black”{}
Line 21- _MaskTex (“Alpha Mask”, 2D) = “white”{}
Line 23- just a blank space
Line 25- “}”
Line 31- CGPROGRAM

_ParallaxMap ("Heightmap (A)", 2D) = "black" {}
_MaskTex ("Alpha Mask", 2D) = "white" {}
 
}

SubShader

I’m not 100% sure, maybe you’re writing a different type of shader. but for sure in a surface shader, you’ll first need to have a SubShader set.

I’m very used to checking the order of my shaders by comparing them to the standard Bumped Specular (i’ll also include it here, just in case :slight_smile: )

Shader "Bumped Specular" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
	_Shininess ("Shininess", Range (0.03, 1)) = 0.078125
	_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
	_BumpMap ("Normalmap", 2D) = "bump" {}
}
SubShader { 
	Tags { "RenderType"="Opaque" }
	LOD 400
	
CGPROGRAM
#pragma surface surf BlinnPhong


sampler2D _MainTex;
sampler2D _BumpMap;
fixed4 _Color;
half _Shininess;

struct Input {
	float2 uv_MainTex;
	float2 uv_BumpMap;
};

void surf (Input IN, inout SurfaceOutput o) {
	fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
	o.Albedo = tex.rgb * _Color.rgb;
	o.Gloss = tex.a;
	o.Alpha = tex.a * _Color.a;
	o.Specular = _Shininess;
	o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
}
ENDCG
}

FallBack "Specular"
}

However, removing the subshader part in my shaders gives me regular syntax error on the first line to come after CGPROGRAM :confused:
Have you checked where you assign the variables for the CGPROGRAM (above the input struct) on (typing) errors manually?
i’ve found myself gaining strange errors multiple times just because i didn’t add my darn semicolon sometimes -.-

I have a SubShader, lol, the shader works great when “Use Direct3D 11” is disabled, but when it is on, I have those strange errors.

As per the unity docs, dx11 is far more picky about your syntax. No more float4(0) and so on. Unfortunately as you can see, Unity doesn’t make it easy to find where these errors are - ie. those errors refer to the attempted compiled version of your shader rather than the source!

Oh that explains a lot. Thanks for letting me know, I’m just starting with the DirectX11 shader work.