C
C#4mo ago
Frite

Monogame, Effect can't find parrameter.

Here is a Visual Studio Solution i want you to test out. e.Parameters["alpha"] is null i its been hours i can't find why
10 Replies
MODiX
MODiX4mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
blueberriesiftheywerecats
its better if you show a piece of code where exatcly you have issue
Frite
FriteOP4mo ago
It seems to be an error from more than code Because, someone told me that my code was fine
Buddy
Buddy4mo ago
Nobody will download a file, especially a zip file to help. Please upload the code by using $paste
MODiX
MODiX4mo ago
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
blueberriesiftheywerecats
what do you mean more than code? where are you getting those values
Frite
FriteOP4mo ago
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif

float alpha;

sampler2D SpriteTextureSampler = sampler_state
{
Texture = <SpriteTexture>;
};

struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};

float4 MainPS(VertexShaderOutput input) : COLOR
{
float4 col = tex2D(SpriteTextureSampler, input.TextureCoordinates) * input.Color;
col.rgb = (col.r + col.g + col.b) / 3.0f;
float a = alpha;
return col;
}

technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
};
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif

float alpha;

sampler2D SpriteTextureSampler = sampler_state
{
Texture = <SpriteTexture>;
};

struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};

float4 MainPS(VertexShaderOutput input) : COLOR
{
float4 col = tex2D(SpriteTextureSampler, input.TextureCoordinates) * input.Color;
col.rgb = (col.r + col.g + col.b) / 3.0f;
float a = alpha;
return col;
}

technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
};
here is the Effect code (hlsl) and in my monogame code, e.Parameters["alpha"] is null where e is an instance of the Effect script
blueberriesiftheywerecats
I dont rly know hlsl but maybe you have to mark "alpha" to be out variable or smth
Frite
FriteOP4mo ago
well i followed a tutorial, and i can't figure out what i did wrong oh wait, i'm so sorry its just because i made an Effect object instead of a SpriteEffect i'm gonna close this down sorry waisting your time
Want results from more Discord servers?
Add your server