Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shaders must be fixed in AGK Studio #20

Open
hannibaldark opened this issue Aug 21, 2024 · 4 comments
Open

Shaders must be fixed in AGK Studio #20

hannibaldark opened this issue Aug 21, 2024 · 4 comments

Comments

@hannibaldark
Copy link

The shaders which work properly in Classic, do not work in Studio, and it is not because renderer api. Please check out https://forum.thegamecreators.com/thread/229696 to see detailed information.

@hannibaldark
Copy link
Author

Since I'm making mobile apps I don't need Vulkan so I updated shader codes to this and set renderer to "Basic";

vertex shader;
[code]
#version 420
in highp vec4 position;
in highp vec4 color;
in highp vec2 uv;
out highp vec2 uvVarying;
out highp vec2 posVarying;
out highp vec4 colorVarying;
uniform mat4 agk_Ortho;
void main()
{
gl_Position = agk_Ortho * position;
posVarying = position.xy;
uvVarying = uv;
colorVarying = color;
}
[/code]

pixel shader;
[code]
#version 420
in highp vec2 uvVarying;
in highp vec2 posVarying;
in highp vec4 colorVarying;
out highp vec4 myOutputColor;
uniform sampler2D texture0;
uniform highp vec4 window;
void main()
{
myOutputColor = texture2D(texture0, uvVarying) * colorVarying;
if(posVarying.x < window.x){myOutputColor = vec4(0.0, 0.0, 0.0, 0.0);}
if(posVarying.x > window.z){myOutputColor = vec4(0.0, 0.0, 0.0, 0.0);}
if(posVarying.y < window.y){myOutputColor = vec4(0.0, 0.0, 0.0, 0.0);}
if(posVarying.y > window.w){myOutputColor = vec4(0.0, 0.0, 0.0, 0.0);}
}
[/code]

the interesting part starts here, when you change the pixel shader code to this;
[code]
#version 420
in highp vec2 uvVarying;
in highp vec2 posVarying;
in highp vec4 colorVarying;
out highp vec4 myOutputColor;
uniform sampler2D texture0;
uniform highp vec4 window;
void main()
{
myOutputColor = texture2D(texture0, uvVarying) * colorVarying;
}
[/code]

still the green sprites are gone. That is a bug.

Even;
myOutputColor = vec4(0.0, 0.0, 1.0, 0.1);
shows only the red sprites but in Classic the alpha blending shows all.

@hannibaldark
Copy link
Author

the attribute vec4 position is wrong, this must be fixed.

@hannibaldark
Copy link
Author

hannibaldark commented Aug 30, 2024

Using LoadSpriteShader works instead of LoadShader but default vertex shader does not have varying position so when I add that and load shader with vertex shader it fails again.

@hannibaldark
Copy link
Author

In the vertex shader setting position attribute as vec2 is less buggy. Studio sends wrong datas for color and position attributes. That's my final effort for a "long time dead" thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant