[BUG] UniversalSurface::transparencyType() returns SOME in the first call and returns NONE in the next.

18 views
Skip to first unread message

Siddharth Singh

unread,
Sep 10, 2020, 9:01:19 AM9/10/20
to g3d-...@googlegroups.com
I was able to get a custom sphere with diffuse texture and normal maps to work. But in the code where it determines if the object is opaque/transparent, I noticed the behavior mentioned above. I took most of this code from the samples folder simpleGame and trimmed it down. Even the quake model in that level was not working and was giving the same assertion but I dismissed it because there were plenty of surfaces in that model. I thought it's better to create a single surface and try to run the same code and I figured this error out. If I do one call while debugging/add a line to the code to transparencyType(), this works and I get a good behaving ball in the scene.

Me and some of my colleagues are trying to learn graphics by building a small game 3D version of bounce and most of us use linux. I will try to ask a windows user to reproduce this in the meanwhile and get back to you. Any suggestions on why this may be happening or pointers to investigate are welcome.

Thanks and Regards,
Sid
latest_screenshot.png

Siddharth Singh

unread,
Sep 14, 2020, 10:25:17 AM9/14/20
to G3D Users

Hi All,

What I observed was that we supply a <white> file to the Transmissive texture which autoloads an opaque texture which is needed but while allocating transparent vs opaque surfaces in
void UniversalSurface::renderDepthOnlyHomogeneous

there is a sequence of steps which is as follows
We are trying to call isBlack() method via

=============================================
bool UniversalSurface::hasTransmission() const {
   return m_material->bsdf()->transmissive().notBlack();
}
=============================================

in UniversalSurface.cpp which calls

=============================================
/** Says nothing about the alpha channel */

inline bool notBlack() const {

   return ! isBlack();

}
=============================================

in Component.h, now the isBlack() method depends on a variable m_max which is initialized to Color::nan() and computed on a need-to basis by computeStats() which I think was done for faster loading.

replacing the member variable with a call to the member function fixes this problem as that ensures computeStats() will be called resulting in correct blackness.

Index: G3D-app.lib/include/G3D-app/Component.h
===================================================================
--- G3D-app.lib/include/G3D-app/Component.h    (revision 7048)
+++ G3D-app.lib/include/G3D-app/Component.h    (working copy)
@@ -425,7 +425,7 @@
 
     /** Says nothing about the alpha channel */
     inline bool isBlack() const {
-        return m_max.rgb().max() == 0.0f;
+        return this->max().rgb().max() == 0.0f;
     }
 };

Complete stack trace is,
#0  G3D::UniversalSurface::transparencyType (this=0x55555887df90) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/UniversalSurface.cpp:40
#1  0x00007ffff7db4aa3 in G3D::UniversalSurface::renderDepthOnlyHomogeneous (this=0x55555887df90, rd=0x5555555cee90, surfaceArray=...,
 previousDepthBuffer=std::shared_ptr<G3D::Texture> (empty) = {...}, minZSeparation=0, transparencyTestMode=..., transmissionWeight=...
) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/UniversalSurface.cpp:294
#2  0x00007ffff7d6b08b in G3D::Surface::renderDepthOnly (rd=0x5555555cee90, surfaceArray=..., cull=..., previousDepthBuffer=std::share
d_ptr<G3D::Texture> (empty) = {...}, minZSeparation=0, transparencyTestMode=..., transmissionWeight=...) at /home/dante/workspace/git/
g3d/G3D10/G3D-app.lib/source/Surface.cpp:337
#3  0x00007ffff7d540ff in G3D::ShadowMap::Layer::renderDepthOnly (this=0x555558610680, renderDevice=0x5555555cee90, shadowMap=0x555558
610600, shadowCaster=..., cullFace=..., polygonOffset=0, transparencyTestMode=..., transmissionWeight=...) at /home/dante/workspace/gi
t/g3d/G3D10/G3D-app.lib/source/ShadowMap.cpp:370
#4  0x00007ffff7d54029 in G3D::ShadowMap::Layer::renderDepthOnly (this=0x555558610680, renderDevice=0x5555555cee90, shadowMap=0x555558
610600, shadowCaster=..., cullFace=..., transparencyTestMode=..., transmissionWeight=...) at /home/dante/workspace/git/g3d/G3D10/G3D-a
pp.lib/source/ShadowMap.cpp:382
#5  0x00007ffff7d535b9 in G3D::ShadowMap::Layer::updateDepth (this=0x555558610680, renderDevice=0x5555555cee90, shadowMap=0x5555586106
00, shadowCaster=..., cullFace=..., transparencyTestMode=..., initialValues=std::shared_ptr<G3D::Framebuffer> (empty) = {...}, transmissionWeight=...)
at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/ShadowMap.cpp:361
#6  0x00007ffff7d529cf in G3D::ShadowMap::updateDepth (this=0x555558610600, renderDevice=0x5555555cee90, lightCFrame=..., lightProject
ionMatrix=..., shadowCaster=..., cullFace=..., transmissionWeight=..., passType=...) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/ShadowMap.cpp:278
#7  0x00007ffff7c434d0 in G3D::Light::renderShadowMaps (rd=0x5555555cee90, lightArray=..., allSurfaces=..., cullFace=...) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/Light.cpp:980
#8  0x00007ffff7cf9c2c in G3D::Renderer::computeShadowing (this=0x5555561fcd60, rd=0x5555555cee90, allSurfaces=..., ) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/Renderer.cpp:53
#9  0x00007ffff7af1524 in G3D::DefaultRenderer::render (this=0x5555561fcd60, rd=0x5555555cee90, camera= {...}, framebuffer = {...}, depthPeelFramebuffer = {...}, lightingEnvironment=..., gbuffer={...}, allSurfaces=...) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/DefaultRenderer.cpp:204
#10 0x00007ffff7b75595 in G3D::GApp::onGraphics3D (this=0x7fffffffc310, rd=0x5555555cee90, allSurfaces=...) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/GApp.cpp:1151
#11 0x00007ffff7b762fd in G3D::GApp::onGraphics (this=0x7fffffffc310, rd=0x5555555cee90, posed3D=..., posed2D=...) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/GApp.cpp:1208
#12 0x00007ffff7b7135b in G3D::GApp::loadScene (this=0x7fffffffc310, sceneName=...) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/GApp.cpp:953
#13 0x000055555555c947 in BallApp::onInit (this=0x7fffffffc310) at /home/dante/workspace/git/bouncy-ball/src/bball.cc:46
#14 0x00007ffff7b70471 in G3D::GApp::beginRun (this=0x7fffffffc310) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/GApp.cpp:1619
#15 0x00007ffff7b703fc in G3D::GApp::onRun (this=0x7fffffffc310) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/GApp.cpp:893
#16 0x00007ffff7b70338 in G3D::GApp::run (this=0x7fffffffc310) at /home/dante/workspace/git/g3d/G3D10/G3D-app.lib/source/GApp.cpp:877
#17 0x000055555555c553 in main (argc=1, argv=0x7fffffffe088) at /home/dante/workspace/git/bouncy-ball/src/bball.cc:13

I am loading the scene using basic objs with a albedo and a normal map,
   5   │     name = "Level",
   6   │
   7   │     models = {
   8   │     playerModel = ArticulatedModel::Specification {
   9   │         filename = "models/ball.obj";
  10 ~ │     };
  11 ~ │     groundModel = ArticulatedModel::Specification {
  12 ~ │         filename = "models/floor.obj";
  13 ~ │     };
  14   │     };
========================================================
  60   │         player = VisibleEntity {
  61   │             model = "playerModel";
  62 ~ │             frame = Point3(0, 2, 0);
  63   │         };
  64   │         
  65   │
  66 ~ │         ground = VisibleEntity {
  67 ~ │             model = "groundModel";
  68 ~ │             frame = Point3(0, 0, 0 );
  69 ~ │             canChange = false
  70 ~ │         };

Please let me know if you agree with the reasoning or (#2)I am doing something wrong here. There is a high chance of #2 happening here :)

Regards,
Siddharth

Morgan McGuire

unread,
Sep 14, 2020, 3:09:46 PM9/14/20
to g3d-...@googlegroups.com
Excellent patch. I have applied this and am testing right now. It may slow down loading by triggering that call; if so, I'll still commit for correctness and then address the performance issue later.

-m


--
You received this message because you are subscribed to the Google Groups "G3D Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to g3d-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/g3d-users/7a9699cf-f4b7-4449-8732-5ff64c2a9165n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages