Jump to content


Photo

Tlighting[2.4] Gm: Studio


  • Please log in to reply
149 replies to this topic

#1 tizzio

tizzio

    GMC Member

  • GMC Member
  • 61 posts
  • Version:GM:Studio

Posted 30 May 2012 - 09:43 PM

logo2.png

Made in  ITALY  cool.gif


sep_features.png
 
New 2.4 Features

  • Fixed flickering shadows bug
  • Light quality & system quality (new argument in tl_init(...,...,...,quality))
  • New Hybrid system (that autoselect the mesh/sprite based rendering, according to the convenience)
  • tl_update & tl_draw now returns 0 if there is a surface error.
  • New shadowsprite Rendering : with many instances does not slow down as before
  • Added tl_mesh_hybrid(id)
  • Added tl_light_quality(light id)
  • Added tl_light_destroy_all() & tl_mesh_destroy_all()
  • Added tl_active(id, true or false) & tl_get_active(id)
  • Added tl_set_view([0..7])Possibility to choose the view index
  • Fixed tl_get_lighting(x,y)

Other features

  • GML knowledge required
  • Pc, Mac, Android, iOS. (not yet HTML5)
  • Static light stored in vram for gain speed!(use tl_light_delete(light id) for free memory)
  • Static & Dynamic Shadows from sprites
  • Static & Dynamic Shadows from meshes (with vertices)
  • Automatic creation of ordinary meshes (square, circle)
  • Lights color selection
  • Lights Auto-deactivation
  • Automatic Shadows Backface culling
  • Automatic meshes deactivation
  • Complete vertices control
  • Light intensity regolation
  • Glimmers of light on shapes
  • Choosing the shape of light through a mask in black and white
  • Get the lighting/shadowness value at (x,y)

DOCUMENTATION (work in progress)

http://tizsoft.alter...a.org/Tlighting


screen0.png

sep_download.png

  • GM:Studio Project (.gmz) + GM8.x Project (.gmk) + Extension (.gex) + Executable (.exe)

Link cooming soon

  • Extension (.gex) only

http://tizsoft.alter...Tlighting24.gex

sep_tutorials.png

  • GM8.x - first demo

http://tizsoft.alter.../Tlighting2.gmk

  • GM8.x tutorial 0 - basics

http://tizsoft.alter...g_tutorial0.gmk

  • GM8.x tutorial 1 - hidden the player

http://tizsoft.alter...g_tutorial1.gmk

  • GM:Studio tutorial 0 - basics

http://tizsoft.alter...ial0_STUDIO.gmz

  • GM:Studio - first demo

http://tizsoft.alter...ting_studio.gmz


The gex was programmed and tested on a Netbook, so performance is optimized at best, to work in any device.

Thanks to jak for rendering method with 2 blend modes and backface culling formula.


Edited by tizzio, 07 April 2013 - 12:23 PM.

  • 5

#2 enick11

enick11

    GMC Member

  • GMC Member
  • 7 posts
  • Version:Unknown

Posted 30 May 2012 - 09:58 PM

O MY GOD ! very nice man! the best light engine ever!

-30/30 fps with a lot of light and meshes!
FANTASTIC ::lmao::

Edited by enick11, 30 May 2012 - 10:08 PM.

  • 0

#3 Drara

Drara

    GMC Member

  • GMC Member
  • 305 posts

Posted 31 May 2012 - 03:16 AM

Very neat!
I've a question though: Is your example compiled in Game Maker Studio? o: Because it works a lot faster than when I'm compiling it myself in GM 8.1
  • 0

#4 enick11

enick11

    GMC Member

  • GMC Member
  • 7 posts
  • Version:Unknown

Posted 31 May 2012 - 09:55 AM

Very neat!
I've a question though: Is your example compiled in Game Maker Studio? o: Because it works a lot faster than when I'm compiling it myself in GM 8.1


I believe he used GM 8.0
  • 0

#5 tizzio

tizzio

    GMC Member

  • GMC Member
  • 61 posts
  • Version:GM:Studio

Posted 31 May 2012 - 12:36 PM

Very neat!
I've a question though: Is your example compiled in Game Maker Studio? o: Because it works a lot faster than when I'm compiling it myself in GM 8.1

I use GM 8.0
  • 0

#6 Drara

Drara

    GMC Member

  • GMC Member
  • 305 posts

Posted 31 May 2012 - 05:16 PM

I use GM 8.0

Oh o: Can it really be that GM 8.1 is slower than 8.0? o-o
  • 0

#7 Pancratius

Pancratius

    GMC Member

  • GMC:Member
  • 55 posts
  • Version:GM8

Posted 31 May 2012 - 06:04 PM

I'm sorry, maybe its because I'm new to game maker coding, but I had a look at the coding in your example, and couldn't get my head around it at all. Would it be possible for you to comment it please. It would make it much easier to understand.

Regards,
Pancratius

#8 enick11

