• Create Account

# ic0de

Member Since 11 Nov 2010
Offline Last Active Apr 21 2016 03:24 PM

### point inside convex quad, using only integers?

03 April 2016 - 01:06 PM

So I'm writing an adventure game for DOS, don't ask why, its because I like to torture myself. I'm working on pathfinding and I need a way to figure out if a point is in a convex quad, but here's the catch: processors prior to the 486dx which my game targets (specifically a 286 or 386sx) had no builtin floating point support, this makes anything using floating point extremely slow, unfortunately most of the algorithms I've seen use floating point. Any know how I might do this?

EDIT: I should mention that this is all using 2D co-ordinates.

### 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:

```in vec4 v_pos;

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

```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?

PARTNERS