2012-11-26 18:58:24 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 BFG Edition GPL Source Code
|
2012-11-28 15:47:07 +00:00
|
|
|
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
2014-04-20 14:29:58 +00:00
|
|
|
Copyright (C) 2013-2014 Robert Beckebans
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
|
|
|
|
|
|
|
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
#ifndef __RENDERPROGS_H__
|
|
|
|
#define __RENDERPROGS_H__
|
|
|
|
|
|
|
|
|
|
|
|
static const int PC_ATTRIB_INDEX_VERTEX = 0;
|
|
|
|
static const int PC_ATTRIB_INDEX_NORMAL = 2;
|
|
|
|
static const int PC_ATTRIB_INDEX_COLOR = 3;
|
|
|
|
static const int PC_ATTRIB_INDEX_COLOR2 = 4;
|
|
|
|
static const int PC_ATTRIB_INDEX_ST = 8;
|
|
|
|
static const int PC_ATTRIB_INDEX_TANGENT = 9;
|
|
|
|
|
|
|
|
// This enum list corresponds to the global constant register indecies as defined in global.inc for all
|
|
|
|
// shaders. We used a shared pool to keeps things simple. If something changes here then it also
|
|
|
|
// needs to change in global.inc and vice versa
|
2012-11-28 15:47:07 +00:00
|
|
|
enum renderParm_t
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// For backwards compatibility, do not change the order of the first 17 items
|
|
|
|
RENDERPARM_SCREENCORRECTIONFACTOR = 0,
|
|
|
|
RENDERPARM_WINDOWCOORD,
|
|
|
|
RENDERPARM_DIFFUSEMODIFIER,
|
|
|
|
RENDERPARM_SPECULARMODIFIER,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_LOCALLIGHTORIGIN,
|
|
|
|
RENDERPARM_LOCALVIEWORIGIN,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_LIGHTPROJECTION_S,
|
|
|
|
RENDERPARM_LIGHTPROJECTION_T,
|
|
|
|
RENDERPARM_LIGHTPROJECTION_Q,
|
|
|
|
RENDERPARM_LIGHTFALLOFF_S,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_BUMPMATRIX_S,
|
|
|
|
RENDERPARM_BUMPMATRIX_T,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_DIFFUSEMATRIX_S,
|
|
|
|
RENDERPARM_DIFFUSEMATRIX_T,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_SPECULARMATRIX_S,
|
|
|
|
RENDERPARM_SPECULARMATRIX_T,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_VERTEXCOLOR_MODULATE,
|
|
|
|
RENDERPARM_VERTEXCOLOR_ADD,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// The following are new and can be in any order
|
|
|
|
|
|
|
|
RENDERPARM_COLOR,
|
|
|
|
RENDERPARM_VIEWORIGIN,
|
|
|
|
RENDERPARM_GLOBALEYEPOS,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_MVPMATRIX_X,
|
|
|
|
RENDERPARM_MVPMATRIX_Y,
|
|
|
|
RENDERPARM_MVPMATRIX_Z,
|
|
|
|
RENDERPARM_MVPMATRIX_W,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_MODELMATRIX_X,
|
|
|
|
RENDERPARM_MODELMATRIX_Y,
|
|
|
|
RENDERPARM_MODELMATRIX_Z,
|
|
|
|
RENDERPARM_MODELMATRIX_W,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_PROJMATRIX_X,
|
|
|
|
RENDERPARM_PROJMATRIX_Y,
|
|
|
|
RENDERPARM_PROJMATRIX_Z,
|
|
|
|
RENDERPARM_PROJMATRIX_W,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_MODELVIEWMATRIX_X,
|
|
|
|
RENDERPARM_MODELVIEWMATRIX_Y,
|
|
|
|
RENDERPARM_MODELVIEWMATRIX_Z,
|
|
|
|
RENDERPARM_MODELVIEWMATRIX_W,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_TEXTUREMATRIX_S,
|
|
|
|
RENDERPARM_TEXTUREMATRIX_T,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_TEXGEN_0_S,
|
|
|
|
RENDERPARM_TEXGEN_0_T,
|
|
|
|
RENDERPARM_TEXGEN_0_Q,
|
|
|
|
RENDERPARM_TEXGEN_0_ENABLED,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_TEXGEN_1_S,
|
|
|
|
RENDERPARM_TEXGEN_1_T,
|
|
|
|
RENDERPARM_TEXGEN_1_Q,
|
|
|
|
RENDERPARM_TEXGEN_1_ENABLED,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_WOBBLESKY_X,
|
|
|
|
RENDERPARM_WOBBLESKY_Y,
|
|
|
|
RENDERPARM_WOBBLESKY_Z,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_OVERBRIGHT,
|
|
|
|
RENDERPARM_ENABLE_SKINNING,
|
|
|
|
RENDERPARM_ALPHA_TEST,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2014-05-10 12:40:01 +00:00
|
|
|
// RB begin
|
|
|
|
RENDERPARM_AMBIENT_COLOR,
|
|
|
|
|
|
|
|
RENDERPARM_GLOBALLIGHTORIGIN,
|
|
|
|
RENDERPARM_JITTERTEXSCALE,
|
|
|
|
RENDERPARM_JITTERTEXOFFSET,
|
|
|
|
RENDERPARM_CASCADEDISTANCES,
|
|
|
|
|
|
|
|
RENDERPARM_SHADOW_MATRIX_0_X, // rpShadowMatrices[6 * 4]
|
|
|
|
RENDERPARM_SHADOW_MATRIX_0_Y,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_0_Z,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_0_W,
|
|
|
|
|
|
|
|
RENDERPARM_SHADOW_MATRIX_1_X,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_1_Y,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_1_Z,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_1_W,
|
|
|
|
|
|
|
|
RENDERPARM_SHADOW_MATRIX_2_X,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_2_Y,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_2_Z,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_2_W,
|
|
|
|
|
|
|
|
RENDERPARM_SHADOW_MATRIX_3_X,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_3_Y,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_3_Z,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_3_W,
|
|
|
|
|
|
|
|
RENDERPARM_SHADOW_MATRIX_4_X,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_4_Y,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_4_Z,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_4_W,
|
|
|
|
|
|
|
|
RENDERPARM_SHADOW_MATRIX_5_X,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_5_Y,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_5_Z,
|
|
|
|
RENDERPARM_SHADOW_MATRIX_5_W,
|
|
|
|
// RB end
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
RENDERPARM_TOTAL,
|
|
|
|
RENDERPARM_USER = 128,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
struct glslUniformLocation_t
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int parmIndex;
|
|
|
|
GLint uniformIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================================================================================
|
|
|
|
idRenderProgManager
|
|
|
|
================================================================================================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
class idRenderProgManager
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
|
|
|
idRenderProgManager();
|
|
|
|
virtual ~idRenderProgManager();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void Init();
|
|
|
|
void Shutdown();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void SetRenderParm( renderParm_t rp, const float* value );
|
|
|
|
void SetRenderParms( renderParm_t rp, const float* values, int numValues );
|
|
|
|
|
|
|
|
int FindVertexShader( const char* name );
|
|
|
|
int FindFragmentShader( const char* name );
|
|
|
|
|
2014-04-20 14:29:58 +00:00
|
|
|
// RB: added progIndex to handle many custom renderprogs
|
|
|
|
void BindShader( int progIndex, int vIndex, int fIndex, bool builtin );
|
|
|
|
// RB end
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void BindShader_GUI( )
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_GUI );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_Color( )
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_COLOR );
|
|
|
|
}
|
2014-05-10 12:40:01 +00:00
|
|
|
|
|
|
|
// RB begin
|
|
|
|
void BindShader_ColorSkinned( )
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_COLOR_SKINNED );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindShader_VertexColor( )
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_VERTEX_COLOR );
|
|
|
|
}
|
|
|
|
// RB end
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_Texture( )
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_TEXTURED );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_TextureVertexColor()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_TEXTURE_VERTEXCOLOR );
|
|
|
|
};
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_TextureVertexColorSkinned()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_TEXTURE_VERTEXCOLOR_SKINNED );
|
|
|
|
};
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_TextureTexGenVertexColor()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_TEXTURE_TEXGEN_VERTEXCOLOR );
|
|
|
|
};
|
|
|
|
void BindShader_Interaction()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_INTERACTION );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_InteractionSkinned()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_INTERACTION_SKINNED );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_InteractionAmbient()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_INTERACTION_AMBIENT );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_InteractionAmbientSkinned()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_INTERACTION_AMBIENT_SKINNED );
|
|
|
|
}
|
2014-05-10 12:40:01 +00:00
|
|
|
|
|
|
|
// RB begin
|
|
|
|
void BindShader_Interaction_ShadowMapping_Spot()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindShader_Interaction_ShadowMapping_Spot_Skinned()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT_SKINNED );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindShader_Interaction_ShadowMapping_Point()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_INTERACTION_SHADOW_MAPPING_POINT );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindShader_Interaction_ShadowMapping_Point_Skinned()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_INTERACTION_SHADOW_MAPPING_POINT_SKINNED );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindShader_Interaction_ShadowMapping_Parallel()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindShader_Interaction_ShadowMapping_Parallel_Skinned()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL_SKINNED );
|
|
|
|
}
|
|
|
|
// RB end
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_SimpleShade()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_SIMPLESHADE );
|
|
|
|
}
|
|
|
|
void BindShader_Environment()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_ENVIRONMENT );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_EnvironmentSkinned()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_ENVIRONMENT_SKINNED );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_BumpyEnvironment()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_BUMPY_ENVIRONMENT );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_BumpyEnvironmentSkinned()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_BUMPY_ENVIRONMENT_SKINNED );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindShader_Depth()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_DEPTH );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_DepthSkinned()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_DEPTH_SKINNED );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_Shadow()
|
|
|
|
{
|
2014-05-10 12:40:01 +00:00
|
|
|
// RB: no FFP fragment rendering anymore
|
|
|
|
//BindShader( -1, builtinShaders[BUILTIN_SHADOW], -1, true );
|
|
|
|
|
|
|
|
BindShader_Builtin( BUILTIN_SHADOW );
|
2014-04-20 14:29:58 +00:00
|
|
|
// RB end
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_ShadowSkinned()
|
|
|
|
{
|
2014-05-10 12:40:01 +00:00
|
|
|
// RB: no FFP fragment rendering anymore
|
|
|
|
//BindShader( -1, builtinShaders[BUILTIN_SHADOW_SKINNED], -1, true );
|
|
|
|
|
|
|
|
BindShader_Builtin( BUILTIN_SHADOW_SKINNED );
|
2014-04-20 14:29:58 +00:00
|
|
|
// RB end
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_ShadowDebug()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_SHADOW_DEBUG );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_ShadowDebugSkinned()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_SHADOW_DEBUG_SKINNED );
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindShader_BlendLight()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_BLENDLIGHT );
|
|
|
|
}
|
|
|
|
void BindShader_Fog()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_FOG );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_FogSkinned()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_FOG_SKINNED );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_SkyBox()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_SKYBOX );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_WobbleSky()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_WOBBLESKY );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_StereoDeGhost()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_STEREO_DEGHOST );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_StereoWarp()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_STEREO_WARP );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_StereoInterlace()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_STEREO_INTERLACE );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_PostProcess()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_POSTPROCESS );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
|
|
|
#if 0
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_ZCullReconstruct()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_ZCULL_RECONSTRUCT );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
#endif
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_Bink()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_BINK );
|
|
|
|
}
|
2014-04-20 14:29:58 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_BinkGUI()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_BINK_GUI );
|
|
|
|
}
|
|
|
|
void BindShader_MotionBlur()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_MOTION_BLUR );
|
|
|
|
}
|
|
|
|
|
2014-05-10 12:40:01 +00:00
|
|
|
void BindShader_DebugShadowMap()
|
|
|
|
{
|
|
|
|
BindShader_Builtin( BUILTIN_DEBUG_SHADOWMAP );
|
|
|
|
}
|
|
|
|
// RB end
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// the joints buffer should only be bound for vertex programs that use joints
|
2014-05-10 12:40:01 +00:00
|
|
|
bool ShaderUsesJoints() const
|
2012-11-28 15:47:07 +00:00
|
|
|
{
|
|
|
|
return vertexShaders[currentVertexShader].usesJoints;
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
// the rpEnableSkinning render parm should only be set for vertex programs that use it
|
2014-05-10 12:40:01 +00:00
|
|
|
bool ShaderHasOptionalSkinning() const
|
2012-11-28 15:47:07 +00:00
|
|
|
{
|
|
|
|
return vertexShaders[currentVertexShader].optionalSkinning;
|
|
|
|
}
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// unbind the currently bound render program
|
2014-05-10 12:40:01 +00:00
|
|
|
void Unbind();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2014-04-20 14:29:58 +00:00
|
|
|
// RB begin
|
2014-05-10 12:40:01 +00:00
|
|
|
bool IsShaderBound() const;
|
2014-04-20 14:29:58 +00:00
|
|
|
// RB end
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// this should only be called via the reload shader console command
|
2014-05-10 12:40:01 +00:00
|
|
|
void LoadAllShaders();
|
|
|
|
void KillAllShaders();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
static const int MAX_GLSL_USER_PARMS = 8;
|
|
|
|
const char* GetGLSLParmName( int rp ) const;
|
2012-11-28 15:47:07 +00:00
|
|
|
int GetGLSLCurrentProgram() const
|
|
|
|
{
|
|
|
|
return currentRenderProgram;
|
|
|
|
}
|
|
|
|
void SetUniformValue( const renderParm_t rp, const float* value );
|
2012-11-26 18:58:24 +00:00
|
|
|
void CommitUniforms();
|
|
|
|
int FindGLSLProgram( const char* name, int vIndex, int fIndex );
|
|
|
|
void ZeroUniforms();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
void LoadVertexShader( int index );
|
|
|
|
void LoadFragmentShader( int index );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
BUILTIN_GUI,
|
|
|
|
BUILTIN_COLOR,
|
2014-05-10 12:40:01 +00:00
|
|
|
// RB begin
|
|
|
|
BUILTIN_COLOR_SKINNED,
|
|
|
|
BUILTIN_VERTEX_COLOR,
|
|
|
|
// RB end
|
2012-11-26 18:58:24 +00:00
|
|
|
BUILTIN_SIMPLESHADE,
|
|
|
|
BUILTIN_TEXTURED,
|
|
|
|
BUILTIN_TEXTURE_VERTEXCOLOR,
|
|
|
|
BUILTIN_TEXTURE_VERTEXCOLOR_SKINNED,
|
|
|
|
BUILTIN_TEXTURE_TEXGEN_VERTEXCOLOR,
|
|
|
|
BUILTIN_INTERACTION,
|
|
|
|
BUILTIN_INTERACTION_SKINNED,
|
|
|
|
BUILTIN_INTERACTION_AMBIENT,
|
|
|
|
BUILTIN_INTERACTION_AMBIENT_SKINNED,
|
2014-05-10 12:40:01 +00:00
|
|
|
// RB begin
|
|
|
|
BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT,
|
|
|
|
BUILTIN_INTERACTION_SHADOW_MAPPING_SPOT_SKINNED,
|
|
|
|
BUILTIN_INTERACTION_SHADOW_MAPPING_POINT,
|
|
|
|
BUILTIN_INTERACTION_SHADOW_MAPPING_POINT_SKINNED,
|
|
|
|
BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL,
|
|
|
|
BUILTIN_INTERACTION_SHADOW_MAPPING_PARALLEL_SKINNED,
|
|
|
|
// RB end
|
2012-11-26 18:58:24 +00:00
|
|
|
BUILTIN_ENVIRONMENT,
|
|
|
|
BUILTIN_ENVIRONMENT_SKINNED,
|
|
|
|
BUILTIN_BUMPY_ENVIRONMENT,
|
|
|
|
BUILTIN_BUMPY_ENVIRONMENT_SKINNED,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
BUILTIN_DEPTH,
|
|
|
|
BUILTIN_DEPTH_SKINNED,
|
|
|
|
BUILTIN_SHADOW,
|
|
|
|
BUILTIN_SHADOW_SKINNED,
|
|
|
|
BUILTIN_SHADOW_DEBUG,
|
|
|
|
BUILTIN_SHADOW_DEBUG_SKINNED,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
BUILTIN_BLENDLIGHT,
|
|
|
|
BUILTIN_FOG,
|
|
|
|
BUILTIN_FOG_SKINNED,
|
|
|
|
BUILTIN_SKYBOX,
|
|
|
|
BUILTIN_WOBBLESKY,
|
|
|
|
BUILTIN_POSTPROCESS,
|
|
|
|
BUILTIN_STEREO_DEGHOST,
|
|
|
|
BUILTIN_STEREO_WARP,
|
|
|
|
BUILTIN_ZCULL_RECONSTRUCT,
|
|
|
|
BUILTIN_BINK,
|
|
|
|
BUILTIN_BINK_GUI,
|
|
|
|
BUILTIN_STEREO_INTERLACE,
|
|
|
|
BUILTIN_MOTION_BLUR,
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2014-05-10 12:40:01 +00:00
|
|
|
BUILTIN_DEBUG_SHADOWMAP,
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
MAX_BUILTINS
|
|
|
|
};
|
|
|
|
int builtinShaders[MAX_BUILTINS];
|
2012-11-28 15:47:07 +00:00
|
|
|
void BindShader_Builtin( int i )
|
|
|
|
{
|
2014-04-20 14:29:58 +00:00
|
|
|
BindShader( -1, builtinShaders[i], builtinShaders[i], true );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
|
2014-05-10 12:40:01 +00:00
|
|
|
enum shaderFeature_t
|
|
|
|
{
|
|
|
|
USE_GPU_SKINNING,
|
|
|
|
LIGHT_POINT,
|
|
|
|
LIGHT_PARALLEL,
|
|
|
|
|
|
|
|
MAX_SHADER_MACRO_NAMES,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char* GLSLMacroNames[MAX_SHADER_MACRO_NAMES];
|
|
|
|
const char* GetGLSLMacroName( shaderFeature_t sf ) const;
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
bool CompileGLSL( GLenum target, const char* name );
|
2014-05-10 12:40:01 +00:00
|
|
|
GLuint LoadGLSLShader( GLenum target, const char* name, const char* nameOutSuffix, uint32 shaderFeatures, bool builtin, idList<int>& uniforms );
|
2012-11-26 18:58:24 +00:00
|
|
|
void LoadGLSLProgram( const int programIndex, const int vertexShaderIndex, const int fragmentShaderIndex );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
static const GLuint INVALID_PROGID = 0xFFFFFFFF;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
struct vertexShader_t
|
|
|
|
{
|
2014-05-10 12:40:01 +00:00
|
|
|
vertexShader_t() : progId( INVALID_PROGID ), usesJoints( false ), optionalSkinning( false ), shaderFeatures( 0 ), builtin( false ) {}
|
2012-11-26 18:58:24 +00:00
|
|
|
idStr name;
|
2014-05-10 12:40:01 +00:00
|
|
|
idStr nameOutSuffix;
|
2012-11-26 18:58:24 +00:00
|
|
|
GLuint progId;
|
|
|
|
bool usesJoints;
|
|
|
|
bool optionalSkinning;
|
2014-05-10 12:40:01 +00:00
|
|
|
uint32 shaderFeatures; // RB: Cg compile macros
|
|
|
|
bool builtin; // RB: part of the core shaders built into the executable
|
2012-11-26 18:58:24 +00:00
|
|
|
idList<int> uniforms;
|
|
|
|
};
|
2012-11-28 15:47:07 +00:00
|
|
|
struct fragmentShader_t
|
|
|
|
{
|
2014-05-10 12:40:01 +00:00
|
|
|
fragmentShader_t() : progId( INVALID_PROGID ), shaderFeatures( 0 ), builtin( false ) {}
|
2012-11-26 18:58:24 +00:00
|
|
|
idStr name;
|
2014-05-10 12:40:01 +00:00
|
|
|
idStr nameOutSuffix;
|
2012-11-26 18:58:24 +00:00
|
|
|
GLuint progId;
|
2014-05-10 12:40:01 +00:00
|
|
|
uint32 shaderFeatures;
|
|
|
|
bool builtin;
|
2012-11-26 18:58:24 +00:00
|
|
|
idList<int> uniforms;
|
|
|
|
};
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
struct glslProgram_t
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
glslProgram_t() : progId( INVALID_PROGID ),
|
2012-11-28 15:47:07 +00:00
|
|
|
vertexShaderIndex( -1 ),
|
|
|
|
fragmentShaderIndex( -1 ),
|
|
|
|
vertexUniformArray( -1 ),
|
|
|
|
fragmentUniformArray( -1 ) {}
|
2012-11-26 18:58:24 +00:00
|
|
|
idStr name;
|
|
|
|
GLuint progId;
|
|
|
|
int vertexShaderIndex;
|
|
|
|
int fragmentShaderIndex;
|
|
|
|
GLint vertexUniformArray;
|
|
|
|
GLint fragmentUniformArray;
|
|
|
|
idList<glslUniformLocation_t> uniformLocations;
|
|
|
|
};
|
|
|
|
int currentRenderProgram;
|
2014-05-10 12:40:01 +00:00
|
|
|
idList<glslProgram_t> glslPrograms;
|
2012-11-28 15:47:07 +00:00
|
|
|
idStaticList < idVec4, RENDERPARM_USER + MAX_GLSL_USER_PARMS > glslUniforms;
|
|
|
|
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int currentVertexShader;
|
|
|
|
int currentFragmentShader;
|
2014-05-10 12:40:01 +00:00
|
|
|
idList<vertexShader_t > vertexShaders;
|
|
|
|
idList<fragmentShader_t > fragmentShaders;
|
2012-11-26 18:58:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern idRenderProgManager renderProgManager;
|
|
|
|
|
|
|
|
#endif
|