Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [ODFAEG] (Open Source Development Framework Adapted for Every Game)  (Read 139311 times)

0 Members and 1 Guest are viewing this topic.

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #135 on: March 23, 2014, 12:16:26 pm »
Hi!

I've done some tests in these days and there are concluant.

The entity manager store now each 2D or 3D objects with the same primitive type and texture in a class before drawing it on an rendertexture. (It's faster. :P)
The map class'll also be able to create the shadow and the lightmap.

And the entity manager choose the best options to render the scene, depending on the hardware support.

If shader are supported, an alpha test is performed : (I had to change the shader a bit)

 "uniform sampler2D depthBuffer;" \
            "uniform sampler2D frameBuffer;" \
            "uniform sampler2D texture;" \
            "uniform vec2 resolution;" \
            "void main () {     " \
                "vec2 position = ( gl_FragCoord.xy / resolution.xy );" \
                "vec4 depth = texture2D(depthBuffer, position);" \
                "vec4 color = texture2D(frameBuffer, position);" \
                "vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);" \
                "vec4 finalColor = pixel;" \
                "if (gl_FragCoord.z >= depth.z) {" \
                    "gl_FragColor = finalColor;" \
                "} else if (color.a < finalColor.a) {" \
                    "gl_FragColor = finalColor;" \
                "}" \
            "}";
 

Otherwhise the objects are sorted by their layer's position for 2D objects.

The same thing happens for 3D objects, excepts that if the shaders aren't support, an internal opengl depth test and alpha test is performed. (But it doesn't work with semi-transparent pixels of coursewith the 3D)

All entity managers and entities systems are now stored in the class World, and the developper'll be able to to store and access to 2D or full 3D entity managers and systems through the world static class everywhere in the source code, the world class have also some usefull functions, and the rendering loop have been simplified :

std::vector<Entity*> entities = World::getVisibleEntities<Entity>("E_TILE");// draw everything here...
            for (unsigned int i = 0; i < entities.size(); i++) {
                    getRenderWindow().draw(*entities[i]);
            }
            entities = World::getVisibleEntities<Entity>("E_WALL+E_DECOR+E_CARACTER+E_PONCTUAL_LIGHT");
            Entity& shadows = World::getShadowMap<Entity>();
            getRenderWindow().draw(shadows, BlendMultiply);
            // draw everything here...
            for (unsigned int i = 0; i < entities.size(); i++) {
                    getRenderWindow().draw(*entities[i]);
            }
            Entity& lights = World::getLightMap<Entity>();
            getRenderWindow().draw(lights, BlendMultiply);
 

The call of the window.clear and window.display functions aren't necessary anymore because it's done in the base application class.

I'll update the git hub when I've corrected all the remaining bugs, I need to have a simple way to generate and display entities before implementing the network and doing some tests on a remote server.

But I found this code more simplier than before and the developper'll not have to worry about which entity to use to render the scene correctly with the supported hardware and the game perspective.

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #136 on: March 23, 2014, 01:25:17 pm »
Is concluant a english word?

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #137 on: March 23, 2014, 01:44:42 pm »
Is concluant a english word?

Event if it's the root of an english word, it's not english itself :) I think he meant "concluding"

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #138 on: March 23, 2014, 03:01:01 pm »
I see.. So, is that also the 3D engine for any game? The snippets you've been showing?

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #139 on: March 24, 2014, 06:51:57 pm »
Yes I meant concluding and not concluant.

I've sorted the graphic engine :

There are 3 engines for the graphics:

The 2D engine which'll be contained in the odaeg::g2d namespace.

The 3D engine which'll be contained in the odfaeg::g3d namespace. (Not finished yet)

And the global graphics engine which'll render all the objects of the two first engines.

-The global engine'll contains the render window, the view, the textures, the vertices and all objects used to render a 2D or a 3D scene at the screen (It's the SFML graphics internal classes that I've rewritten to draw 3D vertices)
-The 2D engine contains the 2D entity manager, and all the 2D entities of the framework.
-The 3D engine'll contains the 3D entity manager and all 3D entities of the framework.

This is currently how it'll works once I'll update the git-hub.

The SFML rendering classes'll not be used anymore. (Even 3D objects'll be rendered with 3D vertices, I need that to manage the tilemaps)





« Last Edit: March 24, 2014, 06:54:07 pm by Lolilolight »

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #140 on: March 24, 2014, 08:24:11 pm »
Can you already make a simple FPS shooter with it? :)

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #141 on: March 24, 2014, 09:10:46 pm »
No, not for the moment but soon.
I've still to implement the 3D terrain generation and the 3D object loader, and after that normally you'll be able to create a simple fps.

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #142 on: March 27, 2014, 11:59:51 am »
I've improved some things and I'll update the git-hub repository this evening!

-Now, animations have children entities, animated entities can have another animated entities as children.

The interest is that you'll now be able to create bones animations, which each bone is a child of a parent animation. (And you can change children animated entity properties at each frame of the parent animation)

It's also usefull if an entity have several animations (a caracter for exemple which can attack, move, etc...)

-The entity manager can'll now choose the best way to render the scene, it depends if your PC support shader and render texture opengl functions or not.

So you don't have to care about the opengl functionnalities that your PC support.

But there is still a bug : the shadows aren't drawing but I'll correct that bug later, now, I would like to do network tests to implement the network module.

(Things become more complicate when I draw on a render texture and then on another render texture. (It's the case for the light and shadow maps, if rendertextures aren't supported the entity manager draw directly on the render window and do screen captures))

I would like to advance faster but I don't have so much time and I'm alone.

Ho, I've forgotten, I've also undefined references problem with my rectangle shapes classes.

Well, when I've finished to correct this last bugs and to put the networking and particule system in ODFAEG, I'll be able to begin to encode 3D features. (Terrain generation, 3D object loading, 3D shapes (sphere, etc...), and shadows and lighting in 3D, I think I'll use the opengl default lighting system if the PC doesn't support shaders otherwhise I'll made a pixel per pixel lighting, but i'm totally new with this but I would like to learn more about GLSL and opengl lighting)

A last things, the entities'll be able to have collision areas or volume now.

But I'm alone to do all of this so it'll take time, but one I'll have finished all of this, I'll be able to create awesome games of all genre. :)

I'm quite happy to have a functionnal 2D graphics engine.

I think I'll also integrate a SQL driver into the framework and the QT SQL modules classes, so, I'll not have to install QT if I want to use a database.
« Last Edit: March 27, 2014, 12:06:43 pm by Lolilolight »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #143 on: March 27, 2014, 12:55:30 pm »
Quote
I'm quite happy to have a functionnal 2D graphics engine.
Where are the demos? You have written 10 pages of technical posts, but I don't think people care about it, we just want to see what your framework is able to achieve. Show something ;)
Laurent Gomila - SFML developer

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #144 on: March 27, 2014, 02:49:47 pm »
Yes your're right I need to make a demo but before I have to change my tilesets a bit. :P

I even started to encode an IA for the demo but I've to rework the source code a bit to adapt the source code of the framework with the source code with my other project and it takes a bit time.

Otherwise I know that many people doesn't care about the technical part, it's why I want to hide it a lot of possible in the frawemork use.

I've started to encode the network, and the server and client classes, for the moment it supports three packets : RSAEncryptedPacket, AESEncryptedPacket and sf::Packet with udp and tpc sockets.

But this is also technical things then, I'll not elaborate this anymore, it'll be explained in more details in the tutorials.

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #145 on: March 27, 2014, 09:03:35 pm »
Git-hub updated!


I've oprimised the rendering in the entity manager, and implementing the network module.
No tutorial for the moment because I've to rewrite it and to make a demo of with the 2.5D engine.
I don't use the graphic module of SFML anymore and I use 3D vertices to render everything. (It's more simple)

SFML'll just be used for the network, the window, the events and I'll also use it for the sound.

But actually I've a problem with code block for projects using ODFAEG, code blocks show me this message every time I want to aexecute the demo :
-It seems that this projet has not been build yet. Do you want to build it now ?
I clicked on the yes button and I have this warwing messages :

Code: [Select]
||Warning: resolving _glewInit by linking to _glewInit@0|
||Warning: resolving _glewGetErrorString by linking to _glewGetErrorString@4|
||=== Build finished: 0 errors, 2 warnings (0 minutes, 1 seconds) ===|

And then, nothing happens...., code::block don't want to build my .exe anymore.  >:(

I haven't changed anything, yesterday it was executing fine but today....

I really don't understand.

I've tried to recreate a code::block projet but it didn't solve the issue.


PS : I've found the problem, I had to declarate this variable to be static :
#ifndef ODFAEG_SINGLETON_HPP
#define ODFAEG_SINGLETON_HPP
#include <mutex>
namespace odfaeg {
    static std::recursive_mutex rec_mutex;
}
#endif
 

Another thing, if I don't declare a pointer to the render texture in the class Map, it crash, same thing in the class TileMap.

« Last Edit: March 27, 2014, 09:26:18 pm by Lolilolight »

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #146 on: March 27, 2014, 09:30:40 pm »
So, is this a component based architecture or you inherit entities?

