Conversation
f5e4556 to
d7013c8
Compare
|
I verified that we don't have strong differences with the original I used that as reference: Which I assume is supposedly a copy of (now broken link):
I have no idea where our bug is living. |
d7013c8 to
a02cb5e
Compare
|
When doing this: diff --git a/src/engine/renderer/glsl_source/fxaa3_11_fp.glsl b/src/engine/renderer/glsl_source/fxaa3_11_fp.glsl
index dd3757b08..c4ed80f73 100644
--- a/src/engine/renderer/glsl_source/fxaa3_11_fp.glsl
+++ b/src/engine/renderer/glsl_source/fxaa3_11_fp.glsl
@@ -1240,6 +1240,7 @@ FxaaFloat4 FxaaPixelShader(
#if (FXAA_DISCARD == 1)
return FxaaTexTop(tex, posM);
#else
+ return vec4(1.0, 0.0, 0.0, 1.0);
return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);
#endif
}We see that the edges are properly detected: But the data written to those areas is garbage. |
|
Since the edge detection worked, I assumed that was the sampling that was broken. I tested using Without FXAA: With FXAA: Here are pixels modified by FXAA with Here are pixels modified by FXAA with This last screenshot is NOT the painting of pixels expected to be modified by FXAA by returning red as FXAA return value (like in previous comment), it is the painting of pixels actually modified by FXAA, by comparing the input and the output of the FXAA computation and painting in red what changed. |
|
So I checked the history, and that |
|
I'm now git blaming the XreaL code (the git reference below is from a locally converted repository), and our code: imageParams.filterType = filterType_t::FT_NEAREST;
imageParams.wrapType = wrapTypeEnum_t::WT_CLAMP;
tr.currentRenderImage[0] = R_CreateImage( "*currentRender0", nullptr, width, height, 1, imageParams );
tr.currentRenderImage[1] = R_CreateImage( "*currentRender1", nullptr, width, height, 1, imageParams );is ultimately deriving from: commit af8e5637ae850c20f375ba198acbe2dc4060e4f1
Author: Robert “Tr3B” Beckebans <xxx>
Date: Sun Sep 10 20:53:54 2006 +0000
simplified render to texture
diff --git a/xreal/code/renderer/tr_image.c b/xreal/code/renderer/tr_image.c
index cafe1ba4..ec253ec2 100644
--- a/xreal/code/renderer/tr_image.c
+++ b/xreal/code/renderer/tr_image.c
@@ -4540,38 +4540,7 @@ static void R_CreateCurrentRenderImage(void)
data = ri.Hunk_AllocateTempMemory(width * height * 4);
- tr.currentRenderImage = R_CreateImage("_currentRender", data, width, height, IF_NOPICMIP, FT_DEFAULT, WT_REPEAT);
-
- ri.Hunk_FreeTempMemory(data);
-}
-
-static void R_CreateCurrentRenderLinearImage(void)
-{
- int width, height;
- byte *data;
-
- width = NearestPowerOfTwo(glConfig.vidWidth);
- height = NearestPowerOfTwo(glConfig.vidHeight);
-
- data = ri.Hunk_AllocateTempMemory(width * height * 4);
-
- tr.currentRenderLinearImage = R_CreateImage("_currentRenderLinear", data, width, height, IF_NOPICMIP, FT_LINEAR, WT_REPEAT);
-
- ri.Hunk_FreeTempMemory(data);
-}
-
-static void R_CreateCurrentRenderNearestImage(void)
-{
- int width, height;
- byte *data;
-
- width = NearestPowerOfTwo(glConfig.vidWidth);
- height = NearestPowerOfTwo(glConfig.vidHeight);
-
- data = ri.Hunk_AllocateTempMemory(width * height * 4);
-
- tr.currentRenderNearestImage =
- R_CreateImage("_currentRenderNearest", data, width, height, IF_NOPICMIP, FT_NEAREST, WT_REPEAT);
+ tr.currentRenderImage = R_CreateImage("_currentRender", data, width, height, IF_NOPICMIP, FT_NEAREST, WT_REPEAT);
ri.Hunk_FreeTempMemory(data);
}
@@ -4673,8 +4642,6 @@ void R_CreateBuiltinImages(void)
R_CreateAttenuationXYImage();
R_CreateContrastRenderImage();
R_CreateCurrentRenderImage();
- R_CreateCurrentRenderLinearImage();
- R_CreateCurrentRenderNearestImage();
R_CreateCurrentRenderFBOImage();
R_CreatePortalRenderFBOImage();
}
diff --git a/xreal/code/renderer/tr_local.h b/xreal/code/renderer/tr_local.h
index 14dcb2fa..5813e7cd 100644
--- a/xreal/code/renderer/tr_local.h
+++ b/xreal/code/renderer/tr_local.h
@@ -1726,10 +1726,9 @@ typedef struct
image_t *identityLightImage; // full of tr.identityLightByte
image_t *noFalloffImage;
image_t *attenuationXYImage;
+
image_t *contrastRenderImage;
image_t *currentRenderImage;
- image_t *currentRenderLinearImage;
- image_t *currentRenderNearestImage;
image_t *currentRenderFBOImage[4];
image_t *portalRenderFBOImage[4];
diff --git a/xreal/code/renderer/tr_shade.c b/xreal/code/renderer/tr_shade.c
index 34ef1b5c..7082fd48 100644
--- a/xreal/code/renderer/tr_shade.c
+++ b/xreal/code/renderer/tr_shade.c
@@ -2637,9 +2637,8 @@ static void Render_heatHaze(int stage)
// capture current color buffer for u_CurrentMap
GL_SelectTexture(0);
- GL_Bind(tr.currentRenderNearestImage);
- qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderNearestImage->uploadWidth,
- tr.currentRenderNearestImage->uploadHeight);
+ GL_Bind(tr.currentRenderImage);
+ qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderImage->uploadWidth, tr.currentRenderImage->uploadHeight);
// clear color buffer
qglClear(GL_COLOR_BUFFER_BIT);
@@ -2668,7 +2667,7 @@ static void Render_heatHaze(int stage)
// bind u_CurrentMap
GL_SelectTexture(1);
- GL_Bind(tr.currentRenderNearestImage);
+ GL_Bind(tr.currentRenderImage);
DrawElements();
@@ -2695,7 +2694,7 @@ static void Render_heatHaze(int stage)
// bind u_CurrentMap
GL_SelectTexture(0);
- GL_Bind(tr.currentRenderNearestImage);
+ GL_Bind(tr.currentRenderImage);
// set 2D virtual screen size
qglPushMatrix();
@@ -2765,8 +2764,8 @@ static void Render_heatHaze(int stage)
}
else
{
- GL_Bind(tr.currentRenderLinearImage);
- qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderLinearImage->uploadWidth, tr.currentRenderLinearImage->uploadHeight);
+ GL_Bind(tr.currentRenderImage);
+ qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderImage->uploadWidth, tr.currentRenderImage->uploadHeight);
}
// bind u_ContrastMap
@@ -2822,9 +2821,8 @@ static void Render_bloom(int stage)
qglUniform2fARB(tr.contrastShader.u_NPOTScale, npotWidthScale, npotHeightScale);
GL_SelectTexture(0);
- GL_Bind(tr.currentRenderNearestImage);
- qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderNearestImage->uploadWidth,
- tr.currentRenderNearestImage->uploadHeight);
+ GL_Bind(tr.currentRenderImage);
+ qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderImage->uploadWidth, tr.currentRenderImage->uploadHeight);
qglMatrixMode(GL_TEXTURE);
qglLoadMatrixf(tess.svars.texMatrices[TB_COLORMAP]);
qglMatrixMode(GL_MODELVIEW);
@@ -2841,9 +2839,8 @@ static void Render_bloom(int stage)
qglUniform2fARB(tr.bloomShader.u_NPOTScale, npotWidthScale, npotHeightScale);
GL_SelectTexture(1);
- GL_Bind(tr.currentRenderLinearImage);
- qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderLinearImage->uploadWidth,
- tr.currentRenderLinearImage->uploadHeight);
+ GL_Bind(tr.contrastRenderImage);
+ qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.contrastRenderImage->uploadWidth, tr.contrastRenderImage->uploadHeight);
DrawElements();
@@ -2877,9 +2874,8 @@ static void Render_bloom2(int stage)
qglUniform2fARB(tr.contrastShader.u_NPOTScale, npotWidthScale, npotHeightScale);
GL_SelectTexture(0);
- GL_Bind(tr.currentRenderNearestImage);
- qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderNearestImage->uploadWidth,
- tr.currentRenderNearestImage->uploadHeight);
+ GL_Bind(tr.currentRenderImage);
+ qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderImage->uploadWidth, tr.currentRenderImage->uploadHeight);
qglMatrixMode(GL_TEXTURE);
qglLoadMatrixf(tess.svars.texMatrices[TB_COLORMAP]);
qglMatrixMode(GL_MODELVIEW);
@@ -2894,9 +2890,8 @@ static void Render_bloom2(int stage)
qglUniform2fARB(tr.blurXShader.u_FBufScale, fbufWidthScale, fbufHeightScale);
qglUniform2fARB(tr.blurXShader.u_NPOTScale, npotWidthScale, npotHeightScale);
- GL_Bind(tr.currentRenderLinearImage);
- qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderLinearImage->uploadWidth,
- tr.currentRenderLinearImage->uploadHeight);
+ GL_Bind(tr.contrastRenderImage);
+ qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.contrastRenderImage->uploadWidth, tr.contrastRenderImage->uploadHeight);
DrawElements();
@@ -2908,9 +2903,8 @@ static void Render_bloom2(int stage)
qglUniform2fARB(tr.blurYShader.u_FBufScale, fbufWidthScale, fbufHeightScale);
qglUniform2fARB(tr.blurYShader.u_NPOTScale, npotWidthScale, npotHeightScale);
- GL_Bind(tr.currentRenderLinearImage);
- qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderLinearImage->uploadWidth,
- tr.currentRenderLinearImage->uploadHeight);
+ GL_Bind(tr.contrastRenderImage);
+ qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.contrastRenderImage->uploadWidth, tr.contrastRenderImage->uploadHeight);
DrawElements();
@@ -2924,10 +2918,10 @@ static void Render_bloom2(int stage)
qglUniform2fARB(tr.bloomShader.u_NPOTScale, npotWidthScale, npotHeightScale);
GL_SelectTexture(0);
- GL_Bind(tr.currentRenderNearestImage);
+ GL_Bind(tr.currentRenderImage);
GL_SelectTexture(1);
- GL_Bind(tr.currentRenderLinearImage);
+ GL_Bind(tr.contrastRenderImage);
DrawElements();
@@ -2963,9 +2957,8 @@ static void Render_rotoscope(int stage)
// bind u_ColorMap
GL_SelectTexture(0);
- GL_Bind(tr.currentRenderNearestImage);
- qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderNearestImage->uploadWidth,
- tr.currentRenderNearestImage->uploadHeight);
+ GL_Bind(tr.currentRenderImage);
+ qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, tr.currentRenderImage->uploadWidth, tr.currentRenderImage->uploadHeight);
qglMatrixMode(GL_TEXTURE);
qglLoadMatrixf(tess.svars.texMatrices[TB_COLORMAP]);
qglMatrixMode(GL_MODELVIEW);Before that XreaL commit, the code had some |
|
This usage of |
- fix FXAA by using GL_LINEAR on currentRender, - restore GL_NEAREST after that to not break other effects.
d505fbf to
2931004
Compare
|
Well, it works until we use bindless textures, and it's not suprising since the tweak requires a bind… |
|
@VReaperV I would appreciate your expertise on this ! 🙂️ The way to fix FXAA is to make sure the framebuffer is using I verified that in non-bindless mode, switching to And something I don't know how to do and what to do at all, is how this interacts with the bindless pipeline and how to make it work the bindless way. |
|
If you're OK with requiring OpenGL 3.3 you can use "sampler" objects.
|
|
Nice! |
|
I tried using |
2be5a7e to
24a5f26
Compare
3ca219b to
24fe6b1
Compare
|
If it works properly, maybe we will enable FXAA in We may want to disable FXAA internally when MSAA is enabled. |
| // That luminance vector comes from a comment in fxaa3_11_fp.glsl. | ||
| vec3 luminanceVector = vec3( 0.299, 0.587, 0.114 ); | ||
|
|
||
| float luminance = dot( color.rgb, luminanceVector ); |
There was a problem hiding this comment.
Apparently it should be called "luma" since you're doing it on sRGB values. While "luminance" would be with linear values

















This is so good to have it I'm now considering it for 0.56.0.
GL_LINEARinstead ofGL_NEAREST)r_FXAAa new-style cvarfxaa_fp(we now have#insert)r_showLuminance)r_showFXAAFix #533 and fix #1701:
Original comment:
No urge. I was looking at it in hope I could find a quick fix, I haven't found a quick fix, this is as broken as before.
Anyway, the rework of this may be useful for when the fix for FXAA will be found.
r_FXAAa new-style cvarfxaa_fp(we now have#insert)r_showLuminance)r_showFXAAThe
r_showFXAAoption paints in red the pixels whose RGB color is modified byFxaaPixelShader(). ActuallyFxaaPixelShader()modifies random pixels (not at edges) and the result image is more buggy than without FXAA.