[solved] Monogame HLSL Shader how to use other version than 4_0_level_9_X ?

I m trying to make a Point Light Shader, though:

With the versions 4_0_level_9_1 and 4_0_level_9_3 I m running into this error in the MonoGame Content Pipeline:

“Invalid const register num: 42 max allowed 31”

In my Shader I have Arrays of LightPositions, Colors etc with Array Size being the max amount of Lights I might need

with my max Lights being higher than 5, I run into this problem above (<=5 no issue)

I looked for a solution and found out that depending on the version, you can use a different number of constants…

v_4_0 or v_5_0 should give me enough, though MonoGame Content Pipeline throws an Error, saying wrong Parameter for this:

technique Shader1
{
pass P0
{
VertexShader = compile vs_5_0 VertexShaderFunction();
PixelShader = compile ps_5_0 PixelShaderFunction();
}
};

Yah, like you said - I think 4_0_level_9 stuff is based on directX 9 which I think someone said is actually like shader 2 which is more limiting. So like you said - other versions should work.
So it’s saying wrong parameter for vs_5_0? The code you show looks fine. Sometimes it’s something else in the code that seems to cause an error so I’m wondering what else is in there that maybe it doesn’t like? Sometimes it’s just something like a missing semicolon on a struct.

thx, though I mistakenly wrote that the Content Pipeline throws the wrong parameter error, but its my code that has a problem… could it be that something is wrong with this line I use to load the Effect File?
For the 4_0_level_9_X versions, this line worked

I think as far as I can see my effect file has no semicolons missing… but tough to tell since visual studio doesnt show me syntax errors in fx files

so I suppose maybe something else is the problem?

btw just ignore the other lines in the screenshot :slight_smile:
and the german words, falscher parameter mean wrong parameter, dunno why visual studio is half english half german for me

and _shader is a public static Effect variable in a class I call Global

SharpDX exception… I remember someone saying you may need to set GraphicsProfile to HiDef?:
graphics.GraphicsProfile = GraphicsProfile.HiDef;

1 Like

thank you so so much, it works :smiley:

Oh good - I’ll have to remember this too. :slight_smile: