Simple terrain splatting [OpenGL]

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Saumane
Posts: 27
Joined: Wed Jul 09, 2008 6:14 pm
Location: Finland

Simple terrain splatting [OpenGL]

Post by Saumane »

I found a simple terrain splatting shader from google, and got it to work in Irrlicht! It only supports 3 detail textures and i have no idea on how to make it support more. It works with Irrlicht's terrain, but when i updated to the latest SVN, terrain always makes the program crash, but it does work with older versions of Irrlicht.

Image

download:
http://www.mediafire.com/?ywltfmhmjty
netpipe
Posts: 670
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

thank you

Post by netpipe »

I know many people have been looking for this, keep up the good work.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

looks fairly cool, nice one!
Image Image Image
Pyritie
Posts: 120
Joined: Fri Jan 16, 2009 12:59 pm
Contact:

Post by Pyritie »

Sweet
Hive Workshop | deviantART

I've moved to Ogre.
Pyritie
Posts: 120
Joined: Fri Jan 16, 2009 12:59 pm
Contact:

Post by Pyritie »

You could probably make it support 256 textures if you just used one color instead of three. Like you could make 255/0/0 be one texture, 254/0/0/ be another, 253/0/0/ be a third, etc.
Hive Workshop | deviantART

I've moved to Ogre.
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

Irrlicht texture matrix only allows 4 textures.
Pyritie
Posts: 120
Joined: Fri Jan 16, 2009 12:59 pm
Contact:

Post by Pyritie »

Oh, never mind then.

Could probably copy the whole terrain node and make the base material transparent or something.
Hive Workshop | deviantART

I've moved to Ogre.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Fourth texture is diffuse one?

Does this shader use dynamic lighting and fog? If yes, what type of fog and how many and what type of lights?
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Post by Mel »

In that meaning could it be posible to split the texture into several subtextures, so, perhaps, a 1024x1024 textures could contain 16 256x256 textures?
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Yes, it is possible. I use atlas texture in my engine for terrain splitting. But You have to remember about texture atlases problems: mipmapping, texel size etc...
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Yeah you can see mipmapping/fract artifactss in this screenshot:
Image

Its the faint white squares between the boundaries of different textures. I'm not talking about the white grid but if you look at the where the grey part meets the grass on the left you can see lots of white squares where I try to bilinear filter between the two textures. They can be alleviated but it takes some work and sometimes a big performance hit. Although I suppose if you don't want bilinear filtered boundaries it's ok.

EDIT: I'm talking about Mel/Nadro's ideas not this code snippet.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

You can increase quality by adding offset on texture. Texture is 4x higher, but quality is better:
Image
Image
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Setting the correct texture clamp mode should fix the bilinear filtering problem, but like blindside said you'll still get ugly borders as they lie in between two pixels at the next mipmap level up.

So unless you disable mipmaps or do expensive multi-sampling in the shader, you're going to have ugly borders.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Pyritie
Posts: 120
Joined: Fri Jan 16, 2009 12:59 pm
Contact:

Post by Pyritie »

bitplane wrote:Setting the correct texture clamp mode should fix the bilinear filtering problem, but like blindside said you'll still get ugly borders as they lie in between two pixels at the next mipmap level up.

So unless you disable mipmaps or do expensive multi-sampling in the shader, you're going to have ugly borders.
What about if you have like a 10px border around your texture (so the left border has 5px copied from the right side of the texture etc). Would that get rid of borders? :o

Also BlindSide your image link is broken.
Hive Workshop | deviantART

I've moved to Ogre.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

I still don't think that would completely solve it in all cases. You'd still get artefacts when looking along the edge, it would look worst as you're looking almost parallel to the faces. Anisotropic texture filtering would go some way to fix this I guess.
The best way to do an advanced terrain is a completely custom solution that doesn't work in general cases. A custom editor, file format, custom vertex format, a node that prepares the data and shaders that render it using specially prepared data like 3D textures with manually edited mipmaps. This would be a very big job and would mean modifying Irrlicht too.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply