Daemon
Daemon copied to clipboard
Investigating the non-working liquid shader
So, in tr_shade.cpp the code is doing that in Render_liquid():
GL_BindToTMU( 1, tr.portalRenderImage );
I happens that portalRenderImage is actually not initialized while it should.
This image is expected to be set in tr_backend.cpp in RB_RenderView(), but it is not set because it happens that backEnd.viewParms.portalLevel is 0.
It is expected that backEnd.viewParms.portalLevel is set in R_MirrorViewBySurface() in tr_main.cpp, but R_MirrorViewBySurface seems to not be called.
One thing is that R_MirrorViewBySurface is called only if shader.sort is SS_PORTAL, but the water material both set mirror then sort postProcess, meaning shader.sort is first set to SS_PORTAL then overwritten to SS_POST_PROCESS. If I remove postProcess for now R_MirrorViewBySurface is called .
But then R_MirrorViewBySurface returns false because R_GetPortalOrientations returns false.
OK, the map needed a misc_portal_surface entity to be close to the water surface, now I get the portal texture be properly initialized (Edit: only if I remove the postProcess line), but there are many other bugs.
So, by looking at the way it is rendered in game, it looks like the surface is rendered as a mirror, not as a liquid shader…
I actually got “good enough” proof that the mirror is rendered above the surface, instead of feeding the liquid shader.
Is it expected to render as a mirror with some sort of distortions by water?