summaryrefslogtreecommitdiff
path: root/src/renderergl2
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderergl2')
-rw-r--r--src/renderergl2/glsl/depthblur_fp.glsl11
-rw-r--r--src/renderergl2/glsl/ssao_fp.glsl5
-rw-r--r--src/renderergl2/tr_backend.c7
3 files changed, 12 insertions, 11 deletions
diff --git a/src/renderergl2/glsl/depthblur_fp.glsl b/src/renderergl2/glsl/depthblur_fp.glsl
index 60a261c5..a5b264fd 100644
--- a/src/renderergl2/glsl/depthblur_fp.glsl
+++ b/src/renderergl2/glsl/depthblur_fp.glsl
@@ -4,6 +4,7 @@ uniform sampler2D u_ScreenDepthMap;
uniform vec4 u_ViewInfo; // zfar / znear, zfar, 1/width, 1/height
varying vec2 var_ScreenTex;
+//float gauss[8] = float[8](0.17, 0.17, 0.16, 0.14, 0.12, 0.1, 0.08, 0.06);
//float gauss[5] = float[5](0.30, 0.23, 0.097, 0.024, 0.0033);
float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044);
//float gauss[3] = float[3](0.60, 0.19, 0.0066);
@@ -11,15 +12,17 @@ float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044);
float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear)
{
- float sampleZDivW = texture2D(depthMap, tex).r;
+ // depth is upside down?
+ float sampleZDivW = texture2D(depthMap, vec2(tex.x, 1.0 - tex.y)).r;
return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW);
}
vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFarDivZNear, float zFar, vec2 scale)
{
float depthCenter = getLinearDepth(depthMap, tex, zFarDivZNear);
- //scale /= zFarDivZNear * depthCenter;
- //int blurSteps = int(float(BLUR_SIZE) / (zFarDivZNear * depthCenter));
+
+ // enable for less blurring for farther objects
+ //scale /= min(zFarDivZNear * depthCenter / 32.0, 2.0);
#if defined(USE_HORIZONTAL_BLUR)
vec2 direction = vec2(scale.x, 0.0);
@@ -64,5 +67,5 @@ vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFa
void main()
{
- gl_FragColor = depthGaussian1D(u_ScreenImageMap, u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y, u_ViewInfo.zw);
+ gl_FragColor = depthGaussian1D(u_ScreenImageMap, u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y, u_ViewInfo.wz);
}
diff --git a/src/renderergl2/glsl/ssao_fp.glsl b/src/renderergl2/glsl/ssao_fp.glsl
index 84f18cb7..1714c2be 100644
--- a/src/renderergl2/glsl/ssao_fp.glsl
+++ b/src/renderergl2/glsl/ssao_fp.glsl
@@ -40,7 +40,8 @@ mat2 randomRotation( const vec2 p )
float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear)
{
- float sampleZDivW = texture2D(depthMap, tex).r;
+ // depth is upside down?
+ float sampleZDivW = texture2D(depthMap, vec2(tex.x, 1.0 - tex.y)).r;
return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW);
}
@@ -80,7 +81,7 @@ float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZN
void main()
{
- float result = ambientOcclusion(u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y, u_ViewInfo.zw);
+ float result = ambientOcclusion(u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y, u_ViewInfo.wz);
gl_FragColor = vec4(vec3(result), 1.0);
}
diff --git a/src/renderergl2/tr_backend.c b/src/renderergl2/tr_backend.c
index 420c785b..708b395f 100644
--- a/src/renderergl2/tr_backend.c
+++ b/src/renderergl2/tr_backend.c
@@ -978,7 +978,7 @@ const void *RB_DrawSurfs( const void *data ) {
qglCopyTextureImage2D(tr.renderDepthImage->texnum, GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 0, 0, glConfig.vidWidth, glConfig.vidHeight, 0);
}
- if (r_ssao->integer)
+ if (tr.hdrDepthFbo)
{
// need the depth in a texture we can do GL_LINEAR sampling on, so copy it to an HDR image
FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, tr.hdrDepthFbo, NULL, NULL, NULL, 0);
@@ -1080,7 +1080,6 @@ const void *RB_DrawSurfs( const void *data ) {
RB_InstantQuad2(quadVerts, texCoords);
-
FBO_Bind(tr.screenShadowFbo);
GLSL_BindProgram(&tr.depthBlurShader[1]);
@@ -1101,6 +1100,7 @@ const void *RB_DrawSurfs( const void *data ) {
viewInfo[2] = 1.0f / ((float)(tr.quarterImage[0]->width) * tan(backEnd.viewParms.fovX * M_PI / 360.0f) * 2.0f);
viewInfo[3] = 1.0f / ((float)(tr.quarterImage[0]->height) * tan(backEnd.viewParms.fovY * M_PI / 360.0f) * 2.0f);
+ viewInfo[3] *= (float)backEnd.viewParms.viewportHeight / (float)backEnd.viewParms.viewportWidth;
FBO_Bind(tr.quarterFbo[0]);
@@ -1542,9 +1542,6 @@ const void *RB_PostProcess(const void *data)
srcBox[3] = backEnd.viewParms.viewportHeight * tr.screenSsaoImage->height / (float)glConfig.vidHeight;
//FBO_BlitFromTexture(tr.screenSsaoImage, srcBox, NULL, srcFbo, dstBox, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO);
- srcBox[1] = tr.screenSsaoImage->height - srcBox[1];
- srcBox[3] = -srcBox[3];
-
FBO_Blit(tr.screenSsaoFbo, srcBox, NULL, srcFbo, dstBox, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO);
}