PDA

View Full Version : Splatting realtime terrain using glsl.


Simon
08-14-2008, 12:21 AM
Heres something I've been working on after work since Monday. I want to eventually create a cool little god game.. mixed with a little 3d sculpting and ecosystem generator.

I started off making a mesh from a heightmap. Then broke it up into chunks for optimization, built dynamic Lod generation... made them into vertex buffer objects for fast rendering. Taught myself glsl in an evening and got it textured.The framerates are obscenely high at the moment... I can render upwards of 4 million polys at 60fps. :/

I've come to a stumbling block at the texturing pass using GLSL. Basicly I want to splat slopes with a rock texture... mountains with a snow texture.. etc.

Problem is I'm not sure how to approach splatting in this new "do it on the gpu" era. My first start was to isolate points over a certain height and say something like "after 100 metres start gradation into snow". Thats easy enough. However what about slopes? I can easily enough say "when the normal stops pointing up make this a slope texture". But then how do I gradate them? Especially when LOD's kick in there will sudden jumps to new textures due to the fact two polys normals could be very different.

I'm not sure if I'm on the right track or just going off on tangents. Can anyone set me straight?

Heres some pics showing off where I am (with textures defined a start height and then a gradation... sorry about that nasty grainy grass texture.

http://img508.imageshack.us/img508/6489/glslfc8.jpg


http://img369.imageshack.us/img369/4371/glsl2py9.jpg


Night

-Si

Simon
08-15-2008, 09:06 PM
Test grass distribution. I need to get the shader to vary the hue. I'll have 3 or 4 textures as well.

Edit: urgh spot the obvious mistake. my depth testing is wrong. hmph. :/

http://img119.imageshack.us/img119/3193/grassvu6.jpg

Took ages but I managed to figure out how to modify the depth value in glsl and then after hours of trying to figure out to do I realise that if you discard the fragment it doesnt make a depth value.

...which is nice. Made the grass multidimensional and randomly sized.

http://img296.imageshack.us/img296/3560/lettherebecake2hx3.jpg

CGTalk Moderation
08-15-2008, 09:06 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.