• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

3D Can't get lights working in 3d

Datky

Member
Howdy,
I'm currently doing a first-person game in GameMaker 1.4, and want to add lights to make it look better. The thing is the 3d view is drawn on a corner of the screen with a surface, I use the remaining space to drawp sprites(with the DrawGUI event). If I try to set lighting, the whole screen becomes dark. If I set lighting to false, well the light isn't working anymore.

The code in the obj_light is something like that :

Code:
d3d_set_lighting(true);
d3d_light_define_point("light1", x, y, z, 200, c_white);
d3d_light_enable("light1", true);
If i put "d3d_set_lighting(false);" after that, there's no light in the room.

Has anyone here worked with 3d lighting ? Could you guys please help me ?

Thanks.
 
You should use numbers instead of strings for the light id's.

It sounds like your drawn objects don't have their normals set properly. What are you drawing, and how?
 

Datky

Member
In the obj_player, I set a surface, and draw the 3d view on that surface so it doesn't take the whole screen. After that, i draw_sprite_ext() to draw images in the draw GUI event(to draw them over the surface and view).
 

Datky

Member
When I set a light with an obj_light, it doesn't work because all that is drawn in the gui(the 3d view and sprites) isn't drawn anymore so I have to deactivate the light.
 

Datky

Member
I tried, ot didn't work. The floor isn't draw either(d3d_draw_floor), if I disable the light before drawing the floor, it's draw without the light. Same goes for every other object I assume.
 
You have to invert the arguments for one of the axes when using d3d_draw_floor() as the normals point downward. Also make sure it's not super large since the lighting is vertex-based. The larger the triangles, the less pretty the lighting.
 
Top