Skip to content

Commit ee0c43d

Browse files
committed
tr_shader: move some code to make diff more readable in future commits
1 parent cb9d354 commit ee0c43d

File tree

1 file changed

+157
-151
lines changed

1 file changed

+157
-151
lines changed

src/engine/renderer/tr_shader.cpp

Lines changed: 157 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,163 @@ static bool FindMapInStage( const char *text, char *buffer, int bufferlen )
15871587
return false;
15881588
}
15891589

1590+
/*
1591+
===================
1592+
ParseDifuseMap
1593+
and others
1594+
===================
1595+
*/
1596+
static void ParseDiffuseMap( shaderStage_t *stage, const char **text )
1597+
{
1598+
char buffer[ 1024 ] = "";
1599+
1600+
stage->active = true;
1601+
stage->type = stageType_t::ST_DIFFUSEMAP;
1602+
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
1603+
stage->stateBits = GLS_DEFAULT;
1604+
1605+
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
1606+
{
1607+
LoadMap( stage, buffer );
1608+
}
1609+
}
1610+
1611+
static void ParseNormalMap( shaderStage_t *stage, const char **text )
1612+
{
1613+
char buffer[ 1024 ] = "";
1614+
1615+
stage->active = true;
1616+
stage->type = stageType_t::ST_NORMALMAP;
1617+
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
1618+
stage->stateBits = GLS_DEFAULT;
1619+
1620+
if ( r_highQualityNormalMapping->integer )
1621+
{
1622+
stage->overrideFilterType = true;
1623+
stage->filterType = filterType_t::FT_LINEAR;
1624+
1625+
stage->overrideNoPicMip = true;
1626+
}
1627+
1628+
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
1629+
{
1630+
LoadMap( stage, buffer );
1631+
}
1632+
}
1633+
1634+
static void ParseSpecularMap( shaderStage_t *stage, const char **text )
1635+
{
1636+
char buffer[ 1024 ] = "";
1637+
1638+
stage->active = true;
1639+
stage->type = stageType_t::ST_SPECULARMAP;
1640+
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
1641+
stage->stateBits = GLS_DEFAULT;
1642+
1643+
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
1644+
{
1645+
LoadMap( stage, buffer );
1646+
}
1647+
}
1648+
1649+
static void ParseMaterialMap( shaderStage_t *stage, const char **text )
1650+
{
1651+
char buffer[ 1024 ] = "";
1652+
1653+
stage->active = true;
1654+
stage->type = stageType_t::ST_MATERIALMAP;
1655+
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
1656+
stage->stateBits = GLS_DEFAULT;
1657+
1658+
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
1659+
{
1660+
LoadMap( stage, buffer );
1661+
}
1662+
}
1663+
1664+
static void ParseGlowMap( shaderStage_t *stage, const char **text )
1665+
{
1666+
char buffer[ 1024 ] = "";
1667+
1668+
stage->active = true;
1669+
stage->type = stageType_t::ST_GLOWMAP;
1670+
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
1671+
stage->stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE; // blend add
1672+
1673+
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
1674+
{
1675+
LoadMap( stage, buffer );
1676+
}
1677+
}
1678+
1679+
static void ParseReflectionMap( shaderStage_t *stage, const char **text )
1680+
{
1681+
char buffer[ 1024 ] = "";
1682+
1683+
stage->active = true;
1684+
stage->type = stageType_t::ST_REFLECTIONMAP;
1685+
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
1686+
stage->stateBits = GLS_DEFAULT;
1687+
stage->overrideWrapType = true;
1688+
stage->wrapType = wrapTypeEnum_t::WT_EDGE_CLAMP;
1689+
1690+
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
1691+
{
1692+
stage->isCubeMap = true;
1693+
LoadMap( stage, buffer );
1694+
}
1695+
}
1696+
1697+
static void ParseReflectionMapBlended( shaderStage_t *stage, const char **text )
1698+
{
1699+
char buffer[ 1024 ] = "";
1700+
1701+
stage->active = true;
1702+
stage->type = stageType_t::ST_REFLECTIONMAP;
1703+
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
1704+
stage->stateBits = GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE;
1705+
stage->overrideWrapType = true;
1706+
stage->wrapType = wrapTypeEnum_t::WT_EDGE_CLAMP;
1707+
1708+
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
1709+
{
1710+
stage->isCubeMap = true;
1711+
LoadMap( stage, buffer );
1712+
}
1713+
}
1714+
1715+
static void ParseLightFalloffImage( shaderStage_t *stage, const char **text )
1716+
{
1717+
char buffer[ 1024 ] = "";
1718+
1719+
stage->active = true;
1720+
stage->type = stageType_t::ST_ATTENUATIONMAP_Z;
1721+
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
1722+
stage->stateBits = GLS_DEFAULT;
1723+
stage->overrideWrapType = true;
1724+
stage->wrapType = wrapTypeEnum_t::WT_EDGE_CLAMP;
1725+
1726+
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
1727+
{
1728+
LoadMap( stage, buffer );
1729+
}
1730+
}
1731+
1732+
struct extraMapParser_t
1733+
{
1734+
const char *suffix;
1735+
const char *description;
1736+
void ( *parser ) ( shaderStage_t*, const char** );
1737+
};
1738+
1739+
static const extraMapParser_t extraMapParsers[] =
1740+
{
1741+
{ "norm", "normal map", ParseNormalMap },
1742+
{ "gloss", "specular map", ParseSpecularMap },
1743+
{ "glow", "glow map", ParseGlowMap },
1744+
{ "luma", "glow map", ParseGlowMap },
1745+
};
1746+
15901747
/*
15911748
===================
15921749
ParseStage
@@ -3076,157 +3233,6 @@ static void ParseSurfaceParm( const char **text )
30763233
SurfaceParm( token );
30773234
}
30783235

3079-
static void ParseDiffuseMap( shaderStage_t *stage, const char **text )
3080-
{
3081-
char buffer[ 1024 ] = "";
3082-
3083-
stage->active = true;
3084-
stage->type = stageType_t::ST_DIFFUSEMAP;
3085-
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
3086-
stage->stateBits = GLS_DEFAULT;
3087-
3088-
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
3089-
{
3090-
LoadMap( stage, buffer );
3091-
}
3092-
}
3093-
3094-
static void ParseNormalMap( shaderStage_t *stage, const char **text )
3095-
{
3096-
char buffer[ 1024 ] = "";
3097-
3098-
stage->active = true;
3099-
stage->type = stageType_t::ST_NORMALMAP;
3100-
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
3101-
stage->stateBits = GLS_DEFAULT;
3102-
3103-
if ( r_highQualityNormalMapping->integer )
3104-
{
3105-
stage->overrideFilterType = true;
3106-
stage->filterType = filterType_t::FT_LINEAR;
3107-
3108-
stage->overrideNoPicMip = true;
3109-
}
3110-
3111-
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
3112-
{
3113-
LoadMap( stage, buffer );
3114-
}
3115-
}
3116-
3117-
static void ParseSpecularMap( shaderStage_t *stage, const char **text )
3118-
{
3119-
char buffer[ 1024 ] = "";
3120-
3121-
stage->active = true;
3122-
stage->type = stageType_t::ST_SPECULARMAP;
3123-
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
3124-
stage->stateBits = GLS_DEFAULT;
3125-
3126-
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
3127-
{
3128-
LoadMap( stage, buffer );
3129-
}
3130-
}
3131-
3132-
static void ParseMaterialMap( shaderStage_t *stage, const char **text )
3133-
{
3134-
char buffer[ 1024 ] = "";
3135-
3136-
stage->active = true;
3137-
stage->type = stageType_t::ST_MATERIALMAP;
3138-
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
3139-
stage->stateBits = GLS_DEFAULT;
3140-
3141-
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
3142-
{
3143-
LoadMap( stage, buffer );
3144-
}
3145-
}
3146-
3147-
static void ParseGlowMap( shaderStage_t *stage, const char **text )
3148-
{
3149-
char buffer[ 1024 ] = "";
3150-
3151-
stage->active = true;
3152-
stage->type = stageType_t::ST_GLOWMAP;
3153-
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
3154-
stage->stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE; // blend add
3155-
3156-
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
3157-
{
3158-
LoadMap( stage, buffer );
3159-
}
3160-
}
3161-
3162-
static void ParseReflectionMap( shaderStage_t *stage, const char **text )
3163-
{
3164-
char buffer[ 1024 ] = "";
3165-
3166-
stage->active = true;
3167-
stage->type = stageType_t::ST_REFLECTIONMAP;
3168-
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
3169-
stage->stateBits = GLS_DEFAULT;
3170-
stage->overrideWrapType = true;
3171-
stage->wrapType = wrapTypeEnum_t::WT_EDGE_CLAMP;
3172-
3173-
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
3174-
{
3175-
stage->isCubeMap = true;
3176-
LoadMap( stage, buffer );
3177-
}
3178-
}
3179-
3180-
static void ParseReflectionMapBlended( shaderStage_t *stage, const char **text )
3181-
{
3182-
char buffer[ 1024 ] = "";
3183-
3184-
stage->active = true;
3185-
stage->type = stageType_t::ST_REFLECTIONMAP;
3186-
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
3187-
stage->stateBits = GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE;
3188-
stage->overrideWrapType = true;
3189-
stage->wrapType = wrapTypeEnum_t::WT_EDGE_CLAMP;
3190-
3191-
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
3192-
{
3193-
stage->isCubeMap = true;
3194-
LoadMap( stage, buffer );
3195-
}
3196-
}
3197-
3198-
static void ParseLightFalloffImage( shaderStage_t *stage, const char **text )
3199-
{
3200-
char buffer[ 1024 ] = "";
3201-
3202-
stage->active = true;
3203-
stage->type = stageType_t::ST_ATTENUATIONMAP_Z;
3204-
stage->rgbGen = colorGen_t::CGEN_IDENTITY;
3205-
stage->stateBits = GLS_DEFAULT;
3206-
stage->overrideWrapType = true;
3207-
stage->wrapType = wrapTypeEnum_t::WT_EDGE_CLAMP;
3208-
3209-
if ( ParseMap( text, buffer, sizeof( buffer ) ) )
3210-
{
3211-
LoadMap( stage, buffer );
3212-
}
3213-
}
3214-
3215-
struct extraMapParser_t
3216-
{
3217-
const char *suffix;
3218-
const char *description;
3219-
void ( *parser ) ( shaderStage_t*, const char** );
3220-
};
3221-
3222-
static const extraMapParser_t extraMapParsers[] =
3223-
{
3224-
{ "norm", "normal map", ParseNormalMap },
3225-
{ "gloss", "specular map", ParseSpecularMap },
3226-
{ "glow", "glow map", ParseGlowMap },
3227-
{ "luma", "glow map", ParseGlowMap },
3228-
};
3229-
32303236
/*
32313237
=================
32323238
ParseShader

0 commit comments

Comments
 (0)