"Unsupported parameter class!" Error on Shader Model 5.0

Hello everyone,

So I’m having trouble compiling this shader code on MonoGame. it works perfectly in XNA but not in MonoGame. I’m compiling the shader code in VS 2010. I compile the code on “Windows 8” profile and using the “MonoGame Effect” Content Processor.

I get this vague error message. “Unsupported parameter class!”. After hours of coding trying to figure out what is wrong, I found out that when I remove the light array and use a single float parameter instead it compiles perfectly and it works.

So here is my question, why doesn’t this code work in MonoGame but in XNA it does?
This is the shader code that works in XNA but not in MonoGame.

struct Light
{
	float3 Position;
	float4 Color;
	float Radius;
	float Intensity;
};

float4x4 MatrixTransform;

float AmbientIntensity;
float4 AmbientColor;

Light lights[50];

float ScreenWidth;
float ScreenHeight;

texture ColorTexture;

sampler ColorMap = sampler_state
{
	Texture = <ColorTexture>;
};

float4 CalculateLight(Light light, float4 TextureMap, float2 PixelPosition)
{
	float2 Direction = light.Position - PixelPosition;
	float Distance = saturate(1 /length(Direction) * light.Radius);
	
	return TextureMap * Distance * light.Color * light.Intensity;
}

float4 PixelShaderFunction(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
	float4 TextureMap = tex2D(ColorMap, texCoord);

	float2 PixelPosition = float2(ScreenWidth * texCoord.x, ScreenHeight * texCoord.y);
		
	float4 FinalColor = (TextureMap * AmbientColor * AmbientIntensity);

	for(int i = 0; i <= 10; i++)
		FinalColor += CalculateLight(lights[i], TextureMap, PixelPosition);

	return FinalColor;
}

technique Technique1
{
    pass Pass1
    {
        PixelShader = compile ps_5_0 PixelShaderFunction();
    }
}

Here is the code that finally compiled in MonoGame. but as you can see I didn’t use any arrays.

float ScreenWidth;
float ScreenHeight;

texture ColorTexture;

float AmbientIntensity;
float4 AmbientColor;

float4 LightPosition;
float4 LightColor;
float LightIntensity;
float LightRadius;

sampler ColorMap = sampler_state
{
	Texture = <RenderTarget>;
};

float4 PixelShaderFunction(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
	float4 TextureMap = tex2D(ColorMap, texCoord);

	float2 PixelPosition = float2(ScreenWidth * texCoord.x, ScreenHeight * texCoord.y);

	float2 Direction = LightPosition - PixelPosition;
	float Distance = saturate(1 /length(Direction) * LightRadius);

	return TextureMap * ((AmbientColor * AmbientIntensity) + (Distance * LightColor * LightIntensity));
}

technique Technique1
{
    pass Pass1
    {
        PixelShader = compile ps_5_0 PixelShaderFunction();
    }
}

Last time I looked at it, certain features (effect parameter structs, semantics, annotations) simply were not implemented in MonoGame. (The MonoGame team had to reimplement the effect system. Direct3D 9 Effects don’t work in Direct3D 11 and they are not cross-platform.)

Fair enough. Well thank you :slight_smile: