Skip to content

fail to detect alpha channel heightmap in png normal map (seems to be the same with webp) #233

Description

@illwieckz

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions