Limited Raytracing for Games?

BlitzMax Forums/BlitzMax Programming/Limited Raytracing for Games?

Endive(Posted 2015) [#1]
I'm interested in writing a software raytracer for rendering small models.

I believe that I can write a fairly fast raymarcher capable of doing perhaps 200x200 pixels at a reasonable speed.

Moreover, every model will have its own pixmap. The rendering will be stored on the pixmap. Every other frame or two out of three frames, the canned sprite will be drawn instead of a live rendering, thus doubling or tripling the number of models that can be rendered. Moreover, if a spot check of rendered pixels have not changed since the last rendering, the canned sprite will be used again.

I realize that obviously OpenGL and shaders would be the better approach, but one reason I'm interested in doing this is to really learn about writing renderers.

Thoughts? Should I use voxel grids? They are friendly to raymarching, as are various other implicit mathematical surfaces and isosurfaces.


dw817(Posted 2015) [#2]
It's out of my league, Endive. I'm old school topview scrolling parallax. http://creatools.gameclassification.com/EN/creatools/481-Scenario-RPGMaker/index.html



Minju, if you manage to make a good 3D engine using graphics and NOT glgraphics, I'll be interested in seeing that and would love to apply it to my current engine for airship tile tilt.


Yasha(Posted 2015) [#3]
This is a similar approach to what I've been doing in the recent past (raymarching on sprites). I've found it is more than fast enough for realtime performance at much larger sizes than that (up to fullscreen: sprites are an optimization), if your models are good. Don't do it in software if you care about performance, use GLSL (you can store a "model" as a set of function calls and stitch it directly into the shader string to load). Voxel grids are workable but should probably be a last resort option if any other way to describe the given shape exists.

Definitely don't be afraid to try this. It's the future of graphics.


Endive(Posted 2015) [#4]
I am going to need to bite the bullet and learn programmable pipeline anyway, but I have had a lot of trouble getting to grips with this stuff.

When you do raymarching on sprites, do you have zsprites and then raymarch those? What tool do you use to make your zsprites?


Yasha(Posted 2015) [#5]
Sorry I'm not 100% up on the terminology (zsprites? I don't use the zSprite library, if that's what you mean). Post above is generic.

What I have in my setup is a "traditional" 3D engine (Blitz3D-style, MoveEntity, TurnEntity etc.), but where the only objects that can be rendered visibly - physics/collision is an unrelated question - are the "backdrop" (a single texture/distfield that draws to the whole screen before anything else) and "sprites", which are like B3D sprites, quadmeshes that face the camera and have their own distfield shader. In the version I've got atm this means that only the "backdrop" scene has correct lighting, as the data isn't available on the second-and-subsequent passes for the movable objects (fixable, but I don't consider this a major problem).

Distfields are created in text form, main interesting thing to work on is a "live coding" environment so they can be typed in at the command line while the program runs. They are built as nested primitive manipulations ( "translate(twistY(cube(), 45), 0, 10, 0)" ) and pasted into the raymarching template. (Voxel objects only exist in my notes at the moment.)

I need to release this as a 3D engine for Max one of these days, but haven't got around to finishing or cleaning it up.


re. learning, the nice thing about raymarching is that (once set up with some shader templates) you can ignore many of the things specific to OpenGL and 3D in general (never need to touch vertex shaders or geometry shaders again), and go back to viewing GLSL as a simple "map this function over that grid of pixels" bulk operation.


Endive(Posted 2015) [#6]
Will get back to you on zsprites when I'm not sick.


Endive(Posted 2015) [#7]
Ok Yasha, Z-sprite was a term used by Nvidia some years ago that their cards have support for. In my understanding it's a sprite that has color information, depth information and possibly normal map information.

For learning shaders, do you recommend GLSL?

I've written a raymarcher before and I'm doing one again but I haven't spent enough time on it yet to get it working.