We get it. We use ad blockers too. But GameDev.net displays them so we can continue to be a great platform for you.
Please whitelist GameDev.net and our advertisers.
Also consider a GDNet+ Pro subscription to remove all ads from GameDev.net.
Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 05 June 2005 - 04:40 AM
Posted 05 June 2005 - 05:07 AM
Posted 05 June 2005 - 05:17 AM
Posted 05 June 2005 - 05:38 AM
Posted 05 June 2005 - 08:11 AM
Posted 05 June 2005 - 08:16 AM
Posted 05 June 2005 - 08:23 AM
Posted 05 June 2005 - 08:34 AM
Posted 05 June 2005 - 08:35 AM
Posted 05 June 2005 - 10:58 AM
Posted 05 June 2005 - 08:58 PM
// converts heightmap to normalmap (bumpmap)
void CImageTools::ConvertHeightMapToNormalMap( CImage &heightMap, CImage &normalMap, const float strength ) {
// error checking
if ( heightMap.GetDepth() != 1 ) {
Log << "<!> Cant convert heightmap to normalmap : invalid input image depth\n";
return;
}
const unsigned int width = heightMap.GetWidth();
const unsigned int height = heightMap.GetHeight();
normalMap.Set( width, height, 3 );
const float normY = 256.0f / strength;
Math::CVector3 normal;
unsigned int pos = 0;
for ( unsigned int y=0; y<height; ++y ) {
for ( unsigned int x=0; x<width; ++x ) {
normal.Set( 0.0f, normY, 0.0f );
normal.x -= static_cast<float>( heightMap.data[ heightMap.GetDataPos( x-1, y ) ] );
normal.x += static_cast<float>( heightMap.data[ heightMap.GetDataPos( x+1, y ) ] );
normal.z -= static_cast<float>( heightMap.data[ heightMap.GetDataPos( x, y-1 ) ] );
normal.z += static_cast<float>( heightMap.data[ heightMap.GetDataPos( x, y+1 ) ] );
normal.NormalizeFast();
normalMap.data[ pos++ ] = Math::FloatToByte( normal.x * 127.0f + 128.0f );
normalMap.data[ pos++ ] = Math::FloatToByte( normal.z * 127.0f + 128.0f );
normalMap.data[ pos++ ] = Math::FloatToByte( normal.y * 127.0f + 128.0f );
}
}
normalMap.SetDataFormat( GL_RGB, GL_RGB );
}
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.