• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Problem with Shaders and YYC

Zekkan

Member
Heyho guys and girls,

I am currently working on a voxel engine/game. Since i had some issues regarding Performance i decided to go through the hassle of installing Visual Studio to use the YYC. But when i now run the game with yyc it messes up my textures. I use a GLSL ES shader for texturing and applying ambient occlusion. After fiddling around i realized that the cause of this problem must be the shader. What iam wondering now is if yyc treats shaders different or not. I am running Gamemaker 1.4 on a win10 machine.


Looking forward to some help,
Zekkan
 

Zekkan

Member
here is the code to my fragment shader.
Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
varying float v_vDepth;

uniform sampler2D mipmap_1;
uniform sampler2D mipmap_2;
uniform sampler2D mipmap_3;
uniform sampler2D mipmap_4;
void main()
{
    vec2 texCoord = vec2(mod(v_vTexcoord.x * .0625, .0625), mod(v_vTexcoord.y * .0625, .0625));
    vec2 atlasCoord = vec2(v_vColour.r * 16. - mod(v_vColour.r * 16., .0625), v_vColour.g * 16. - mod(v_vColour.g * 16., .0625));
    vec4 ambientColor = vec4(v_vColour.a, v_vColour.a, v_vColour.a, 1.);
    ambientColor = mix(ambientColor, vec4(1., 1., 1., 1.), .6);
    vec4 light = vec4(v_vColour.b, v_vColour.b, v_vColour.b, 1.);
    gl_FragColor = light * ambientColor * texture2D( gm_BaseTexture, vec2(atlasCoord.x + texCoord.x, atlasCoord.y + texCoord.y));
    if(v_vDepth > 16.) gl_FragColor = light * ambientColor * texture2D( mipmap_1, vec2(atlasCoord.x + texCoord.x, atlasCoord.y + texCoord.y));
    if(v_vDepth > 24.) gl_FragColor = light * ambientColor * texture2D( mipmap_2, vec2(atlasCoord.x + texCoord.x, atlasCoord.y + texCoord.y));
    if(v_vDepth > 32.) gl_FragColor = light * ambientColor * texture2D( mipmap_3, vec2(atlasCoord.x + texCoord.x, atlasCoord.y + texCoord.y));
    if(v_vDepth > 40.) gl_FragColor = light * ambientColor * texture2D( mipmap_4, vec2(atlasCoord.x + texCoord.x, atlasCoord.y + texCoord.y));
}
 

Jase217

Member
Try pressing the clean up button before building with YYC again, sometimes old cached files will cause problems like this.
 

Zekkan

Member
I found the probllem. Apperently the vm compiler doesnt really care about the order of defining a vertex. You can define your fertex format in a diffrent order than assigning the data in code. But the YYc wants bothto be in the same order.
 
I found the probllem. Apperently the vm compiler doesnt really care about the order of defining a vertex. You can define your fertex format in a diffrent order than assigning the data in code. But the YYc wants bothto be in the same order.
To be fair, the manual does implicitly state that the order is important, but it is interesting to learn that the VM side doesn't respect it!
 
Top