-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigating portal issues #1010
Comments
When I modify
The portal is still rendered, instead of a blue texture! Maybe the portal is written to the wrong framebuffer and written directly on the screen? 🤔️ |
|
Even if I make sure it runs that does nothing. Maybe |
Could it be in Daemon/src/engine/renderer/tr_backend.cpp Line 5505 in 6d14410
Daemon/src/engine/renderer/tr_backend.cpp Line 5577 in 6d14410
The first one seems to be used in depth pre-pass and the second one to actually render the portal. |
Oh, true, depth is written somewhere between calls to PreparePortalCommand::ExecuteSelf( ) and FinalisePortalCommand::ExecuteSelf( ). Looks like this Daemon/src/engine/renderer/tr_main.cpp Line 1835 in 6d14410
|
It looks like both methods add new rendering cmds for the backend to render. It seems to be rendering them in the order they were added, and the only draw call using a texture rendered from a portal seems to be between those 2 cmds. So I think the actual rendering of the portal surface happens somewhere here: Daemon/src/engine/renderer/tr_main.cpp Lines 1871 to 1895 in 6d14410
Presumably in R_RenderView( &newParms ) ? Might be wrong though.
|
The framebuffers seem to be correct... At least the drawing of the actual map seems to use the same framebuffer for everything including portals, then a different framebuffer is used for the UI. |
What I mean is that maybe the portal should be rendered to a specific framebuffer to be able to render it? Or is it simply expected to be rendered first so other stages are blended later on it? |
The latter is the case I think. It doesn't seem to be using separate framebuffers, instead it sets the matrices for the shader that renders the portals so that it's rendered as if you were at the other side of the portal itself. And they are indeed rendered first, so probably supposed to blend with stuff on top yeah. |
What can prevent a translucent object in front of a portal to not blend with it? As seen in: I guess we can get that result if:
Is there any other possibility? |
Not sure... Translucent stuff seems to always be rendered last (before the player though), so things that are in front of them get rendered properly because the depth test fails there. It would seem like neither of these are the case with things rendered by portals though. The translucent stuff also seems to be rendered with this shader: https://github.com/DaemonEngine/Daemon/blob/6d1441070ebc8d3faa775754c201cdc95079c578/src/engine/renderer/glsl_source/generic_fp.glsl. I'm not seeing anything in it that would make it fail, maybe the inputs there should be checked (e. g. by outputting the values from texture samplers directly). |
@illwieckz I believe I found the issue. These are the color buffer and depth buffer as seen in Nsight on pulse near the window: |
What can be the fix? multiply/shift the portal depth-from-portal-point-of-view with current surface depth? |
Maybe, although that might introduce issues with depth testing during portal rendering. We can just draw the portal surface again after everything in the portal is rendered, but with ColorMask set to false on all colours, depth test set to GL_ALWAYS and depth write enabled. In fact, the engine appears to be already doing so, but with depth test disabled, which prevents the depth write (from refpages: "GL_DEPTH_TEST Also, it's worth noting that |
I think changing this Daemon/src/engine/renderer/tr_backend.cpp Line 5609 in 6d14410
GL_State( GLS_DEPTHMASK_TRUE | GLS_COLORMASK_BITS ); should fix it.
|
Actually, also need to add a state bit for GL_ALWAYS or manually do glDepthFunc( GL_ALWAYS). |
Sets glDepthFunc to GL_ALWAYS when rendering the portal surface and enables depth test. Fixes DaemonEngine#1012, Unvanquished/Unvanquished#2476, and partially fixes DaemonEngine#1010. Introduces GLS_DEPTHFUNC_ALWAYS which sets glDepthFunc to GL_ALWAYS. Shifted some enums to avoid conflicts in GL_State().
Sets glDepthFunc to GL_ALWAYS when rendering the portal surface and enables depth test. Fixes #1012, Unvanquished/Unvanquished#2476, and partially fixes #1010. Introduces GLS_DEPTHFUNC_ALWAYS which sets glDepthFunc to GL_ALWAYS. Shifted some enums to avoid conflicts in GL_State().
Our portal implementation is incomplete, it's basically a proof of concept waiting for more to be done.
Our portal code is very similar to the one in RBQUAKE-3, what is believed to be the most recent version of XreaL, so I guess this cannot help us more.
I identified that Tremulous 1.3 by GrangerHub, which is based on ioquake3, has working portal blending in its
opengl2
renderer.The code is much complete there. This seems to be nothing more than ioquake3 implementation and we could look at the ioquake3 impementation as well, but this build makes easier to load tremulous maps to compare with Dæmon.
I noticed we have some very small
portal_fp.glsl
andportal_vp.glsl
shaders while ioquake3 just usegeneric_fp.glsl
andgeneric_vp.glsl
for portals.I noticed that if I tell the Dæmon engine to use
Render_generic
instead ofRender_portal
function (generic GLSL instead of portal GLSL), the portals are rendered the same, and despite blending works on all other textures withgeneric
glsl, this still doesn't work with portals.This seems to confirm our portals are not rendered like other textures, I always assumed that portals were rendered after everything else is done. For sure they render above translucent textures that are in front of them.
Known portal issues:
alphaGen portal
keyword is not implemented yet #935The text was updated successfully, but these errors were encountered: