oreon-engine icon indicating copy to clipboard operation
oreon-engine copied to clipboard

[Demo] OpaqueTransparencyBlendingShader

Open viloskovic opened this issue 6 years ago • 18 comments

Hi

I am working on Arch Linux (Manjaro) and MSI GTX 980 today and found a little bug.

INFO  [GLContext] OpenGL version: 4.3 (Core Profile) Mesa 18.1.4 bytes
INFO  [GLContext] Max Geometry Uniform Blocks: 14
INFO  [GLContext] Max Geometry Shader Invocations: 32
INFO  [GLContext] Max Uniform Buffer Bindings: 84
INFO  [GLContext] Max Uniform Block Size: 65536 bytes
INFO  [GLContext] Max SSBO Block Size: 134217728 bytes
INFO  [GLContext] Max Image Bindings: 192
INFO  [GLContext] Vendor: nouveau
INFO  [GLContext] Graphic Card: NV124
Disconnected from the target VM, address: '127.0.0.1:42777', transport: 'socket'
org.oreon.gl.engine.transparency.OpaqueTransparencyBlendingShader active samplers with a different type refer to the same texture image unit

I haven't been able to look much into this issue. My desktop is dual boot and on Windows the demo works fine.

viloskovic avatar Aug 03 '18 23:08 viloskovic

Hm I know this issue only on Intel HD graphics... I will go into that soon. Are you able to run the Vulkan demo with your system?

I guess this issue happens because the transparencyblend shader uses too much samplers and image uniforms, there is space to optimize and reduce it, I will do that soon. Hopefully it works then.

fynnfluegge avatar Aug 04 '18 05:08 fynnfluegge

Arch Linux does not use proprietary drivers. The driver I use for my GTX 980 is some community driven driver designed and written by the NVIDIA team and contributors if I am correct. Maybe the community driven driver just does not support that much samplers.

The optimalisatieonderdelen would be a great help in resolving those issues I guess.

viloskovic avatar Aug 05 '18 07:08 viloskovic

I was just fiddling around with the transparencyBlend_FS.glsl since that's where the problem is occurring. While I was doing that I changed the uniform opaqueSceneDepthMap from sampler2DMS to sampler2D and suddenly no error anymore!

The result however was awful: image

viloskovic avatar Aug 30 '18 18:08 viloskovic

Damn you are right, that was the problem, finally it works at my Intel HD graphics too. But I just have just minor graphics bugs on the skydome,

fynnfluegge avatar Aug 30 '18 21:08 fynnfluegge

I have some bigger issues. The only thing I can see is the flare and it freezes. Did you change something else?

viloskovic avatar Aug 30 '18 21:08 viloskovic

Hm are all other entities like sun and sky are actually rendered?

fynnfluegge avatar Aug 31 '18 08:08 fynnfluegge

I can see this: bild_2018_08_31_10_27_40_110

bild_2018_08_31_10_28_01_409

When I move the camera black artifacts appear at the skydome, further the sun is not visible for me. Only the lens flare effect. I think this is because of the multisample depthmap which is interpreted not correctly now, I'll find a workaround to fix this.

fynnfluegge avatar Aug 31 '18 08:08 fynnfluegge

I can't look this up at the moment. Maybe tonight I will investigate it further.

viloskovic avatar Aug 31 '18 08:08 viloskovic

The graphics artifacts appear because of the texel read operation, the depth texture is in the wrong format now because it is a multisample texture (sampler2DMS). However, I guess I detected the issue with the Intel graphics devices, it seems they cannot access multisample samplers (sampler2DMS) in fragment shaders... In an other cases at pixelvelocity compute shader for motion blur it works correctly with a multisample sampler, so I will change the transparency blending shaderpipeline to a single compute shader instead vertex and fragment pipeline and hopefully it works correctly then.

fynnfluegge avatar Aug 31 '18 16:08 fynnfluegge

Will this give any performance hits?

viloskovic avatar Aug 31 '18 17:08 viloskovic

No, it doesn't affect performance, I will commit the workaround with bugfix soon

fynnfluegge avatar Sep 02 '18 09:09 fynnfluegge

Alright, I got it, but there are some graphical bugs left on my Intel HD graphics device. I am pretty sure that the graphics issues depending on the depthmap which is somehow interpreted wrong. However, I was not able to fix this, maybe my device cannot handle multisample depthmaps with OpenGL. I was playing around with glFinish() and glFlush() at almost every place but unfortunately it didn't really help. At least the application is running now. Here are some screenshots of the graphical artifacts which appear sometimes in a fraction of a second:

bild_2018_09_03_10_15_07_808 nd: bild_2018_09_03_10_15_16_458 bild_2018_09_03_10_15_48_38

As metioned in my earlier post the sun is still not visible, which also depends on the erroneous depthmap since the opaque and transparency objects are blended based on a depth comparison: bild_2018_08_31_10_27_32_892

fynnfluegge avatar Sep 03 '18 08:09 fynnfluegge

The sun is visible now and depth values are compared correctly in opaqueTransparencyBlend.comp shader. The problem was at transparency framebuffer (TransparencyFbo.java), where five color attachments were added to the framebuffer but only three were used. However, the attachments were accessed correctly with the right index by the sun shader, but somehow the Intel HD graphics has problems with unused attachments, so now the framebuffer's attachments are reduced to three. I have still black artifacts sometimes flickering at the skydome as depcited in my last post, if somebody has the same issues please reopen.

bild_2018_09_03_17_34_32_290

fynnfluegge avatar Sep 03 '18 15:09 fynnfluegge

I detect one last issue where both opaque- and transparency-depthmaps are bound to the same image index, because of this some flickering of the sun can occur. I Will fix and push this asap.

fynnfluegge avatar Sep 04 '18 07:09 fynnfluegge

