Эх сурвалжийг харах

~ changed priority of assets loading, so background's assets should be loaded before looking into the assets folder
~ hopefully fixed effects that use shader targets so they now display properly

Signed-off-by: Alexis Maiquez <almamu@almamu.com>

Alexis Maiquez 5 жил өмнө
parent
commit
f86eba347c

+ 2 - 2
main.cpp

@@ -148,8 +148,6 @@ int main (int argc, char* argv[])
     std::string project_path = path + "project.json";
     auto containers = new WallpaperEngine::Assets::CCombinedContainer ();
 
-    // add containers to the list
-    containers->add (new WallpaperEngine::Assets::CDirectory ("./assets/"));
     // the background's path is required to load project.json regardless of the type of background we're using
     containers->add (new WallpaperEngine::Assets::CDirectory (path));
     // check if scene.pkg exists and add it to the list
@@ -164,6 +162,8 @@ int main (int argc, char* argv[])
     {
         // ignore the exception, this is to be expected of normal backgrounds
     }
+    // add containers to the list
+    containers->add (new WallpaperEngine::Assets::CDirectory ("./assets/"));
 
     // parse the project.json file
     auto project = WallpaperEngine::Core::CProject::fromFile ("project.json", containers);

+ 10 - 10
src/WallpaperEngine/Render/Objects/CImage.cpp

@@ -115,12 +115,12 @@ CImage::CImage (CScene* scene, Core::Objects::CImage* image) :
     memcpy (this->m_texCoordList, data2, sizeof (data2));
 
     GLfloat data3 [] = {
-        0.0f, 0.0f,
-        1.0f, 0.0f,
-        0.0f, 1.0f,
-        0.0f, 1.0f,
-        1.0f, 0.0f,
-        1.0f, 1.0f
+        -1.0f, -1.0f, 0.0f,
+        1.0f, -1.0f, 0.0f,
+        -1.0f, 1.0f, 0.0f,
+        -1.0f, 1.0f, 0.0f,
+        1.0f, -1.0f, 0.0f,
+        1.0f, 1.0f, 0.0f,
     };
 
     memcpy (this->m_passTexCoordList, data3, sizeof (data3));
@@ -183,7 +183,7 @@ void CImage::simpleRender ()
     auto end = this->m_material->getPasses ().end ();
 
     for (; cur != end; cur ++)
-        (*cur)->render (this->getScene ()->getFBO (), this->getTexture ());
+        (*cur)->render (this->getScene ()->getFBO (), this->getTexture (), false);
 }
 
 void CImage::complexRender ()
@@ -197,7 +197,7 @@ void CImage::complexRender ()
     auto end = this->m_material->getPasses ().end ();
 
     for (; cur != end; cur ++)
-        (*cur)->render (drawTo, asInput);
+        (*cur)->render (drawTo, asInput, false);
 
     // render all the other materials
     auto effectCur = this->getEffects ().begin ();
@@ -232,7 +232,7 @@ void CImage::complexRender ()
                 if ((*materialCur)->getMaterial ()->hasTarget () == false)
                     this->pinpongFramebuffer (&drawTo, &asInput);
 
-                (*passCur)->render (drawTo, asInput);
+                (*passCur)->render (drawTo, asInput, (*materialCur)->getMaterial ()->hasTarget ());
             }
         }
     }
@@ -251,7 +251,7 @@ void CImage::complexRender ()
     glColorMask (true, true, true, false);
 
     for (; cur != end; cur ++)
-        (*cur)->render (this->getScene ()->getFBO (), asInput);
+        (*cur)->render (this->getScene ()->getFBO (), asInput, false);
 }
 
 void CImage::render ()

+ 1 - 1
src/WallpaperEngine/Render/Objects/CImage.h

@@ -62,7 +62,7 @@ namespace WallpaperEngine::Render::Objects
         GLfloat m_vertexList [6 * 3];
         GLfloat m_passesVertexList [6 * 3];
         GLfloat m_texCoordList [6 * 2];
-        GLfloat m_passTexCoordList [6 * 2];
+        GLfloat m_passTexCoordList [6 * 3];
         GLuint m_vertexBuffer;
         GLuint m_passesVertexBuffer;
         GLuint m_texCoordBuffer;

+ 4 - 1
src/WallpaperEngine/Render/Objects/Effects/CPass.cpp

@@ -64,7 +64,7 @@ ITexture* CPass::resolveTexture (ITexture* expected, int index, ITexture* previo
     return fbo;
 }
 
-void CPass::render (CFBO* drawTo, ITexture* input)
+void CPass::render (CFBO* drawTo, ITexture* input, bool hasTarget)
 {
     // set the framebuffer we're drawing to
     glBindFramebuffer (GL_FRAMEBUFFER, drawTo->getFramebuffer ());
@@ -133,6 +133,9 @@ void CPass::render (CFBO* drawTo, ITexture* input)
     this->a_TexCoord = *this->m_material->getImage ()->getTexCoordBuffer ();
     this->a_Position = *this->m_material->getImage ()->getVertexBuffer ();
 
+    if (hasTarget)
+        this->a_Position = *this->m_material->getImage ()->getPassTexCoordBuffer ();
+
     // use the shader we have registered
     glUseProgram (this->m_programID);
 

+ 1 - 1
src/WallpaperEngine/Render/Objects/Effects/CPass.h

@@ -21,7 +21,7 @@ namespace WallpaperEngine::Render::Objects::Effects
     public:
         CPass (CMaterial* material, Core::Objects::Images::Materials::CPass* pass);
 
-        void render (CFBO* drawTo, ITexture* input);
+        void render (CFBO* drawTo, ITexture* input, bool hasTarget);
 
     private:
         enum UniformType