@elzabbul wrote:
Hi guys, I have a problem compiling this shader code. To be fair with you, I'm no specialist in shaders and probably the issue is quite small and somehow I can't see it. The compilation is performed for Android, thus with /Profile:OpenGL switch enabled.
VertexToPixel TexturedWithLightsVS(float4 inPos : SV_POSITION, float3 inNormal : NORMAL, float2 inTexCoords : TEXCOORD0)
{
VertexToPixel Output = (VertexToPixel)0;Output.Position = mul(inPos, WorldViewProjection); Output.TextureCoords = inTexCoords; float3 Normal = normalize(mul(normalize(inNormal), xWorld)); Output.LightingFactor = dot(Normal, xLightDirection); if (Output.LightingFactor<0.30f) Output.LightingFactor = 0.30f; Output.clipDistances = dot(inPos, ClipPlane0); Output.Position3D = mul(inPos, xWorld); Output.Normal = (mul(inNormal, (float3x3)xWorld)); Output.View=dot(Normal,vecEye-Output.Position3D); return Output;
}
PixelToFrame TexturedWithLightsPS(VertexToPixel PSIn) : SV_TARGET0
{
if (Clipping) clip(PSIn.clipDistances);
PixelToFrame Output = (PixelToFrame)0;float diffuseLightingFactor = 0;// PSIn.LightingFactor + DotProduct(xLightPos, PSIn.Position3D, PSIn.Normal); float3 N = mul(PSIn.Normal, PSIn.Position); float D = saturate(dot(N, diffuseLightingFactor)); float3 R = normalize(reflectionPower * D * N - diffuseLightingFactor); float S = pow(saturate(dot(R, PSIn.View)), 2)*specularPower; float4 tmp = mul(PSIn.Position3D, xWorld); float3 worldPosition = tmp / tmp.w; float4 light0 = float4(0, 0, 0, 0); if (Light0Intensity>0) { float3 L = normalize(Light0Position - worldPosition); float3 H = normalize(PSIn.View + L); float2 ret = lit(dot(N, L), dot(N, H), 1).yz; float intensity = max(L.x, L.z)*Light0Intensity; light0 = max(dot(L, PSIn.Normal), 0) * Light0Color *ret.y*intensity; } Output.Color = tex2D(TextureSampler, PSIn.TextureCoords) +light0; Output.Color.rgb *= saturate(PSIn.LightingFactor) + 0.5f; clip(Output.Color[3] < 0.1f ? -1 : 1); float dist = distance(vecEye, PSIn.Position3D); float fog = saturate((dist - FogNear) / (FogNear - FogFar)); Output.Color = lerp(FogColor, Output.Color, fog); if (forceRed) { Output.Color.r = 1.0f; } Output.Color.a = transparency; return Output;
}
technique TexturedWithLights
{
pass Pass0
{
AlphaBlendEnable = TRUE;
DestBlend = INVSRCALPHA;
SrcBlend = SRCALPHA;VertexShader = compile vs_3_0 TexturedWithLightsVS(); PixelShader = compile ps_3_0 TexturedWithLightsPS(); }
}
And the error is:
error X5631: z or w components of vPos register are not available in this version, and cannot be dcl'd.Could you please take a look at this?
Posts: 1
Participants: 1