Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Aug 2010
Offline Last Active Jun 17 2015 11:05 AM

#5233554 Game in pure C99

Posted by Dawoodoz on 08 June 2015 - 10:56 AM

I need a framework for my own programming language so that I can test it with real interfaces but haven't found anything for over a year now.

Is there any graphical C99 code sample based entirely on the Windows API and DirectX without any static linking?


I tried to integrate parts of SDL but can't take out one thing without pulling out the whole framework.

#5190542 Quick question about basic lighting

Posted by Dawoodoz on 01 November 2014 - 06:14 AM

The normals are linearly interpolated from vertex to pixel so you have to normalize the normals in each pixel or have results close to vertex light. If you have smoothing on an edgy object then vertex light will only produce light spots on the vertices.

#5187713 2D Physics/Game Engine For Massive Environment

Posted by Dawoodoz on 17 October 2014 - 02:24 PM

If performance is not an issue, you could use the Bullet engine and lock the position to a plane and rotation to an axis.
Bullet has optional 64-bit precision, continuous collision detection and don't require dynamic linking.

If you end up making your own engine anyway, the trick is to apply some of the force directly to the position to simulate how the velocity is converted into heat and then measure the difference between the stored velocity and displayed velocity to stop items from rotating by themself.

#5128120 Renderqueue / shader system design question

Posted by Dawoodoz on 02 February 2014 - 03:45 AM

I only sort by instances since anything advanced will just move the bottleneck to the CPU.


I use one opaque/alpha flag for the whole model and design with separate instances. This is not a problem since it is mostly particles and breakable windows that use alpha filtering.


I once tried removing the code that changed textures and the framerate did not change at all.

#5127959 AreaLight : Rectangle

Posted by Dawoodoz on 01 February 2014 - 10:25 AM

I don't see any multiplication with NdotL in the light intensity.

#5125824 Database modeling

Posted by Dawoodoz on 23 January 2014 - 03:43 AM

I discovered that higher normal forms on tables that I use to represent things in games reduce code complexity by up to 80% in safe languages. Instead of having 3 loops nested in each other, I have one loop over a list targeting child objects with many different parent objects in other tables.

#5120716 Shader Management for Lighting?

Posted by Dawoodoz on 02 January 2014 - 10:46 AM


In DirectX, I pasted some generic light sampling functions at the top of each shader before compiling them.


Pasted as in you paste in on every shader files, or you have some sort of a function that contains light texts in strings and combine it with every shader files to be linked during the first load?

I haven't got into shadow mapping yet, but thank you for your extra information, I'm pretty sure I'm getting there after this.



Pasted as text into every shader that is used for materials. I made it fast by saving pre-compiled shaders with check sums that tell if the shader has changed since the last compilation. The hard thing was to maintain backward compability without bloating the code to insert so try to have a powerful interface from the start that is compatible with, amibient, diffuse and specular light for solid, thin and fog materials. Fog will sample the light without caring much about the direction of the light. Thin materials like fabric will sample the light on 2 sides of the surface. I did not implement anisotropic light but think about how you can implement it later on top of the old interface just in case.


For sampling the depth maps, I sampled with both bilinear interpolation and the percentage closer method. I took the maximum intensity of both to remove acne from the percentage closer method. The depth bias was calculated dynamically, based on depth map resolution and dimensions of the light source. For a spot light, the bias must be multiplied by the depth (not distance) from the light source.

#5120700 Shader Management for Lighting?

Posted by Dawoodoz on 02 January 2014 - 09:42 AM

In DirectX, I pasted some generic light sampling functions at the top of each shader before compiling them. An array from the CPU stored up to 64 light sources that passed the culling test. Having more lights than that would be too slow to render anyway. They same thing should be possible in OpenGL and works without dynamic shader linking.


For depth based shadow mapping, I made a 2D allocation argorithm that is 100% free from fragmentation because the only way to free an allocation is to free every light source. Start with a whole square in bucket 0 and let the remaining buckets be empty. Each bucket can at most have 4 unallocated slots and that is only right before one of them is use or divided again. When there is no unused square of the right resolution, divide a larger square until you have something. The only case where you can't get more memory is when the total amount of pixels is not enough because no matter how many smaller sizes that use 3/4, their sum is always smaller than one larger square.


#5066193 Starting C#

Posted by Dawoodoz on 30 May 2013 - 11:45 AM

I would stay away from any book that present any paradigm as a "silver bullet" since all programming paradigms have their advantages and pitfalls in different situations.

Functional programming is good for testability and GPU acceleration.

Data driven programming is good when the major bottle neck is loading lots of memory.

Object orientated programming is good when there is a clear one to one mapping between data and methods or you want safe polymorphism.

Relational programming is good when many objects share the same methods or you want persistence with a database.

#5060519 Entity state and animation

Posted by Dawoodoz on 09 May 2013 - 03:53 AM

My engine's SDK show how to make procedural bone animation from math so that jumping forward and landing sideway cause the character to sidestep when landing to keep balance. "BoneAnimation" is the simpler example and "GiantMaze" allow colliding with things. Previously I tried following the laws of physics with ragdolls that fall to the ground like drunk people but even with a perfect balance system you would still have to break the natural laws with air acceleration to make it fun to play.

#5060515 Making a texture 'point' at something?

Posted by Dawoodoz on 09 May 2013 - 03:30 AM

You can use a tangent function to compute the offset in the head's space.

Could you elaborate on this?

What would you be comparing to get the tangent?



EDIT: On Hodgman's suggestion, there's code to calculate the UVs of a point on a sphere based on a normalized direction (i.e: a radius connecting the center of the sphere to the point where you want to find the UVs). It's from the wikipedia article on UV Mapping:





So I could take the vector from [center of eye] to [object being looked at], normalize it and use that as d.


It all depends on how you projected the textures in the first place and flat eyes will always be a rough approximation. if you want real precision, you can rotate 3D spheres instead.

#5060223 Making a texture 'point' at something?

Posted by Dawoodoz on 08 May 2013 - 01:58 AM

Apply a UV offset from a constant buffer to move the eyes like that. Then you cover the edges by lerping the eyes to visibility where the skin's alpha is low. You can use a tangent function to compute the offset in the head's space.

#5060220 Another X vs. Y thread: Java + GWT vs. JavaScript

Posted by Dawoodoz on 08 May 2013 - 01:43 AM

Java is better for beginners than JavaScript because you don't have to learn HTML and you get consistent compilation to bytecode instead of randomly not working on a certain browser with a certain combination of plugins.

#5050260 How do I get feedback from my engine's users?

Posted by Dawoodoz on 05 April 2013 - 05:31 AM

I only hear from the users of my engine in the guestbook when they can't register the component and I have never recieved a bug report. I don't know if my engine is too good so that they never found a bug or too bad so that they don't use it. Making a forum did nothing since they don't believe that anyone will answer in an empty forum. The only answer I got in my survey is from when someone pressed the button by mistake.

#5050255 DirectX Window drops to 30fps when it is not the foreground window in Win7

Posted by Dawoodoz on 05 April 2013 - 05:17 AM

I think it is implemented in the DXUT code. One of the many reasons for throwing it away and making your own.