Can any shader experts help with debugging this shader?
http://pastebin.com/raw/8dKBzsY6
get the following error
Incorrect number of arguments to numeric-type constructor glcore 50
Can any shader experts help with debugging this shader?
http://pastebin.com/raw/8dKBzsY6
get the following error
Incorrect number of arguments to numeric-type constructor glcore 50
You’re passing a float4 (i.tex) to a float2 constructor. Try this:
float2( i.tex.xy)
Thanks for the feedback!! Almost there.
The vertex portion of the shader I think is still incorrect. In the attached video you can see that the backs of the cards (which corresponds to _SecondTex in the shader) switch when they shouldn’t.
Whats interesting is that in the scene view, when I simulate the particles and have ‘Simulation Space = World’ selected, everything plays correctly.
here is the complete shader again for reference
Shader "Custom/TwoSided" {
Properties {
_FirstTex ("First(RGB)", 2D) = "white" {}
_SecondTex ("Second(RGB)", 2D) = "white"{}
}
SubShader {
Pass {
Cull Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _FirstTex;
sampler2D _SecondTex;
struct v2f {
float4 pos : SV_POSITION;
fixed4 color : COLOR;
float4 tex : TEXCOORD0;
};
v2f vert (appdata_base v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
float3 viewVector = normalize(_WorldSpaceCameraPos);
//Convertingthenormaltoworldspaceaswehaveviewvectorinworldspace.Weneedtotransferbothtosamespaceforanyoperations.
float3 worldSpaceNormal = normalize(mul((float3x3)_World2Object,v.normal));
//Dotproducttoknowwhichsideweare facing
float NdotL = dot(viewVector,v.normal);
o.color.w = NdotL;
o.tex = v.texcoord;
return o;
}
fixed4 frag (v2f i) : COLOR0 {
if(i.color.w > 0.0f)
{
i.color.xyz = tex2D(_FirstTex, float2(i.tex.xy)).xyz;
}
else
{
i.color.xyz = tex2D(_SecondTex, float2(i.tex.xy)).xyz;
}
return i.color;
}
ENDCG
}
}
}