Dante-666 / bouncy-ball

hello world game for g3d development and learning
1 stars 0 forks source link

Add a opaque dfffused ball to the scene. #1

Closed Dante-666 closed 4 years ago

Dante-666 commented 4 years ago

Transparent objects are causing some shader comilation issue which is really easy to fix in the UniversalShader but we need to learn how to work with the Any scene files and how to set attributes. This can be tackled with later.

Dante-666 commented 4 years ago

Added a basic ball with normal map and a diffuse texture. I am getting a weird error with g3d however wherein the opaque object is getting assigned to a transparent surface because the call to transparency check somehow returns SOME in the first call and later NONE.

This happened also with some sample scenes and a bsp model but I assumed that was broken and that there actually were transparent surface but the shader was screwing up.

Need to check if this happens in Windows as well, or on another Linux OS where the iCompile scripts were used. Workarounds need to be thought of but this will create an easier workflow in which we only have to model the surface and a normal map for basic looks.

Dante-666 commented 4 years ago

Checked that it happens with a release build of g3d as well. I am guessing that it has to do with linux and some conditional statements having a problem.

Dante-666 commented 4 years ago

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

258  void UniversalSurface::renderDepthOnlyHomogeneous

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

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

in UniversalSurface.cpp which calls

  1     /** Says nothing about the alpha channel */                                                                                                                                                                                             
417     inline bool notBlack() const {
  1         return ! isBlack();
  2     }

in Component.h, replacing the member variable with a call to return the member function fixes this issue as a call to a private member

310     void computeStats() const {

is performed in the max() member function resulting in the correct blackness which is true rendering the hasTransmission to result in false and assigning correct material properties.

Index: G3D10/G3D-app.lib/include/G3D-app/Component.h
===================================================================
--- G3D10/G3D-app.lib/include/G3D-app/Component.h   (revision 7047)
+++ G3D10/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;
     }
 };

Update Morgan if the issue is reproducible in Windows and other non-rolling Linux platforms as well.

Dante-666 commented 4 years ago

I guess we can call this a close. Will reopen this if Morgan disagrees with the fix.