Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


ic0de

Member Since 11 Nov 2010
Offline Last Active Apr 10 2015 09:00 PM

Topics I've Started

fitting Geomipmapping into my existing tree system

02 December 2014 - 12:59 PM

In my OpenGL based renderer I organize all the scenery in my world into a BVH tree which allows me to efficiently cull objects outside of the frustum. The leaves of the BVH tree are a data structure that I called a chunk, a chunk is simply a bunch of vertex data that is rendered using one draw call. The other day I added a loader for heightmaps and that was fairly straightforward, it generated a bunch of triangle tiles and offset the vertices by the heightmap value then the resulting data was stored in one chunk. Obviously drawing all the vertices in the heightmap in one go results in terrible performance. So I looked into geomipmapping which seems to fit my needs, the problem is the fact that geomipmapping requires I split up my chunks obviously but I am unsure how I should organize this from a Software architecture point of view. Should I totally separate terrain from the rest of the world and keep it in a separate tree? or should I just throw heightmap chunks into the regular BVH tree probably deriving a class heightmapChunk which adds LoD code? should I nest a quad tree inside my BVH as a node, in that case the whole quadtree is analogous to one regular chunk? 


getting better results with exponential shadow mapping

15 November 2014 - 03:14 PM

So after procrastinating for a long time I finally decided to add shadows to my game. I got regular shadow maps up and running pretty quickly but that had was not enough for me. After a failed attempt at variance shadow mapping I settled on exponential shadow mapping (ESM). It was fairly easy to get working but my implementation seems to have artifacts which were expected but for more severely the other implementations I have seen. The problem is where the shadow fades to nothing near the occluder, I expected this but not as severely as my results. So I was wondering if anyone knew of any ways to improve this property of ESM?

 

My worlds linear depth is rendered to a 32 bit floating point fbo from the light's point of view and then sampled using textureProj in glsl.

 

the area where the artifact is the worst is circled in the screenshot.

 

Here are screenshots and my code:

 

shadow.fsh

in vec4 v_pos;

void main()
{
	float linearDepth = length(v_pos) / nearSubFar;
    gl_FragColor.r = linearDepth;
}

shadow.vsh

void main(void)
{
	v_pos = modelViewProjectionMatrix * localTransform * vec4(position, 1.0);

    gl_Position = v_pos;
}

lighting.fsh

float getOcclusion(vec4 coord, float d)
{
	float occluder = textureProj(shadow_texture, coord).r;

	return clamp(exp(620.0 * (occluder - d  / nearSubFar)), 0.0, 1.0);
}

odd behavior with globally declared scoped reference types, is this normal?

22 October 2014 - 11:12 AM

Hi,

 

I've was having a little trouble with aligned data types so I tried using scoped reference types to represent these in angelscript. While they seem to work pretty well for managing aligned data I've noticed some funny behavior when they are declared in the global scope. Specifically When I try to access them from the script it causes my application to crash, not the script but my application. So here is an example of this behavior:
 

vec pos = vec(-74.25679016113281f, 0.0f, 27.4027156829834f); //this is a scoped reference type

void loop()
{	
	if(playerInSphere(pos, 25)) //it crashes where I access pos
	{
		//do stuff
	}
}

My guess is that the engine is somehow erroneously determining that 'pos' is out of scope and deleting it so that it ends up passing my application a null pointer which it tries to access and then crashes. Of course I could be wrong, I may have registered the type incorrectly or misunderstood the use of scoped reference types. Does anyone know what might be causing this or is it normal?


Optimization philosophy and what to do when performance doesn't cut it?

16 September 2014 - 01:59 PM

So I often have a dilemma when coding where I have to make things run faster but the project isn't finished. As programmers we are often told to code first and then optimize later, this is related to the famous saying "premature optimization is the root of all evil". However adhering by this philosophy is not necessarily always practical, this would require a costly review of a huge codebase, a much more economical approach would be to optimize "as you go" or basically making things as efficient as possible before moving on. I always have trouble figuring out which method is the most practical, when I'm faced with the fact that my project while not finished it simply does not meet performance requirements for the given hardware. What approach should I take to speeding it up?


orienting an object towards a point in bullet

25 July 2013 - 01:00 PM

In my game I need enemies to turn towards the object they are chasing. So I tried to make a function to turn their rigid body towards the point their going to by applying a rotational impulse proportional to the dot product between the way they're facing and the direction they need to do to. Here is my code:
 
void lookAtPoint(btVector3 point, btRigidBody* body)
{
	btVector3 pos = body->getCenterOfMassPosition();

	btVector3 dir = (point - pos);
	dir.setY(0.0); //restrict to two dimentsions
	dir.normalize();

	btTransform t;

	body->getMotionState()->getWorldTransform(t);
	btVector3 forwards(t.getBasis()[2]);

	forwards.normalize();

	body->applyTorqueImpulse(btVector3(0.0f, forwards.dot(dir), 0.0f));
}
The problem is that the object seems to turn in the direction opposite to where it's supposed to even if I reverse the direction of the impulse. For example if the object is to their right they will turn left. Is their any problem with my approach or am I making a simple stupid mistake with my code?

PARTNERS