Sign in to follow this  
FeverGames

OpenGL true occlusion culling

Recommended Posts

FeverGames    126
Hi, I need to know wether an object is visible or not. Since we have some issues with openGL and hardware occlusion queries and the support of prev. video cards, I decided to propose another way, and see if this is doable. Maybe I am missing something, or maybe my methods would suck, please give me some feedback! First we render the whole scene to the backbuffer and depthbuffer, without the objects to test. Second we use the depthbuffer from the main scene, use a render target texture, and render all the objects to identify with a color code that can reproduce a number once read back. Third we scale down the rendertexture to a small size. This will remove all "little visible" objects but maintain most very visible once, say we scale with a factor of 4 Forth we read back all the pixels from the scaled down texture and identify the visible objects. How does this sound?

Share this post


Link to post
Share on other sites
Hodgman    51222
That requires you to synch up the CPU and GPU, so you'll create a large stall...

Some new console games are actually using a software renderer to rasterize a low-resolution depth buffer, and then do all the occlusion tests on the CPU to avoid the stall ;)

Share this post


Link to post
Share on other sites
FeverGames    126
Do you have any idea if this is more productive than causing that stall? It seems logic to reuse the original depthbuffer, but i get your point about transfering the data...

Share this post


Link to post
Share on other sites
Momoko_Fan    100
Is your scene static? Perhaps you can precompute occlusion information into a scene partitioning structure like a BSP or octree then you don't have to do this in real time.

Share this post


Link to post
Share on other sites
Hodgman    51222
Hardware occlusion culling isn't used by lots of games, and it definitely shouldn't be the only method of occlusion-culling used.

There's an article on gamasutra (can't find it at the moment) and probably some here on Gamedev too, which describe "occluders" or "occlusion volumes".

Basically, you define a convex polygonal shape for large objects in your scene. You then find the edges of this shape and use them to project an occlusion frustum out into the scene. You can then test the bounding-boxes of small objects on the CPU to see if they lie inside any of these frustums -- if they do, they're hidden.

You should probably also look into sector/portal systems. Portals can be culled using the same method as above (test the portal's BB against occluders, if hidden, don't traverse into the sector linked by the portal).

Share this post


Link to post
Share on other sites
Krypt0n    4721
before you start with occlusion culling, you shall identify what you want to achive.

occlusion culling is not to make something faster, it's rather to load-balance work. you will have more costs on one side and less on another, the goal is to save time in average by utilizing underutilized resources.

e.g.
-you have damn expensive pixelshaders, in this case your goal #1 is to cull pixels. This could be accomplished by a z-prepass.
-you are vertex limited. in this case your idea is not that bad, you could use the ID-rendertarget in a 2nd pass and identify the visible IDs. resolve them into an ID-buffer (1d texture either set to 0 or 1) and the first instruction in the vertexshader would check the ID and either reject the wohle vertex (dynamic branching) or execute the whole shader (like comple FFT for water or 8weight skinning for some 50k character).
-you are drawcall bound, in this case u need an earlier stage to cull, maybe a software rasterizer or even some artist set anti-portals (which are damn simple to implement) would help already.

sometimes some middleware could help :)

Share this post


Link to post
Share on other sites
staticVoid2    381
Quote:

You should probably also look into sector/portal systems. Portals can be culled using the same method as above (test the portal's BB against occluders, if hidden, don't traverse into the sector linked by the portal).


I would advise against using portals for the following reasons:

1. the are limited to indoor environments

2. you cannot classify where you are in the world without keeping track of every single sector you are in and testing whether you intersects a portal or not every time you move. (you also need to pair yourself with an initial sector) (this goes for all objects, not just the player). You *could* use a BSP tree to classify where you are (like in doom3) but anything involving a bsp is hellish work.

3. portal culling is done in world space, image-space methods should be used as they address the actual problem of occlusion on a raster grid rather than be specific to triangular meshes. e.g. In an image space method - dynamic particles could also be used as occluders.

Share this post


Link to post
Share on other sites
Krypt0n    4721
Quote:

2. you cannot classify where you are in the world without keeping track of every single sector you are in and testing whether you intersects a portal or not every time you move. (you also need to pair yourself with an initial sector) (this goes for all objects, not just the player). You *could* use a BSP tree to classify where you are (like in doom3) but anything involving a bsp is hellish work.
that depends on the rooms. if you have room geometry as well, it's fairly easy to check where you're in, and you can assume that "indoor" scene do have those "rooms". in cryengine it seems to be a simple n-gone.

