1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 Aura 2

Discussion in 'Marketplace' started by Nocturne, Nov 9, 2017.

  1. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    Icon_200x200.png

    Aura2 is a GMS2 specific remake of the lightweight, easy to set up lighting engine that I created for your 2D games. It's main feature is that it's a simple to use, no-fuss solution to the problem of creating basic lights and shadows in GameMaker, even with concave shapes, and that it is very fast and customisable!


    Version 2.0 offers numerous improvements over the original, and makes the most of the new GMS2 capabilities, making it more feature rich than ever!


    • FEATURES
      • Cross platform! Tested on UWP, Desktop, and Mobile

      • Instance based lights that you can scale, rotate, colour and fade easily

      • Static or dynamic lighting - static lights are blindingly fast, even in large numbers, and can even be temporarily turned into dynamic lights so that you can control the performance of your game at all times

      • Dynamic lights create realistic shadows, with multiple lights casting multiple shadows

      • Shadows can be defined as box, circle or polygon shapes. Polygon shadows can be created easily through a points list method and can be convex or concave.

      • You can create a shadow mesh from a tilemap layer too!

      • Option to have "soft" shadows

      • Huge number of "convenience" scripts included to make using the engine a breeze

      • Lighting created with "Multiply" blending rather than "Additive" blending, giving super-natural effects, without any of the brightness and saturation associated with other lighting engines.

      • Three demo rooms included for Dynamic Lights, Static Lights, and a General demo room where you can see how all the features work together.

      • Every single script is commented in detail, explaining exactly how it works, typical uses, return values and suggestions for edits or changes

    Screenshot_2.png
     
    Nux, BMatjasic, Rivo and 1 other person like this.
  2. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    Evening @Nocturne, this looks great but I have a couple of questions as I am not sure if I am ready to make use of this just yet. How suitable is this for a side on project? And how well does it work with tilemaps?Lastly, what is required to get this up and running?

    Thank you in advance and please forgive my ignorance!
     
  3. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    Hello @Snayff ! Thanks for the interest... By side on do you mean something like Stealth Bastard?

    [​IMG]

    If so, then yes, Aura is more than capable of doing that. :)

    As for working with tilemaps, yes, it can do that and (imho) it works well, but I would recommend working with square tiles only. Finally, to actually use the engine it requires you to have a controller object that calls the initialisation script and the draw scripts, a single script in the create event of all shadow caster objects (all shadow casters need to have the same parent object too), and then an object (or objects) for lights. The engine comes with a demo project that shows you how to set it all up and it is very heavily commented so that everything is as easy and obvious as possible.
     
  4. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    Thanks for coming back to me, @Nocturne . Yes I mean something exactly like that! So shadow caster objects need the script but what about tilemaps?

    It looks like I might be best off just buying it and digging in; after asking my question earlier I took a stab at adding lighting and it is about passable... maybe. Still lots of questions and amendments required, so Aura might be the ticket to answer those! ;)

    P.S. looking forward to Skein!
     
    rIKmAN likes this.
  5. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,336
    I did the same thing a while ago - just bought it and dug in.

    I spent a couple of hours playing with it and had some test projects with lights working with tilemaps and objects etc, and the asset has loads of comments in each object explaining how things work - it's quite thorough.

    I haven't gone back to using it yet as I'm working on other things, but from what you asked it sounds like it would do what you are after without a problem once you get your head around how it works / read the docs etc.

    In saying that, it is pretty easy to start using - you can get setup and working inside 30mins.
     
    Snayff likes this.
  6. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    Thank you for sharing your experience with it @rIKmAN . It sounds well worth the purchase - you have me convinced! ;)

    Edit: Bought it, time to dive in!

    Edit 2: @Nocturne Aura is pretty darn great. I have got most of it setup after a couple of hours and I have lights being created and following the player and enemy. I have a couple of questions I hope you might be able to help with/point me in the right direction for. Apologies if this is the wrong place to put them.
    1. How would I show part of the tile that is casting the shadows? I am thinking that you would see the floor when the light touches it. Image below. Note that the path you can see is a separate tile.
    upload_2017-11-13_20-2-18.png
    2. How would you go about creating shadows being cast by the player/enemies? Is that the poly options?
    3. It looks like if the radius is below a certain size (~100) it becomes a rectangle instead of a circle. Am I doing something wrong with this?

    Would definitely say it is a great toolset (just a poor user ;) )
     
    Last edited: Nov 13, 2017
  7. Gamerev147

    Gamerev147 Member

    Joined:
    Sep 12, 2016
    Posts:
    444
    I've noticed that the polygon system isn't like a json string with vertices.
    Is there anyway to cast a shadow that is the exact shape of the sprite that is casting the shadow. In addition, how can I rotate that shadow?

    EDIT: I also tried using the polygon shadow caster to cast my shadow the same as the sprite. I entered in coordinates to the Aura_Add_Polygon_Points (or whatever it is) and it gave me an error saying that my points are not an array. I simply put in X and Y coordinates as the arguments state...
     
    Last edited: Nov 13, 2017
  8. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    Evening @Nocturne , Aura2 is working well and easy to work with, however I havent managed to solve my earlier questions. Would you be able to offer any suggestions?
     
  9. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    Hmmm... I'm not sure you can I'm afraid. Because of the way Aura is coded it's either under or over the tiles, and there is no real fading. Keep in mind the engine was designed for speed and ease of use, and as such certain features aren't included (or even possible without compromising the speed and ease of use!).

    I'm afraid I have to repeat the answer from above... Sprite shadows would require a LOT more work and are probably better done in a full shader lighting engine rather than a surface lighting engine like this one. You can use the polygon shapes to approximate the sprite shape, but exact shadow mapping is not possible and not something the engine was designed for, sorry... :(

    Okay, that's weird. I'll check it out and see... Shouldn't matter the size, it should always be a circle!

    Have you initialised the polygon shape first? You need to call the poly_init function first then define the points.

    Sorry I didn't reply previously, but for some reason I got no notifications that anyone had replied!!!!
     
  10. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    @Nocturne Thank you for coming back to me!

    Re. the tiles, I could add two layers of the same tile, with the underlying layer being the shadow generator. That might be a work around. Aura2 is definitely strong enough to give me most things so I can completely appreciate that it cant do everything.

    The rectangle/square effect is pretty dramatic so it would be great to know if we can overcome that! :)
     
  11. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    @Nocturne sorry to message you again buddy, but did you have chance to have a look at the square issue? Can I provide any details to help?
     
  12. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    Hello! I have been looking at it, but can't seem to replicate the issue at all. What exactly have you done to get the circle/square effect? I made smaller and smaller circle occluders (down to a 5px radius) and it was all fine... :(
     
  13. BMatjasic

    BMatjasic Member

    Joined:
    Jun 22, 2016
    Posts:
    77
    I seem to have troubles when I put my camera object inside of the room. I get the following error:
    Code:
    ___________________________________________
    ############################################################################################
    FATAL ERROR in
    action number 1
    of Draw Event
    for object obj_Aura_Control:
    
    Can't create a surface with either a width or height of 0
     at gml_Script_Aura_ReInit (line 26) -            aura_surface = surface_create(_vw, _vh);
    ############################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_Script_Aura_ReInit (line 26)
    called from - gml_Script_Aura_Update (line 19) - if !Aura_ReInit(50)
    called from - gml_Object_obj_Aura_Control_Draw_0 (line 3) - Aura_Update();
    
    So I've put my camera object inside the same layer when aura controller object is and it doesn't seem to work. If I set views to -1 I don't even see the lights :/

    obj_aura_controller:

    Code:
    Aura_Init(0.1, c_aqua, true, 0, 0, 2);
    
    obj_camera:
    create:

    Code:
    /// @description Insert description here
    // You can write your code in this editor
    camera = camera_create();
    
    var vm = matrix_build_lookat(x,y,-20,x,y,0,0,1,0);
    var pm = matrix_build_projection_ortho(384, 288, 1, 10000);
    
    camera_set_view_mat(camera, vm);
    camera_set_proj_mat(camera, pm);
    
    view_camera[0] = camera;
    follow = obj_player;
    x_to = x;
    y_to = y;
    
    step:

    Code:
    move_towards_point(mouse_x, mouse_y, 0);
    x_to = follow.x + lengthdir_x(min(64, distance_to_point(mouse_x, mouse_y)), direction);
    y_to = follow.y + lengthdir_y(min(64, distance_to_point(mouse_x, mouse_y)), direction);
    
    
    
    x+=(x_to - x)/22;
    y+=(y_to - y)/22;
    
    if(follow != noone) {
    
        x_to = follow.x;
        y_to = follow.y;
        
    }
    
    var vm = matrix_build_lookat(x,y,-100,x,y,0,0,1,0);
    camera_set_view_mat(camera,vm);
    
    
    Thanks in advance!
     
  14. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    Hi there! I think the issue is with the creation order... make sure that the lighting controller is created LAST after everything else. If that fails, then please contact me via PM as I'll probably need to look at the project.
     
  15. BMatjasic

    BMatjasic Member

    Joined:
    Jun 22, 2016
    Posts:
    77
    Tried, and was unable to :/ I'll send you a PM. Thanks for your response!
     
  16. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    @Nocturne looks like it is something I am doing then!

    So it looks like this:
    upload_2017-11-24_17-8-15.png

    And the code to create that is....

    Code:
    scCreateFollowingPointLight(id,20, make_colour_rgb(247, 246, 227), 0.9, false);
    

    Code:
    var _objectToFollow = argument0;
    var _radius = argument1;
    var _colour = argument2;
    var _alpha = argument3;
    var _static = argument4;
    
    if layer_exists("Lighting"){
    
        var _id = instance_create_layer(_objectToFollow.x,_objectToFollow.y,"Lighting", oPointLight);
        with(_id){
            objectToFollow = _objectToFollow;
            Aura_Light_Init(argument1, argument2, argument3, argument4);
            aura_light_enabled = true;
        }
    
    }
    


    Code:
    sprite_index = spr_Aura_Point_Light;
    objectToFollow = noone;
    


    Code:
    //if object being followed exists then follow it, else destroy self
    if instance_exists(objectToFollow){
        x = objectToFollow.x;
        y = objectToFollow.y;
    } else {
    
        instance_destroy();
    }
    

    Have I missed something obvious? I can't see anything jumping out in the debug. :(

    Thank you for your help with this, Nocturne.
     
  17. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    Thanks for the extra information... Looking at it, the code seems solid, so I'm wondering if the point light sprite larger than the radius of the light being set? It looks like the radius is being set correctly for the surface, but the sprite isn't being scaled to fit (and I can't remember right now whether it should!!! Will check...)... If the sprite half-width IS larger than the radius, then could you create a new sprite the size of the light radius and test with that?
     
  18. BMatjasic

    BMatjasic Member

    Joined:
    Jun 22, 2016
    Posts:
    77
    Thank you, @Nocturne for a provided solution! Very friendly, Explained what the problem was in detail and solved it in no time. I would recommend this asset to everyone!
     
    Nocturne likes this.
  19. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    @Nocturne Thank you for the suggestion mate. You were right, if the radius is ever less than half of the point light sprite it starts to become square. Is that likely to be an easy fix or am I better off adding some conditionals when creating the light to adjust the point light sprite size?
     
  20. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    Let me look at it tonight and I'll see whether the fix is something I can post here for you to do... If it requires more work, then you'll need to either wait until I can update the asset or work around it yourself.
     
  21. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
  22. AndrewN

    AndrewN Member

    Joined:
    Aug 17, 2016
    Posts:
    11
    Hello. I had the same problem so took a quick look. It looks like its because the image size of the light sprite doesnt get scaled. I fixed this by adding the following to the Aura_Light_Set_Radius script.

    image_xscale = (aura_light_radius*2) / sprite_get_width(sprite_index)
    image_yscale = (aura_light_radius*2) / sprite_get_height(sprite_index) ​

    I added this just line 24. This seemed to fix the issue for me. Hope this helps.

    Andrew
     
  23. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    @AndrewN Thank you for the suggestion. I added it to line 43 of Aura_light_Init and it worked for me!

    Thank you for the help!
     
  24. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    I've just pushed out an Update to Aura... This addresses the issue mentioned by @Snayff whereby the sprite wouldn't scale with the light radius. The scripts now have an optional "scale" argument, and if set to true, then setting the light radius will also scale the sprite to fit. This has one caveat though: The light sprite MUST have a centered origin.

    I've also added a new convenience script for shadow casters: Aura_ShadowCaster_Rotate(angle). As you can imagine, calling this script will rotate a shadow caster by the given amount (works on all shadow types except tile shadows!)

    Another new convenience script is also provided for creating spriteless box shadows: Aura_ShadowCaster_Rect_Init()... You can already do this with circular shadows, so I felt that box shadows also needed the feature.

    Finally, there is a new experimental feature for setting shadow lengths. It is an optional argument in shadow init scripts, and takes a pixel value. I say this is experimental since it does work but I'm not 100% happy with the results. A lot depends on the shape used and the light sprite, etc... so use with care and if you create anything that looks good using different shadow lengths, then please let me know!
     
  25. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    @Nocturne Thank you for the update!

    I hope you might be able to help; do you think Aura is capable of creating flickering light (for fire torches or the like)? I can't find an obvious way so I am wondering if it would be a matter of setting several lights of different sizes and having it rotate between them at a random interval.

    Thank you for any advice you can offer.
     
  26. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    :) Good news! It's REALLY EASY TO DO! This was one thing I had in mind when I designed Aura... So, there are actually 3 ways that you can go about this, which I'll list:

    1) Change the image_x/yscale for the sprite being used for the light (ALWAYS less than 1, so something like 0.5 + random(0.5) should be good)
    2) Set the alpha of the light surface by setting the "aura_light_alpha" value in the light instance (you can also use the setter script "Aura_Light_Set_Alpha", BUT it's bugged currently - I'll push out an update later with a fix!).
    3) Use an animated sprite and simply set the image_speed in the light instance

    There isn't really any method better than any other, so just use whichever one works best for you and gives the effect you want.

    :)
     
  27. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    Fantastic, thank you very much @Nocturne ! I look forward to trying the different methods out. :)
     
  28. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    @Nocturne You're a star, thank you very much.

    For anyone else interested I added to my create light script to return the id of the returned light instance, then set a timer that counted down in the step event, amending both the image X/Y scale and the alpha, as described above. After some playing with the values it looks pretty good (if I say so myself!)

    N.B. increasing the x and y scales reintroduced the square lighting for some reason. :/
     
  29. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    ;)

    This happens because we don't want to resize the surface every step if we can avoid it, so we set it to the initial x/y scale and leave it at that... Anything else would hurt performance.
     
  30. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    So I actually have it at less than 1. Something odd; I have several instances of the same object which contains two calls to create lights. One of the instances shows as expected but another shows with rectangle lights!

    Code:
    leftLight = scCreateStaticPointLight(id.x + 10 , id.y + 6 ,20, make_colour_rgb(149, 239, 124), 0.5, true);
    rightLight = scCreateStaticPointLight(id.x + 24 , id.y + 8 ,24, make_colour_rgb(149, 239, 124), 0.5, true);
    
    leftFlickerTimer = 25;
    rightFlickerTimer = 25;
    
    


    Code:
    if leftFlickerTimer <= 0 {
        var _random = random(0.1);
        leftLight.aura_light_alpha = 0.5 + _random;
        leftLight.image_xscale = 0.9 + _random; //N.B. cannot go larger than 1 or will revert to square lighting
        leftLight.image_yscale = 0.9 + _random;
           
        leftFlickerTimer = scRoll(15,30);
       
    } else {
       
    leftFlickerTimer -= 1;
    
    }
    
    if rightFlickerTimer <= 0 {
       
        var _random = random(0.2);
        rightLight.aura_light_alpha = 0.5 + _random;
        rightLight.image_xscale = 0.8 + _random;
        rightLight.image_yscale = 0.8 + _random;
       
        rightFlickerTimer = scRoll(15,30);
       
    } else {
       
    rightFlickerTimer -= 1;
    
    }
    
    

    When I turn off any reference to the image scale it goes back to being fine. Any thoughts?

    I appreciate your help with this, @Nocturne .
     
  31. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    Hmm... Odd that it works for one but not the other! Would you be willing to send me the project? If you could, then I can give it a lookover this weekend. :)
     
  32. Snayff

    Snayff Member

    Joined:
    Jul 18, 2017
    Posts:
    213
    That's kind of you to offer. What is the best way to get the project over to you?
     
  33. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    Ping me an email at info(at)nocturnegames.com please!
     
  34. theroarer

    theroarer Member

    Joined:
    May 7, 2017
    Posts:
    10
    Hey Nocturne. I'm getting the same error as BMatjasic

    ___________________________________________
    ############################################################################################
    FATAL ERROR in
    action number 1
    of Create Event
    for object obj_Aura_Control:

    Can't create a surface with either a width or height of 0
    at gml_Script_Aura_Init (line 139) - aura_surface = surface_create(_vw, _vh);
    ############################################################################################
    --------------------------------------------------------------------------------------------
    stack frame is
    gml_Script_Aura_Init (line 139)
    called from - gml_Object_obj_Aura_Control_Create_0 (line 54) - Aura_Init(0.1, c_aqua, true, 0, "Shadow_Tiles", 2);

    Could you provide me with the solution as well?
     
  35. djrain

    djrain Member

    Joined:
    Aug 13, 2017
    Posts:
    139
    I was hoping to create a flat shadows look, like in the game Phases. In other words, I want uniform lighting except for the shadows. How would I go about doing that?
     
    Last edited: Aug 30, 2018
  36. Chillicat

    Chillicat Member

    Joined:
    Nov 5, 2018
    Posts:
    2
    Hallo,
    I just tried out Aura and it is really easy to setup and use - thanks for that.
    What would be the best way to detect that my player object is in light/shadow? I would like to either change the sprite of the player or apply an effect.
     
  37. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,778
    Hi there! Okay, that's an interesting question... I haven't really thought about it... :)

    I guess the best way would be to simply use collision_circle on each light, with the radius of the circle being the radius of the light. Anything that ISN'T in collision with a light source, is by default in shadow. You could refine this further with a point_distance check when in collision, to increase the "visibility" of the instance the closer it gets to the light source.
     
  38. Chillicat

    Chillicat Member

    Joined:
    Nov 5, 2018
    Posts:
    2
    Now you say it, it makes absolute sense :) thanks.
     
  39. abeldev

    abeldev Member

    Joined:
    Aug 17, 2017
    Posts:
    26
    In fullscreen mode I get a white flash whenever the system is initialised (eg between rooms). Is there a way to remove it?
     
  40. Berserk_Jeff

    Berserk_Jeff Member

    Joined:
    Jan 18, 2017
    Posts:
    1
    I love how easy Aura has been to learn to use. But, I've hit a brick wall trying to get the effect I want.

    I'm attempting to make objects cast shadows without blacking themselves out.

    If I set the objects depth to be a lower depth than the surface, the object will cast a shadow without blacking itself out, like I want. The issue when it's drawn over top of the surface is that it will never be shaded regardless of light sources. You can see what I mean below:

    above and below surface lighting example.png

    I've considered the solution used by Chillicat, where if an object isn't in a light source draw it as black manually and ease off the closer to a light you get. The issue there is I have some long objects, specifically ships, and it looks really weird when a light approaches the front of a ship making the whole ship light up uniformly.

    I need a way to draw an objects shadow lines, then draw the object itself on top of its shadow, then draw the black overlay surface. I'm not very familiar with surfaces though so I'm not sure how to do this.

    If anyone has any recommendations I'd love to hear them.
     

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