3D 3D Background...

T

Thexel PIN

Guest
Hi, I'm making a Shoot'em up game that needs 3D backgrounds in constant movement (That loop every now and then). I have tried everything, but I can't make it work... So, starting from zero, any advice?
 

Xer0botXer0

Senpai
Never played that game, why not get the background animated in 2d sprite art ?


What have you tried so far, and what were the results ?
I'm pretty sure it would be something like this .

create an object: obj_background_0
set the depth to the highest(is it highest) so it's in the far back of the game view.
in the create event you'd use d3d_start(); //import 3d models ? d3d_end();

Buut there is the animating thing, Im not sure how to animate 3d models or anything like that. Maybe start there and wait to see if someone can help you further.
 
T

Thexel PIN

Guest
I already tried using 2D sprites. Looks nice, but those were never the ones that I was expecting for the final product. I tried already with an engine someone on the internet made for me, but it only worked for the example he sent me. When I tried putting it in my game, most of the sprites disappeared. I'm not searching for animations, but for movement, as if you were walking through a hallway and you see the windows pass by or other things (Obviously not only that, but making the engine customizable so I can replace it with houses, add floor, instead of going to the front go up and stuff).
 
T

Thexel PIN

Guest
Here I'll put some examples (Pay attention to the background of the game and how it moves):
 

Niels

Member
That second video example looks really out of place:) I assume the ship has some sort of forward motion and the camera moves to the bottom left!
You could probably do it with a flat background and a shader that fakes a perspective by bending the surface
 
T

Thexel PIN

Guest
Well, first of all... What ship? Second, doing that limits the amount of things I can do with the engine... I wouldn't be able to do some things such as the background in the second example... I need 3D.
 

lolslayer

Member
Some questions first

How far did you get? Did you get 3D backgrounds to work? Do you only need help with the looping? if not, with what do you need help too?
 
T

Thexel PIN

Guest
As I said, the engine was ready for me to use. I got the 3D background to work and they looped perfectly. The only problem was that some sprites weren't displaying appropiately.
 

okasion

Member
Sorry to bump this topic, but I have the same problem, I need to add a simple background layer that just "travels" through some 3D objects, like in the videos @Thexel PIN posted; you guys never played a Touhou game?
Anyway, thanks in advance for any help.
 

Binsk

Member
It's just a background; set up a 3D camera, render the 3D scene, change the camera back to 2D and render the rest of your game as normal.

You can do so by setting the appropriate matrices before rendering.
 

okasion

Member
It's just a background; set up a 3D camera, render the 3D scene, change the camera back to 2D and render the rest of your game as normal.

You can do so by setting the appropriate matrices before rendering.
Could you please explain me how to do this? I have bought GMS2 Desktop only a month ago, I'm working non stop on a game, but I watched some videos on YouTube that said to don't use the camera, I couldn't find any tutorial that would explain how to make a 3D terrain, nothing fancy...
IDK what to do
 

Binsk

Member
If you are completely new to this then I will 100% say don't do it and use a 2D scrolling background or something (even if you have to layer it). 3D is difficult in its own right and GameMaker makes it significantly more so. If you don't know what you're doing from the get-go then you are going to have significant trouble.

I'm not going to step you through this but I will throw some concepts your way that, should you take the time to research them, you should be able to figure them out.

Concept 1:
Positions get converted from one place to another by multiplying them by matrices. This happens on the GPU, but the matrices can be set on the CPU with matrix_set functions. There are three main matrices you should worry about: 1) The world matrix, it converts the location of your sprite / 3D model from its local space (e.g., top-left of sprite is 0,0) into the world space (wherever you placed the sprite in the world). 2) The view matrix, it tells the game where the camera is in the world (even if you don't specify to use a camera, GameMaker uses a default one in the background. This matrix is always required), 3) the projection matrix, it is used for to define things like field-of-view, and clipping distances (a bit different w/ 2D since it is orthogonal, but 3D requires a proper perspective projection matrix) and effectively "projects" the final result of pixels onto a plane which is your screen.

When you render something, 2D or 3D, every pixel is effectively transformed around these matrices. When you use GameMaker's build-in 2D systems it makes these matrices for you in the background and you don't have to think about it. When you do 3D things you have to set these yourself. GameMaker, thankfully, does provide functions to build these matrices for you. You can find them in the manual.

When rendering your 3D background you would essentially store all the old matrices being used by GameMaker in variables, setup your new 3D ones, draw your 3D stuff, then set the matrices back to how they were.

Concept 2:
Vertex buffers and shaders. Your game runs on your CPU, that is, your computer's multi-purpose processor. A shader is a small piece of software that runs on your GPU, your very specific-purpose graphics processor. GameMaker shaders have two parts, the vertex shader and the fragment shader. The vertex shader takes every point of your model (and in 2D, 6 points to make two triangles forming a rectangle that holds your sprite) and multiplies its position by the matrices listed above. It gets this result and passes it to the fragment shader where every pixel inside of these points then gets their color calculated.

In 2D, GameMaker handles building the underlying shapes that it can use to paint your sprites on top of which it then passes to the GPU (and thus the default shader) when you call draw_sprite(). As you might suspect, in 3D you have to build these buffers (aka., your model shapes) yourself, tell each vertex how to attach it to your image, which direction the vertex is facing (if you want to use lighting, this is called a 'normal'), and finally pass it to the GPU with your desired image (aka., texture) with vertex_submit().

Doing all this requires a vertex format, defining the model shape via a vertex buffer, then submitting it to the GPU for rendering. You can find more details about all these in the manual.

Concept 3:
Loading models from a file is completely unsupported by GameMaker. This means you literally have to sculpt your models with vertex math. Even a simple cube is a pain in the butt to make. Loading anything from a file requires that you write it yourself. This means, 1) you have to really understand vertex buffers because that is what you are building and 2) you have to understand how the file you are reading is formatted and how to parse the data. I have written an OBJ file reader long ago and, while totally doable, it does take time and knowledge of what you are doing.



