Where to begin learning how to create shadows

Discussion in 'Programming' started by JML, Aug 16, 2019.

  1. JML

    JML Wabbajackalope

    Joined:
    Jun 22, 2016
    Posts:
    347
    i would like to learn how to create shadows on objects, preferably in a manner which would allow me to control the variables that effect the location of the light.

    where would i begin learning this?

    Thank you.
     
  2. Bentley

    Bentley Member

    Joined:
    Jun 18, 2017
    Posts:
    789
    His website has a tutorial about shadows: www.davetech.co.uk

    Basically, you draw every instance that you want to have a shadow to a surface, and draw that surface before you draw everything else.
    I didn't test this code, but I hopefully this shows you what I mean.
    Code:
    if (!surface_exists(surf))
    {
        surf = surface_create(room_width, room_height);
        surface_set_target(surf);
        draw_clear_alpha(c_black, 0);
        surface_reset_target();
    }
    
    surface_set_target(surf);
    with (par_shadow)
    {
        draw_self();
    }
    surface_reset_target();
    
    draw_surface_ext(surf, 16, 16, 1, 1, 0, c_black, 0.5);  
    draw_surface_ext lets you draw the surface offset (16, 16), black, and semi-transparent.
     

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