Quote:

3. portal culling is done in world space, image-space methods should be used as they address the actual problem of occlusion on a raster grid rather than be specific to triangular meshes. e.g. In an image space method - dynamic particles could also be used as occluders.


imagespace doesn't strictly imply that a raster grid is used. doing portalculling in imagespace reduces the work to simple 2d-vector-math (rect-rect clipping).

I think a big advantage and at the same time disadvantage is that you need humans to set it up. so they need to be skilled in setting them in the most performant way. portals to cull empty rooms are useless, but also missing portals can be a big performance hit.

but I think the OP was anyway asking for something for dynamic scene, that makes PVS and portals kinda obsolete.

Share this post


Link to post
Share on other sites
Momoko_Fan    100
You can still make use of scene partitioning even if not the entire scene is static. If you know, given a part of the map, what other parts are visible, you can check if the dynamic object is outside the visible parts, and if so, cull it.

Share this post


Link to post
Share on other sites
FeverGames    126
Just to let you guys know:

I need to know if a view specific objects are visible for the viewer or not, hence the idea of checking with occluders. This doesn't need to be 100% pixel perfect, I need to know if an object is visible enough, so there is room for error (thus I can use a primitive object like a box in replacement of the actual objects in the scene)

I thought about using a software rasterizer (idea1, extension) in case of no hardware occlusion support.

Also i thought about using hardware occlusion when possible, either hardware occlusion queries or the method I described in my fipo.

It is not important that the check is done every frame from the game, but it does need to be checked periodically (let's say at least twice each second) so in case of software rasterizing / occlusion check this could be threaded in a second thread, away from the main thread.

Please keep spoofing me with idea's, critism and suggestions, since I am very curious on how to solve this.

Oh and p.s. as in any case, it needs to be as fast as possible :-P

Share this post


Link to post
Share on other sites
crowley9    226
How is your scene structured? I.e., Is there a good amount of occlusion from just culling dynamic objects behind static objects, or do you really need dynamic objects to cull dynamic objects?

If there are good static occluders (indoor scenes, outdoor scenes with occluding obstacles?), then I suggest looking for a visibility preprocessing algorithm or tool, which will allow you to make very quick decisions using simple queries at run-time.

If you really need to test for occlusion behind dynamic objects, then as another poster said, you should really consider where your bottleneck is, and see if either a z-pass or front-to-back sorting will get you what you need (removing pixel shaded overdraw). If you are geometry limited, then you should probably consider hardware occlusion culling (be careful with this, if you query to frequently, you will sync gpu to cpu and perf will suffer, if you batch too much, then by the definition of your scene type you may not get enough occlusion).

A SW rasterizer is good and all, but it is really difficult to build one with the flexibility of the API geometry pipe (VS and all). Perhaps if you were only using a some simple transforms (single matrices, pass through, etc.)

Something that you haven't really mentioned is if you intend to use this for rendering or for some other purpose (e.g., AI). Is it the former or latter? If the latter, then definitely use occlusion queries, and read back the results after a few frames.

As for the original idea. Just don't do it. :-) Reading back the frame data is a terrible idea (a huge stall, at least in DX9).

Share this post


Link to post
Share on other sites
staticVoid2    381
You could render all occluders in the scene without texture mapping, lighting etc. (This could be done in one draw call).

Then get the z buffer and build mip-maps, each mip-map is one fourth the size of the previous. When building a mip map you combine four z values into one by using the maximum z value of the four. At the highest level you would have just one pixel (z value) which is the furthest z value in the scene for this view point.

You could then take your objects 3d bounding box, project all vertices to the screen and build a 2d bounding box around those vertices. You then would use the closest z value of the bounding box and rasterize a simple rectangle to the highest level mip-map. If at any point the rectangles z value is < the z-value in the z buffer you move to a lower level mip until you reach the lowest level, if however no z-values in the buffer are < the rectangles z value you know that the box is not visible and can be culled away.

This is an idea I am going to implement soon, its just a slightly modified HOM's algorithm. I don't know how expensive it would be to lock the z buffer and build mip-maps each frame.

Share this post


Link to post
Share on other sites
FeverGames    126
Quote:
Original post by crowley9
How is your scene structured? I.e., Is there a good amount of occlusion from just culling dynamic objects behind static objects, or do you really need dynamic objects to cull dynamic objects?

If there are good static occluders (indoor scenes, outdoor scenes with occluding obstacles?), then I suggest looking for a visibility preprocessing algorithm or tool, which will allow you to make very quick decisions using simple queries at run-time.

If you really need to test for occlusion behind dynamic objects, then as another poster said, you should really consider where your bottleneck is, and see if either a z-pass or front-to-back sorting will get you what you need (removing pixel shaded overdraw). If you are geometry limited, then you should probably consider hardware occlusion culling (be careful with this, if you query to frequently, you will sync gpu to cpu and perf will suffer, if you batch too much, then by the definition of your scene type you may not get enough occlusion).

A SW rasterizer is good and all, but it is really difficult to build one with the flexibility of the API geometry pipe (VS and all). Perhaps if you were only using a some simple transforms (single matrices, pass through, etc.)

Something that you haven't really mentioned is if you intend to use this for rendering or for some other purpose (e.g., AI). Is it the former or latter? If the latter, then definitely use occlusion queries, and read back the results after a few frames.

As for the original idea. Just don't do it. :-) Reading back the frame data is a terrible idea (a huge stall, at least in DX9).


Hi,

to remove some confusion, we trying to make different setups for different engines plugin-wise, to check if certain objects were seen by the user, for testing purpose in research. The scene's are dynamic and not persé static, but it would be for lower profile games that do not take the extreme out of your pc just yet ;-)

I read some articles but i forgot to bookmark them since it was a while ago that a lot of engines now days create CPU occlusion maps to optimize scenes, which would be a good idea the other way around, to test if something was visible rather then if something is invisible.

To react on your idea about software rasterizers: nothing fancy is needed, it is just pure for testing occlusion, on a non 100% accurate basis but accurate enough for us to tell that the person beeing tested saw the object good enough. Imagine us hanging a plane with a bord saying "did u see this?" in a room. The whole idea of the plugin probably has some different output later on, that's why i want to try a software solution rather then standing behind it. So nothing fancy, just transformation of the view/projection and draw of an id or something.

I do know about all other techniques to pre process a lot (frustum culling, octtree's etc) and I also even thought about the idea that we can have a maximum radius where visibilty comes in to action. Since we have about 5 objects per scene/level to test, we can make a routine that first checks if those objects are in range, and if so, if they are visible.

And to note: I have no intention to think I can make a plugin that works on any engine that is out there, but I do want to try and make a few fallback theories to support things that are there (hardware occlusion queries, my idea was an idea but as we can see it was crushed and shot down ;) ) and based on that try to make plugins for different engines.

Thanks so much for all your help guys, you are really giving me some idea's and thoughts. I hope I answer any unclear questions/idea's with this post, and I hope you have some energy left ;-)

Share this post


Link to post
Share on other sites
FeverGames    126
Quote:
Original post by staticVoid2
You could render all occluders in the scene without texture mapping, lighting etc. (This could be done in one draw call).

Then get the z buffer and build mip-maps, each mip-map is one fourth the size of the previous. When building a mip map you combine four z values into one by using the maximum z value of the four. At the highest level you would have just one pixel (z value) which is the furthest z value in the scene for this view point.

You could then take your objects 3d bounding box, project all vertices to the screen and build a 2d bounding box around those vertices. You then would use the closest z value of the bounding box and rasterize a simple rectangle to the highest level mip-map. If at any point the rectangles z value is < the z-value in the z buffer you move to a lower level mip until you reach the lowest level, if however no z-values in the buffer are < the rectangles z value you know that the box is not visible and can be culled away.

This is an idea I am going to implement soon, its just a slightly modified HOM's algorithm. I don't know how expensive it would be to lock the z buffer and build mip-maps each frame.


To me, this sounds very expensive and a lot of work. How would this improve against rendering 3D bounding volumes to an occluder buffer and do a read-back on that? Wether this occluder buffer is through hardware occlusion queries of an offscreen plane or a smart software rasterizer thing, I think making mipmaps and locking the depth buffer would stall a lot, but I am not sure about this?

Share this post


Link to post
Share on other sites
staticVoid2    381
Quote:

To me, this sounds very expensive and a lot of work. How would this improve against rendering 3D bounding volumes to an occluder buffer and do a read-back on that?


it is essentially the same thing although with using mip-maps you avoid expensive fill rates.

you also render a simple rectangle around the bounding box rather than up to a possible 6 triangles.

Share this post


Link to post
Share on other sites
Krypt0n    4721
Quote:

Then get the z buffer and build mip-maps, each mip-map is one fourth the size of the previous.

from VMem to system mem? that's probably more expensive than anything you can gain from it. if you want to rely on the hardware, you need to work asynchronously and for that occlusion queries are the way to go.

Quote:

You could then take your objects 3d bounding box, project all vertices to the screen and build a 2d bounding box around those vertices. You then would use the closest z value of the bounding box and rasterize a simple rectangle to the highest level mip-map.
this approauch would be very view dependend. in lot of cases object would be market visible behind walls, just because their rect in screenspace, using nearest-z stick through walls. it would work great with occluders that are coplanar with the nearplane, but you just need to turn the came slightly and you might get an dramatic increase in drawcalls.

maybe that'll be good as an first-pass approach.

Quote:
This is an idea I am going to implement soon, its just a slightly modified HOM's algorithm. I don't know how expensive it would be to lock the z buffer and build mip-maps each frame.
building mipmaps on gpu would probably be fairly simple, but getting the buffer might be damn expensive.
you could maybe experiment with staging buffers from d3d10/11 and map them like 5frames later to be sure u dont stall anything. but then again, occlusion queries would deliver the same result with the same latency.

@FeverGames
so you're making a culling middleware like dPVS by umbra? what exactly do you mean by "we have about 5 objects per scene/level to test"? just 5objects? is it worth to implement culling for 5objects?
but yeah, distance based "culling" is quite common, it's usually combined with LOD systems, so the lowest LOD is just an empty mesh.

Share this post


Link to post
Share on other sites
FeverGames    126
Quote:
Original post by Krypt0n
Quote:

Then get the z buffer and build mip-maps, each mip-map is one fourth the size of the previous.

from VMem to system mem? that's probably more expensive than anything you can gain from it. if you want to rely on the hardware, you need to work asynchronously and for that occlusion queries are the way to go.

Quote:

You could then take your objects 3d bounding box, project all vertices to the screen and build a 2d bounding box around those vertices. You then would use the closest z value of the bounding box and rasterize a simple rectangle to the highest level mip-map.
this approauch would be very view dependend. in lot of cases object would be market visible behind walls, just because their rect in screenspace, using nearest-z stick through walls. it would work great with occluders that are coplanar with the nearplane, but you just need to turn the came slightly and you might get an dramatic increase in drawcalls.

maybe that'll be good as an first-pass approach.

Quote:
This is an idea I am going to implement soon, its just a slightly modified HOM's algorithm. I don't know how expensive it would be to lock the z buffer and build mip-maps each frame.
building mipmaps on gpu would probably be fairly simple, but getting the buffer might be damn expensive.
you could maybe experiment with staging buffers from d3d10/11 and map them like 5frames later to be sure u dont stall anything. but then again, occlusion queries would deliver the same result with the same latency.

@FeverGames
so you're making a culling middleware like dPVS by umbra? what exactly do you mean by "we have about 5 objects per scene/level to test"? just 5objects? is it worth to implement culling for 5objects?
but yeah, distance based "culling" is quite common, it's usually combined with LOD systems, so the lowest LOD is just an empty mesh.


Well yeah, "just 5". These objects are important to be marked as seen once they have been seen, so yeah, a fair small share of the CPU or GPU can be given away for this. To come to a fair trade of cost against speed, I already said it doesn't need to check every game frame, it can be done in a fixed once in a while time step.

Why would a threaded CPU occlusion rasterizer be not done? With Bounding boxes?

Share this post


Link to post
Share on other sites
staticVoid2    381
Quote:


from VMem to system mem? that's probably more expensive than anything you can gain from it. if you want to rely on the hardware, you need to work asynchronously and for that occlusion queries are the way to go.



you could implement a basic software rasterizer to render the occlusion geometry to a low-resolution z buffer and then build the mip-maps but then it becomes of a problem of determining the set of occluders that are visible as the software rasterizer will likely be to slow to render them all.

Share this post


Link to post
Share on other sites
FeverGames    126
Quote:
Original post by staticVoid2
Quote:


from VMem to system mem? that's probably more expensive than anything you can gain from it. if you want to rely on the hardware, you need to work asynchronously and for that occlusion queries are the way to go.



you could implement a basic software rasterizer to render the occlusion geometry to a low-resolution z buffer and then build the mip-maps but then it becomes of a problem of determining the set of occluders that are visible as the software rasterizer will likely be to slow to render them all.


I still don't really get what the use of mip maps are in the ideas..

Share this post


Link to post
Share on other sites
FeverGames    126
The objects that I want to know visibility from are always a plane. How about calculating a few rows and columns of points on that plane in world space, and test with rays from the centre of the camera to these points against the view frustum visible objects their bounding volumes?

Share this post


Link to post
Share on other sites
Krypt0n    4721
Quote:

Well yeah, "just 5". These objects are important to be marked as seen once they have been seen, so yeah, a fair small share of the CPU or GPU can be given away for this. To come to a fair trade of cost against speed, I already said it doesn't need to check every game frame, it can be done in a fixed once in a while time step.

so you're cost would be kinda 99% for generating an occlusion buffer, 1% for testing some bounding box against it. that's not effective.

Quote:

Why would a threaded CPU occlusion rasterizer be not done? With Bounding boxes?
why that effort if the result is the same as a hardware occlusion query would be?


in a case where you've few variable costs and most is fixcost, you goal needs to be to reduce the fix costs, so get rid of generating an occlusion buffer.
an alternative method to accomplish that can be raycasts. That's a common way to check for visibility e.g. for AI where you have N objects (typically <10) that need to know if there is any visibility inbetween. that would usually mean you have to rasterize N occlusion buffers. it's cheaper to make raycasts in that case.
especially with just 5 objects to test, you'll probably be faster.


Quote:

I still don't really get what the use of mip maps are in the ideas..

Mipmaps are used to have a conservative representation of far more data. it's useful in cases where u assume that most objects will be culled.
Imagin the simplest case, the mip level with just 1zexel. you just need to compare the nearest-z of an object with one depth value an if everything works out, you reject the whole object immediatelly.
it's of course the opposide with fine occlusion that is not that dense e.g. open enviropments where you always have some skybox-depth value that is max.
for reference: http://www.gamasutra.com/view/feature/3394/occlusion_culling_algorithms.php?page=2



Quote:
The objects that I want to know visibility from are always a plane.
you test always 5 planes? i'm really curious what you're doing. with 5 planes you might be able to have the possibility for some fast analytical methode, like projecting the scene triangles on the planes and tesselate it (some kind of 2d bsp). that could be specially fast if you have a low amount of triangles that cause a lot of overdraw.

Quote:

How about calculating a few rows and columns of points on that plane in world space, and test with rays from the centre of the camera to these points against the view frustum visible objects their bounding volumes?

i guess you had the idea already I described above, damn.;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By Kjell Andersson
      I'm trying to get some legacy OpenGL code to run with a shader pipeline,
      The legacy code uses glVertexPointer(), glColorPointer(), glNormalPointer() and glTexCoordPointer() to supply the vertex information.
      I know that it should be using setVertexAttribPointer() etc to clearly define the layout but that is not an option right now since the legacy code can't be modified to that extent.
      I've got a version 330 vertex shader to somewhat work:
      #version 330 uniform mat4 osg_ModelViewProjectionMatrix; uniform mat4 osg_ModelViewMatrix; layout(location = 0) in vec4 Vertex; layout(location = 2) in vec4 Normal; // Velocity layout(location = 3) in vec3 TexCoord; // TODO: is this the right layout location? out VertexData { vec4 color; vec3 velocity; float size; } VertexOut; void main(void) { vec4 p0 = Vertex; vec4 p1 = Vertex + vec4(Normal.x, Normal.y, Normal.z, 0.0f); vec3 velocity = (osg_ModelViewProjectionMatrix * p1 - osg_ModelViewProjectionMatrix * p0).xyz; VertexOut.velocity = velocity; VertexOut.size = TexCoord.y; gl_Position = osg_ModelViewMatrix * Vertex; } What works is the Vertex and Normal information that the legacy C++ OpenGL code seem to provide in layout location 0 and 2. This is fine.
      What I'm not getting to work is the TexCoord information that is supplied by a glTexCoordPointer() call in C++.
      Question:
      What layout location is the old standard pipeline using for glTexCoordPointer()? Or is this undefined?
       
      Side note: I'm trying to get an OpenSceneGraph 3.4.0 particle system to use custom vertex, geometry and fragment shaders for rendering the particles.
    • By markshaw001
      Hi i am new to this forum  i wanted to ask for help from all of you i want to generate real time terrain using a 32 bit heightmap i am good at c++ and have started learning Opengl as i am very interested in making landscapes in opengl i have looked around the internet for help about this topic but i am not getting the hang of the concepts and what they are doing can some here suggests me some good resources for making terrain engine please for example like tutorials,books etc so that i can understand the whole concept of terrain generation.
       
    • By KarimIO
      Hey guys. I'm trying to get my application to work on my Nvidia GTX 970 desktop. It currently works on my Intel HD 3000 laptop, but on the desktop, every bind textures specifically from framebuffers, I get half a second of lag. This is done 4 times as I have three RGBA textures and one depth 32F buffer. I tried to use debugging software for the first time - RenderDoc only shows SwapBuffers() and no OGL calls, while Nvidia Nsight crashes upon execution, so neither are helpful. Without binding it runs regularly. This does not happen with non-framebuffer binds.
      GLFramebuffer::GLFramebuffer(FramebufferCreateInfo createInfo) { glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); textures = new GLuint[createInfo.numColorTargets]; glGenTextures(createInfo.numColorTargets, textures); GLenum *DrawBuffers = new GLenum[createInfo.numColorTargets]; for (uint32_t i = 0; i < createInfo.numColorTargets; i++) { glBindTexture(GL_TEXTURE_2D, textures[i]); GLint internalFormat; GLenum format; TranslateFormats(createInfo.colorFormats[i], format, internalFormat); // returns GL_RGBA and GL_RGBA glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, createInfo.width, createInfo.height, 0, format, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); DrawBuffers[i] = GL_COLOR_ATTACHMENT0 + i; glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, textures[i], 0); } if (createInfo.depthFormat != FORMAT_DEPTH_NONE) { GLenum depthFormat; switch (createInfo.depthFormat) { case FORMAT_DEPTH_16: depthFormat = GL_DEPTH_COMPONENT16; break; case FORMAT_DEPTH_24: depthFormat = GL_DEPTH_COMPONENT24; break; case FORMAT_DEPTH_32: depthFormat = GL_DEPTH_COMPONENT32; break; case FORMAT_DEPTH_24_STENCIL_8: depthFormat = GL_DEPTH24_STENCIL8; break; case FORMAT_DEPTH_32_STENCIL_8: depthFormat = GL_DEPTH32F_STENCIL8; break; } glGenTextures(1, &depthrenderbuffer); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); glTexImage2D(GL_TEXTURE_2D, 0, depthFormat, createInfo.width, createInfo.height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glBindTexture(GL_TEXTURE_2D, 0); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthrenderbuffer, 0); } if (createInfo.numColorTargets > 0) glDrawBuffers(createInfo.numColorTargets, DrawBuffers); else glDrawBuffer(GL_NONE); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) std::cout << "Framebuffer Incomplete\n"; glBindFramebuffer(GL_FRAMEBUFFER, 0); width = createInfo.width; height = createInfo.height; } // ... // FBO Creation FramebufferCreateInfo gbufferCI; gbufferCI.colorFormats = gbufferCFs.data(); gbufferCI.depthFormat = FORMAT_DEPTH_32; gbufferCI.numColorTargets = gbufferCFs.size(); gbufferCI.width = engine.settings.resolutionX; gbufferCI.height = engine.settings.resolutionY; gbufferCI.renderPass = nullptr; gbuffer = graphicsWrapper->CreateFramebuffer(gbufferCI); // Bind glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); // Draw here... // Bind to textures glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, textures[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, textures[1]); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, textures[2]); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, depthrenderbuffer); Here is an extract of my code. I can't think of anything else to include. I've really been butting my head into a wall trying to think of a reason but I can think of none and all my research yields nothing. Thanks in advance!
    • By Adrianensis
      Hi everyone, I've shared my 2D Game Engine source code. It's the result of 4 years working on it (and I still continue improving features ) and I want to share with the community. You can see some videos on youtube and some demo gifs on my twitter account.
      This Engine has been developed as End-of-Degree Project and it is coded in Javascript, WebGL and GLSL. The engine is written from scratch.
      This is not a professional engine but it's for learning purposes, so anyone can review the code an learn basis about graphics, physics or game engine architecture. Source code on this GitHub repository.
      I'm available for a good conversation about Game Engine / Graphics Programming
    • By C0dR
      I would like to introduce the first version of my physically based camera rendering library, written in C++, called PhysiCam.
      Physicam is an open source OpenGL C++ library, which provides physically based camera rendering and parameters. It is based on OpenGL and designed to be used as either static library or dynamic library and can be integrated in existing applications.
       
      The following features are implemented:
      Physically based sensor and focal length calculation Autoexposure Manual exposure Lense distortion Bloom (influenced by ISO, Shutter Speed, Sensor type etc.) Bokeh (influenced by Aperture, Sensor type and focal length) Tonemapping  
      You can find the repository at https://github.com/0x2A/physicam
       
      I would be happy about feedback, suggestions or contributions.

  • Popular Now