Kahrabaa
Member
Hi.
In a 3D space, Im drawing 3 sprites with different y coordinates to place them in front of each other. The problem is the front sprite covers the back sprites even in areas that are transparent on that sprite.
Left pic is without shader. Right pic with new default shader
This only happens when I draw the sprites through a shader. (New unchanged shader)
Noticed that if i invert the drawing order then the problems goes away by swapping the code for sprite 3 with sprite 1
It should draw correctly no matter the order since game objects will move around. I am trying to avoid adding all objects to a ds list to sort them then draw..
What am I doing wrong?
Thanks for your time
In a 3D space, Im drawing 3 sprites with different y coordinates to place them in front of each other. The problem is the front sprite covers the back sprites even in areas that are transparent on that sprite.
Left pic is without shader. Right pic with new default shader
This only happens when I draw the sprites through a shader. (New unchanged shader)
Code:
shader_set(shader0);
matrix_set(matrix_world,matrix_build(0,0,0,60,0,0,1,1,1));
draw_sprite_ext(sprite_index,image_index,0,0,1,1,image_angle,image_blend,image_alpha); //Sprite 1
matrix_set(matrix_world,matrix_build(24,-1,0,60,0,0,1,1,1)); //Shift y up a pixel
draw_sprite_ext(sprite_index,image_index,0,0,1,1,image_angle,image_blend,image_alpha); //Sprite 2
matrix_set(matrix_world,matrix_build(48,-2,0,60,0,0,1,1,1)); //Shift y up another pixel
draw_sprite_ext(sprite_index,image_index,0,0,1,1,image_angle,image_blend,image_alpha); //Sprite 3
shader_reset();
It should draw correctly no matter the order since game objects will move around. I am trying to avoid adding all objects to a ds list to sort them then draw..
What am I doing wrong?
Code:
gpu_set_alphatestenable(1);
gpu_set_ztestenable(1);
gpu_set_zwriteenable(1);
gpu_set_cullmode(cull_noculling);
Code:
var camera=camera_get_active();
camera_set_view_mat(camera,matrix_build_lookat(x+cam3dx,y+cam3dy+250,cam3dz+500,x+cam3dx,y+cam3dy,0,0,1,0));
camera_set_proj_mat(camera,matrix_build_projection_perspective_fov(60,window_get_width()/window_get_height(),1,32000));
camera_apply(camera);
Thanks for your time