Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Glare Engine - 2D Lighting for GameMaker Studio

GameMaker:Studio Extension, shader based dynamic lighting. · By Tiz

Sprite-based shadow casting?

A topic by JesterOC created 26 days ago Views: 68 Replies: 14
Viewing posts 1 to 5

From what I could tell the end of the video showed Sprite-based shadow casting? with text in it?
looking to upgrade from using Aura 2 and need Sprite-based shadow casting and something faster (Your asset looks like the right choice)

Developer

Hi, jester, it supports also sprite shadows but are slower than mesh based shadows. The text seen in the video/demo is a sprite

Yeah kewl I bought it and had only 1 problem... indoor wall shadows... i found a solution with obj_glr_wall and obj_glr_roof where I set the roof to a height just below the walls and use it as a floor...  but it only works fully with 1 object for the roof/"floor" segment. otherwise it cuts the shining outside once i've left the first indoor floor "segment" and my game has modular building segments, so i can't just use 1 object.
Any ideas how to get the shining to work through the door with multiple "floor" segments?
heres some pics to explain better,
here's how it shines if i use 1 big floor obj, or if i stand upon the obj near the door.


outside always worked scaled 1 obj or segments.. shines like this


but here's whats wrong if i walked inside and off the first obj, it loses the shining out through the 1st objects edge. i marked the corners of the first object to show where it is..



i don't know what else to do,
so would you have any ideas how to get the shining to work through the door with multiple "floor" segments?

the only code i changed was these

glr_mesh_set_scaling(mesh_id, image_xscale, image_yscale);//scaling fix oc
glr_mesh_set_height(mesh_id, 10); 
(in obj_glr_roof)

glr_mesh_set_height(mesh_id, 8); 
(in obj_glr_wall)

Developer (3 edits)

Since the floor does not cast shadows you can treat it as a normal object without any glare related code. It would work out of the box. Btw I suggest you to use the nine slice feature of gamemaker with the repeat flag set to have more performance and use less “floor pieces”

i was using floors to not cast shadows upon the floor area... so i do need floor to have a mesh_set_height value greater than the walls.. can't use a standard object cus that just lets in unrealistic inside shadows from directional light.

see the wall shadow above the floor if i'm not using glare setup code in "floor" obj


is there a way you could make a simple workaround that works with multiple floor segments?
I can't use just one obj for floor cus the player houses in my game are editable and modules...
also, is there a way to turn off/on a shadowcaster? I implemented a non-shader lighting system that was able to and have finished code that requires the shadowcaster(s) to be enabled/disabled based upon the house shape (so the player can walk from module to module in the house

Developer

To block the directional light you could use a roof (make it invisible when running the game)

This is what I'm doing but multiple roofs at the caveat of losing some outdoor lighting when inside enough..

But i have another problem 😔 

Android shadowcasters meshes are hollow..

I set it up fer PC and expected mobile to be mostly same.. but it's not working at all..

It looks like the system is interpreting the mesh coordinates inside out (clockwise or anticlockwise) and getting the wrong look.. cus the same thing happens upon pc with rotated masks when turned.

Here's a picture u can see it looks wonk fer the walls. And the roof segments im using as floor have shadows cast upon each other instead of just outside.

And Pc looks more like this

Have you had this kind of behaviour with it before? I need a cross-platform mobile/PC solution and can't util this if android isn't gonna work the same or similar.

Developer

Looks like gamemaker changed something in the recent versions I’ll check and, in case, release a new version

Ok. Cus i was hoping to utilise Glare Engine for my open world game's 2D lighting

Non-directional light works with Android/PC but has no day/night cycle and stays dark.

If you could add day/night cycle to it without the extra shadows from directional lighting that would solve my cross-platform issue. (I'd actually prefer without the extra directional shadows, just for simplicity). 

Let me know if you can update it.

Update..
I got  day/night it working with non-directional light..
added this to the draw event before drawing and up = true; and day = 0; to the create event.

if up = true {day+= 0.01;}
else {day-=0.01}
glr_set_ambient_daytime(day); if day == 1 { up = false }else if day == 0 {up = true}

(1 edit)

I tried following the documentation at 
https://tizsoft.altervista.org/glare/docs/grouping_meshes

to try to group the floor meshes as one..
they turned out even more disconnected. and still has the same issue with door lighting spill if i step off the initial floor onto another floor.

Developer

It is the wrong approach to have different pieces for the floor. You should remove any glare related code from the floor and use a ceiling object. There is an example in the top down demo

(2 edits)

Edited: Having an issue with Lights not drawing ShadowCasters not working in my main room after importing the asset...
was having an issue with lights not showing but i fixed that with 
gpu_set_ztestenable(false);//false fer lighting
and then i set it to true again cus it's used by my grass...
 gpu_set_ztestenable(true);//true again


Using Non-directional lighting with day/night ambience 
Day/Night Cycle still works with ambient light... I have no idea what's causing this.
Any suggestions? some way to debug it and work out what's happening with the lights shadowcasters perhaps?

EDIT 2: 

 gpu_set_ztestenable(true);  appears to be why the shadowcasters won't work... 
this sucks, nd i don't wanna choose between shader grass and shadowcasting, gonna look for a fix

Any idea why shadowcasting doesn't work with gpu_set_ztestenable(true); even if i set gpu_set_ztestenable(false); before drawing lighting? 

i was able to get lights working by setting it to false and then back to true after.. but the shadowcaster side of the lighting system doesn't like that and refuses to cast shadows.

I might have to do without shadowcasters 😭

At least I was able to get lights working with the shader grass I'm using

If you are able to update the asset to include shadowcasters that work when gpu_set_ztestenable(true) is set, that'd be great.

I tried getting the shader grass I'm using (TouchGrass) to work without gpu_set_ztestenable(true); but it was always invisible, everything i tried.

I think I'm gonna have to give up trying and settle for what I was able to get working, lights + grass.