Now, a fair amount of this can probably be done by using extensions that other people have made (external file loading especially). But as you may be realizing, this is not a simple task. To do ANYTHING even remotely practical in 3D with GameMaker, you need to grasp these three concepts and how to implement / use them very well. If you are already familiar with all this then it isn't too bad to implement, but if you are just starting I would say either choose a different option or make a separate project to learn the systems and play around before trying to add it to your game.
 
Last edited:
R

robproctor83

Guest
Basically, if your doing real 3D don't use Gamemaker unless you are well established with 3d math and concepts otherwise your doomed. You would probably be better off making the game in Unity if you wanted 3D and don't have any experience.

My suggestion though would be to forgo the 3D background and just use sprites. Personally, if I were you, I would probably render out a handful of layers and make a nice parallax effect. Also, you need to be careful of not using really large high resolution art. You might be inclined to make a nice 3d background rendered in high resolution and use that, but really large images means really large processing. So, I would probably take all my renders and scale them down to really small pixel graphics and then sort of tone my art style around that 3d pixelated concept. There are also some pixel shaders if you dont feel like doing all that.
 

Yal

šŸ§ *penguin noises*
GMC Elder
Simplest idea: draw 3D stuff in the Draw event, draw the 2D stuff in the Draw GUI event. The GUI layer is drawn on top of everything else, so it's perfect for a flat danmaku scene (if you don't need any interaction with the background)
 

okasion

Member
I'm gonna say this, I hope the mods don't delete my post has they did when I just mentioned Godot.
I was able to make what I wanted using calls to Direct3D; I have previously programmed in C++ and OpenGL, and setting up the scene was a little easier than it is right now on GMS2; I asked in the Discord chat for help, and the answer I got from the admin nonetheless was:

upload_2019-11-28_0-1-15.png

The person later gave me a link to this guide: https://forum.yoyogames.com/index.p...arted-with-3d-in-gms2-project-download.12145/
Which I found difficult to understand, and seemed it was made on a rush. After Googling a lot I found this guide: https://johnkeen.tech/gamemaker-3d-background-surface-basics/
A lot shorter, and more to the point. I was not able to initiate the Direct3D with the yoyo guide, but I had no problems at all with the guide of this programmer.

This is the end result:

Game Maker has excellent functions to develop faster 2D games, I love it; but it is sold as a 2D and 3D capable studio for game development; how come the developers have not made some functions no initialize the 3D render engine?
 

okasion

Member
Bump, I won't let this thread die. It will be worse if nobody answers or close this thread.

My question is, GMS 2 Desktop is advertised as a 2D and 3D gaming engine; however all the calls to make a 3D instance have to call directly to the Direct3D API and the GPU; we will have functions that makes this process easier in the future or you plan to leave it like that?

Maybe I'm doing something wrong, the image it's one of your examples; but I read that it isn't even possible to load an asset from Game Maker 2 Desktop. Please, help. Thanks in advance.


 
H

Homunculus

Guest
@okasion You should contact yoyogames directly if you have a question about possible future implementation.

If you want my opinion, itā€™s not going to happen anytime soon. Itā€™s not on the roadmap for 2020 or 2021, and not even in the planned features.

GMS is clearly focused on 2D, and honestly Iā€™ve never seen it advertised as a 3D tool except in the old days pre-studio. It has 3D capabilities, but itā€™s quite clear from everything you can see in tutorials and the website that itā€™s not the next unreal engine.

Whatā€™s wrong with that image though?
 

okasion

Member
@okasion You should contact yoyogames directly if you have a question about possible future implementation.

If you want my opinion, itā€™s not going to happen anytime soon. Itā€™s not on the roadmap for 2020 or 2021, and not even in the planned features.

GMS is clearly focused on 2D, and honestly Iā€™ve never seen it advertised as a 3D tool except in the old days pre-studio. It has 3D capabilities, but itā€™s quite clear from everything you can see in tutorials and the website that itā€™s not the next unreal engine.

Whatā€™s wrong with that image though?
It's an image hosted on yoyo games marketplace to show the 3D capabilities of Game Maker 2.
 

okasion

Member
It's an image from an asset made by a 3rd party. It is no reflection on Yoyogame's focus on the GMS product.
You know what I say is true, do I have to go to the Steam page of GMS 2 Desktop and copy paste the text and the pictures? you think I'm lying after so much work?
 
Screenshot(9).png

I understand being disappointed in GM's lacking 3D features, but there's really no need to complain for a reason that is easily proven false.
 
Top