Some time ago I added some code to be able to autodetect an heightmap in a normalmap, this is very useful when loading third-party asset from games that relies on such mechanism (Xonotic maps are good example of maps that push our engine forward):
|
// detect heightmap in normalmap alpha channel and enable it |
|
// if not already enabled by explicit shader keyword |
|
if ( image->bits & IF_NORMALMAP ) |
|
{ |
|
if ( ! ( image->bits & IF_DISPLACEMAP ) ) |
|
{ |
|
switch ( image->internalFormat ) |
|
{ |
|
case GL_RGBA: |
|
case GL_RGBA8: |
|
case GL_RGBA16: |
|
case GL_RGBA16F: |
|
case GL_RGBA32F: |
|
case GL_RGBA32UI: |
|
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
|
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: |
|
image->bits |= IF_DISPLACEMAP; |
|
} |
|
} |
|
} |
I discovered that code is not able to autodetect the heightmap in png, and if I'm right, webp too. It would be useful to test against tga too.
I verified it works against crn and dds by the way (haven't experimented with ktx at all) which are some kind of “native” GPU formats.
I plan to implement an explicit normalHeightMap keyword (as others idtech3 derivated engines did) but it would be good to know why the above code fails on non-GPU textures formats.
Some time ago I added some code to be able to autodetect an heightmap in a normalmap, this is very useful when loading third-party asset from games that relies on such mechanism (Xonotic maps are good example of maps that push our engine forward):
Daemon/src/engine/renderer/tr_image.cpp
Lines 1364 to 1383 in e63aa21
I discovered that code is not able to autodetect the heightmap in png, and if I'm right, webp too. It would be useful to test against tga too.
I verified it works against crn and dds by the way (haven't experimented with ktx at all) which are some kind of “native” GPU formats.
I plan to implement an explicit
normalHeightMapkeyword (as others idtech3 derivated engines did) but it would be good to know why the above code fails on non-GPU textures formats.