GMS 2 Static Background in a 3D Game

C

ChampionTom1993

Guest
So basically I have a 3d racing game where the player drives through a 3d environment. Everything seems to work so far! What I'm stuck on now is how to create backgrounds that don't move when the camera changed direction and doesn't grow or shrink. This might be similar to how the original Super Mario Kart for SNES worked.

I'd love to know where to even start with this. Graphics have never been my forte and I'd like to get better at it if I can. Thanks in advance!!
 

zbox

Member
GMC Elder
Before your 3d-draw starts in the event, change the projection to orthographic, draw the BG and then continue maybe?
 

flerpyderp

Member
I'm interested in learning how this is achieved also. Specifically, what the method is to make the background wrap around room. The only method I can think of would be to draw a huge cylinder around the room with the background textured on the inside, but I want to know what other options exist.

EDIT: In Super Mario Kart's case, it appears to be sprites which always face the camera rather than one background.
 
Last edited:

zbox

Member
GMC Elder
I'm interested in learning how this is achieved also. Specifically, what the method is to make the background wrap around room. The only method I can think of would be to draw a huge cylinder around the room with the background textured on the inside, but I want to know what other options exist.

EDIT: In Super Mario Kart's case, it appears to be sprites which always face the camera rather than one background.
No need to be in the 3d space for this and it would infact be a waste of resources to do it that way - especially when you can just straight draw it to the screen using ortho projection as I mentioned
 

flerpyderp

Member
Can you elaborate on how it would be drawn? In my experience of drawing the background using ortho projection I had to draw 4 backgrounds like walls around the room, which was fine for an indoor environment where you have limited view of the outside/background through windows. Making it wrap around the room is what I don't understand how to do.
 

zbox

Member
GMC Elder
You literally just coat the back buffer with the background, and then draw the 3d stuff to it - the background does not need to be aware of the 3d context? (Which is what I'm pretty sure OP wanted?)

Draw event:

//set ortho
draw_sprite(bg)

//set 3d proj
//draw 3d stuff
 

flerpyderp

Member
So that would just be drawing a single wall of background sprite, which would either remain stationary on one side of the room, or would be set to rotate around with the player's view. They already specified that it shouldn't move when the camera changes direction, so the latter option doesn't suffice. And if the camera changes direction, then only having the background on one side of the room also won't suffice.

They mentioned Super Mario Kart, where the player can rotate 360 degrees and the background appears seamless. As I mentioned, that game appears to use multiple billboard sprites of hills etc. to give this effect, which is an option for OP.
 
Last edited:
So that would just be drawing a single wall of background sprite, which would either remain stationary on one side of the room, or would be set to rotate around with the player's view. They already specified that it shouldn't move when the camera changes direction, so the latter option doesn't suffice. And if the camera changes direction, then only having the background on one side of the room also won't suffice.

They mentioned Super Mario World, where the player can rotate 360 degrees and the background appears seamless. As I mentioned, that game appears to use multiple billboard sprites of hills etc. to give this effect, which is an option for OP.
What are you talking about? zbox's suggestion is basically a reverse Draw GUI situation. All "movement" lies in you manually shifting the background, which then becomes as easy as just scrolling the texture.
 
Yeah, that is essentially what it does (although it doesn't "move" with the camera as it's a separate entity), which seems to be what the OP is looking for. If you want something like Super Mario Kart, you'd then have to manually scroll the background the same as you would if working in 2D space (since that's where the image basically exists).
 

flerpyderp

Member
you'd then have to manually scroll the background the same as you would if working in 2D space (since that's where the image basically exists).
So, having a really wide background texture that scrolls when the player turns, and then loops back to the start after a 360 turn so that it appears seamless. I think this is what OP is asking for. This is almost certainly what Super Mario Kart is doing, I was wrong about it using individual billboard sprites for the hills etc.
 
Last edited:
It doesn't need to be wider than the screen; the image itself could even be smaller depending on how much tiling you want in view. You just scroll the UVs to get the turning effect.
 
G

Guest User

Guest
@zbox can you achieve something like "Resident Evil 3", background behind 3D models?

 
G

Guest User

Guest
If I remember right, those games just had a static background for each camera angle, there wasn't even any scrolling or anything involved.
I know. I don't remember exactly when I tried to achieve this but I remember I struggled when I wanted a background behind models. I ended up drawing a wall with a pretty high depth.
 

flerpyderp

Member
What problems did you face? I think in this situation, just drawing a wall wouldn't cause issues. Though it would be better to set ortho projection and draw the background that way, then set it to 3D for the models.
 
I know. I don't remember exactly when I tried to achieve this but I remember I struggled when I wanted a background behind models. I ended up drawing a wall with a pretty high depth.
You don't need to adjust the depth so much. You can temporarily disable hidden for the background, then nothing drawn after will clip through it.
 
G

Guest User

Guest
What problems did you face? I think in this situation, just drawing a wall wouldn't cause issues. Though it would be better to set ortho projection and draw the background that way, then set it to 3D for the models.
You don't need to adjust the depth so much. You can temporarily disable hidden for the background, then nothing drawn after will clip through it.
I was a beginner back in 2013, didn't even know what "hidden" means. I did the ortho thingie but it ended up drawing the background on top of the models.
 
C

ChampionTom1993

Guest
Wow! I had no idea how much chatter goes on when I'm not looking lol.

All of this is well and good, but I'm working with Game Maker Studio 2, which mean d3d functions don't exist anymore. In order to achieve 3d effects, I had to watch multiple tutorials just to get that to work. The code I'm using is verbatim from the video link below.



10:21


Anyway, while I appreciate all the tips and tricks, none of them will work because I'm working with an entirely different set of tools than you guys are.
 

zbox

Member
GMC Elder
Just import the project, it'll patch it up to work with 2 and you can work backwards from there and optimise it
 
Top