Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Ray Casting

    Beginners
    13
    70
    11538
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      faz808 F last edited by

      Managed to get the texture mapping running but it's less than 1 fps with the screen at gWidth/4 and gHeight/4. I think it's the maths (converting the textures to screen cords) where the problem is.
      At full screen it's like 20 seconds before it even starts. Pressing on and on ….

      1 Reply Last reply Reply Quote 1
      • mario.bodemann
        mario.bodemann F last edited by mario.bodemann

        That's very interesting. I was hoping the speed might be enough ... Do you mind resharing your code? I would love to take a look at it.

        (Once I'm at home that is)

        1 Reply Last reply Reply Quote 0
        • F
          faz808 F last edited by

          The code is a mess - sorry.
          NHT3DMND15 - still pending as I write this.

          1 Reply Last reply Reply Quote 1
          • F
            faz808 F last edited by

            World map need to be rewritten :-

            int worldMap[mapWidth][mapHeight]=
            {
            {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,7,7,7,7,7,7,7},
            {4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,7},
            {4,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7},
            {4,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7},
            {4,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,7},
            {4,0,4,0,0,0,0,5,5,5,5,5,5,5,5,5,7,7,0,7,7,7,7,7},
            {4,0,5,0,0,0,0,5,0,5,0,5,0,5,0,5,7,0,0,0,7,7,7,1},
            {4,0,6,0,0,0,0,5,0,0,0,0,0,0,0,5,7,0,0,0,0,0,0,8},
            {4,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,7,7,1},
            {4,0,8,0,0,0,0,5,0,0,0,0,0,0,0,5,7,0,0,0,0,0,0,8},
            {4,0,0,0,0,0,0,5,0,0,0,0,0,0,0,5,7,0,0,0,7,7,7,1},
            {4,0,0,0,0,0,0,5,5,5,5,0,5,5,5,5,7,7,7,7,7,7,7,1},
            {6,6,6,6,6,6,6,6,6,6,6,0,6,6,6,6,6,6,6,6,6,6,6,6},
            {8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4},
            {6,6,6,6,6,6,0,6,6,6,6,0,6,6,6,6,6,6,6,6,6,6,6,6},
            {4,4,4,4,4,4,0,4,4,4,6,0,6,2,2,2,2,2,2,2,3,3,3,3},
            {4,0,0,0,0,0,0,0,0,4,6,0,6,2,0,0,0,0,0,2,0,0,0,2},
            {4,0,0,0,0,0,0,0,0,0,0,0,6,2,0,0,5,0,0,2,0,0,0,2},
            {4,0,0,0,0,0,0,0,0,4,6,0,6,2,0,0,0,0,0,2,2,0,2,2},
            {4,0,6,0,6,0,0,0,0,4,6,0,0,0,0,0,5,0,0,0,0,0,0,2},
            {4,0,0,5,0,0,0,0,0,4,6,0,6,2,0,0,0,0,0,2,2,0,2,2},
            {4,0,6,0,6,0,0,0,0,4,6,0,6,2,0,0,5,0,0,2,0,0,0,2},
            {4,0,0,0,0,0,0,0,0,4,6,0,6,2,0,0,0,0,0,2,0,0,0,2},
            {4,4,4,4,4,4,4,4,4,4,1,1,1,2,2,2,2,2,2,3,3,3,3,3}
            };

            1 Reply Last reply Reply Quote 0
            • F
              faz808 F last edited by MikeDX

              With [ ] not { } of course !

              1 Reply Last reply Reply Quote 0
              • F
                faz808 F last edited by

                I've tided up the code a bit - removed rems etc. 3VR63MND15

                1 Reply Last reply Reply Quote 0
                • F
                  faz808 F last edited by

                  I think, on reflection, N9LKAMND15 is the preferred version. There's no way that true texture mapping without getPixel is feasible. I'm open to ideas but I think the maths is the bottleneck.

                  Gothon 1 Reply Last reply Reply Quote 0
                  • F
                    faz808 F last edited by

                    Changed the world map. It's a bit more interesting. Move and rotate speeds adjusted a touch.
                    Now called Ray Casting, XFF63MND15
                    30 - 33 fps with plain coloured blocks.

                    1 Reply Last reply Reply Quote 1
                    • F
                      faz808 F last edited by

                      I've updated Ray Casting to Raycasting2.
                      I think I can turn it into a game if I add a random exit and maybe monster sprites floating around the map. SY573MND15

                      1 Reply Last reply Reply Quote 1
                      • Gothon
                        Gothon F @faz808 last edited by Gothon

                        @faz808 said in Ray Casting:

                        There's no way that true texture mapping without getPixel is feasible. I'm open to ideas but I think the maths is the bottleneck.

                        The problem is that the tutorial processes each pixel 1 by 1 in software. It is true that Wolfenstein 3D ran on a 286 computer, but no 286 computer had a 1920x1080 or even a 1280x720 pixel screen. Using the builtin line() function with a screen width reduced by factor of 4 as you have done alleviates this. You can also use the builtin Box() function to draw a 4 pixel wide vertical line with a single command.

                        However to do this with texture mapping, you will need to use a builtin image drawing command instead of slowly looping over all the pixels on the line. You will also need to generate the textures in video (image) memory using the createImage(), setDrawTarget() functions.

                        I cannot think of a reason why you think a 'getPixel' function would speed this up. Moving data from the video card just to send it back should only slow it down.

                        I have tried this with a few functions. drawImage() works but doesn't handle the clipping well. It will error if you are too close to a wall with out clipping code and it doesn't have a tint parameter to darken a side with. I was going to try drawImageEx(), but it doesn't have a source rectangle parameter which is needed to select a 1 pixel wide strip from the texture. It could probably still be used if you had a huge array of 1 pixel wide texture images.

                        I tried drawQuad(). It is a tiny bit slower because of the array of 4 vectors it needs as a parameter, but the results are very good. No clipping code is needed and the 'Tint' parameter enables the darkening of one side.

                        I also went ahead and wrote code to generate the generated textures in the tutorial. The way the tutorial loops over the pixels of all 8 textures in one loop is a bit awkward and causes Fuze to produce an error unless an update() call is placed in the loop. The update() call I put into the loop only cause a fraction of a second of black screen at startup. I also added modes to do no textures, and simple (no black screen startup) textures.

                        My modified program is named "ray casting w textures" and is shared, submitted (and pending atm) with code: D1SR3MND9L

                        1 Reply Last reply Reply Quote 7
                        • xevdev
                          xevdev F last edited by

                          That is pretty awesome.
                          Awesome.

                          1 Reply Last reply Reply Quote 0
                          • F
                            faz808 F last edited by

                            More than awesome - brilliant. Absolutely brilliant. I knew there had to be an answer somewhere .
                            I just needed to look outside the box but I was stuck in a rut. Kept trying to modify the existing code. Just needed a complete rethink. Thanks a bundle.

                            xevdev 1 Reply Last reply Reply Quote 2
                            • xevdev
                              xevdev F @faz808 last edited by

                              @faz808 I can see the smile on your face it's the same as mine

                              1 Reply Last reply Reply Quote 0
                              • Dave
                                Dave Fuze Team last edited by

                                Unbelivably awesome. My jaw is on the floor...

                                1 Reply Last reply Reply Quote 0
                                • F
                                  faz808 F last edited by

                                  I thought I could finally put this to bed … (or my wife did !) - but then I found this ,,,

                                  http://www.wolfenvault.com/resources.html

                                  Sorry Gothon, but I'm not finished yet ...

                                  1 Reply Last reply Reply Quote 1
                                  • F
                                    faz808 F last edited by

                                    Did some graphics work. Phew !!!
                                    Wolfy ID: X66M3MND15

                                    pianofire 1 Reply Last reply Reply Quote 2
                                    • pianofire
                                      pianofire Fuze Team @faz808 last edited by

                                      @faz808 Oh that is so cool!

                                      1 Reply Last reply Reply Quote 0
                                      • xevdev
                                        xevdev F last edited by

                                        Looking slick.
                                        It runs pretty fast .
                                        I'm amazed.
                                        How far can you scale the textures ?

                                        1 Reply Last reply Reply Quote 0
                                        • xevdev
                                          xevdev F last edited by xevdev

                                          Dumb question when I can just try it myself.

                                          1 Reply Last reply Reply Quote 1
                                          • xevdev
                                            xevdev F last edited by

                                            Love this.
                                            Looked 2 steps into the code changed the images to a bit bigger about x 2
                                            Changed the 64,64 to 128,128
                                            And got this

                                            Retrocade_media 1 Reply Last reply Reply Quote 5
                                            • First post
                                              Last post