aboutsummaryrefslogtreecommitdiff
path: root/source/Irrlicht/CNullDriver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Irrlicht/CNullDriver.cpp')
-rw-r--r--source/Irrlicht/CNullDriver.cpp118
1 files changed, 0 insertions, 118 deletions
diff --git a/source/Irrlicht/CNullDriver.cpp b/source/Irrlicht/CNullDriver.cpp
index 8779cbd..da64779 100644
--- a/source/Irrlicht/CNullDriver.cpp
+++ b/source/Irrlicht/CNullDriver.cpp
@@ -1291,124 +1291,6 @@ void CNullDriver::makeColorKeyTexture(video::ITexture* texture,
}
-
-//! Creates a normal map from a height map texture.
-//! \param amplitude: Constant value by which the height information is multiplied.
-void CNullDriver::makeNormalMapTexture(video::ITexture* texture, f32 amplitude) const
-{
- if (!texture)
- return;
-
- if (texture->getColorFormat() != ECF_A1R5G5B5 &&
- texture->getColorFormat() != ECF_A8R8G8B8 )
- {
- os::Printer::log("Error: Unsupported texture color format for making normal map.", ELL_ERROR);
- return;
- }
-
- core::dimension2d<u32> dim = texture->getSize();
- amplitude = amplitude / 255.0f;
- f32 vh = dim.Height / (f32)dim.Width;
- f32 hh = dim.Width / (f32)dim.Height;
-
- if (texture->getColorFormat() == ECF_A8R8G8B8)
- {
- // ECF_A8R8G8B8 version
-
- s32 *p = (s32*)texture->lock();
-
- if (!p)
- {
- os::Printer::log("Could not lock texture for making normal map.", ELL_ERROR);
- return;
- }
-
- // copy texture
-
- u32 pitch = texture->getPitch() / 4;
-
- s32* in = new s32[dim.Height * pitch];
- memcpy(in, p, dim.Height * pitch * 4);
-
- for (s32 x=0; x < s32(pitch); ++x)
- for (s32 y=0; y < s32(dim.Height); ++y)
- {
- // TODO: this could be optimized really a lot
-
- core::vector3df h1((x-1)*hh, nml32(x-1, y, pitch, dim.Height, in)*amplitude, y*vh);
- core::vector3df h2((x+1)*hh, nml32(x+1, y, pitch, dim.Height, in)*amplitude, y*vh);
- //core::vector3df v1(x*hh, nml32(x, y-1, pitch, dim.Height, in)*amplitude, (y-1)*vh);
- //core::vector3df v2(x*hh, nml32(x, y+1, pitch, dim.Height, in)*amplitude, (y+1)*vh);
- core::vector3df v1(x*hh, nml32(x, y+1, pitch, dim.Height, in)*amplitude, (y-1)*vh);
- core::vector3df v2(x*hh, nml32(x, y-1, pitch, dim.Height, in)*amplitude, (y+1)*vh);
-
- core::vector3df v = v1-v2;
- core::vector3df h = h1-h2;
-
- core::vector3df n = v.crossProduct(h);
- n.normalize();
- n *= 0.5f;
- n += core::vector3df(0.5f,0.5f,0.5f); // now between 0 and 1
- n *= 255.0f;
-
- s32 height = (s32)nml32(x, y, pitch, dim.Height, in);
- p[y*pitch + x] = video::SColor(
- height, // store height in alpha
- (s32)n.X, (s32)n.Z, (s32)n.Y).color;
- }
-
- delete [] in;
- texture->unlock();
- }
- else
- {
- // ECF_A1R5G5B5 version
-
- s16 *p = (s16*)texture->lock();
-
- if (!p)
- {
- os::Printer::log("Could not lock texture for making normal map.", ELL_ERROR);
- return;
- }
-
- u32 pitch = texture->getPitch() / 2;
-
- // copy texture
-
- s16* in = new s16[dim.Height * pitch];
- memcpy(in, p, dim.Height * pitch * 2);
-
- for (s32 x=0; x < s32(pitch); ++x)
- for (s32 y=0; y < s32(dim.Height); ++y)
- {
- // TODO: this could be optimized really a lot
-
- core::vector3df h1((x-1)*hh, nml16(x-1, y, pitch, dim.Height, in)*amplitude, y*vh);
- core::vector3df h2((x+1)*hh, nml16(x+1, y, pitch, dim.Height, in)*amplitude, y*vh);
- core::vector3df v1(x*hh, nml16(x, y-1, pitch, dim.Height, in)*amplitude, (y-1)*vh);
- core::vector3df v2(x*hh, nml16(x, y+1, pitch, dim.Height, in)*amplitude, (y+1)*vh);
-
- core::vector3df v = v1-v2;
- core::vector3df h = h1-h2;
-
- core::vector3df n = v.crossProduct(h);
- n.normalize();
- n *= 0.5f;
- n += core::vector3df(0.5f,0.5f,0.5f); // now between 0 and 1
- n *= 255.0f;
-
- p[y*pitch + x] = video::RGBA16((u32)n.X, (u32)n.Z, (u32)n.Y);
- }
-
- delete [] in;
- texture->unlock();
- }
-
- texture->regenerateMipMapLevels();
-}
-
-
//! Returns the maximum amount of primitives (mostly vertices) which
//! the device is able to render with one drawIndexedTriangleList
//! call.