Painting decals/blood on 3D scene

Started by
2 comments, last by dpadam450 7 years, 10 months ago

I had an idea to use a render to texture method in my game to be able to have blood splats on the ground, like sc2 creep, splatoon's paint or portal 2's gel. I need some help making a plan on how to make this work, here are my ideas so far:

1) The 3D scene is a terrain with some buildings on it, take the scene bounding box's min plane and store it as a separate plane.

2) Raycast into this plane, alternative method is to raycast the physics engine collision mesh?

3) Make a texture for the plane during scene init, but keep the texture within a reasonable dimension, 2kx2k?

4) Render whatever we want to this texture and let the scene shader's sample it.

That's the rough idea, how comes the hard part, so we have the ray intersection point for either the plane or the triangle on the mesh.

1) How to find that point on the texture?

2) How to generate the new texture coord's for the scene meshes?

3) Should I be using some kind of unwrap uv like OpenGI http://opengi.sourceforge.net ?

4) What about the technique projective texturing? I know it is similar to a shadowmap, just not sure if that's what I need, the entire scene can be covered at any one point by the blood/gel/creep material.

Any help would be appreciated! Thanks.

Advertisement
Maybe you can use a separate "blood splatter" object, basically a quad (or pointsprite), using a semi transparant texture. You could render that "on top" of the ground object for example.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

1) You need to find the bary centric coordinates and then project that onto the UV grid for the texture. Each vertex should have a UV coordinate in it's data structure. What ever barcenter your computation produced can be used to find the 2D coords for the texture after multiplying it to the UV range. Be sure to carry a list of effected triangles. Otherwise you will be painting something you don't want to.
2) You don't. You just create the texture and apply it via shader. Your UV coordinates are mesh specific, not texture specific. Because the range of a UV coordinate is between (0.00000,0.00000) and (1.00000, 1.00000) You have a percentile range. The GPU will scale accordingly for the size of the texture.

3) It shouldn't be necessary. The objects should already be UV mapped before your game starts, if not easily computed in the case of terrain.
4) Projective Textureing depends on the method. Useing decals is good but only if the effect is to remain temporary. You can bake the texture into a UV map, but this method is pretty tricky, and might not look right in some instances.

Another note. If you are trying to put all your blood UV textures on one bigass one, you might find yourself having a really bad time if you do not know what you are doing. But the outcome is that you can get more work done with less calls.

Create a texture that maps to the entirety of your terrain that has an alpha channel.

Tile the SC2 goo / Blood texture.

Multiply it by the alpha map.

Wherever a person dies you simply find where they map into the 2D texture and plop a pixel or a few with some alpha value.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

This topic is closed to new replies.

Advertisement