Skip to content
Permalink
Browse files

R_UploadImage: detect heightmap in normalmap alphachanel

detect heightmap in normalmap alpha channel
and enable parallax for the given shader
  • Loading branch information...
illwieckz committed Feb 10, 2019
1 parent f71cba5 commit fba1c87d5866d387f0ae4459a28064bfdf721c40
Showing with 27 additions and 0 deletions.
  1. +21 −0 src/engine/renderer/tr_image.cpp
  2. +6 −0 src/engine/renderer/tr_shader.cpp
@@ -1361,6 +1361,27 @@ void R_UploadImage( const byte **dataArray, int numLayers, int numMips,
ri.Hunk_FreeTempMemory( scaledBuffer );
}

// 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;
}
}
}

GL_Unbind( image );
}

@@ -1442,6 +1442,12 @@ static bool LoadMap( shaderStage_t *stage, const char *buffer )
return false;
}

// enable parallax if an heightmap is found
if ( stage->bundle[ 0 ].image[ 0 ]->bits & IF_DISPLACEMAP )
{
shader.parallax = true;
}

return true;
}

0 comments on commit fba1c87

Please sign in to comment.
You can’t perform that action at this time.