Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 21 Oct 2004
Offline Last Active Apr 29 2013 12:16 PM

Topics I've Started

How to make a 1Demensional Array Loose Octree?

09 April 2013 - 11:13 AM

So My current octree is node-pointer based, where each node has 8 child nodes.  I was reading that you can achieve O(1) insertion/deletion by using a 1Demensional Array.  Unless I'm wrong, the 1D array is not optimal for searching the tree when frustum culling?  So I was thinking of having both, where I use the 1D array for insert/delete objects, and the parent/child nodes when traversing the tree.


I've been trying to think how to map my parent/child data structure to a more flat 1Demensional array.  I wanted to know if anyone had done this and can give me any tips/pointers.


I was thinking maybe making an array for each depth?


My Children nodes are in a 3D array




Suggestions for Keeping track of Lights and Entities in a scene. [Design Question]

05 April 2013 - 11:13 AM

Let me describe my Idea of how I wanted my Scene/Renderer classes to work.  Then maybe someone with more experience can guide me and steer me the right direction.

The Scene Manager could arrange them in a Oct(quad) tree.  Scene Manager also holds all the light information.

My Renderer class gets a list of visible entities from the Scene Manger when it goes to render the scene.  It also gets a list of Lights from each entity and lets say I limit the lights that can be sent to the shaders by 8.  It sends the closest lights (and all directional lights) to the shaders.

So I was thinking that there would be a "dirty" flag gets set when an entity is moved.  And then once a frame the scene manager checks all dirty flags of entities and re-caches lights information (scene manager re adds it to the octree).

I Guess if I cached light information they would need dirty flags as well, and moving a light means iterating all entities to update light information for that light.


Would it be better for the scene manager to return a query of lights when the redenderer asked for them based on the position of an object and this not cached?  That way Scene manager doesn't have to keep checking dirty states etc..

Any thoughts or comments that someone can help me with?

Light following camera in OpenGL shader (problem)

04 April 2013 - 11:08 AM

So I'm trying to implement my own per-pixel light shader.  I'm using OpenGL


If I use gl_LightSource[0].position.xyz in my fragment shader everything works like it's suppose too.  I'm trying to send in the light position to a uniform variable, instead of using the gl_LightSource attribute.  I just can't seem to get it right.


In my Render Function (psuedo code)


setup projection

change to modelview and load idenity




for each object




 Bind Buffers







So using LightSouce[] position works when i set the position after the cameraMatrix before the FOR loop.


I'm trying to send the Light Position in eye Coordnates.  so I'm taking the light position and multiplying by the CameraMatix  (modelView).  Thats what I pass into the shader when setting shader uniforms.



So where did I go wrong when looking at this ?  Also, Should I be doing push/pop matrices with shaders?  If not, is there a better way to organize and send them to the shader?   But mostly, I want to know where I went wrong.


Thanks for any help, and those that took the time to read this.

Quick Question on shadow mapping and terrains

06 March 2013 - 05:43 PM

I've found tutorials that impliment shadows on objects in a small scene.  My question is what simple appoach do you take to do this on a large world terrain (think MMORPG Terrain).


I have a terrain and a light (the sun) that moves depending on time of day.  So it's position changes and thus the need for dynamic shadows on my terrain.


So my question is about the best way to set up the "projection from the light"


Do you move to the position of the sun and look at the center of the world (0,0,0) and make sure every object can be drawn to the depth buffer.  My guess is the light would have to be positioned really far away?




Do you adjust the view to point to some bounded box region (your view frustrum) and then draw objects.  My guess is this would allow the light to be closer ?



If these methods are both wrong, What is the correct appoach to setting up the light view/projection matrix for shadow mapping?

Help, I've optimized too much!

15 January 2013 - 12:59 PM

So my game was running around 50 FPS, but then I reworked my terrain by implimenting GeoMipMapping, and sending my entity draw calls to a frustrum check instead of just rendering all entities.


I'm now pushing 170 fps, and my laptops fan ramps up and gets loud.  I'm assuming this will cook the GPU after a while.


Is there a way to figure out how much to sleep given the FPS? I want to get it back down to 60ish fps (or some lower value).