[SOLVED] d3d_model_vertex_colour is always grey

Discussion in 'Programming' started by FeetUpGaming, Mar 31, 2018.

  1. FeetUpGaming

    FeetUpGaming Member

    Joined:
    Apr 2, 2017
    Posts:
    104
    Hey okay i'm trying to use a surface buffer to get the colours of pixels but when i do and create a 3d model using d3d_model_vertex_colour() it's all greyed out. I'm not sure why it keeps doing it. Here is the code i'm using:
    Code:
    ///sprite_make_model(index)
    
    var sprite = argument[0];
    var w = sprite_get_width(sprite);
    var h = sprite_get_height(sprite);
    
    var surf = surface_create(w,h);
    surface_set_target(surf);
    draw_clear_alpha(c_black,0);
    draw_sprite(sprite,0,0,0);
    
    var _buff = buffer_create(w*h*5, buffer_fixed, 4);
    buffer_get_surface(_buff, surf, 0, 0, 0);
    
    var model = d3d_model_create();
    d3d_model_primitive_begin(model,pr_trianglelist);
    
    for(i=0;i<w;i+=1)
    {
        for(j=0;j<h;j+=1)
        {
            var _col = buffer_read(_buff, buffer_u32);
            var _a = (_col >> 24) & 255;
            var _b = (_col >> 16) & 255; //r
            var _g = (_col >> 8) & 255; //g
            var _r = _col & 255; //b
            var color = make_colour_rgb(_r, _g, _b);
       
            if _a > 0
            {
    
            d3d_model_vertex_colour(model,i,j,0.5,color,1);
            d3d_model_vertex_colour(model,i+1,j,0.5,color,1);
            d3d_model_vertex_colour(model,i,j,0,color,1);
       
            d3d_model_vertex_colour(model,i+1,j,0.5,color,1);
            d3d_model_vertex_colour(model,i+1,j,0,color,1);
            d3d_model_vertex_colour(model,i,j,0,color,1);
       
            d3d_model_vertex_colour(model,i,j,0.5,color,1);
            d3d_model_vertex_colour(model,i+1,j,0.5,color,1);
            d3d_model_vertex_colour(model,i,j+1,0.5,color,1);
       
            d3d_model_vertex_colour(model,i+1,j,0.5,color,1);
            d3d_model_vertex_colour(model,i+1,j+1,0.5,color,1);
            d3d_model_vertex_colour(model,i,j+1,0.5,color,1);
            }
        }
    
    }
    buffer_delete(_buff);
    d3d_model_primitive_end(model);
    
    surface_reset_target();
    surface_free(surf);
    
    return model; 
    Please can someone help. The model i get is greyed out.

    EDIT: I have debugged it abit and it seems like it wont draw any colour i set with d3d_model_vertex_colour

    EDIT: SOLVED. I was using lighting which because i had no normals it messed up.
     
    Last edited: Mar 31, 2018
  2. FeetUpGaming

    FeetUpGaming Member

    Joined:
    Apr 2, 2017
    Posts:
    104
    Here is an image of what it looks like, i have also changed the color to c_blue but it is still grey for some reason:[​IMG]
     

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