Hi guys
I am new in monogame and sorry for my bad english level.
I want to transform all my XNA project but fx files have problems.
First it’s not possible to declare array struct, “unsupported parameter class”.
So I had make a new effect file with variable array but update postion doesn’t work.
Can you help me?
What is a difference between ->
float4 position;
float4 color;
float invRadius;
float4 ambientColor;
int screenWidth;
int screenHeight;
sampler ColorMap : register(s0);
sampler NormalMap = sampler_state
{
Texture = <normaltexture>;
};
float4 DeferredNormalPS(float4 Position : SV_Position, float4 Color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 base = tex2D(ColorMap, texCoord);
float3 normal = normalize(tex2D(NormalMap, texCoord) * 2.0f - 1.0f);
float3 PixelPosition = float3(screenWidth * texCoord.x, screenHeight * texCoord.y,0);
float2 Direction;
float Distance;
float4 finalresult = 0;
float modifer = 1; //max((1 - atten), 0);
Direction = position * normal - PixelPosition*normal;
invRadius = 1 / invRadius;
Distance = saturate(1 / length(Direction) * invRadius);
finalresult = (Distance * color * 1);
return base * ((ambientColor * 1) + finalresult);// *((ambientColor * 1) + (Distance * color[0] * 1));
}
technique Deferred
{
pass Pass0
{
PixelShader = compile ps_4_0_level_9_1 DeferredNormalPS();
}
}
and this
float4 position [1];
float4 color [1];
float invRadius [1];
int NUMBEROFLIGHT;
float4 ambientColor;
int screenWidth;
int screenHeight;
sampler ColorMap : register(s0);
sampler NormalMap = sampler_state
{
Texture = <normaltexture>;
};
float4 DeferredNormalPS(float4 Position : SV_Position, float4 Color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 base = tex2D(ColorMap, texCoord);
float3 normal = normalize(tex2D(NormalMap, texCoord) * 2.0f - 1.0f);
float3 PixelPosition = float3(screenWidth * texCoord.x, screenHeight * texCoord.y,0);
float2 Direction [1];
float Distance [1];
float4 finalresult = 0;
for(int i =0; i<= NUMBEROFLIGHT; i++)
{
Direction[i] = position[i] * normal - PixelPosition*normal;
invRadius[i] = 1 / invRadius[i];
Distance[i] = saturate(1 / length(Direction[i]) * invRadius[i]);
finalresult += (Distance[i] * color[i] * 1);
}
return base * ((ambientColor * 1) + finalresult);// *((ambientColor * 1) + (Distance * color[0] * 1));
}
technique Deferred
{
pass Pass0
{
PixelShader = compile ps_4_0_level_9_1 DeferredNormalPS();
}
}
Thank you in advance