x-ray rendering

I would like to obtain a x-ray rendering of a scene with any kind of objetcs. The problem is that the using of the blending doesn’t allow to differenciate the thicknessses of the objects (more the object is thick in a given direction view, more the intensity of the x-ray is high).

Does anybody already solved this problem using only OpengGL functions (zbuffer, fog, …) ?

You can use fog for color and subtract frontface color from backface color.

You can also use texgen in eyespace, perhaps even bounding objects with the texture matrix for more precisionl. Extended range may be a problem since it will be difficult to clamp so you may want to render underbright and do some post processing on the scene.

This very recent thread also discusses similar concepts.
http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/011296.html

AFAIK that´s something like volume-rendering (volumetric fog, volumetric light, etc.).

You could google for that (i know that there is a really good article on gamasutra.com).

Jan.

Originally posted by leman_nc:
The problem is that the using of the blending doesn’t allow to differenciate the thicknessses of the objects (more the object is thick in a given direction view, more the intensity of the x-ray is high).

Actually blending (more precisely, “compositing”) does allow you to do what you want. Have you tried using glBlendFunc with SRC_ALPHA, ONE_MINUS_SOURCE_ALPHA ? Render the 3D-textured polygons back-to-front, always slicing across the viewing axis. (more the object is thick in a given direction view, more the samples and more the opacity accumulation).

Karthik

How can I subtract frontface color from backface color by using fog for color ?

Read this

Thanks Harsman,

The GDC seems really what I am looking for. But, there is no way to avoid the using of DirectX to have a real-time x-ray rendering effect?

There’s no need to use DirectX. The presentation is pretty advanced though, so you might not be familliar with how to do it in OpenGL. Do you have any more specific questions?

Oh and the GDC isn’t the name of the technique, it’s short for Game Developers Conference, that’s where the presentation was given.

OK, I’ve just simplified GDC for not saying Game Developers Conference … :wink:

But you’re right for the first thing. I’m not familiar with how to do that in OpenGL. I look for the version of Pixel Shaders, it’s why I was directed on the DirectX.

OK, I would like to know how to compute the thickness of the object (in the GDC link, the slides “Rendering Thickness per Pixel”). I hope it is not a mathematical computation for each pixel, because it should be a very time consuming for a real-time rendering technique.

Regards.

Well what you need to compute to get the thickness per pixel is the sum of all back face distances - the sum of all front face distances.

You can do this in several ways:

Set up texgen and a 1D texture to map distance to alpha. Set the colour to white. Render all back faces with additive blending and then all front faces with subtractive. This will have very bad precision but it is fairly easy to set up.

For better precision render RGB-encoded depth for front faces into one texture, F, and back faces into another, B. Then you can bind these two textures and in your fragment shader compute B-F to get the thickness per pixel. You can use this as a texture coordinate in a 1D colour texture or use it with some scattering math to get the effect you want. This requires more powerful hardware than the earlier technique but looks much better.

By the way, this has been discussed before so you will probably get some tips from searching on “x-ray” and “volume fog” in these forums.

Originally posted by Jan2000:
[b]AFAIK that´s something like volume-rendering (volumetric fog, volumetric light, etc.).

You could google for that (i know that there is a really good article on gamasutra.com).

Jan.[/b]
I really don´t like to quote myself.
Jan.

If you want a quick and cheesy hack that’s good enough for games, you can make the assumption that facing angles are “thick” and glancing angles are “thin”.

Then use NORMAL_MAP texgen, and use a cube map (or 1D texture, even) where it’s full-bright when pointing towards the viewer, and falls off when pointing away. Do this in ONE,ONE blend mode for additive, X-ray rendering.

This is very similar to having a point light at the camera, and doing per-pixel lighting.