Lolilolight

  • Hero Member
  • *****
  • Posts: 1232
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #147 on: March 27, 2014, 09:43:10 pm »
Quote
So, is this a component based architecture or you inherit entities?

No I inherit from entity, because I've a scene graph and each entities have children and parents, and I combine transformations.

It's not like in the SFML tutorial where the node have only one child (the sf::Sprite), it's more complicate than that but more powerfull, I can put all the information in the entity node, and do collision test in the node entities or in the root entity, and don't need to use OBB-Trees or something like that and for animations it's more simple too.

I've modified my shader in the tilemap class and it work event with full 3D semi-transparent objects : (The previous code was wrong)

 "void main () {"
                "gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;"
                "gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;"
                "gl_FrontColor = gl_Color;"
            "}";
            const std::string  depthGenFragShader =
            "uniform sampler2D depthBuffer;"
            "uniform sampler2D texture;"
            "uniform vec2 resolution;"
            "void main () {"
                  "vec2 position = ( gl_FragCoord.xy / resolution.xy );"
                  "vec4 color = texture2D(depthBuffer, position);"
                  "vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);"
                  "if (gl_FragCoord.z > color.z && pixel.a >= color.a) {"
                     "gl_FragColor = vec4(0, 0,  gl_FragCoord.z, pixel.a);"
                  "} else {"
                     "gl_FragColor = color;"
                  "}"
            "}";
            const std::string frameBufferGenFragShader =
            "uniform sampler2D depthBuffer;"
            "uniform sampler2D frameBuffer;"
            "uniform sampler2D texture;"
            "uniform vec2 resolution;"
            "void main () {     "
                "vec2 position = ( gl_FragCoord.xy / resolution.xy );"
                "vec4 depth = texture2D(depthBuffer, position);"
                "vec4 color = texture2D(frameBuffer, position);"
                "vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);"
                "if (gl_FragCoord.z >= depth.z) {"
                    "gl_FragColor = pixel;"
                "} else if (color.a < pixel.a) {"
                    "gl_FragColor = pixel;"
                "} else {"
                    "gl_FragColor = color;"
                "}"
            "}";
 

I don't undestrand why it's not integrated in the opengl pipeline...

But there is a limitation, the value of the zFar can't be greater than 253, because, I've to use a color component to store the z value on the depthtexture.

But I don't thing it's a real problem, I've read an article to do the perpective projection matrix (but I've change the matrix a bit because it wasn't very exact)  and it was said that if the zfar valu is too great it can cause depth test precision problems.

PS : I think this'll be the final version of the graphics engine node, the rest'll only be the add of new functionnalities then. (Drawing 2D/3D shapes, 3D terrain generation, etc...)
« Last Edit: March 27, 2014, 10:06:16 pm by Lolilolight »

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #148 on: March 28, 2014, 01:04:46 am »
Wasn't everyone concluding component based architectures are more powerful and the way to go? Also, having a scene graph is usually really bad as a primary storage for your scene data. It will be a nightmare to iterate efficiently in most cases, from what I've seen all around the web.

Ogre makes something like you do, attaching multiple items in a single node, I believe.

Wasn't there a alpha test in OpenGL? I think so (Not sure if its deprecated in latest API's).

Limiting the zFar to such a small value is really a bad thing to do. That definitely doesn't suit the "all kinds of games model", MANY 3D games implement huge zFar values to render geometry very far away. Many times over 1.000 units away I believe. Even more in cases like Arma, I think.

One question, why are you using a depth texture over a depthbuffer? Also, why don't you use the depth texture as a special kind of texture, made specifically for depths, I think the type is GL_DEPTH_COMPONENT? It works quite the same as a depth buffer I think.

I really think you are underestimating to have a fully functional 3D engine, which also does well all sorts of 2D tasks. If you suddenly realized you are only at the 0.05% progress, would you have the will to carry on until the end?

lolz123

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
Re: [ODFAEG] (Open Source Development Framework Adapted for Every Game)
« Reply #149 on: March 28, 2014, 01:43:10 am »
Some suggestions:

- Don't do the depth test manually.
- Try not to use if's in a shader, especially a fragment shader. It is very slow, especially when not branching on a uniform or constant.
- Use custom attributes.
- gl_ModelViewProjectionMatrix and the associated matrix stack are deprecated AFAIK.
- You probably don't need a texture matrix.
- You don't need gl_FrontColor.
- texture2D is deprecated.
- Use VBO's.
- Use deferred shading.
- glFlush is not needed.
- The way your engine is set up will make rendering shadow maps quite difficult, since it keeps swapping the shaders on you. Unless I understand it incorrectly.

I would recommend first reading up on modern OpenGL before making a 3D engine. Something like http://www.arcsynthesis.org/gltut/
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.