multitextured gunshot effect in walls

Started by
15 comments, last by jatobu 16 years, 5 months ago
Quote:Original post by yahastu
Yes...that is clearly the problem, which is why I suggested using a pixel shader to correct the problem by adding a depth bias...I didn't realize that a function to do depth bias already exists:

Quote:IDirect3DDevice9::SetRenderState method just before rendering them, setting the State parameter to D3DRS_DEPTHBIAS, and the Value parameter to a value between 0-16 inclusive. A higher z-bias value increases the likelihood that the polygons you render will be visible when displayed with other coplanar polygons.


Great!... I'm going to take a try on it!... I'll let you know if I succeeded with it or not.

(ofcourse, any other ideas on how to solve this problem would be appreciated too)


Thanks!
Advertisement
I think stencil buffers will work and they r fine to emulate theese effect like burned wall after a rocket hits it.
Another common technique for fixing the coplanar decal problem is biasing the near/far depth range in the perspective matrix by a small amount when you render the decals, so that it pulls all depth values slightly closer to the camera. I've tried all the fancy DX slope biasing stuff and it never seemed as though it worked as well as straight depth range biasing.
I have worked with decals using a face in front of a wall in 2 programs and it has always looked ok to me, CS even has a system to make the decal shape to 3d surfaces, like a real bloodstain or shadow would.

http://crystalspace3d.org
Well,

Here I am again... I changed the DepthBias and SlopeScaleDepthBias to see if I could fix the overlapping problem, I think it helped, it doesn't look so flicky as before, although the overlapping is still happening... any other ideas why this could be happening??...

It defenitly looks to be something at the pixel level, since when I render the scene in wireframe mode the vertex do not change (actually, the overlapping can happen at different regions of a single triangle)...

I think I'll try to change the depth values in the DepthBuffer as yahastu suggested... but it would just be a twick to make it look right, not exactly to fix the problem from the roots.

There's a distance of about 0.1 between the "wall" and the "bullet-hole-sprite", is it too little??... as I said, when the camera is near that point there isn't any overlapping, but as you get far from it it becomes to make more and more visible...

Thanks!
The resolution of the depth buffer gets worse as you get further away from the camera, so you cannot rely on "physical separation" between the wall and the decal. The most common solution is the depth biasing that has already been mentioned.

One thing that hasn't been said is that you have to set the depth culling method so that when you're drawing the decal it'll draw a pixel if the depth buffer value is "greater or equal" to the decal's depth, as opposed to "greater". In OpenGL this is done with glDepthFunc; I don't know about D3D.
Hi fingers_,

Well, I think I'll have to stick to that method then... Thanks!


Does anyone know how to change the Depth Buffer using Direct3D?... I think this would best fit to be done under the pixel shader, doesn't it? (accualy I can't think of a way to doit otherwise).


Thanks!

This topic is closed to new replies.

Advertisement