enick11

    GMC Member

  • GMC Member
  • 7 posts
  • Version:Unknown

Posted 31 May 2012 - 07:04 PM


I use GM 8.0

Oh o: Can it really be that GM 8.1 is slower than 8.0? o-o


oh yes :confused:
  • 0

#9 tizzio

tizzio

    GMC Member

  • GMC Member
  • 61 posts
  • Version:GM:Studio

Posted 31 May 2012 - 10:15 PM

I'm preparing some tutorials ;)

SEE at OPENPOST

If you also want to post some examples, or if you create some games using this gex
Send me a PM! I will provide to include them in the OpenPost

Edited by tizzio, 02 June 2012 - 01:37 AM.

  • 0

#10 Pancratius

Pancratius

    GMC Member

  • GMC:Member
  • 55 posts
  • Version:GM8

Posted 01 June 2012 - 04:37 PM

That tutorial is quite helpful, but doesn't seem to work. It gives an error when I right click the lights to remove them.

This is the error:

___________________________________________
ERROR in
action number 1
of Destroy Event
for object obj_light:

Error in code at line 2:
   tl_light_delete(l);
                   ^
at position 18: Unknown variable l

To fix this I created a variable using the D&D method called my_light, before the code in the create event of the obj_light. I then changed the line causing the problem to:

tl_light_delete(my_light);

and this problem did not occur again.

Also, I am working on a game which is using this extension. However I am attempting to make the game at a resolution larger than 640x480. The problem is the ambient lighting does not extend to the size of the room. Here is an image which illustrates what I mean:

Posted Image

Uploaded with ImageShack.us
How might I extend the ambient lighting to the extents of the room?

Edited by Pancratius, 01 June 2012 - 04:38 PM.


#11 tizzio

tizzio

    GMC Member

  • GMC Member
  • 61 posts
  • Version:GM:Studio

Posted 02 June 2012 - 01:35 AM

Thank you, for testing ;)

The light follows the size of the view.
So set the view, equal to the size of the window! :)

in Room editor
-> room width : 900
-> room height: 700

-> view wport : 900
-> view hport : 700

view sizes must be smaller (or equal) than room width !

Edited by tizzio, 02 June 2012 - 01:43 AM.

  • 0

#12 Pancratius

Pancratius

    GMC Member

  • GMC:Member
  • 55 posts
  • Version:GM8

Posted 02 June 2012 - 09:53 AM

Thank you, for testing ;)

The light follows the size of the view.
So set the view, equal to the size of the window! :)

in Room editor
-> room width : 900
-> room height: 700

-> view wport : 900
-> view hport : 700

view sizes must be smaller (or equal) than room width !



Working perfectly now thanks for your help :).

#13 CrazyGuyGames

CrazyGuyGames

    YYGF Member

  • GMC Member
  • 194 posts
  • Version:GM8.1

Posted 02 June 2012 - 03:40 PM

Amaizing, just what I need, but I don't understeand it, can you comment it or make another example, but more simple?
  • 0

#14 thatonenerd22

thatonenerd22

    GMC Member

  • New Member
  • 2 posts

Posted 02 June 2012 - 03:56 PM

Well, now I feel silly for wasting 3+ months and multiple versions making a not-quite-as-good lighting engine. :(
global.viewx = round(view_xview/gridsize)*gridsize
global.viewy = round(view_yview/gridsize)*gridsize
r = 0
g = 0 
b = 0
strength = 0
xx = global.viewx-gridsize*2
yy = global.viewy-gridsize*2
reps = 0
draw_set_color(c_white)
lines = 0
repeat((view_wview/gridsize+2)*(view_hview/gridsize+2)+view_wview)
{
with(light_parent)
{
i = collision_line(x,y,controller.xx,controller.yy,obj_solid,true,true)
if i <1
{
if (point_direction(x,y,controller.xx,controller.yy) <= maxdir and point_direction(x,y,controller.xx,controller.yy) >= mindir)
or (point_direction(x,y,controller.xx,controller.yy)-360 <= maxdir and point_direction(x,y,controller.xx,controller.yy)-360 >= mindir)
or (point_direction(x,y,controller.xx,controller.yy)+360 <= maxdir and point_direction(x,y,controller.xx,controller.yy)+360 >= mindir)
{if
point_distance(x,y,controller.xx,controller.yy) < strength
{if (x > global.viewx-strength and y > global.viewy-strength and x < global.viewx+view_wview+strength and y < global.viewy+view_hview+strength)

{
controller.strength = max(0,min(1,controller.strength,(point_distance(x,y,controller.xx,controller.yy)/strength)*intensity))
controller.r = max(controller.r,r*(1-point_distance(x,y,controller.xx,controller.yy)/strength)*cintensity)
controller.g = max(controller.g,g*(1-point_distance(x,y,controller.xx,controller.yy)/strength)*cintensity)
controller.b = max(controller.b,b*(1-point_distance(x,y,controller.xx,controller.yy)/strength)*cintensity)
controller.lines+=1
}}}}



}
draw_sprite_ext(spr_shadow,0,xx,yy,
gridsize/8,gridsize/8,0,
make_color_rgb(r,g,b),strength)
 
//draw_sprite_ext(spr_shadow,0,xx,yy,gridsize,gridsize,0,c_black,strength)
xx += gridsize
if !(xx < global.viewx+view_wview+gridsize*2)
{xx = global.viewx-gridsize*2
yy += gridsize}

r = 10*global.sunlight
g = 10*global.sunlight
b = 0
strength = global.sunlight
}

Edited by thatonenerd22, 02 June 2012 - 04:00 PM.

  • 0

#15 tizzio

tizzio

    GMC Member

  • GMC Member
  • 61 posts
  • Version:GM:Studio

Posted 02 June 2012 - 06:47 PM

Come on, do not demoralize!
I started this light engine 4-5 months ago, but I use game maker for the past 2 ½ years.
I am sure that you will be able to do better than me ;)

Edited by tizzio, 02 June 2012 - 06:48 PM.

  • 0

#16 Pancratius

Pancratius

    GMC Member

  • GMC:Member
  • 55 posts
  • Version:GM8

Posted 09 June 2012 - 11:05 AM

Hello.

I have been trying to use this extension now for a few days, and I think I'm getting the hang of it. However I am lagging really badly when using multiple lights in my own work. However when I used your example, there were no issues. I am hoping you can help me with this. Here is a link to my GMK file.

http://www.mediafire...da90hqrrg56mbdf

Could you please point me towards where my problem could be.

Kind Regards,
Pancratius

#17 tizzio

tizzio

    GMC Member

  • GMC Member
  • 61 posts
  • Version:GM:Studio

Posted 11 June 2012 - 02:47 PM

ok i try and tell you
  • 0

#18 tizzio

tizzio

    GMC Member

  • GMC Member
  • 61 posts
  • Version:GM:Studio

Posted 11 June 2012 - 02:51 PM

The problem is that you used 300000000000 mesh :huh:
1 mesh for each piece of wall
Use a single mesh for long pieces of wall, it will go much faster!
  • 0

#19 JeroenV

JeroenV

    GMC Member

  • New Member
  • 15 posts

Posted 12 June 2012 - 06:44 PM

I have a problem that's mainly my faul, I just need to find how to fix it. I have a random generation code for my game wich is quite extensive, I recently wanted to try and add your lighting engine to improve the looks of the game. I'm just using all the standard codes from the example but because of my generation code (I believe) it does not work properly.

I created a "Light" room, with the obj_engine and then let it move on to the next room. Yet if I use room_next it will just skip the next room and if I use room_goto("Roomname") it's just a black screen.

And I believe it might be because of this code.

var o;
global.loaddone=0
o=random(100)
{

for(i=0;i<100;i+=1){
a=random(room_width)
b=random(room_height)
position_destroy(a,b) 
instance_create(a,b,obj_tree)
}



for(i=0;i<100;i+=1){
a=random(room_width)
b=random(room_height)
position_destroy(a,b) 
instance_create(a,b,obj_tree1)
}



for(i=0;i<100;i+=1){
a=random(room_width)
b=random(room_height)
position_destroy(a,b) 
instance_create(a,b,obj_tree2)
}


for(i=0;i<1;i+=1){
a=random(room_width)
b=random(room_height)
position_destroy(a,b) 
instance_create(a,b,obj_seasource)
}

for(i=0;i<5;i+=1){
a=random(room_width)
b=random(room_height)
position_destroy(a,b) 
instance_create(a,b,obj_forestsource)
}

for(i=0;i<30;i+=1){
a=random(room_width)
b=random(room_height)
instance_create(a,b,obj_stone)
}



if(o=1)
{
a=random(room_width)
b=random(room_height)
position_destroy(a,b) 
instance_create(a,b,obj_oceansource)
}

for(i=0;i<10;i+=1){
a=random(room_width)
b=random(room_height)
position_destroy(a,b) 
instance_create(a,b,obj_water)
}


}
timeline_running=true

Now, as you can see this code deletes everything beneath it to make sure there isn't more than 1 instance on the same spot. The obj_light is created after the world has generated using a 'loading' timeline. So why is my screen black, entirely?

It's quite a big project I'm working on I would love if this could work with my current setup.

Thanks.
  • 0

#20 tizzio

tizzio

    GMC Member

  • GMC Member
  • 61 posts
  • Version:GM:Studio

Posted 12 June 2012 - 07:24 PM

Hi, JeroenV!
Check that you have initialized the object "engine" light in the room and set this as "Persistent".
If you make a .gmk without your code, it works?

If you want, send me a Private message with an example.
I'll try to help you!




NEW VERSION 1.1
-fix for tl_light_delete

DOWNLOAD AT THE SAME LINK

Edited by tizzio, 05 October 2012 - 09:25 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users