TheCheeseMaster
Member
Hi there,
Basically what I'm trying to achieve is this:
-have "cloud shadows" moving across the screen
-draw the cloud shadows with an alpha I can control (all with the same value at any given time)
-have the cloud shadows create a uniform shadow colour when overlapping, rather than having two alphas combine to make darker patches when overlapping
To achieve this I created a surface, made all of the cloud shadow sprites completely black (alpha 1.0) and drew them all onto a surface (cloud_surf). I then would draw the surface at an adjusted alpha, to achieve my desired effect. Here's the code (in the Draw End event):
The problem is, though I achieve the effect I'm going for, the clouds don't appear to be moving super smoothly.
While troubleshooting, I tried just drawing the clouds in the manner I was trying to avoid: where when they overlap the overlapping areas will appear darker. This troubleshooting method avoids using a surface altogether, and though the appearance isn't exactly what I wanted, the clouds DO move smoothly.
You can see what I mean in this video (the first part of the vid uses a surface, the second part doesn't)
Example in YouTube Video
Is there something I'm misunderstanding when it comes to using shaders the way I'm trying? I seem to have run into this problem before, though in a slightly different form:
Game Maker Community Unresolved Surface related Post
and I never did find a solution to that one...
Any tips or insights into something I might be misunderstanding would be greatly appreciated!
(Note I did try drawing the surface instead in the different draw events to no success)
Basically what I'm trying to achieve is this:
-have "cloud shadows" moving across the screen
-draw the cloud shadows with an alpha I can control (all with the same value at any given time)
-have the cloud shadows create a uniform shadow colour when overlapping, rather than having two alphas combine to make darker patches when overlapping
To achieve this I created a surface, made all of the cloud shadow sprites completely black (alpha 1.0) and drew them all onto a surface (cloud_surf). I then would draw the surface at an adjusted alpha, to achieve my desired effect. Here's the code (in the Draw End event):
GML:
//draw clouds
if(!surface_exists(cloud_surf))
{
cloud_surf = surface_create(480,270);
}
if(surface_exists(cloud_surf))
{
surface_set_target(cloud_surf);
draw_clear_alpha(c_black,0);
with(obj_menu_clouds)
{
draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,0,c_white,1);
}
surface_reset_target();
draw_surface_ext(cloud_surf,0,0,1,1,0,c_white,cloud_alpha);
}
While troubleshooting, I tried just drawing the clouds in the manner I was trying to avoid: where when they overlap the overlapping areas will appear darker. This troubleshooting method avoids using a surface altogether, and though the appearance isn't exactly what I wanted, the clouds DO move smoothly.
GML:
var ca = cloud_alpha;
with(obj_menu_clouds)
{
if(sprite_index != -1)
{
draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,0,c_white,ca);
}
}
Example in YouTube Video
Is there something I'm misunderstanding when it comes to using shaders the way I'm trying? I seem to have run into this problem before, though in a slightly different form:
Game Maker Community Unresolved Surface related Post
and I never did find a solution to that one...
Any tips or insights into something I might be misunderstanding would be greatly appreciated!
(Note I did try drawing the surface instead in the different draw events to no success)