Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions client/render/gl_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,18 @@ void GL_ClipPlane( bool enable )
}
}

/*
=================
GL_InitClipPlane
=================
*/
void GL_InitClipPlane( const mplane_t *in, GLdouble *out )
{
out[0] = in->normal[0];
out[1] = in->normal[1];
out[2] = in->normal[2];
out[3] = -in->dist;
}

/*
=================
Expand Down
17 changes: 17 additions & 0 deletions client/render/gl_cubemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,23 @@ static void GL_FilterCubemapSpecularIBL(mcubemap_t *cubemap)
projectionMatrix.CopyToArray(matrixBuffer);
u->SetValue(&matrixBuffer[0]);
break;
case UT_MODELVIEWMATRIX:
u->SetValue(&RI->view.worldMatrix);
break;
case UT_MODELVIEWPROJECTIONMATRIX:
u->SetValue(&RI->view.worldProjectionMatrix);
break;
case UT_CLIPPLANE:
{
GLdouble clip[4];
mplane_t *p = &RI->clipPlane;

GL_InitClipPlane(p, clip);

u->SetValue(clip);

break;
}
}
}
COpenGLUnitCube::GetInstance().Draw();
Expand Down
16 changes: 16 additions & 0 deletions client/render/gl_decals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,23 @@ void R_SetDecalUniforms( brushdecal_t *decal )
break;
case UT_SWAYHEIGHT:
u->SetValue(desc->swayHeight);
case UT_MODELVIEWMATRIX:
u->SetValue(&RI->view.worldMatrix);
break;
case UT_MODELVIEWPROJECTIONMATRIX:
u->SetValue(&RI->view.worldProjectionMatrix);
break;
case UT_CLIPPLANE:
{
GLdouble clip[4];
mplane_t *p = &RI->clipPlane;

GL_InitClipPlane(p, clip);

u->SetValue(clip);

break;
}
default:
ALERT( at_error, "%s: unhandled uniform %s\n", RI->currentshader->name, u->name );
break;
Expand Down
8 changes: 8 additions & 0 deletions client/render/gl_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ static dllfunc_t opengl_200funcs[] =
{ NULL, NULL }
};

static dllfunc_t opengl_310funcs[] =
{
{ "glGetUniformBlockIndex" , (void **)&pglGetUniformBlockIndex },
{ "glUniformBlockBinding" , (void **)&pglUniformBlockBinding },
{ NULL, NULL }
};

static dllfunc_t drawrangeelementsextfuncs[] =
{
{ "glDrawRangeElementsEXT" , (void **)&pglDrawRangeElements },
Expand Down Expand Up @@ -533,6 +540,7 @@ static void GL_InitExtensions( void )
// initialize gl extensions
GL_CheckExtension("OpenGL 1.1.0", opengl_110funcs, NULL, R_OPENGL_110);
GL_CheckExtension("OpenGL 2.0", opengl_200funcs, NULL, R_OPENGL_200);
GL_CheckExtension("OpenGL 3.1", opengl_310funcs, NULL, R_OPENGL_310);

if (!GL_Support(R_OPENGL_110))
{
Expand Down
8 changes: 8 additions & 0 deletions client/render/gl_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,12 @@ typedef unsigned int GLhandleARB;
#define GL_ACTIVE_UNIFORMS 0x8B86
#define GL_SHADER_SOURCE_LENGTH 0x8B88

#define GL_UNIFORM_BUFFER 0x8A11
#define GL_UNIFORM_BUFFER_BINDING 0x8A28
#define GL_UNIFORM_BUFFER_START 0x8A29
#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
#define GL_INVALID_INDEX 0xFFFFFFFFu

// GL_NV_alpha_to_coverage_dither_control
#define GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV 0x934D
#define GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV 0x934E
Expand Down Expand Up @@ -1311,6 +1317,8 @@ EXTERN void (APIENTRY *pglGetShaderInfoLog)(GLuint shader, GLsizei maxLength, GL
EXTERN void (APIENTRY *pglGetProgramInfoLog)(GLuint program, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
EXTERN void (APIENTRY *pglGetActiveUniform)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
EXTERN GLint (APIENTRY *pglGetUniformLocation)(GLuint program, const GLcharARB *name);
EXTERN GLuint (APIENTRY *pglGetUniformBlockIndex)(GLuint program, const GLcharARB *uniformBlockName);
EXTERN void (APIENTRY *pglUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);

EXTERN void ( APIENTRY *pglProgramStringARB)(GLenum target, GLenum format, GLsizei len, const void *string);
EXTERN void ( APIENTRY *pglProgramEnvParameter4fARB)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
Expand Down
19 changes: 18 additions & 1 deletion client/render/gl_grass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,24 @@ void R_SetGrassUniforms( word hProgram, grass_t *grass )
break;
case UT_GRASSPARAMS:
u->SetValue( m_flGrassFadeStart, m_flGrassFadeDist, m_flGrassFadeEnd );
break;
break;
case UT_MODELVIEWMATRIX:
u->SetValue(&RI->view.worldMatrix);
break;
case UT_MODELVIEWPROJECTIONMATRIX:
u->SetValue(&RI->view.worldProjectionMatrix);
break;
case UT_CLIPPLANE:
{
GLdouble clip[4];
mplane_t *p = &RI->clipPlane;

GL_InitClipPlane(p, clip);

u->SetValue(clip);

break;
}
default:
ALERT( at_error, "%s: unhandled uniform %s\n", RI->currentshader->name, u->name );
break;
Expand Down
2 changes: 2 additions & 0 deletions client/render/gl_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ enum
{
R_OPENGL_110 = 0, // base
R_OPENGL_200,
R_OPENGL_310,
R_WGL_PROCADDRESS,
R_ARB_VERTEX_BUFFER_OBJECT_EXT,
R_ARB_VERTEX_ARRAY_OBJECT_EXT,
Expand Down Expand Up @@ -763,6 +764,7 @@ void GL_DisableAllTexGens(void);
void GL_DepthMask(GLint enable);
void GL_FrontFace(GLenum front);
void GL_ClipPlane(bool enable);
void GL_InitClipPlane( const mplane_t *in, GLdouble *out );
void GL_BindFBO(GLuint buffer);
void GL_AlphaTest(GLint enable);
void GL_AlphaToCoverage(bool enable);
Expand Down
4 changes: 4 additions & 0 deletions client/render/gl_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ static uniformTable_t glsl_uniformTable[] =
{ "u_LightScale", UT_LIGHTSCALE, UFL_GLOBAL_PARM },
{ "u_LightThreshold", UT_LIGHTTHRESHOLD, UFL_GLOBAL_PARM },
{ "u_NumVisibleModels", UT_NUMVISIBLEMODELS, UFL_GLOBAL_PARM },
{ "u_ModelViewMatrix", UT_MODELVIEWMATRIX, 0 },
{ "u_ModelViewProjectionMatrix", UT_MODELVIEWPROJECTIONMATRIX, 0 },
{ "u_ClipPlane", UT_CLIPPLANE, 0 },
{ "u_Undefined", UT_UNDEFINED, 0 },
};

Expand Down Expand Up @@ -717,6 +720,7 @@ static bool GL_ProcessShader( glsl_program_t *program, const char *filename, GLe

// add internal defines
outputFile->Printf("#version 130\n"); // OpenGL 3.0 required (because bit operations support needed)
outputFile->Printf("#extension GL_ARB_uniform_buffer_object : enable\n");
outputFile->Printf("#ifndef M_PI\n#define M_PI 3.14159265358979323846\n#endif\n");
outputFile->Printf("#ifndef M_PI2\n#define M_PI2 6.28318530717958647692\n#endif\n");

Expand Down
3 changes: 3 additions & 0 deletions client/render/gl_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ typedef enum
UT_LIGHTSCALE,
UT_LIGHTTHRESHOLD,
UT_NUMVISIBLEMODELS,
UT_MODELVIEWMATRIX,
UT_MODELVIEWPROJECTIONMATRIX,
UT_CLIPPLANE,
UT_UNDEFINED,
} uniformType_t;

Expand Down
17 changes: 17 additions & 0 deletions client/render/gl_sky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,23 @@ static void GL_DrawSkySide( word hProgram, int skyside )
case UT_ZFAR:
u->SetValue( RI->view.farClip );
break;
case UT_MODELVIEWMATRIX:
u->SetValue(&RI->view.worldMatrix);
break;
case UT_MODELVIEWPROJECTIONMATRIX:
u->SetValue(&RI->view.worldProjectionMatrix);
break;
case UT_CLIPPLANE:
{
GLdouble clip[4];
mplane_t *p = &RI->clipPlane;

GL_InitClipPlane(p, clip);

u->SetValue(clip);

break;
}
default:
ALERT( at_error, "%s: unhandled uniform %s\n", RI->currentshader->name, u->name );
break;
Expand Down
17 changes: 17 additions & 0 deletions client/render/gl_studio_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3707,6 +3707,23 @@ void CStudioModelRenderer :: DrawSingleMesh( CSolidEntry *entry, bool force, boo
case UT_SWAYHEIGHT:
u->SetValue(mat->swayHeight);
break;
case UT_MODELVIEWMATRIX:
u->SetValue( &RI->view.worldMatrix );
break;
case UT_MODELVIEWPROJECTIONMATRIX:
u->SetValue( &RI->view.worldProjectionMatrix );
break;
case UT_CLIPPLANE:
{
GLdouble clip[4];
mplane_t *p = &RI->clipPlane;

GL_InitClipPlane(p, clip);

u->SetValue(clip);

break;
}
default:
ALERT( at_error, "%s: unhandled uniform %s\n", RI->currentshader->name, u->name );
break;
Expand Down
17 changes: 17 additions & 0 deletions client/render/gl_studiodecal_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,23 @@ void CStudioModelRenderer :: SetDecalUniforms( studiodecal_t *pDecal )
height = pDecal->texinfo->gl_heightmap_id.GetHeight();
u->SetValue( (float)width, (float)height, pDecal->texinfo->matdesc->reliefScale, cv_shadow_offset->value );
break;
case UT_MODELVIEWMATRIX:
u->SetValue(&RI->view.worldMatrix);
break;
case UT_MODELVIEWPROJECTIONMATRIX:
u->SetValue(&RI->view.worldProjectionMatrix);
break;
case UT_CLIPPLANE:
{
GLdouble clip[4];
mplane_t *p = &RI->clipPlane;

GL_InitClipPlane(p, clip);

u->SetValue(clip);

break;
}
default:
ALERT( at_error, "Unhandled uniform %s\n", u->name );
break;
Expand Down
17 changes: 17 additions & 0 deletions client/render/gl_world_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2868,6 +2868,23 @@ void R_SetSurfaceUniforms( word hProgram, msurface_t *surface, bool force )
case UT_LIGHTNUMS1:
u->SetValue( (float)e->lights[4], (float)e->lights[5], (float)e->lights[6], (float)e->lights[7] );
break;
case UT_MODELVIEWMATRIX:
u->SetValue(&RI->view.worldMatrix);
break;
case UT_MODELVIEWPROJECTIONMATRIX:
u->SetValue(&RI->view.worldProjectionMatrix);
break;
case UT_CLIPPLANE:
{
GLdouble clip[4];
mplane_t *p = &RI->clipPlane;

GL_InitClipPlane(p, clip);

u->SetValue(clip);

break;
}
default:
ALERT( at_error, "%s: unhandled uniform %s\n", RI->currentshader->name, u->name );
break;
Expand Down
4 changes: 2 additions & 2 deletions game_dir/glsl/cubemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ vec3 CubemapProbeInternal( const vec3 vPos, const vec3 vView, const vec3 nWorld,
vec3 wRef = normalize( reflect( I, NW ));
vec3 R1 = CubemapBoxParallaxCorrected( wRef, vPos, u_CubeOrigin[0], u_BoxMins[0], u_BoxMaxs[0] );
vec3 R2 = CubemapBoxParallaxCorrected( wRef, vPos, u_CubeOrigin[1], u_BoxMins[1], u_BoxMaxs[1] );
vec3 srcColor0 = textureCubeLod( cubemap0, R1, u_CubeMipCount.x - smoothness * u_CubeMipCount.x ).rgb;
vec3 srcColor1 = textureCubeLod( cubemap1, R2, u_CubeMipCount.y - smoothness * u_CubeMipCount.y ).rgb;
vec3 srcColor0 = textureLod( cubemap0, R1, u_CubeMipCount.x - smoothness * u_CubeMipCount.x ).rgb;
vec3 srcColor1 = textureLod( cubemap1, R2, u_CubeMipCount.y - smoothness * u_CubeMipCount.y ).rgb;
vec3 reflectance = mix( srcColor0, srcColor1, u_LerpFactor );
return reflectance;
}
Expand Down
7 changes: 5 additions & 2 deletions game_dir/glsl/forward/decal_bmodel_vp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ uniform float u_LightStyleValues[MAX_LIGHTSTYLES];
uniform vec3 u_ViewOrigin; // already in modelspace
uniform mat4 u_ModelMatrix;
uniform mat4 u_ReflectMatrix;
uniform mat4 u_ModelViewMatrix;
uniform mat4 u_ModelViewProjectionMatrix;
uniform vec4 u_ClipPlane;

varying vec4 var_TexDiffuse;
varying vec3 var_TexLight0;
Expand All @@ -51,8 +54,8 @@ void main( void )
vec4 position = vec4( attr_Position, 1.0 );
vec4 worldpos = u_ModelMatrix * position;

gl_Position = gl_ModelViewProjectionMatrix * worldpos;
gl_ClipVertex = gl_ModelViewMatrix * worldpos;
gl_Position = u_ModelViewProjectionMatrix * worldpos;
gl_ClipDistance[0] = dot( worldpos, u_ClipPlane );

// compute TBN
mat3 tbn = ComputeTBN( u_ModelMatrix );
Expand Down
7 changes: 5 additions & 2 deletions game_dir/glsl/forward/decal_studio_vp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ uniform float u_Smoothness;
uniform vec3 u_LightDiffuse;
uniform vec2 u_LightShade;
uniform vec3 u_LightDir;
uniform mat4 u_ModelViewMatrix;
uniform mat4 u_ModelViewProjectionMatrix;
uniform vec4 u_ClipPlane;

#if defined (VERTEX_LIGHTING)
uniform float u_LightGamma;
Expand All @@ -59,8 +62,8 @@ void main( void )
mat4 boneMatrix = ComputeSkinningMatrix();
vec4 worldpos = boneMatrix * position;

gl_Position = gl_ModelViewProjectionMatrix * worldpos;
gl_ClipVertex = gl_ModelViewMatrix * worldpos;
gl_Position = u_ModelViewProjectionMatrix * worldpos;
gl_ClipDistance[0] = dot( worldpos, u_ClipPlane );

// compute TBN
mat3 tbn = ComputeTBN( boneMatrix );
Expand Down
8 changes: 6 additions & 2 deletions game_dir/glsl/forward/depth_bmodel_vp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ GNU General Public License for more details.
attribute vec3 attr_Position;
attribute vec2 attr_TexCoord0;

uniform mat4 u_ModelViewMatrix;
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
uniform vec4 u_ClipPlane;
uniform vec2 u_TexOffset;


varying vec2 var_TexCoord; // for alpha-testing

void main( void )
Expand All @@ -27,8 +31,8 @@ void main( void )
vec4 worldpos = u_ModelMatrix * position;

// transform vertex position into homogenous clip-space
gl_Position = gl_ModelViewProjectionMatrix * worldpos;
gl_ClipVertex = gl_ModelViewMatrix * worldpos;
gl_Position = u_ModelViewProjectionMatrix * worldpos;
gl_ClipDistance[0] = dot( worldpos, u_ClipPlane );

var_TexCoord = attr_TexCoord0 + u_TexOffset;
}
7 changes: 5 additions & 2 deletions game_dir/glsl/forward/depth_grass_vp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ GNU General Public License for more details.
attribute vec4 attr_Position;
attribute vec4 attr_Normal;

uniform mat4 u_ModelViewMatrix;
uniform mat4 u_ModelViewProjectionMatrix;
uniform mat4 u_ModelMatrix;
uniform vec3 u_GrassParams;
uniform vec3 u_ViewOrigin;
uniform float u_RealTime;
uniform vec4 u_ClipPlane;

varying vec2 var_TexDiffuse;

Expand All @@ -46,7 +49,7 @@ void main( void )
}

vec4 worldpos = u_ModelMatrix * position;
gl_Position = gl_ModelViewProjectionMatrix * worldpos;
gl_Position = u_ModelViewProjectionMatrix * worldpos;
var_TexDiffuse = GetTexCoordsForVertex( int( attr_Normal.w ));
gl_ClipVertex = gl_ModelViewMatrix * worldpos;
gl_ClipDistance[0] = dot( worldpos, u_ClipPlane );
}
Loading
Loading