Volume decals

Hi peoples,

Been trying to port Humus’ volume decals here:

Haven’t had too much luck so far - even though his shader code looks like to should be fairly simple to port.

Has anyone else tried this? Decals I would have thought comes up in most games, be it bullet holes, selection markers, or terrain details - but I haven’t seen an example Panda implementation.


Runnable code:
dl.dropboxusercontent.com/u/199 … -decal.zip

I don’t think I’m calculating the depth properly. So trying a different way, and have come across an issue:

Is texpad_x available in GLSL?

AssertionError: Shader input texpad_depthmap is not present.
 at line 496 of c:\buildslave\dev_sdk_win_i386\build\panda3d\panda\src\pgraph\shaderAttrib.cxx
:display:gsg:glgsg(error): at 3598 of c:\buildslave\dev_sdk_win_i386\build\panda3d\panda\src\glstuff\glGraphicsStateGuardian_src.cxx : invalid operation

Its listed here:
panda3d.org/manual/index.ph … der_Inputs

Although I’m using a vec4 like:

uniform vec4 texpad_depthmap;

Edit Actually - probably doesn’t matter, I’ll just use 0.5 for the time being

Edit 2 Although this rendering issue might be because I’ve got the decal texture mode on repeat…

Getting closer. The decal projects (fairly) nicely onto a cube and the plane beneath.

Two problems:

  1. I can get the decal projecting onto geometry, but the screensize needs to be square (FilterManager doing its thing with non-square resolutions). If texpad_ doesn’t seem to work in GLSL, is there an easy way I can calculate it and input that into the shader based on screensize?

  2. My decal moves within the volume when the camera is translated. Spinning the camera in ok. I think its to do with the line : vec4 localPos = inv_modelview * worldPos; Is there a matrix I can use to offset this translation? I tried several that panda provides, but thinking I might need to calculate some sort of matrix python side and pass it to the shader?

Ended up putting setting textures-power-2 to get around this. (Updated code with this in)

loadPrcFileData('', 'textures-power-2 0' )

Still can’t get the localposition working in the shader - but will keep trying.

If you want to transform something without taking the translation into account, set the fourth (.w) coordinate to 0 before multiplying it with the matrix.

Hmm, when I try

Hmm, but setting .w to 0 then results in decal always appearing at world 0, so when you have 2 volumes doesn’t seem to work well:

Not too sure - but the decal seems to be projecting from the cameras view rather then relative to the models up direction.