Daemon icon indicating copy to clipboard operation
Daemon copied to clipboard

Investigating the non-working liquid shader

Open illwieckz opened this issue 2 years ago • 7 comments

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.

illwieckz avatar May 01 '23 06:05 illwieckz

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.

illwieckz avatar May 01 '23 07:05 illwieckz

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.

illwieckz avatar May 01 '23 07:05 illwieckz

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…

illwieckz avatar May 01 '23 08:05 illwieckz

I actually got “good enough” proof that the mirror is rendered above the surface, instead of feeding the liquid shader.

illwieckz avatar May 01 '23 08:05 illwieckz

Is it expected to render as a mirror with some sort of distortions by water?

VReaperV avatar Jul 30 '24 08:07 VReaperV