The Daily Click ::. Projects ::. Stone Goose OpenGL Engine
 

Project: Stone Goose OpenGL Engine
Project Started: 26th October, 2010 Last Update: 26th November, 2010
Project Owner: ~Matt Esch~ Project Members:
Project Type: MMF2 Extension Project Progress:

Sprite scaling consistency
Posted 29th Oct 10, by ~Matt Esch~  
The Stone Goose OpenGL engine has the ability to calculate sprite scales. Lets see if I can explain the difficulty here...

OpenGL measures everything in "texels". When you specify sizes in OpenGL, you are working with texels. When you have finished telling OpenGL what to draw, the scene is rendered and you can see the image you have produced.

Sometimes, we want to know how big our polygons are going to be in pixels on our screens. If I draw a square that's 32 x 32 texels in size at a distance z from the camera, how big is that going to appear in pixels?

Well really we don't care what size it is going to be, rather, we want to know how we can draw a square that appears to be 32 x 32 pixels on our screen at distance z.

What we need to compute is the texel to pixel ratio. How many texels are there to the pixel? Stone Goose OpenGL engine can do this calculation for you. Of course this depends on how far things are away from the camera ( z distance ), since things get smaller due to perspective as they move away from the camera, so you have to specify the z distance and you get a ratio for that distance.

I have attached a screenshot of this in action. Thanks go to Hayo for the lovely graphics.

You can see that the main player looks like a 2D image. I decided that my main player sprite was going to be 50 texels away from the camera, and then calculated the sprite scale at z = 50. I calculate this number, and then draw all my sprites at actual pixel size * sprite scale, and then all of the sprites are scaled relatively.

I am thinking of making this scaling automatic, it would probably make it easier for people who don't understand it very well, but it might cause issues for people using lighting.

Another point to mention is that the HUD graphic you can see is actually a 2D sprite. This is not drawn in 3D but actually drawn as a 2D image on top.

That's all for now
Preview


Posted by Eternal Man [EE] 30th October, 2010

This is truly incredible. I am deeply thrilled about this! Now the only question remaining is, why Stone Goose?
 
Posted by ~Matt Esch~ 30th October, 2010

Maybe that will be explained some day
 
Posted by Hayo 2nd November, 2010

You will have to be in a certain state of mind and body to understand it though.
 
Posted by W3R3W00F 5th November, 2010

This is really cool! Good to hear there's a 3D engine in the works; I can barely understand the Raycaster extension.
 
Posted by Marko 6th November, 2010

Awesome, really awesome!
 
Posted by Strife 8th November, 2010

I wonder if it would be worthwhile to switch Paper Kart's engine from Mode7 to this. One thing's for sure: it would allow me to render stuff above the horizon line (such as walls), which Mode7 can't do.
 
Posted by Hayo 8th November, 2010

It probably would be worth it. The only downside is that it might be a bit less compatible with some systems but even that might have been fixed by the mighty Esch.
 


 



Project Forums


Favourite

Advertisement

Worth A Click