1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

surface colour misalignment for meta balls

Discussion in 'Programming' started by JML, Nov 8, 2019 at 10:55 AM.

  1. JML

    JML Wabbajackalope

    Joined:
    Jun 22, 2016
    Posts:
    350
    i am using the following code to blend two objects on a surface together to create one item visually and have run into a problem related to what colours are used.

    the following code is based off the youtube video on metaballs linked to at the bottom of this page

    specifically the problem lies in how the "way" variable is represented, if i use 0 or 255 for the colours then the object appears fine, but if i try to use partial variables (for instance to make an orange metaball) then i end up with an item that looks more yellow than orange and their is a change in colour from the outside going into the center, which isnt present if i pick red or green or aqua.

    please note, if i draw an orange metaball without the surface, it is correctly coloured, but going through the surface it turns more yellow with an orange ish outline, so im at a loss.

    is their something i am doing wrong with the surfaces? how could i correct the drawing system so that the colours of objects i choose will be correctly represented on screen?

    thank you.


    Code:
    var way = make_colour_rgb(255,128,000);
    if surface_exists(surf)
    {
    if instance_exists(obj_ball)
    {
    surface_set_target(surf);
    draw_clear_alpha(way,0.5);
    draw_set_blend_mode(bm_add);
    with(obj_ball)
    {
    draw_sprite_ext(sp_ball,0,x,y,image_xscale,image_yscale,0,way,1)
    }
    draw_set_blend_mode(bm_normal);
    surface_reset_target();
    draw_set_alpha_test(true);
    draw_set_alpha_test_ref_value(200);
    draw_surface(surf,0,0)
    draw_set_alpha_test(false);
    }
    }else{
    surf = surface_create(room_width,room_height);
    }
    
     
    Last edited: Nov 8, 2019 at 11:03 AM
  2. flyingsaucerinvasion

    flyingsaucerinvasion Member

    Joined:
    Jun 20, 2016
    Posts:
    2,182
    Would you please post a screenshot of your problem.
     
  3. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    3,846
    Not gonna lie, only clicked on this topic because of the title.

    Does the ball sprite have transparent edges? The way alpha works on surfaces basically makes alpha more extreme than when drawing normally. You could consider turning off writing the alpha channel to amend this.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice