PhysicsMod icon indicating copy to clipboard operation
PhysicsMod copied to clipboard

Optifine compatibility issue on buffer blend state [Bug]

Open GeForceLegend opened this issue 1 year ago • 4 comments

Describe the bug Currently there is some issues on Optifine compatibility, even the shader is compiled successful: Buffer blend state (like blend.gbuffers_water=ONE ZERO ONE ZERO in shaders.properties) is not applied. This will affect almost all shaders that using deferred pipeline calculating lighting.

To Reproduce I am the owner of this project: https://github.com/GeForceLegend/SEUS_PTGI_GFME , and I'm working on Physics mod's ocean compatibility. Currently, Iris side is working fine, but Optifine side sucks. And above is the issue I'v noticed: Buffer blend state is not applied, as I'v set blend.gbuffer_waters to ONE ZERO ONE ZERO, but the Renderdoc capture shows that when rendering oceans, blend state is SRC_ALPHA ONE_MINUS_SRC_ALPHA SRC_ALPHA ONE_MINUS_SRC_ALPHA 20240118120654

Screenshots A renderdoc screenshot is provided above.

Minecraft Version: 1.20.1 Physics Mod Version: v164b-forge-1.20.1

GeForceLegend avatar Jan 18 '24 04:01 GeForceLegend

You are absolutely right! When calculating the ripples I change the blend state and don't revert it properly (I change it back to the default blend func which probably doesn't get handled properly on Optifines end). To test this theory you can disable ripples and the blending should then be set properly.

haubna avatar Jan 22 '24 13:01 haubna

Looks like the blending is still not correct with Ocean > Water Ripples off? Is this the correct setting I should disable? 20240122233016

GeForceLegend avatar Jan 22 '24 15:01 GeForceLegend

Huh, you could also try disabling cloth rendering and liquid rendering. I reset to the default blend func there as well.

haubna avatar Jan 22 '24 15:01 haubna

I almost disabled everything excepts ocean physics but still cannot get correct blend. The ocean draw is directly called after last deferred shader, and between these 2 draw calls there are only 2 blend state changes, maybe some blend state changes like the defaultBlendFunc() call you said are blocked by Minecraft's state machine RenderSystem?

// gl events copied from Nsight Graphics

void glBlendFunc(GLenum sfactor = GL_ONE, GLenum dfactor = GL_ZERO);
void glBlendFuncSeparate(GLenum sfactorRGB = GL_SRC_ALPHA, GLenum dfactorRGB = GL_ONE_MINUS_SRC_ALPHA, GLenum sfactorAlpha = GL_ONE, GLenum dfactorAlpha = GL_ONE_MINUS_SRC_ALPHA);

GeForceLegend avatar Jan 22 '24 16:01 GeForceLegend