|
|
| Raycasting problems |
|
aybabtu
Member #2,891
November 2002
|
I've attached a .zip with a DOS binary, the source code, and my little texture set. Could you guys test it out and tell me what kind of FPS you get with the "Ray Skip" at 1, and at 5? Use the -/+ butons to change it. It makes it run a lot faster on 5, but you lose detail...I wanna see how fast it runs on ppl's computers. Goodbytes: I'm using 16bit color. Down with palettes! J13: That screenshot looks nifty...I kinda like it with the lines on top of the walls! Zaphos said: For your outdated as anything setup, however, I'm afraid there might be more errors, which is entirely your fault. Update your software.
Fine...I'll download allegro 4 or the newest WIP or something... [WHOOPS! The post's too big with it...just download the attachment] As you can see, I've eliminated another call to the cos() function, by using a table to fix the distortion! EDIT: 23: Words are backwards on my textures only on certain sides of a cube. 2 sides are right, 2 sides are backwards. I tested it with the all powerful NYAH. |
|
Thomas Fjellstrom
Member #476
June 2000
|
YaY!!! I was waiting for source and some textures edit: -- |
|
aybabtu
Member #2,891
November 2002
|
Are you going to FPS-test mine? |
|
Thomas Fjellstrom
Member #476
June 2000
|
heh, edited.. -- |
|
Goodbytes
Member #448
June 2000
|
aybabtu said: Goodbytes: I'm using 16bit color. Down with palettes!
Good. Then lighting is easy enough... sorta. I guess. Or something. Yeah. Anyways, if you want to shade based on depth, as if the player has a light on his/her head or whatever, you'll probably want to shade the ceiling and floor as well as the walls. So, you need to darken your floor/ceiling gradient a little as it reaches the horizon. Then, as for shading the walls, you can probably just subtract a little from the colour components of each pixel based on how far away it is. Allow me to rip some code from FBlend for a minute. Okay, here's a sort of example program for ya:
This is C++ code, so compile it as so. The two parts to note are the creation of the light table, and the actual subtractive blending parts, which are commented as important parts numbers one and two, respectively. Now, credit must go to Bob for actually writing the subtractive blending part in FBlend, which I modified a teensy bit. The rest of the program is my fault. Actually, I think it works well. Make a small bitmap called src.bmp, compile this, and put them in the same directory, and try it out yourself. Anyhow, now on to how it works. It's kind of hard to explain... basically, in the subtractive blending part, the color is grabbed from the source bitmap(you should use a faster method than _getpixel16 if possible, btw) and then the individual colour components are separated apart, so where originally the binary representation of the colour looks like this: This is basically the same thing as doing unsigned int r, g, b, c; c = _getpixel16(src, x, y); r = getr16(c); g = getg16(c); b = getb16(c); r -= distance; g -= distance; b -= distance; c = makecol16(r, g, b); _putpixel16(dst, x, y, c); But hopefully faster. Finally, remember that since you only have 32 distance values, try to spread them out a little - i.e. you would probably want a slice that's 32 'pixels' away to actually be quite bright. In fact, you can probably map distance in 'tile units' - i.e. with a slice that is 1 tile length away being a distance value of 1. Hope this helps. |
|
23yrold3yrold
Member #1,134
March 2001
|
Quote: EDIT: 23: Words are backwards on my textures only on certain sides of a cube. 2 sides are right, 2 sides are backwards. I tested it with the all powerful NYAH. That's what happened to me. My latest code up there corrects this. Quote: YaY!!! I was waiting for source and some textures Dude, that's all we've been posting Sweet mother, aybabtu, why does your code run at 0 FPS?!? BTW, if you aren't texturing the floor or roof, gradient shading becomes very easy -- |
|
Thomas Fjellstrom
Member #476
June 2000
|
Quote: Dude, that's all we've been posting
Sory, didnt notice any textures. -- |
|
Trezker
Member #1,739
December 2001
|
I've done some bugfixes and other stuff. |
|
23yrold3yrold
Member #1,134
March 2001
|
I used my own texture. Just throw a 64x64 truecolor texture in with the executable and you're good to go. Try it with mine; how's it work for you? -- |
|
Thomas Fjellstrom
Member #476
June 2000
|
Textures? I don't have no stinkin textures. Really. (um.. you want me to try yours now? demands... sheesh -- |
|
23yrold3yrold
Member #1,134
March 2001
|
I don't have any texture either; I just drew some scribbles in MSPaint -- |
|
Thomas Fjellstrom
Member #476
June 2000
|
edit: ok that wolf one is like 50-60 fps now... edit: ok, yours chris edit: more updates... with DGA it hits 300-370 (400 at max) fps, and at 640x480 in DGA mode, I get 80-100fps. -- |
|
23yrold3yrold
Member #1,134
March 2001
|
BTW, can anyone help with this little bit of math? The if statement is to skip the offscreen pixels (HUGE fps boost) but it messes up the texture a bit. I've attached a screenshot which demonstrates this ...
See anything wrong with that first half of the function? -- |
|
Thomas Harte
Member #33
April 2000
|
Quote: TH: Could you compile it into a binary? My DJGPP complains about MANY "errors". I tried fixing some, but I just gave up. How smooth is it? Would you think that you were in a raycaster when you're running it? What is a 2D portal engine? Portal engines work on the principle of sectors. For my engine, a sector is a convex room. Some of the walls are thought to be portals. In ray casting terms of thought, when a ray hits a portal, it carries on through the portal into another sector rather than deciding that it has hit a wall. To do all this, the engine knows which sector the player is currently in, and works on the following (pseudo-code) draw loop: function DrawSector(s) { for(all non-portal walls in sector) draw walls to the display for(all portals) { calculate area of screen that portal would cover if it were a solid wall call DrawSector with the connected sector, specifying to restrict to that area of wall } } Because the sectors are convex, if we know the start sector, this gives a no-overdraw front to back draw. I shall try to dust off a copy of DJGPP and compile my code. It was developed on MSVC so I may have inadvertently used some Microsoft extensions (e.g. unnamed structs) without realising... Quote: TH, I think the word you're looking for is sliver, not slither. Nah, its all to do with the first tutorial I read about Wolfenstein type things, many years ago, which compared them to snakes (don't ask). [My site] [Tetrominoes] |
|
MiquelFire
Member #3,110
January 2003
|
Chris: Where's yours? I don't have a compiler here at work (and don't feel like setting one up here) --- |
|
23yrold3yrold
Member #1,134
March 2001
|
Okay, I'm attaching a zip with makefile, source, Win32 binary and texture file (32KB). -- |
|
Zaphos
Member #1,468
August 2001
|
23: Your code stays over 150 on my computer even near walls, and tends to be >200 ... very nice! I can't really see the glitches you're talking about, though, so I can't really comment on what might be causing them. Perhaps you could post a screenie of a pronounced glitch? (Heh, you could even check miran's screenie module in the early modules submission thread to do it ...). This test result is from using your latest code posted in this thread, which is quite a few posts up, actually, so I guess you may have made progress since then. EDIT: Gah! I idle a bit and look what happens ... takes me 20 minutes to write this post and to test 23's code and sooo many people have already posted. It's not being beaten ... it's being completely demolished
|
|
23yrold3yrold
Member #1,134
March 2001
|
I did post a screenshot (5 posts up) as an attachment. Guess you missed it, dawdle-boy -- |
|
Zaphos
Member #1,468
August 2001
|
For reference, to document the worst beating I've seen yet: the last post in this thread when I wrote the above response was TF saying: Quote: Textures? I don't have no stinkin textures. Really. (um.. you want me to try yours now? demands... sheesh )
|
|
Thomas Fjellstrom
Member #476
June 2000
|
Actually if you face the wall right up close, the ray infront gets quite abit bigger than it should, if you take a look at the size of the rays around it.. -- |
|
MiquelFire
Member #3,110
January 2003
|
23: Stays over 260 with this 1.70GHz machine I have here at work. When not close to a wall, I get around 313. aybabtu: 2000 don't like DOS apps Will do a test at home on my 600 MHz system (which, I assume because of RAM and other network stuff, run laps around this computer --- |
|
23yrold3yrold
Member #1,134
March 2001
|
TF: If that's directed at me, I'm not seeing it ... If Matthew closes this thread for length, I'd like to start another one, because I'd really like some help with those texture errors -- |
|
aybabtu
Member #2,891
November 2002
|
Thomas JelloStorm said: edit: ok that wolf one is like 50-60 fps now... Yay! What's your system? Goodbytes: Thanks...I'll try that stuff out tonight or something... 23: Your new code skips off screen pixels! Yay! Maybe even more FPS! Miquel: Sorry it's DOS! I don't have MinGW or anything, but it shouldn't be hard to compile...you should just have to stick END_OF_MAIN in there. |
|
MiquelFire
Member #3,110
January 2003
|
Ahem I went over this already. --- |
|
Thomas Fjellstrom
Member #476
June 2000
|
23: darned. well, it seems that must have been a fluke, or only happens in very rare circumstances... but I did see something else thats a bit odd.. hard to explain, just that I found if you're standing right up to a wall, and turn back and forth a bit the colors on the texture move Quote: Yay! What's your system? Athlon 900. -- |
|
|
|