Windows Surfaces and 3D not working.

Hello!

I am making a game using a lighting system called Aura 2.0 which is surface based.

My game is also 3d with a topdown perspective. However, when enabling the 3D stuff, the surface mismatches the world (The light starts to move with the camera).

This is the command that triggers the issues
projMat = matrix_build_projection_perspective_fov(60 , (global.default_camera_w)/global.default_camera_h, 32, 32000 );
camera_set_proj_mat( view_camera[0], projMat );
camera_set_update_script( view_camera[0], camera_update_script );

If i disable this part, it works just fine.

Can someone give me a lead? What is the issue here exactly?
 

Yal

🐧 *penguin noises*
GMC Elder
You need to add the coordinates of how much the view has scrolled as well, right now you're building the matrix centered around 0, 0, 0.
 

Yal

🐧 *penguin noises*
GMC Elder
Build a matrix with the position changes, then you can use matrix multiplication to combine them into one.
 
Hey thanks for your response! However, doing that makes the surface with the lights move in the opposite direction of the Camera. Everyone with similar problems I have seen online seem to have fixed it with that command so I'm sure I am doing something wrong :(
 
I'm assuming a couple of things. Is your light surface supposed to show the same part of the world as is drawn on screen? Also, how are you using your light surface after you draw to it?
 
Yes, the light is supposed to show the same part of the world as is drawn on the screen. What do you mean specifically with in what way am I using it?

The specific draw command is draw_surface_ext(aura_light_surface, x - aura_light_radius - _vx, y - aura_light_radius - _vy, 1, 1, 0, aura_light_colour, aura_light_alpha);
 
You'll need to break down for us what is the intended function of that line of code. Don't make me buy the light engine just so I can figure it out.

What is, x,y, aura_lighyt_radius and _vx,_vy?

By the way, when drawing your surface, if the surface covers the same area as your view, you do not want to draw the surface with the same camera settings you use to draw your world. Instead you should use an orthographic projection and a view with the upper-left corner at 0,0, and a width and height equal (presumably) to the size of your application surface.
 
Last edited:

Joe Ellis

Member
You'll need to break down for us what is the intended function of that line of code. Don't make me buy the light engine just so I can figure it out.

What is, x,y, aura_lighyt_radius and _vx,_vy?

By the way, when drawing your surface, if the surface covers the same area as your view, you do not want to draw the surface with the same camera settings you use to draw your world. Instead you should use an orthographic projection and a view with the upper-left corner at 0,0, and a width and height equal (presumably) to the size of your application surface.
Yeah, when drawing to that surface (surface_set_target) you will use a 3d view, but when overlaying it onto the app surface, which you do with surface_draw(surface, x, y) that is in screen coords, so you like old fsi said, you need to set a new view, orthographic (2d) and simply print it onto the screen over the top
 
Hey thanks for your response.
X and Y are the position of the light in the room itself. aura_light_radius is well, the radius and it is just a number.

The other two are :
var _vx = camera_get_view_x(view_camera[argument0]);
var _vy = camera_get_view_y(view_camera[argument0]);

About the second thing, how do I do that?
 
Okay I'll try my best to explain. I don't know exactly how it works myself, to be honest since it was very plug and play before this.

There is a main controller object thas two scripts in the draw event: One is a an "update" script which first of all makes sure the surface still exists and then creates _vw (which is camera_get_view_width(view_camera[aura_view])) and _vh (camera_get_view_height(view_camera[aura_view])) . It then also calls the draw events of the lights themselves (i'll get to that later)

The other one is a "draw" script (that's what its called) and it creates the _vx and _vy variables from before, as well as recreating the _vh and _vw, draws the surface and does some shaders things which are only used for softening the shadows and are not useful in our case ( I even turned it off.)

Then there are the light scripts. These are called for every light. When created they create a layer with instance_create_layer, and the arguments are stuff like the position, radius, ecc.

Then, it creates a new surface (I was wrong before apparently) called aura_light_surface, and it sets it as a target, draws to it and resets it.

Every step it updates, it makes sure the surfaces still exist (recreating it if it doesn't) and then draws the sprite on it, doing a lot of stuff with vertex to calculate the shadow and I'm not sure I am even allowed to share it in too much detail. After that, it resets surfaces again

The last thing is the draw script itself. It calculates _vx and _vy variables again, and draws on the surface again. the comment says "Draw the individual light surface, using the colour and alpha settings"

I hope this is enough. And thanks for your time.
 
Top