Using Textures - 3D Games in GameMaker

Поделиться
HTML-код
  • Опубликовано: 8 янв 2025

Комментарии • 65

  • @DragoniteSpam
    @DragoniteSpam  4 года назад +4

    The next video, possibly two, are going to be about moving around in 3D - not too hard, but people have been asking, and I don't want to just say "look it up somewhere else." After that I'm probably going to go straight into shaders, because that's where all of the fun happens, but if there's anything you want to see before that let me know.

    • @Karurosagu
      @Karurosagu 4 года назад

      will you cover 3d collisions (REAL 3d collisions) and jumping?????

    • @DragoniteSpam
      @DragoniteSpam  4 года назад +2

      @@Karurosagu I've got them written down on the to-do list, not entirely 100% sure when but they'll be soon-ish.

  • @xchronox0
    @xchronox0 3 года назад +2

    Texture UVs are also helpful for having "texture quality" settings in games. They're often scaled down at lower settings, but since UVs are 0.0 to 1.0, it'll still map correctly.

  • @Shnurbinator
    @Shnurbinator 4 года назад +10

    Since all of the Game Maker Studio 1 tutorials are essentially obsolete, this series have become my bread and butter. Thank you for laying everything out in a really comprehensible way! I was wondering what your technique for doing a skybox/background for 3D games is, since I've looked around everywhere and haven't found anything.

    • @DragoniteSpam
      @DragoniteSpam  4 года назад

      Glad you found it useful! The simplest form of a skybox is just an unlit, inside-out cube with a different background of some sort on each plane, but there are other things you could do for it. Talking about different skybox strategies is something I could do later on down the line, certainly.

  • @Nurg0
    @Nurg0 4 года назад +2

    I just thought I'd mention; if you are drawing an object and the texture is messed up. Edit the sprite and flip it.
    Also thank you for making these tutorials.

    • @Kazak29
      @Kazak29 2 года назад

      I have no idea why, but your advice helped with my messed up textures! Its a texture page update bug or something I assume, changing the sprite in the editor updates it properly.

  • @zedernt5338
    @zedernt5338 Год назад +5

    The code stopped rendering the triangles when I applied the grass texture to them, but thankfully I fixed this by going to the texture settings for the sprite spr_grass and checking "separate texture page." In case anybody else runs into this problem.

    • @maj02jr
      @maj02jr 10 месяцев назад

      my man!! you just saved me. thank you for this comment lol

    • @superstinkybeans
      @superstinkybeans 10 месяцев назад +1

      wow thanks that fixed my problem... it was using every sprite as the texture

    • @Gamesaucer
      @Gamesaucer 6 месяцев назад +3

      Sorry to say, but this solution is awful, for a bunch of reasons. This is not your fault, though. It's because this video is oddly vague about how UVs work in Game Maker.
      - Every texture page is a power of two in size. That means if you try to render anything that's not exactly a power of two large, you'll end up with a bunch of empty space on the edges of those textures.
      - Even if a sprite has its own texture page, each of its subimages do not. So if a sprite has more than one subimage, everything suddenly breaks.
      - Even if all your sprites consist of a single image and are a perfect power of 2, this is just _begging_ for performance problems to hit you very hard as your game grows. I'll cut to the chase: there are exactly two solutions to this. One of them is incredibly tedious, and the other is texture pages. In other words, your solution amounts to manually undoing a vital optimisation Game Maker mostly _does for you._ Is this likely to matter when you're just a beginner? No, probably not... but you're learning bad habits.
      The root issue here is that you're mixing up local UVs and global UVs. The code in this video is using local UVs where global UVs are required.
      Luckily, this is a very easy fix, because Game Maker has a function that lets you get the global UVs relative to the texture you're actually trying to draw. You just do `uvs = texture_get_uvs(texture)` to get the uvs. For the U argument, replace all the zeroes with `uvs[0]`, and all the ones with `uvs[2]`. For the V argument, it's `uvs[1]` and `uvs[3]` respectively. If you ever want to use a local UV that's not 0 or 1 you can use the `lerp` function like so: `global_u = lerp(uvs[0], uvs[2], local_u)`.

  • @Sandman13sq
    @Sandman13sq 4 года назад +1

    11:23 There's a way to keep the sprite if needed. If you create a tile set resource from a sprite there's a checkbox on it's properties named "Disable Source Sprite Export". Leaving this on will ensure that the original sprite will not exist when the game is built. Turning it off will let you access both the sprite and tile set. v2.3 keeps this feature.
    I assume this is done for memory purposes.

    • @DragoniteSpam
      @DragoniteSpam  4 года назад +1

      Funny you bring that up, someone told me about that... yesterday.
      I don't know if it would be done for memory purposes since the tileset and the sprite would ideally point to the same texture and there would just be a few extra kb of sprite metadata (origin, collision shape, etc), I imagine it's more there to prevent people from trying to use the sprite and tileset interchangeably and messing things up.

  • @powergannon
    @powergannon 4 года назад +2

    When I use sprite_get_texture(), instead of using the sprite texture, it's using the project's texture atlas. This doesn't happen if I select 'separate texture page' on my texture, but if I do this, the texture doesn't fill the entire UV space, only about half of it. Do you know why this could be?

    • @DragoniteSpam
      @DragoniteSpam  4 года назад +1

      That's what separate texture pages are for. The graphics hardware requires them to be a power-of-two size though (64x64, 256x256, etc), so if your sprites aren't there's going to be empty space around the edges of them.
      You can also use sprite_get_uvs to get the exact texture coordinates of a sprite or tileset.

    • @powergannon
      @powergannon 4 года назад

      DragoniteSpam Ahh, I see. I’m coming from d3d so I didn’t realize power of 2 textures were needed now. Thanks.

    • @DragoniteSpam
      @DragoniteSpam  4 года назад

      It was that way in GMS1, older versions had a different way of dealing with textures though.

    • @powergannon
      @powergannon 4 года назад

      @@DragoniteSpam I ported my project from 1.4 and textures rendered to my trianglestrip model properly without breaking sprites into separate texture atlases or using power of 2 textures. I wonder whether it's the way textures changed or how vertex buffers work in GMS2 that causes the difference.

    • @DragoniteSpam
      @DragoniteSpam  2 года назад

      @@strifestrives5454 Did you put it on a separate texture page?

  • @matthe06w
    @matthe06w 8 месяцев назад

    What's the tutorial that comes directly after this? The playlist is not in order

  • @gydgeza
    @gydgeza Год назад +1

    Hello! I've just recently discovered this great series of tutorials and things have been going well for the most part, but I am encountering an issue with the textures when I have multiple sprites, as the surfaces will take every sprite and stretch them into parallel bands when displayed, instead of only displaying the texture set in vertex_submit. Is there some extra step I need to do to have it only use the one sprite I am telling it to use?

    • @gydgeza
      @gydgeza Год назад +1

      Actually, setting the sprites to individual texture pages solved it, just need to tick that box in the sprite object's texture settings field.

    • @DNVPIVIN
      @DNVPIVIN 10 месяцев назад

      @@gydgezathx

  • @schwammkopfspitspill
    @schwammkopfspitspill Год назад

    i need some help. when i coded this (version is above 2.3) instead of loading the sprite properly, it just loads each square separated and the texture is squished. and around the space made when the textures were squished, there were weird white scribbles. help?

    • @schwammkopfspitspill
      @schwammkopfspitspill Год назад

      create code was
      gpu_set_ztestenable(true);
      gpu_set_zwriteenable(true);
      vertex_format_begin();
      vertex_format_add_position_3d();
      vertex_format_add_normal();
      vertex_format_add_texcoord();
      vertex_format_add_color()
      vertex_format = vertex_format_end();
      vbuff = vertex_create_buffer();
      vertex_begin(vbuff, vertex_format);
      /*
      var x1 = 400;
      var y1 = 400;
      var x2 = 600;
      var y2 = 600;
      vertex_add_point(vbuff, x1, y1, 100, 0, 0, 1, 0, 0,c_white, 1);
      vertex_add_point(vbuff, x2, y1, 100, 0, 0, 1, 0, 0,c_white, 1);
      vertex_add_point(vbuff, x2, y2, 100, 0, 0, 1, 0, 0,c_white, 1);
      vertex_add_point(vbuff, x2, y2, 100, 0, 0, 1, 0, 0,c_lime, 1);
      vertex_add_point(vbuff, x1, y2, 100, 0, 0, 1, 0, 0,c_lime, 1);
      vertex_add_point(vbuff, x1, y1, 100, 0, 0, 1, 0, 0,c_lime, 1);
      */
      var s = 128;
      for (var i = 0; i < room_width; i += s){
      for (var j = 0; j < room_height; j += s){
      if ((i % (s * 2) == 0 && j % (s * 2) == 0) || (i % (s * 2) > 0 && j % (s * 2) > 0)){
      var color = c_white;
      } else {
      var color = c_dkgray;
      }

      vertex_add_point(vbuff, i, j, 100, 0, 0, 1, 0, 0, color, 1);
      vertex_add_point(vbuff, i + s, j, 100, 0, 0, 1, 1, 0, color, 1);
      vertex_add_point(vbuff, i + s, j + s, 100, 0, 0, 1, 1, 1, color, 1);
      vertex_add_point(vbuff, i + s, j + s, 100, 0, 0, 1, 1, 1, color, 1);
      vertex_add_point(vbuff, i, j + s, 100, 0, 0, 1, 0, 1, color, 1);
      vertex_add_point(vbuff, i, j, 100, 0, 0, 1, 0, 0, color, 1);
      }
      }
      vertex_end(vbuff);
      draw code was
      var cam = camera_get_active();
      camera_set_view_mat(cam, matrix_build_lookat(0, 0, 400, room_width, room_height, 0, 0, 0, -1));
      camera_set_proj_mat(cam, matrix_build_projection_perspective_fov(60, window_get_width() / window_get_height(), 1, 64000));
      camera_apply(cam);
      vertex_submit(vbuff, pr_trianglelist, sprite_get_texture(sp_Ground, 0));

  • @joelamaster7200
    @joelamaster7200 2 года назад

    For some reason gamemaker keeps drawing parts of other textures. Help?

  • @superzilla784
    @superzilla784 Год назад

    Your tutorial playlist is not in order. the playlist says that this is video 4, but there are videos that actually game before this and what is supposed to be video 3.

  • @They0ungTravler
    @They0ungTravler 3 года назад

    My texture is only drawing half way into the coordinates, and so I decided to see if maybe I put the wrong coordinates in or something, so I made the texture 32 by 32 instead of 64 by 64, and now the texture draws at the bottom right of the plane. Like. The top right of the texture is touching the bottom right of the plane.
    I’m going to rewatch the video and see if I messed up somehow, but if I can’t then I don’t know what to do. I’ll add an edit if I find anything

    • @DragoniteSpam
      @DragoniteSpam  3 года назад

      is it on a separate texture page?

    • @They0ungTravler
      @They0ungTravler 3 года назад

      @@DragoniteSpam no, that’s most likely the problem 😂

  • @KingDingusIII
    @KingDingusIII 2 года назад

    Not sure if you already covered this in another video but I'll ask anyways: If I were to draw multiple textures on a single plane for example, how would I be able to do that?

    • @DragoniteSpam
      @DragoniteSpam  2 года назад

      You can't, although there is this:
      ruclips.net/video/sU2C3XfLfyo/видео.html

  • @borektuleja1121
    @borektuleja1121 4 года назад +1

    Have you written your own GUI scripts for the editor or is it a 3rd party library?

  • @inbo7057
    @inbo7057 2 года назад

    I have a 3d object that has a partially transparent texture, and when you look through the transparent parts of the texture, the world shows through the tiles on the ground, any way to fix this?

    • @DragoniteSpam
      @DragoniteSpam  2 года назад

      transparency in 3D is cursed, although to (mostly) get around the problem you can make sure to draw the transparent objects last

    • @inbo7057
      @inbo7057 2 года назад

      @@DragoniteSpam Fixed it, thank you

  • @OcramRatte
    @OcramRatte 2 года назад

    For some reason my RAM usage when running the game goes to 100% until it crashes after some minutes, did I miss something?

    • @OcramRatte
      @OcramRatte 2 года назад

      LOL My PC almost died

    • @DragoniteSpam
      @DragoniteSpam  2 года назад

      You're probably trying to load a texture or model every frame or something

    • @OcramRatte
      @OcramRatte 2 года назад

      @@DragoniteSpam Looks like it had something to do with a font I added from datafiles, not sure what though, now that I deleted it works, thanks for replying!

  • @ianhahn4031
    @ianhahn4031 4 года назад

    How would I go about adding textures to a object with multiple sides? I am using the vertex_add_point function to make a cube, and when I tried to add a texture into vertex_submit, my cube was just black. Any idea what might be going wrong? (I'm new to making 3d games)

    • @DragoniteSpam
      @DragoniteSpam  4 года назад

      You need to texture map the texture coordinates to the correct locations. Doing them by hand is a pain, I recommend using some kind of model creator for making them.

    • @ianhahn4031
      @ianhahn4031 4 года назад

      @@DragoniteSpam Okay Thank you!

  • @plazer2044
    @plazer2044 3 года назад

    What code do you use for setting a tile layer as 3D ground?

    • @DragoniteSpam
      @DragoniteSpam  3 года назад

      This code doesn't. It's possible, but it's kind of a pain thanks to the way GameMaker stores tilesets.

  • @ZerobreakerEduEnt
    @ZerobreakerEduEnt 3 года назад

    it didn't work for me, everything is black, as a test i out another object on the map to see if it loads and it does but not like yours

    • @DragoniteSpam
      @DragoniteSpam  3 года назад

      Try unchecking the Clear Display Buffer option in the room settings; if there's a background layer make sure it's below the camera, or delete/disable it entirely; it's usually preferable to clear the screen in the camera's draw event than to rely on GameMaker instance order anyway

    • @ZerobreakerEduEnt
      @ZerobreakerEduEnt 3 года назад

      @@DragoniteSpam lol i shouldn't code at 1am, what i wrote made no sense. thx for the reply :D and i'll give it a try i was actually up till 7am trying to work it out -.-!
      it still doesnt work now it's worse lol

    • @ZerobreakerEduEnt
      @ZerobreakerEduEnt 3 года назад

      i think i'll restart from zero lol, 5th times a charm

  • @spiritlamp6324
    @spiritlamp6324 4 года назад

    Epic tutorials! But I've ran into this problem that when I use a sprite for my texture (with the function to look for it's texture) It didnt work and it just gave me a red triangle (because i had red in my sprite for it i think) i need help on that

    • @DragoniteSpam
      @DragoniteSpam  4 года назад +1

      What are the texture coordinates you're using, and is your sprite on a separate texture page?

    • @spiritlamp6324
      @spiritlamp6324 4 года назад

      @@DragoniteSpam At first my texcords were 0, 0, but then i tried x,y
      and also my sprites on a seperate texture page. And its 64x64

    • @DragoniteSpam
      @DragoniteSpam  4 года назад

      @@spiritlamp6324 Texture coordinates go from 0 to 1.

    • @spiritlamp6324
      @spiritlamp6324 4 года назад

      @@DragoniteSpam wow thanks! i just found it in the tutorial and now i just noticed how unnoticeable i am.
      but still, thanks

  • @ar4ijs97
    @ar4ijs97 3 года назад +1

    there is no function called vertex_add_point in my gms2 copy...

    • @techiemay
      @techiemay 3 года назад +2

      He programs it in a previous tutorial

  • @hati3813
    @hati3813 Год назад

    📝🐀

  • @hati3813
    @hati3813 Год назад

    🐀❗ Problem with the tutorial:
    1. You don't link to the model creator.
    2. You don't make any suggestions on what to do if we don't have it.
    3. Textures. Where? How? Who? Could you at least link the texture files/objects you're using so I don't have to switch from learning to scavenging?
    You just pull it out of your dragonite hat along with a fully prepared house and expect us to follow along. Well I don't have a house mr. dragon, I don't have the model creator for gamemaker studio, and I do not have the 3d-related knowledge to know how to pull a 3d model out of my ratty behind to follow along which might be the reason why I am watching a hundred bloody videos on the theme of "Introduction to 3d in gamemaker" 🐀💢💢

  • @ryryt8634
    @ryryt8634 Год назад

    Gives me error: ERROR in
    action number 1
    of Create Event
    for object :
    vertex_position_3d argument 1 incorrect type (undefined) expecting a Number (YYGI32)
    at gml_GlobalScript_vertex_add_point (line 26) - vertex_position_3d(vbuffer, xx, yy, zz);
    ############################################################################################
    gml_GlobalScript_vertex_add_point (line 26)

    • @reddicing
      @reddicing Год назад

      Use this in the script:
      /// @param vbuffer
      /// @param xx
      /// @param yy
      /// @param zz
      /// @param nx
      /// @param ny
      /// @param nz
      /// @param utex
      /// @param vtex
      /// @param color
      /// @param alpha
      function vertex_add_point(argument0, argument1, argument2, argument3, argument4, argument5, argument6, argument7, argument8, argument9, argument10) {
      var vbuffer = argument0;
      var xx = argument1;
      var yy = argument2;
      var zz = argument3;
      var nx = argument4;
      var ny = argument5;
      var nz = argument6;
      var utex = argument7;
      var vtex = argument8;
      var color = argument9;
      var alpha = argument10;
      // Collapse four function calls into a single one
      vertex_position_3d(vbuffer, xx, yy, zz);
      vertex_normal(vbuffer, nx, ny, nz);
      vertex_texcoord(vbuffer, utex, vtex);
      vertex_color(vbuffer, color, alpha);
      }

    • @GabrielSlusser
      @GabrielSlusser Год назад +1

      YOU SAVED MY LIFE DAWG@@reddicing