I still get this: image

Console:

/usr/lib/jvm/java-8-openjdk/bin/java -javaagent:/opt/intellij-idea-ultimate-edition/lib/idea_rt.jar=37885:/opt/intellij-idea-ultimate-edition/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-8-openjdk/jre/lib/charsets.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/jaccess.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/nashorn.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/jce.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/jsse.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/management-agent.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/resources.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/rt.jar:/home/barbarian/Projects/OpenSource/oreon-engine/oreonengine/examples-opengl/target/classes:/home/barbarian/Projects/OpenSource/oreon-engine/oreonengine/oe-core/target/classes:/home/barbarian/Projects/OpenSource/oreon-engine/oreonengine/oe-core-opengl/target/classes:/home/barbarian/Projects/OpenSource/oreon-engine/oreonengine/oe-gl-components/target/classes:/home/barbarian/Projects/OpenSource/oreon-engine/oreonengine/oe-common-world/target/classes:/home/barbarian/Projects/OpenSource/oreon-engine/oreonengine/oe-common-ui/target/classes:/home/barbarian/Projects/OpenSource/oreon-engine/oreonengine/oe-gl-engine/target/classes:/home/barbarian/.m2/repository/org/lwjgl/lwjgl/3.1.7-SNAPSHOT/lwjgl-3.1.7-20180727.141658-13.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-assimp/3.1.7-SNAPSHOT/lwjgl-assimp-3.1.7-20180727.141728-13.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-glfw/3.1.7-SNAPSHOT/lwjgl-glfw-3.1.7-20180727.142017-13.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-jemalloc/3.1.7-SNAPSHOT/lwjgl-jemalloc-3.1.7-20180727.141840-13.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-openal/3.1.7-SNAPSHOT/lwjgl-openal-3.1.7-20180727.141951-13.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-opengl/3.1.7-SNAPSHOT/lwjgl-opengl-3.1.7-20180727.141925-13.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-vulkan/3.1.7-SNAPSHOT/lwjgl-vulkan-3.1.7-20180727.142038-13.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-stb/3.1.7-SNAPSHOT/lwjgl-stb-3.1.7-20180727.141959-13.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl/3.1.7-SNAPSHOT/lwjgl-3.1.7-20180727.141658-13-natives-linux.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-assimp/3.1.7-SNAPSHOT/lwjgl-assimp-3.1.7-20180727.141728-13-natives-linux.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-glfw/3.1.7-SNAPSHOT/lwjgl-glfw-3.1.7-20180727.142017-13-natives-linux.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-jemalloc/3.1.7-SNAPSHOT/lwjgl-jemalloc-3.1.7-20180727.141840-13-natives-linux.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-openal/3.1.7-SNAPSHOT/lwjgl-openal-3.1.7-20180727.141951-13-natives-linux.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-opengl/3.1.7-SNAPSHOT/lwjgl-opengl-3.1.7-20180727.141925-13-natives-linux.jar:/home/barbarian/.m2/repository/org/lwjgl/lwjgl-stb/3.1.7-SNAPSHOT/lwjgl-stb-3.1.7-20180727.141959-13-natives-linux.jar:/home/barbarian/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar:/home/barbarian/.m2/repository/org/projectlombok/lombok/1.18.2/lombok-1.18.2.jar:/home/barbarian/.m2/repository/org/springframework/spring-context/5.0.4.RELEASE/spring-context-5.0.4.RELEASE.jar:/home/barbarian/.m2/repository/org/springframework/spring-aop/5.0.4.RELEASE/spring-aop-5.0.4.RELEASE.jar:/home/barbarian/.m2/repository/org/springframework/spring-beans/5.0.4.RELEASE/spring-beans-5.0.4.RELEASE.jar:/home/barbarian/.m2/repository/org/springframework/spring-core/5.0.4.RELEASE/spring-core-5.0.4.RELEASE.jar:/home/barbarian/.m2/repository/org/springframework/spring-jcl/5.0.4.RELEASE/spring-jcl-5.0.4.RELEASE.jar:/home/barbarian/.m2/repository/org/springframework/spring-expression/5.0.4.RELEASE/spring-expression-5.0.4.RELEASE.jar org.oreon.examples.gl.oreonworlds.GLOreonworlds
Sep 04, 2018 10:11:22 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@2a33fae0: startup date [Tue Sep 04 22:11:22 CEST 2018]; root of context hierarchy
Sep 04, 2018 10:11:22 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [gl-context.xml]
INFO  [GLContext] OpenGL version: 4.3 (Core Profile) Mesa 18.1.7 bytes
INFO  [GLContext] Max Geometry Uniform Blocks: 14
INFO  [GLContext] Max Geometry Shader Invocations: 32
INFO  [GLContext] Max Uniform Buffer Bindings: 84
INFO  [GLContext] Max Uniform Block Size: 65536 bytes
INFO  [GLContext] Max SSBO Block Size: 134217728 bytes
INFO  [GLContext] Max Image Bindings: 192
WARN  [DirectionalLight] DirectionalLight vector up [0.57735026,0.57735026,0.57735026] and direction [-0.6337243,-0.44360697,-0.6337243] not orthogonal

viloskovic avatar Sep 04 '18 18:09 viloskovic

Hm okay, in the oe-config.properties file of the opengl demo, when you set multisamples to 1 and run the demo, what do you get?

fynnfluegge avatar Sep 04 '18 21:09 fynnfluegge

Just about the same as before.

viloskovic avatar Sep 04 '18 21:09 viloskovic

what do you see if you set in GLRenderEngine line 278 to

fullScreenQuad.setTexture(deferredLighting.getDeferredLightingSceneTexture());

fynnfluegge avatar Sep 04 '18 22:09 fynnfluegge