From 51ec6c8b5b27a8090390599b6d5fe54727011ec5 Mon Sep 17 00:00:00 2001 From: slipher Date: Fri, 4 Jun 2021 22:03:38 -0500 Subject: [PATCH 1/4] Add a generated CBSE header in sources list --- cmake/DaemonCBSE.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/DaemonCBSE.cmake b/cmake/DaemonCBSE.cmake index 2f1db353ad..b3648deafa 100644 --- a/cmake/DaemonCBSE.cmake +++ b/cmake/DaemonCBSE.cmake @@ -50,7 +50,8 @@ function(CBSE target definition output) endif() set(GENERATED_CBSE ${output}/backend/CBSEBackend.cpp ${output}/backend/CBSEBackend.h - ${output}/backend/CBSEComponents.h) + ${output}/backend/CBSEComponents.h + ${output}/backend/CBSEEntities.h) add_custom_command( OUTPUT ${GENERATED_CBSE} COMMENT "Generating CBSE entities for ${definition}" From cd0087a2ff8d06fa5102ebb435e689caba512e11 Mon Sep 17 00:00:00 2001 From: slipher Date: Fri, 4 Jun 2021 22:07:32 -0500 Subject: [PATCH 2/4] Remove unused shader lightVolume_omni --- src.cmake | 2 - src/engine/renderer/gl_shader.cpp | 24 --- src/engine/renderer/gl_shader.h | 18 --- .../glsl_source/lightVolume_omni_fp.glsl | 146 ------------------ .../glsl_source/lightVolume_omni_vp.glsl | 33 ---- src/engine/renderer/shaders.cpp | 4 - src/engine/renderer/tr_shade.cpp | 1 - 7 files changed, 228 deletions(-) delete mode 100644 src/engine/renderer/glsl_source/lightVolume_omni_fp.glsl delete mode 100644 src/engine/renderer/glsl_source/lightVolume_omni_vp.glsl diff --git a/src.cmake b/src.cmake index 9661dbe9e7..9752a88f45 100644 --- a/src.cmake +++ b/src.cmake @@ -178,8 +178,6 @@ set(GLSLSOURCELIST ${ENGINE_DIR}/renderer/glsl_source/lightMapping_vp.glsl ${ENGINE_DIR}/renderer/glsl_source/lighttile_fp.glsl ${ENGINE_DIR}/renderer/glsl_source/lighttile_vp.glsl - ${ENGINE_DIR}/renderer/glsl_source/lightVolume_omni_fp.glsl - ${ENGINE_DIR}/renderer/glsl_source/lightVolume_omni_vp.glsl ${ENGINE_DIR}/renderer/glsl_source/liquid_fp.glsl ${ENGINE_DIR}/renderer/glsl_source/liquid_vp.glsl ${ENGINE_DIR}/renderer/glsl_source/motionblur_fp.glsl diff --git a/src/engine/renderer/gl_shader.cpp b/src/engine/renderer/gl_shader.cpp index ba1e52e87f..a069bbdf2e 100644 --- a/src/engine/renderer/gl_shader.cpp +++ b/src/engine/renderer/gl_shader.cpp @@ -54,7 +54,6 @@ GLShader_blurX *gl_blurXShader = nullptr; GLShader_blurY *gl_blurYShader = nullptr; GLShader_debugShadowMap *gl_debugShadowMapShader = nullptr; GLShader_depthToColor *gl_depthToColorShader = nullptr; -GLShader_lightVolume_omni *gl_lightVolumeShader_omni = nullptr; GLShader_liquid *gl_liquidShader = nullptr; GLShader_volumetricFog *gl_volumetricFogShader = nullptr; GLShader_motionblur *gl_motionblurShader = nullptr; @@ -2078,29 +2077,6 @@ void GLShader_depthToColor::BuildShaderVertexLibNames( std::string& vertexInline vertexInlines += "vertexSimple vertexSkinning "; } -GLShader_lightVolume_omni::GLShader_lightVolume_omni( GLShaderManager *manager ) : - GLShader( "lightVolume_omni", ATTR_POSITION, manager ), - u_ViewOrigin( this ), - u_LightOrigin( this ), - u_LightColor( this ), - u_LightRadius( this ), - u_LightScale( this ), - u_LightAttenuationMatrix( this ), - u_ModelViewProjectionMatrix( this ), - u_UnprojectMatrix( this ), - GLCompileMacro_USE_SHADOWING( this ) -{ -} - -void GLShader_lightVolume_omni::SetShaderProgramUniforms( shaderProgram_t *shaderProgram ) -{ - glUniform1i( glGetUniformLocation( shaderProgram->program, "u_DepthMap" ), 0 ); - glUniform1i( glGetUniformLocation( shaderProgram->program, "u_AttenuationMapXY" ), 1 ); - glUniform1i( glGetUniformLocation( shaderProgram->program, "u_AttenuationMapZ" ), 2 ); - glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowMap" ), 3 ); - glUniform1i( glGetUniformLocation( shaderProgram->program, "u_ShadowClipMap" ), 4 ); -} - GLShader_liquid::GLShader_liquid( GLShaderManager *manager ) : GLShader( "liquid", ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ), u_TextureMatrix( this ), diff --git a/src/engine/renderer/gl_shader.h b/src/engine/renderer/gl_shader.h index ce6e9e943c..e9c69b2b6a 100644 --- a/src/engine/renderer/gl_shader.h +++ b/src/engine/renderer/gl_shader.h @@ -2588,23 +2588,6 @@ class GLShader_depthToColor : void BuildShaderVertexLibNames( std::string& vertexInlines ); }; -class GLShader_lightVolume_omni : - public GLShader, - public u_ViewOrigin, - public u_LightOrigin, - public u_LightColor, - public u_LightRadius, - public u_LightScale, - public u_LightAttenuationMatrix, - public u_ModelViewProjectionMatrix, - public u_UnprojectMatrix, - public GLCompileMacro_USE_SHADOWING -{ -public: - GLShader_lightVolume_omni( GLShaderManager *manager ); - void SetShaderProgramUniforms( shaderProgram_t *shaderProgram ); -}; - class GLShader_liquid : public GLShader, public u_TextureMatrix, @@ -2726,7 +2709,6 @@ extern GLShader_blurX *gl_blurXShader; extern GLShader_blurY *gl_blurYShader; extern GLShader_debugShadowMap *gl_debugShadowMapShader; extern GLShader_depthToColor *gl_depthToColorShader; -extern GLShader_lightVolume_omni *gl_lightVolumeShader_omni; extern GLShader_liquid *gl_liquidShader; extern GLShader_volumetricFog *gl_volumetricFogShader; extern GLShader_motionblur *gl_motionblurShader; diff --git a/src/engine/renderer/glsl_source/lightVolume_omni_fp.glsl b/src/engine/renderer/glsl_source/lightVolume_omni_fp.glsl deleted file mode 100644 index 33e39375fb..0000000000 --- a/src/engine/renderer/glsl_source/lightVolume_omni_fp.glsl +++ /dev/null @@ -1,146 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2007-2009 Robert Beckebans - -This file is part of XreaL source code. - -XreaL 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 2 of the License, -or (at your option) any later version. - -XreaL 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 XreaL source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -/* lightVolume_omni_fp.glsl */ - -/* swizzle one- and two-component textures to RG */ -#ifdef TEXTURE_RG -# define SWIZ1 r -# define SWIZ2 rg -#else -# define SWIZ1 a -# define SWIZ2 ar -#endif - -uniform sampler2D u_DepthMap; -uniform sampler2D u_AttenuationMapXY; -uniform sampler2D u_AttenuationMapZ; -uniform samplerCube u_ShadowMap; -uniform vec3 u_ViewOrigin; -uniform vec3 u_LightOrigin; -uniform vec3 u_LightColor; -uniform float u_LightRadius; -uniform float u_LightScale; -uniform mat4 u_LightAttenuationMatrix; -uniform mat4 u_UnprojectMatrix; - -IN(smooth) vec3 var_TexAttenXYZ; - -DECLARE_OUTPUT(vec4) - -void main() -{ - // calculate the screen texcoord in the 0.0 to 1.0 range - vec2 st = gl_FragCoord.st / r_FBufSize; - - // reconstruct vertex position in world space - float depth = texture2D(u_DepthMap, st).r; - vec4 P = u_UnprojectMatrix * vec4(gl_FragCoord.xy, depth, 1.0); - P.xyz /= P.w; - - // compute incident ray in world space - vec3 incidentRay = normalize(P.xyz - u_ViewOrigin); - //vec3 incidentRay = normalize(u_ViewOrigin - P.xyz); - - //float traceDistance = dot(P.xyz - (u_ViewOrigin.xyz + incidentRay * u_ZNear ), forward); - //traceDistance = clamp(traceDistance, 0.0, 2500.0 ); // Far trace distance - - float traceDistance = distance(P.xyz, u_ViewOrigin); - traceDistance = clamp(traceDistance, 0.0, 2500.0); - - // TODO move to front clipping plane - - vec4 color = vec4(0.0, 0.0, 0.0, 1.0); - - //int steps = 40; - //float stepSize = traceDistance / float(steps); - - int steps = int(min(traceDistance, 2000.0)); // TODO r_MaxSteps - float stepSize = 64.0; - - for(float tracedDistance = 0.0; tracedDistance < traceDistance; tracedDistance += stepSize) - { - //vec3 T = P.xyz + (incidentRay * stepSize * float(i)); - //vec3 T = u_ViewOrigin + (incidentRay * stepSize * float(i)); - vec3 T = u_ViewOrigin + (incidentRay * tracedDistance); - - // compute attenuation - vec3 texAttenXYZ = (u_LightAttenuationMatrix * vec4(T, 1.0)).xyz; - vec3 attenuationXY = texture2D(u_AttenuationMapXY, texAttenXYZ.xy).rgb; - vec3 attenuationZ = texture2D(u_AttenuationMapZ, vec2(texAttenXYZ.z, 0)).rgb; - - float shadow = 1.0; - -#if defined(VSM) -#if defined(USE_SHADOWING) - { - // compute incident ray - vec3 I2 = T - u_LightOrigin; - - vec2 shadowMoments = textureCube(u_ShadowMap, I2).SWIZ2; - -#if defined(VSM_CLAMP) - // convert to [-1, 1] vector space - shadowMoments = 0.5 * (shadowMoments + 1.0); -#endif - - float shadowDistance = shadowMoments.r; - float shadowDistanceSquared = shadowMoments.g; - - const float SHADOW_BIAS = 0.001; - float vertexDistance = length(I2) / u_LightRadius - SHADOW_BIAS; - - // standard shadow map comparison - shadow = vertexDistance <= shadowDistance ? 1.0 : 0.0; - - // variance shadow mapping - float E_x2 = shadowDistanceSquared; - float Ex_2 = shadowDistance * shadowDistance; - - // AndyTX: VSM_EPSILON is there to avoid some ugly numeric instability with fp16 - float variance = min(max(E_x2 - Ex_2, 0.0) + VSM_EPSILON, 1.0); - - float mD = shadowDistance - vertexDistance; - float mD_2 = mD * mD; - float p = variance / (variance + mD_2); - - color.rgb += attenuationXY * attenuationZ * max(shadow, p); - } - - if(shadow <= 0.0) - { - continue; - } - else -#endif -#endif - { - color.rgb += attenuationXY * attenuationZ; - } - } - - color.rgb /= float(steps); - color.rgb *= u_LightColor; - //color.rgb *= u_LightScale; - - outputColor = color; -} diff --git a/src/engine/renderer/glsl_source/lightVolume_omni_vp.glsl b/src/engine/renderer/glsl_source/lightVolume_omni_vp.glsl deleted file mode 100644 index 819e3d66cc..0000000000 --- a/src/engine/renderer/glsl_source/lightVolume_omni_vp.glsl +++ /dev/null @@ -1,33 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2007-2009 Robert Beckebans - -This file is part of XreaL source code. - -XreaL 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 2 of the License, -or (at your option) any later version. - -XreaL 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 XreaL source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -/* lightVolume_omni_vp.glsl */ - -IN vec3 attr_Position; - -uniform mat4 u_ModelViewProjectionMatrix; - -void main() -{ - // transform vertex position into homogenous clip-space - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); -} diff --git a/src/engine/renderer/shaders.cpp b/src/engine/renderer/shaders.cpp index 98c02afee8..22282590a2 100644 --- a/src/engine/renderer/shaders.cpp +++ b/src/engine/renderer/shaders.cpp @@ -46,8 +46,6 @@ #include "lightMapping_vp.glsl.h" #include "lighttile_fp.glsl.h" #include "lighttile_vp.glsl.h" -#include "lightVolume_omni_fp.glsl.h" -#include "lightVolume_omni_vp.glsl.h" #include "liquid_fp.glsl.h" #include "liquid_vp.glsl.h" #include "motionblur_fp.glsl.h" @@ -101,8 +99,6 @@ std::unordered_map shadermap({ { "glsl/heatHaze_vp.glsl", std::string(reinterpret_cast(heatHaze_vp_glsl), sizeof(heatHaze_vp_glsl)) }, { "glsl/lightMapping_fp.glsl", std::string(reinterpret_cast(lightMapping_fp_glsl), sizeof(lightMapping_fp_glsl)) }, { "glsl/lightMapping_vp.glsl", std::string(reinterpret_cast(lightMapping_vp_glsl), sizeof(lightMapping_vp_glsl)) }, - { "glsl/lightVolume_omni_fp.glsl", std::string(reinterpret_cast(lightVolume_omni_fp_glsl), sizeof(lightVolume_omni_fp_glsl)) }, - { "glsl/lightVolume_omni_vp.glsl", std::string(reinterpret_cast(lightVolume_omni_vp_glsl), sizeof(lightVolume_omni_vp_glsl)) }, { "glsl/lighttile_fp.glsl", std::string(reinterpret_cast(lighttile_fp_glsl), sizeof(lighttile_fp_glsl)) }, { "glsl/lighttile_vp.glsl", std::string(reinterpret_cast(lighttile_vp_glsl), sizeof(lighttile_vp_glsl)) }, { "glsl/liquid_fp.glsl", std::string(reinterpret_cast(liquid_fp_glsl), sizeof(liquid_fp_glsl)) }, diff --git a/src/engine/renderer/tr_shade.cpp b/src/engine/renderer/tr_shade.cpp index a34113a48e..18a6804644 100644 --- a/src/engine/renderer/tr_shade.cpp +++ b/src/engine/renderer/tr_shade.cpp @@ -238,7 +238,6 @@ void GLSL_ShutdownGPUShaders() gl_forwardLightingShader_directionalSun = nullptr; gl_depthToColorShader = nullptr; gl_shadowFillShader = nullptr; - gl_lightVolumeShader_omni = nullptr; gl_reflectionShader = nullptr; gl_skyboxShader = nullptr; gl_fogQuake3Shader = nullptr; From f3b1d2094aa2a15440a0d75eb23382849e2d94d5 Mon Sep 17 00:00:00 2001 From: slipher Date: Fri, 4 Jun 2021 22:34:35 -0500 Subject: [PATCH 3/4] Remove unused shaders depthToColor --- src.cmake | 2 - src/engine/renderer/gl_shader.cpp | 14 ----- src/engine/renderer/gl_shader.h | 12 ---- .../renderer/glsl_source/depthToColor_fp.glsl | 61 ------------------- .../renderer/glsl_source/depthToColor_vp.glsl | 50 --------------- src/engine/renderer/shaders.cpp | 4 -- src/engine/renderer/tr_image.cpp | 3 - src/engine/renderer/tr_local.h | 2 - src/engine/renderer/tr_shade.cpp | 7 --- 9 files changed, 155 deletions(-) delete mode 100644 src/engine/renderer/glsl_source/depthToColor_fp.glsl delete mode 100644 src/engine/renderer/glsl_source/depthToColor_vp.glsl diff --git a/src.cmake b/src.cmake index 9752a88f45..380875fc38 100644 --- a/src.cmake +++ b/src.cmake @@ -157,8 +157,6 @@ set(GLSLSOURCELIST ${ENGINE_DIR}/renderer/glsl_source/depthtile1_vp.glsl ${ENGINE_DIR}/renderer/glsl_source/depthtile2_fp.glsl ${ENGINE_DIR}/renderer/glsl_source/depthtile2_vp.glsl - ${ENGINE_DIR}/renderer/glsl_source/depthToColor_fp.glsl - ${ENGINE_DIR}/renderer/glsl_source/depthToColor_vp.glsl ${ENGINE_DIR}/renderer/glsl_source/dispersion_C_fp.glsl ${ENGINE_DIR}/renderer/glsl_source/dispersion_C_vp.glsl ${ENGINE_DIR}/renderer/glsl_source/fogGlobal_fp.glsl diff --git a/src/engine/renderer/gl_shader.cpp b/src/engine/renderer/gl_shader.cpp index a069bbdf2e..cc2fda0465 100644 --- a/src/engine/renderer/gl_shader.cpp +++ b/src/engine/renderer/gl_shader.cpp @@ -53,7 +53,6 @@ GLShader_cameraEffects *gl_cameraEffectsShader = nullptr; GLShader_blurX *gl_blurXShader = nullptr; GLShader_blurY *gl_blurYShader = nullptr; GLShader_debugShadowMap *gl_debugShadowMapShader = nullptr; -GLShader_depthToColor *gl_depthToColorShader = nullptr; GLShader_liquid *gl_liquidShader = nullptr; GLShader_volumetricFog *gl_volumetricFogShader = nullptr; GLShader_motionblur *gl_motionblurShader = nullptr; @@ -2064,19 +2063,6 @@ void GLShader_debugShadowMap::SetShaderProgramUniforms( shaderProgram_t *shaderP glUniform1i( glGetUniformLocation( shaderProgram->program, "u_CurrentMap" ), 0 ); } -GLShader_depthToColor::GLShader_depthToColor( GLShaderManager *manager ) : - GLShader( "depthToColor", ATTR_POSITION | ATTR_QTANGENT, manager ), - u_ModelViewProjectionMatrix( this ), - u_Bones( this ), - GLCompileMacro_USE_VERTEX_SKINNING( this ) -{ -} - -void GLShader_depthToColor::BuildShaderVertexLibNames( std::string& vertexInlines ) -{ - vertexInlines += "vertexSimple vertexSkinning "; -} - GLShader_liquid::GLShader_liquid( GLShaderManager *manager ) : GLShader( "liquid", ATTR_POSITION | ATTR_TEXCOORD | ATTR_QTANGENT, manager ), u_TextureMatrix( this ), diff --git a/src/engine/renderer/gl_shader.h b/src/engine/renderer/gl_shader.h index e9c69b2b6a..c5de3f3d3a 100644 --- a/src/engine/renderer/gl_shader.h +++ b/src/engine/renderer/gl_shader.h @@ -2577,17 +2577,6 @@ class GLShader_debugShadowMap : void SetShaderProgramUniforms( shaderProgram_t *shaderProgram ); }; -class GLShader_depthToColor : - public GLShader, - public u_ModelViewProjectionMatrix, - public u_Bones, - public GLCompileMacro_USE_VERTEX_SKINNING -{ -public: - GLShader_depthToColor( GLShaderManager *manager ); - void BuildShaderVertexLibNames( std::string& vertexInlines ); -}; - class GLShader_liquid : public GLShader, public u_TextureMatrix, @@ -2708,7 +2697,6 @@ extern GLShader_cameraEffects *gl_cameraEffectsShader; extern GLShader_blurX *gl_blurXShader; extern GLShader_blurY *gl_blurYShader; extern GLShader_debugShadowMap *gl_debugShadowMapShader; -extern GLShader_depthToColor *gl_depthToColorShader; extern GLShader_liquid *gl_liquidShader; extern GLShader_volumetricFog *gl_volumetricFogShader; extern GLShader_motionblur *gl_motionblurShader; diff --git a/src/engine/renderer/glsl_source/depthToColor_fp.glsl b/src/engine/renderer/glsl_source/depthToColor_fp.glsl deleted file mode 100644 index 81124d1c4c..0000000000 --- a/src/engine/renderer/glsl_source/depthToColor_fp.glsl +++ /dev/null @@ -1,61 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2009 Robert Beckebans - -This file is part of XreaL source code. - -XreaL 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 2 of the License, -or (at your option) any later version. - -XreaL 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 XreaL source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -/* depthToColor_fp.glsl */ - -#if __VERSION__ > 120 -out vec4 outputColor; -#else -#define outputColor gl_FragColor -#endif - -void main() -{ - // compute depth instead of world vertex position in a [0..1] range - float depth = gl_FragCoord.z; - -//#if 0 -// outputColor = vec4(0.0, 0.0, 0.0, depth); -//#else - // 32 bit precision - const vec4 bitSh = vec4(256 * 256 * 256, 256 * 256, 256, 1); - const vec4 bitMsk = vec4( 0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); - - vec4 comp; - comp = depth * bitSh; - comp = fract(comp); - comp -= comp.xxyz * bitMsk; - outputColor = comp; -/* - // 24 bit precision - const vec3 bitSh = vec3(256 * 256, 256, 1); - const vec3 bitMsk = vec3( 0, 1.0 / 256.0, 1.0 / 256.0); - - vec3 comp; - comp = depth * bitSh; - comp = fract(comp); - comp -= comp.xxy * bitMsk; - outputColor = vec4(comp, 0.0); -*/ -//#endif -} - diff --git a/src/engine/renderer/glsl_source/depthToColor_vp.glsl b/src/engine/renderer/glsl_source/depthToColor_vp.glsl deleted file mode 100644 index 9157597fcd..0000000000 --- a/src/engine/renderer/glsl_source/depthToColor_vp.glsl +++ /dev/null @@ -1,50 +0,0 @@ -/* -=========================================================================== -Copyright (C) 2009 Robert Beckebans - -This file is part of XreaL source code. - -XreaL 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 2 of the License, -or (at your option) any later version. - -XreaL 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 XreaL source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ - -/* depthToColor_vp.glsl */ - -IN vec3 attr_Position; -#if defined(USE_VERTEX_SKINNING) -IN vec3 attr_Normal; -#endif - -uniform mat4 u_ModelViewProjectionMatrix; - -void main() -{ -#if defined(USE_VERTEX_SKINNING) - { - vec4 position; - vec3 normal; - - VertexSkinning_P_N( attr_Position, attr_Normal, position, normal ); - - // transform vertex position into homogenous clip-space - gl_Position = u_ModelViewProjectionMatrix * position; - } -#else - { - // transform vertex position into homogenous clip-space - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - } -#endif -} diff --git a/src/engine/renderer/shaders.cpp b/src/engine/renderer/shaders.cpp index 22282590a2..c7928447d5 100644 --- a/src/engine/renderer/shaders.cpp +++ b/src/engine/renderer/shaders.cpp @@ -25,8 +25,6 @@ #include "depthtile1_vp.glsl.h" #include "depthtile2_fp.glsl.h" #include "depthtile2_vp.glsl.h" -#include "depthToColor_fp.glsl.h" -#include "depthToColor_vp.glsl.h" #include "dispersion_C_fp.glsl.h" #include "dispersion_C_vp.glsl.h" #include "fogGlobal_fp.glsl.h" @@ -76,8 +74,6 @@ std::unordered_map shadermap({ { "glsl/debugShadowMap_fp.glsl", std::string(reinterpret_cast(debugShadowMap_fp_glsl), sizeof(debugShadowMap_fp_glsl)) }, { "glsl/debugShadowMap_vp.glsl", std::string(reinterpret_cast(debugShadowMap_vp_glsl), sizeof(debugShadowMap_vp_glsl)) }, { "glsl/deformVertexes_vp.glsl", std::string(reinterpret_cast(deformVertexes_vp_glsl), sizeof(deformVertexes_vp_glsl)) }, - { "glsl/depthToColor_fp.glsl", std::string(reinterpret_cast(depthToColor_fp_glsl), sizeof(depthToColor_fp_glsl)) }, - { "glsl/depthToColor_vp.glsl", std::string(reinterpret_cast(depthToColor_vp_glsl), sizeof(depthToColor_vp_glsl)) }, { "glsl/depthtile1_fp.glsl", std::string(reinterpret_cast(depthtile1_fp_glsl), sizeof(depthtile1_fp_glsl)) }, { "glsl/depthtile1_vp.glsl", std::string(reinterpret_cast(depthtile1_vp_glsl), sizeof(depthtile1_vp_glsl)) }, { "glsl/depthtile2_fp.glsl", std::string(reinterpret_cast(depthtile2_fp_glsl), sizeof(depthtile2_fp_glsl)) }, diff --git a/src/engine/renderer/tr_image.cpp b/src/engine/renderer/tr_image.cpp index 09f854dad6..05954221fe 100644 --- a/src/engine/renderer/tr_image.cpp +++ b/src/engine/renderer/tr_image.cpp @@ -2550,9 +2550,6 @@ static void R_CreateDepthToColorFBOImages() imageParams.bits = IF_NOPICMIP; imageParams.filterType = filterType_t::FT_NEAREST; imageParams.wrapType = wrapTypeEnum_t::WT_CLAMP; - - tr.depthToColorBackFacesFBOImage = R_CreateImage( "_depthToColorBackFacesFBORender", nullptr, width, height, 1, imageParams ); - tr.depthToColorFrontFacesFBOImage = R_CreateImage( "_depthToColorFrontFacesFBORender", nullptr, width, height, 1, imageParams ); } // Tr3B: clean up this mess some day ... diff --git a/src/engine/renderer/tr_local.h b/src/engine/renderer/tr_local.h index 960758bf52..7d560a943d 100644 --- a/src/engine/renderer/tr_local.h +++ b/src/engine/renderer/tr_local.h @@ -2645,8 +2645,6 @@ static inline void halfToFloat( const f16vec4_t in, vec4_t out ) image_t *lighttileRenderImage; image_t *portalRenderImage; - image_t *depthToColorBackFacesFBOImage; - image_t *depthToColorFrontFacesFBOImage; image_t *downScaleFBOImage_quarter; image_t *downScaleFBOImage_64x64; image_t *shadowMapFBOImage[ MAX_SHADOWMAPS * 2 ]; diff --git a/src/engine/renderer/tr_shade.cpp b/src/engine/renderer/tr_shade.cpp index 18a6804644..40789427fe 100644 --- a/src/engine/renderer/tr_shade.cpp +++ b/src/engine/renderer/tr_shade.cpp @@ -69,12 +69,6 @@ static void GLSL_InitGPUShadersOrError() gl_shaderManager.load( gl_lighttileShader ); } -#if !defined( GLSL_COMPILE_STARTUP_ONLY ) - - gl_shaderManager.load( gl_depthToColorShader ); - -#endif // #if !defined(GLSL_COMPILE_STARTUP_ONLY) - // shadowmap distance compression gl_shaderManager.load( gl_shadowFillShader ); @@ -236,7 +230,6 @@ void GLSL_ShutdownGPUShaders() gl_forwardLightingShader_omniXYZ = nullptr; gl_forwardLightingShader_projXYZ = nullptr; gl_forwardLightingShader_directionalSun = nullptr; - gl_depthToColorShader = nullptr; gl_shadowFillShader = nullptr; gl_reflectionShader = nullptr; gl_skyboxShader = nullptr; From df1feaa44d83bd5e9359f64e45d9ebda79549532 Mon Sep 17 00:00:00 2001 From: slipher Date: Sun, 6 Jun 2021 20:25:13 -0500 Subject: [PATCH 4/4] Change vertex skinning weight calculation The `weights` values calculated by VertexFetch in GLSL seem to end up being different somehow in the generic shader and the lightMapping shader under the Nvidia proprietrary driver for Linux (#472). Arbitrarily change how the values are extracted in order to avoid an unfortunate GLSL compilation. --- src/engine/renderer/glsl_source/vertexSkinning_vp.glsl | 5 ++--- src/engine/renderer/tr_vbo.cpp | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/engine/renderer/glsl_source/vertexSkinning_vp.glsl b/src/engine/renderer/glsl_source/vertexSkinning_vp.glsl index c56f0e84ce..71121ef2d3 100644 --- a/src/engine/renderer/glsl_source/vertexSkinning_vp.glsl +++ b/src/engine/renderer/glsl_source/vertexSkinning_vp.glsl @@ -41,9 +41,8 @@ void VertexFetch(out vec4 position, const float scale = 1.0 / 256.0; localBasis inLB; - ivec4 idx = 2 * ivec4( floor( attr_BoneFactors * scale ) ); - vec4 weights = fract( attr_BoneFactors * scale ); - weights.x = 1.0 - weights.x; + ivec4 idx = 2 * ( ivec4(attr_BoneFactors) >> 8 ); + vec4 weights = ( ivec4(attr_BoneFactors) & 0xFF ) / 255.0; vec4 quat = u_Bones[ idx.x ]; vec4 trans = u_Bones[ idx.x + 1 ]; diff --git a/src/engine/renderer/tr_vbo.cpp b/src/engine/renderer/tr_vbo.cpp index a7ec225bfb..e51185d5ac 100644 --- a/src/engine/renderer/tr_vbo.cpp +++ b/src/engine/renderer/tr_vbo.cpp @@ -304,11 +304,11 @@ static void R_SetVBOAttributeLayouts( VBO_t *vbo ) } } -// index has to be in range 0-255, weight has to be >= 0 and < 1 +// index has to be in range 0-255, weight has to be >= 0 and <= 1 static inline unsigned short boneFactor( int index, float weight ) { - int scaledWeight = lrintf( weight * 256.0 ); - return (unsigned short)( ( index << 8 ) | std::min( scaledWeight, 255 ) ); + int scaledWeight = lrintf( weight * 255.0 ); + return (unsigned short)( ( index << 8 ) | scaledWeight ); } static void R_CopyVertexData( VBO_t *vbo, byte *outData, vboData_t inData ) @@ -370,9 +370,7 @@ static void R_CopyVertexData( VBO_t *vbo, byte *outData, vboData_t inData ) { uint32_t j; - ptr[ v ].boneFactors[ 0 ] = boneFactor( inData.boneIndexes[ v ][ 0 ], - 1.0f - inData.boneWeights[ v ][ 0 ]); - for ( j = 1; j < 4; j++ ) { + for ( j = 0; j < 4; j++ ) { ptr[ v ].boneFactors[ j ] = boneFactor( inData.boneIndexes[ v ][ j ], inData.boneWeights[ v ][ j ] ); }