GLSL Volumetric Transparency

Hello,

[Technically, this is not a BGE question, as this won’t be used in the BGE, but it could definitely be applied to it, and I figured you guys would know best what I meant by volumetric transparency.]

I’m looking for a GLSL shader script (fragment shader, if I am not mistaken) that will cheaply emulate volumetric transparency. That is, the amount of opacity depends on the distance between the near/facing face and the far/anti-facing face (either z-wise or normal-wise). This is similar to Blender 2.5’s volumetric material feature, but much cheaper.

I am sure this is possible in GLSL, but I wanted to see if something existed before I went to try to make it myself (if I do do this, I may want pointers). Something like alpha = 1 - 2^-thickness, probably, but computationally optimized (which I will do if I write it myself). It should be rather simple, though shading does become a little weird (don’t want the solid shading to happen anymore, but it can be dealt with, possibly by making it shadeless–that should look pretty decent, I think…).

I don’t need to worry about (I’ll pretend they’re rays) a ray hitting multiple facing faces before hitting an anti-facing face, because this is for a board-style game that involves a 3D grid of cubes.

Thanks.

Well… suggestions on other places to post this problem?

I think it would be simpler if it was done with IPO, and python. Python script that tracks the object’s distance from other objects, and according to that, sets the lamp’s IPO according to the distance(I don’t know a lot about python, but i guess it would be done with ray sensores?), becuase, when you set the lamp to only cast shadows, the energy slider kind of becomes an alpha slider. Correct me if im wrong tho :confused: