I’ve just twigged what was wrong with the perspective in the previous screenshots- I was setting the range for the Z-axis of the eye coordinates so it went negative. Negative Z-values go right through the surface, and you end up looking at it from behind, but with reversed perspective. Very odd.
Here are some screenshots of the corrected version.
Incidentally, I should mention that the Isosurface being rendered is Paul Bourke’s ‘The Blob’, though according to tonfilm’s comments in the HLSL code, you can use other Isosurface recipes too. Time to look for some, I think! This looks like a good candidate.
It’s also worth noting that this shader produces quite a lot of aliasing. I may be wrong, but I think it’s probably quite hard to get around that with this type of rendering method. Raytracing works by casting rays at the object, and ultimately, these rays either hit something, in which case a shading calculation is carried out, or they don’t, and the background colour is returned. They can’t ‘half-hit’ the object, so you get aliasing.
These screenshots look nice and smooth because I captured them full-screen (1440 x 900), then reduced them down in Photoshop. Supersampling, essentially. I can’t imagine supersampling working at anything approaching a decent framerate with this shader in QC though, unless the output size was verry small, or you have a REALLY fast graphics card. I’m sure it will be possible in the future though.
The next challenge will be to make the camera orbit around the raytraced object in a convincing way. Currently, you can only move the virtual camera on the 3 axes, but you can’t change the ‘point of interest’, so what you essentially end up doing is moving the rendered object past the camera. I have a screenshot showing how this is done in VVVV. The difference is, in VVVV, you can get access to the list of vertices outside the shader itself, so it’s possible to apply matrix transformations to the mesh and camera position values outside the shader. This kind of thing isn’t possible in QC, so it has to be implemented in the Vertex Shader. I just have to try and get my head around how to do this though…