I have a question about decals and non-static geometry. I originally asked this question over in another thread, but because that wasn't really the place for the question, I started this thread. So, here's the carry-over from http://irrlicht.sourceforge.net/forum/v ... =9&t=45604
HAWK0987654321 wrote:Hello
Thanks for releasing this code, it's the best decal system I have seen for Irrlicht.
I am wondering if there is a way to use these decals with non static meshes, as with the F.E.A.R. games where blood decals are created at bullet hits.
serengeor wrote:Maybe those aren't decals, but rather another texture layer? (Just a guess)
That was my original idea for decals, but getting the decals in the right spot and the right size may be a bit tricky...also, normal maps would be a challenge as Irrlicht only has two texture layers.
They had discussed something similar in the forums here: http://irrlicht.sourceforge.net/forum/v ... hp?t=39440
Irrlicht has more than two texture layers....
Also from what I guess its likely an adaptation of a terrain texture 'splatting' type pixel shader whereby the decals are painted on the uv from a sprite sheet.
Thanks for replying, guys.
Ok, I see. At first I thought it only had 2 because of intellisenes in MSVC(and I hadn't noticed anything in the API docs saying otherwise).
I don't know that much about shaders yet, but I think I'm starting to understand them a bit.
I think I may be able to figure out the UV coords and how to paint. I'll post back with either finished code or questions sometime later.
//My test texture is a 24 bit bitmap
line3d<f32> ray = coll->getRayFromScreenCoordinates(vector2di(TEvent.MouseInput.X, TEvent.MouseInput.Y));
vector3df point;
triangle3df triangle;
ISceneNode *colNode=coll->getSceneNodeAndCollisionPointFromRay(ray, point, triangle);
u32 *a=(u32*)colNode->getMaterial(0).getTexture(0)->lock();
int p=colNode->getMaterial(0).getTexture(0)->getSize().Height*colNode->getMaterial(0).getTexture(0)->getSize().Width;
for(int b=0;b<=p/2;b++)
{
a[p]=0;
}
colNode->getMaterial(0).getTexture(0)->unlock();
colNode->getMaterial(0).getTexture(0)->regenerateMipMapLevels();
Ah, there we go. Thanks
I missed that typo...and that would be why I wasn't noticing a change in texture. Changing one pixel 65,536 times to the same value...just doesn't do much.
What is texture pitch exactly? I checked the API docs and it says the pitch is the amount of bytes in a row of the texture. I called getPitch() and it returned a value of 1024.
Well, actually textures usually don't have a pitch, and those gpus that don't support NPOT will scale the texture to 512x512. Because otherwise a texture coord of 1 would have to be scaled on each access, or would lead to wrong results. But images can have a pitch, as well as framebuffers (only useful for software implementations, though). It just means that you have additional pixels, which you have to skip and which do not count as part of the image. PItch can also help defining a sub-image on a larger image.