Forum archive
some questions about voxelrendering
- hello everyone i just registered cuz i hope to find some answers to my questions in this forum :-> well first of all i think u should
know that im writing on my own voxel-based engine and till now everything looks fine .... but theres still something in my mind
that makes my nights sleepless , performance , i simply dont know what kind of optimizations i can use to speed up the whole thing
so i can achieve a playerable framerate.So any suggestions ? :-> Re: some questions about voxelrendering
Set default screen-res to 320x200 and/or buy a homogenous, general-purpose many-core CPU.Edited by ConsistentCallsign at- Have a demo? I'd like to see what you got. What are you coding it in?
- well its ansi c (mingw) till now not much is done except the basic functions like windowsetup,keyinput etc....
but i guess the rendering functions are more what u are looking for :P
int ztable[maxz][2];
void r_setuprotmat(void)
{
int i;
for(i = 0;i<maxz;i++)
{
ztable[i][0] = floor((cos(angx) + sin(angx))*i/4); //the depth is devided by two in this projection (2*2 = 4 :P)
ztable[i][1] = floor((cos(angx) - sin(angx))*i/4);
}
}
bool r_trace(int posx,int posy)
{
vec3_i curpos; // our position in voxelspace , we have to check here for a voxel!!!
int z;
for(z=0;z<maxz;z++)
{
curpos[0] = ztable[z][0]+posx;
curpos[1] = ztable[z][1]+posy;
curpos[2] = maxz-z;
//if voxel found set the colour and jump to the end of the func
}
if(col[0] == 0 && col[1] == 0 && col[2] == 0) return false;
else return true;
}
void r_cast(void)
{
int x,y;
r_setuprotmat();
for(x = 0;x<screensizex;x++) //add a variable for pixeldoubling would be nice here
{
for(y=0;y<screensizey;y++)
{
if(r_trace(x,y)) r_pixel(x,y,col[0],col[1],col[2]);
}
}
}
[edit]
ok after some thoughts and benchmarks i have kicked out the projection matrix and made a lookuptable which can tell
for every heightvalue where we are in the voxelarray, nice side effect: about 20fps more and additional 17fps for some
optimizations in win32 code :->Edited by yunharla at - what file format does this use? Is it usable? do you have screenshots?
- ok its been a long time (was a bit busy with studys -.- ) but i also made some progress with my little project
and here are some ingame impressions of the terrain engine (yeah i know nothing special but as i said i was busy :P)
the framerate is now at a playable level (about 130 @ 1440*900) and im going to add the voxel objects next (they'll be responsible for trees etc)
http://img142.imageshack.us/img142/9886/screenshotao.th.jpg
http://img267.imageshack.us/img267/4650/screenshot2o.th.jpgEdited by yunharla at - You should add some interpolation between voxels, so all voxels appear to be 1 pixel instead of a block it will make it look smoother.