A downloadable asset pack for Windows

Buy Now$2.00 USD or more

Take a look at how to add 3D point lights to your GMS2 projects, using a shader instead of the built-in hardware lights.

GameMaker's built-in hardware lighting relies on vertex shading to calculate how bright a polygon should be, which can result in very poor quality lighting effects on low-poly models. However, when utilizing a fragment shader, your GPU can calculate the brightness of each individual pixel on screen and nicely smooth out lighting, resulting in a much more realistic effect.

This project is fairly tiny, so there's not a ton of code to actually comment on, but I think I've gone through and added enough comments to help things make sense.

Hopefully it's helpful to some devs looking to spice up their 3D projects in GMS2.

There is also a free demo version available for download to check it out before purchasing.

NOTE: You must have Game Maker Studio: 2.0 installed on your computer to open these project files. They will NOT open with Game Maker 1.4

StatusReleased
CategoryAssets
Rating
Rated 4.7 out of 5 stars
(3 total ratings)
AuthorDaniel Davis
Made withGameMaker
Tags3D, fragment, GameMaker, gms2, lighting, point, Shaders, sourcecode

Purchase

Buy Now$2.00 USD or more

In order to download this asset pack you must purchase it at or above the minimum price of $2 USD. You will get access to the following files:

DDG Point Lights.zip 65 kB

Download demo

Download
Free Demo 1 MB

Comments

Log in with itch.io to leave a comment.

(2 edits)

It seems to be very well written and commented. Unfortunately, it lacks one critical thing: Matrix translation (position and rotation) support.

In explaining, anything that moves and/or rotates within the world will not be lit properly, meaning it's almost useless for a game because you will undoubtedly have moving entities that need to get lit, such as enemies, spinning item pickups, moving platforms, etc. That said, perhaps I'm doing my matrix translations wrong somehow?

To demonstrate the problem, I modified the floor in the original code to shift back and forth, like so:

-- CODE START --
//send the frozen models over to be drawn
var _mat_translate = matrix_build(sin(current_time/500)*50, sin(current_time/500)*50, 0, 0, 0, 0, 1, 1, 1);
matrix_set(matrix_world, _mat_translate);
vertex_submit(global.model_floor,pr_trianglelist,sprite_get_texture(tex_floor,0))
matrix_set(matrix_world, matrix_build_identity());
vertex_submit(global.model_walls,pr_trianglelist,sprite_get_texture(tex_wall,0))
shader_reset()
-- CODE END --
(Note: I'm assuming it's okay to post that snippet of code, since it really doesn't show anything related to the workings of the asset.)

When you run the project with the above code, the lights will shift along with the floor, rather than the desired result of them staying in place.
I assume the shader needs to get the translation information passed in somehow, but I'm having trouble figuring out exactly how to do that.


Again, a great asset and easily worth the price, but severely limited in its usability, due to this issue. As it stands, I cannot use it for what I purchased it for, unfortunately.

A very good point and I agree that it’s pretty limited in that sense. I suppose in my mind I was I had only focused on lighting the static level and didn’t even consider moving entities, so that’s a massive oversight on my part 

I appreciate the response. Even though it wasn't useful in how I had hoped, it still helped me get a better understanding of shaders, so I'm a happy customer. Thank you.
:)