mMcFab
Member
Hi everybody!
You might know by now that I really like to play around in 3D with GameMaker, and by extension I end up using shaders a lot
However, I'm having some problems adjusting to HLSL 11 - as far as I'm aware, HLSL 9 shaders should no longer work, and need updating.
I have a pretty solid understanding of HLSL 9 shaders, but I can't seem to figure out how to port them to HLSL 11
I always get these two errors - the first appears at compile time:
The second appears at runtime when the shader is set:
Unfortunately, "Invalid Shader" is far from a helpful error message. Sometimes it tells me the error is in Fragment Compilation, so I'm really having a hard time finding the source of the problem
So, here's a HLSL 9 passthrough shader which works perfectly in 1.X:
And here's my attempt at updating it to HLSL 11 to use with GMS2:
As far as I can tell from googling, I should just need to update SV_Position and SV_Target, but that doesn't seem to be working - am I doing something totally wrong?
My graphics card uses DirectX 11 (dxdiag confirms this), so I don't think that could be an issue.
I am on Windows 7, which wasn't originally listed as supported in 1.X, could that be the problem? Is this going to be the thing that forces me to update to Windows 10?
My GLSL ES shaders still seem to work fine, but I still can't figure out what I need to name blendweights and indices within the shader (in_BlendWeights, in_Blendweights, in_BlendWeight and in_Blendweight don'y work, neither do respective indices tests - always get a "Could not generate input layout (is there a mismatch between your shader and vertex format?)" error on compile and "Draw failed due to invalid input layout" on draw).
Would be real nice if we got a documentation page telling us what attribute names an ES shader needs to use for each format usage type
Anway, back to the point at hand - is anybody able to explain where I'm going wrong and point me in the right direction? It'd be really appreaciated
You might know by now that I really like to play around in 3D with GameMaker, and by extension I end up using shaders a lot
However, I'm having some problems adjusting to HLSL 11 - as far as I'm aware, HLSL 9 shaders should no longer work, and need updating.
I have a pretty solid understanding of HLSL 9 shaders, but I can't seem to figure out how to port them to HLSL 11
I always get these two errors - the first appears at compile time:
Code:
Invalid shader (is it marked as incompatible type for this target?) "shader_0":
Code:
ERROR!!! :: ############################################################################################
FATAL ERROR in Vertex Shader compilation
ShaderName: shader_0
Invalid shader
at gml_Object_test_Draw_0 (line 4) - shader_set(shader_0);
############################################################################################
So, here's a HLSL 9 passthrough shader which works perfectly in 1.X:
Vertex
Frag
Code:
struct VS_INPUT
{
float4 vPos : POSITION;
//float4 vNormal : NORMAL;
float4 vColor : COLOR;
float2 vTexCoord : TEXCOORD0;
};
struct PS_INPUT
{
float4 Position : POSITION; // interpolated vertex position (system value)
float4 Color : COLOR; // interpolated diffuse color
float2 TexCoord : TEXCOORD0;
};
PS_INPUT main(VS_INPUT input) // main is the default function name
{
PS_INPUT Output;
// Transform the position from object space to homogeneous projection space
Output.Position = mul(gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION], input.vPos);
// Just pass through the color data
Output.Color = input.vColor;
Output.TexCoord = input.vTexCoord;
return Output;
}
Code:
struct PS_INPUT
{
float4 Color : COLOR;
float2 TexCoord : TEXCOORD0;
};
struct PS_OUTPUT {
float4 Color : COLOR;
};
PS_OUTPUT main(PS_INPUT In)
{
PS_OUTPUT Output;
Output.Color = In.Color * tex2D(gm_BaseTexture, In.TexCoord);//In.Color;
return Output;
}
And here's my attempt at updating it to HLSL 11 to use with GMS2:
Vertex
Fragment
Code:
struct VS_INPUT
{
float4 vPos : POSITION;
//float4 vNormal : NORMAL;
float4 vColor : COLOR;
float2 vTexCoord : TEXCOORD0;
};
struct PS_INPUT
{
float4 Position : SV_POSITION; // interpolated vertex position (system value)
float4 Color : COLOR; // interpolated diffuse color
float2 TexCoord : TEXCOORD0;
};
PS_INPUT main(VS_INPUT input) // main is the default function name
{
PS_INPUT Output;
// Transform the position from object space to homogeneous projection space
Output.Position = mul(gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION], input.vPos);
// Just pass through the color data
Output.Color = input.vColor;
Output.TexCoord = input.vTexCoord;
return Output;
}
Code:
struct PS_INPUT
{
float4 Color : COLOR;
float2 TexCoord : TEXCOORD0;
};
struct PS_OUTPUT {
float4 Color : SV_TARGET;
};
PS_OUTPUT main(PS_INPUT In)
{
PS_OUTPUT Output;
Output.Color = In.Color * tex2D(gm_BaseTexture, In.TexCoord);//In.Color;
return Output;
}
As far as I can tell from googling, I should just need to update SV_Position and SV_Target, but that doesn't seem to be working - am I doing something totally wrong?
My graphics card uses DirectX 11 (dxdiag confirms this), so I don't think that could be an issue.
I am on Windows 7, which wasn't originally listed as supported in 1.X, could that be the problem? Is this going to be the thing that forces me to update to Windows 10?
My GLSL ES shaders still seem to work fine, but I still can't figure out what I need to name blendweights and indices within the shader (in_BlendWeights, in_Blendweights, in_BlendWeight and in_Blendweight don'y work, neither do respective indices tests - always get a "Could not generate input layout (is there a mismatch between your shader and vertex format?)" error on compile and "Draw failed due to invalid input layout" on draw).
Would be real nice if we got a documentation page telling us what attribute names an ES shader needs to use for each format usage type
Anway, back to the point at hand - is anybody able to explain where I'm going wrong and point me in the right direction? It'd be really appreaciated
Last edited: