Finally got around to adding those few lines of code to add textured walls to the ray caster.


(Click to Show Full Size)


(Click to Show Full Size)

A few details:

1) The texture isn’t mine, I merely found it via Google Images with the term “wall texture” and it has the filename “Wall_Texture_by_shadowh3.JPG”
2) There’s still a problem with the corners of the grids having a weird fringe. It’s better than it was, but still not right. Haven’t tracked that down yet, but have some ideas
3) The somewhat hybrid mix (Courtesy of XNA) of performing the ray casting algorithm and then using the hardware to render (i.e. the column strips as Lines, plus using the hardware to render the correct strip of texture, which is all nice and filtered) is arguably making using the ray caster seem futile. Depends on how you look at that one I suppose. I think it’s neat
4) A bit of “FYI”. John Carmack’s article on how he wrote the iPhone version of Wolfenstein 3D is what really got me wanting to do this. Many thanks to him for the unrelenting inspiration!

Two updates in one day. This is probably a first on my blog ๐Ÿ™‚

Here’s an image of a single reflective sphere in the middle of three other spheres of various colours with lighting and shadows:

Ray Tracing #4 - Three spheres with lighting and shadows being reflected by a single central reflective sphere in the middle of the scene

Here’s a quick look at all of the spheres featuring reflectivity and how they look when recursively casting off one and another:

Ray Tracing #4 - Four reflective spheres with lighting, shadows and reflections

Here’s what I have so far:

Ray Tracing Update #2 - Two Planes and a Sphere being lit

Of course, it’s still very much some ways off the high quality rendering that ray tracing can be known for, but it’s a good learning experience all the same.

Having spent a lot of time on rasterizer based rendering, I’ve wanted to learn more about ray tracing, if only for the sake of curiosity. I also wanted to revisit ray casting, as it had been some time and I took some of the finer details for granted the first time around, so this time, I went through it with a fine toothcomb to make sure I got all of the details down.

Given that the majority of speed is lost in blitting the columns to the screen in traditional ray casters, I decided to render each vertical strip as line primitives in XNA. It’s not a shabby use of the hardware, although I’d love to take a crack at writing a shader based ray caster sometime down the road.

I gave a quick performance test, although nothing too extensive but I did run it at 2048×1152 (amongst other oversized resolutions) and it managed to fulfil the synced 60fps, which was nice to see.

Here’s a look at the basic ray caster in XNA:

Very simple ray caster in XNA

As for the ray tracing, I’ve not made too much progress and for the moment, I’m just performing intersections with a plane. I hear it only gets harder from there ๐Ÿ™‚

Another detail; given that I’m working with a plane extending in just the X and Z directions (Facing +Y), I’m also hacking this slightly for test purposes due to the fact that I’m clamping its size at 64 units in the X (-32 to 32), and 64 units in the Z (-32 to 32) in order to give the plane some shape.

And also a look at the basic ray tracer in XNA:

Very simple ray traced plane

Again, I’m using XNA and except this time, I’m doing something a little different to the ray caster and I’m modifying the content of a texture and just drawing that texture to the screen with a SpriteBatch. I never said I was after performance.. At least not just yet anyway!

This is “Arcane” by an unknown artist (Please do e-mail me if you know who the original author is).

It’s something a little different this time. It’s a shame the excellent bit in the last 27 seconds or so doesn’t make more an appearance throughout the song.

[audio:http://www.terrybutler.co.uk/wp-content/uploads/2009/11/arcane2.mod.mp3]

Download MP3
Download MOD