Terrain Lightning
I was thinking about using different color values, I can compute them in build time, and then but them in a Color array.
Is this a good method or are there better methods?
VTerrain has an extensive section on terrain illumination.
Death of one is a tragedy, death of a million is just a statistic.
Death of one is a tragedy, death of a million is just a statistic.
I''m not interested in the math behind it, only how to implement it in openGL( the fastest way)
Well, you''re gonna have to understand the algorithms to implement it aren''t you?
Death of one is a tragedy, death of a million is just a statistic.
Death of one is a tragedy, death of a million is just a statistic.
I hate to break it to you but it is nothing but math!
here is a function that will create a color value based on height...
of course this is not optimized and it is only a quick and dirty way to do it!
www.lanceusa.com
[edited by - dnagcat on July 6, 2003 1:58:26 AM]
here is a function that will create a color value based on height...
//this funtion was quite FUN!!!...it takes the min and max z's of any map//and displays the color values red(max) to purple(min)...It was quite difficult//to figure out the math to make sure any map's (with any z range) RGB values//are assigned 255 for max z's and 0 for min z's...but it works...check the math!void SetVetexColor3ub(float max_z, float min_z){ //interval: the difference between 255 and 204 is 51 intervals //over that 51 intervals we would like to go from 0 to 128, or //128 to 255, etc...so 128/51 is 2.51 changes to the color value //to each of the 51 intervals //float interval = 128.0/51.0; if(max_z>255) max_z=255; //get rid of int span = (max_z-min_z)/5.0; //this is the span between each "if statement" float interval = 128.0/span; //this is the amount of the color to change for //each interval within a span int pad_max = 255-max_z; //this makes up for low max...for example if max is //224...we need this value (31) to bring it up to 255 float z; //changed as a prerendering calculation function for(int i = 0; i < num_squares; i++) { for(int j = 0; j<4; j++) { z = -(poly[i].vertex[j].z); if(z>255) z=255; //make sure z is not larger than 255 if(z<=max_z) { poly[i].vertex[j].color.red = (max_z-((max_z-z)*interval))+pad_max; //OK poly[i].vertex[j].color.green = (max_z-z)*interval; //OK poly[i].vertex[j].color.blue = 0; if(z<=(max_z-(span*1))) { poly[i].vertex[j].color.red = (max_z-((max_z-z)*interval))+pad_max; //OK poly[i].vertex[j].color.green = (max_z-z)*interval; //OK poly[i].vertex[j].color.blue = 0; if(z<=(max_z-(span*2))) { poly[i].vertex[j].color.red = 0; poly[i].vertex[j].color.green = (((max_z+pad_max)*2)-((max_z-z)*interval)); //OK poly[i].vertex[j].color.blue = ((max_z-(span*2))-z)*interval; //OK if(z<=(max_z-(span*3))) { poly[i].vertex[j].color.red = 0; poly[i].vertex[j].color.green = ((max_z+pad_max)*2)-((max_z-z)*interval); //OK poly[i].vertex[j].color.blue = ((max_z-(span*2))-z)*interval; //OK if(z<=(max_z-(span*4))) { poly[i].vertex[j].color.red = ((max_z-(span*4))-z)*interval; //OK poly[i].vertex[j].color.green = 0; poly[i].vertex[j].color.blue = ((max_z+pad_max)*2)-(((max_z-(span*2))-z)*interval); } } } } } } }}
of course this is not optimized and it is only a quick and dirty way to do it!
www.lanceusa.com
[edited by - dnagcat on July 6, 2003 1:58:26 AM]
quote:Original post by dnagcat
I hate to break it to you but it is nothing but math!
Whats your point? Are you telling me that you somehow are able to implement an algorithm you know nothing about ( without simply cut and pasting code, something which I disagree with )? Graphics programming is maths, get used to it.
Death of one is a tragedy, death of a million is just a statistic.
Guys I know the math else this post wouldn't be in the openGL section. The only thing I want to know: is it fast? and does it look good? btw I'm using geo-mipmapping.
[edited by - trilobyte on July 6, 2003 4:29:42 PM]
[edited by - trilobyte on July 6, 2003 4:29:42 PM]
Lmao, I think i''m the only one that gets what you''re saying. You can calculate lighting.. but you''re just wondering the best way to apply it to the terrain, right? I''ve used vertex lighting in my engine.. but it looks like crap, hehe. With the amount of subdivisions i have in my terrain, the smoothness just isn''t there. I haven''t implemented lightmapping yet, but it i know it''d be just as easy to do, and i''d have the ability to add so much more shadow detail. The one effect i love is calculating lighting values based on a higher resolution version of the terrain than the one that is being displayed (I noticed it in ace combat 4). This would be impossible with vertex lighting. Plus, you can scale the quality of the lightmaps for computers that don''t have the capability for the high resolution (and memory requirements) texture.
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
Python, just to let ya know, dnagcat said the same thing you did. Re-read his message, he is saying that the algorithm is full of math.
Ah yes, sorry about that Mr. Cat, I was at work so never spent much time reading over your post.
Mr. Byte : Your post asked for better methods, there are far better methods on vterrain.
Death of one is a tragedy, death of a million is just a statistic.
Mr. Byte : Your post asked for better methods, there are far better methods on vterrain.
Death of one is a tragedy, death of a million is just a statistic.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement