Splend DX Shader

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Splend DX Shader // The Garage

1  |  

Post by Délé // Apr 2, 2008, 8:02pm

Délé
Total Posts: 1374
pic
Hey guys, here is a little shader I whipped up today called "Splend". Some of you might be familiar with a technique called "Splatting". It is used in game engines to blend textures together. It's used a lot in ground textures so you can make the ground have different colored areas (grass, soil, etc.). Anyway, splatting is a technique that efficiently blends textures together.


Now this shader is not quite splatting. It doesn't employ the same blending technique and isn't quite as efficient. It is a more efficient way of blending then was previously available in tS though. Before if you wanted to blend color maps, you would have had to use large maps because you couldn't tile the color maps without tiling the alpha map. This shader is a solution for that. It still uses regular blending, but it allows you to tile the color maps while keeping the alpha map at a 1:1 scale. So now you can use smaller tiled maps and still blend them together with an alpha map that blankets the whole ground.


If you try applying different alpha maps and play with the tiling, you will see what I'm talking about. ;) There is a 2x version and a 3x version. The 2x allows two color maps with one alpha, and the 3x allows 3 color maps with 2 alphas.


I think this shader should work ok, but if you find any quirks let me know and I'll see if I can fix them.


11865


11866


Btw, I have the fog shaders working well now too. I will upload those soon. I figured that I should make a short video to demonstrate those as they only work with certain lighting setups and such. ;)


EDIT: I have uploaded a new Splend RGB shader. This is much more efficient than the last one. You don't need to push a button to separate the alpha maps anymore, just drag and drop your images. Other than that it is the same. You can just click, ctrl click, or drag and drop textures into each slot. The last slot is for an RGB alpha map. It will use this to blend together your images using each color channel as an alpha map for each texture. At the very bottom you can adjust the offset and tiling of the textures (this will not tile the alpha map, only the texture maps).


15719

Post by Jack Edwards // Apr 2, 2008, 10:29pm

Jack Edwards
Total Posts: 4062
pic
Nice work Dele! :jumpy:

Post by RAYMAN // Apr 3, 2008, 11:39am

RAYMAN
Total Posts: 1496
pic
Thanks Dele !

Peter

Post by Délé // Sep 9, 2008, 2:11pm

Délé
Total Posts: 1374
pic
Upon request, I have uploaded a new Splend shader (Splend RGB). This shader allows four color maps and uses a single RGB map to blend them. Just drag and drop, click, or ctrl click to load the images into each slot. When you load a new RGB alpha map, you must press the "Generate Alpha" button before it will take affect. This breaks your RGB map into three separate alpha maps used to blend each color map.


IMPORTANT: It may take a few moments to generate the alpha maps. The larger the original RGB map, the longer it will take. It is recommended that you use smaller map sizes (512x512 or under).


The shader is available for download in my original post.


15007

Post by Délé // Sep 9, 2008, 3:06pm

Délé
Total Posts: 1374
pic
Sorry, I just realized that I saved the wrong object. If you already downloaded the Splend RGB shader, you might want to redownload it. I swapped the file with the correct one.


The new file is the actual shader. You will be able to drag and drop it onto your objects. Sorry for the mix up. :o

Post by robert // Sep 9, 2008, 4:10pm

robert
Total Posts: 609
pic
Amazing work Délé

:banana::jumpy::banana::jumpy:

Post by Tiles // Sep 9, 2008, 9:18pm

Tiles
Total Posts: 1037
pic
WEEEHA :D


Many thanks Dele :)

Post by Tiles // Sep 9, 2008, 9:46pm

Tiles
Total Posts: 1037
pic
Really great :)

Mmh, one more request, is there a way to adjust the UV repeating of the single textures? It is 1 and 1 at the moment, it stretches the textures to the colourmap size. This is the greatest benefit from the Multitexture terrainshader for the Gamestudio. Here you can tile the texture so that it looks good when being close, so that you can see a grass texture instead a green washy spot. And that would also be nice to have here :)

Post by Délé // Sep 10, 2008, 7:16am

Délé
Total Posts: 1374
pic
Thanks guys. :)

There should be a DefaultTexCoordShader node just below the Splend RGB node. Here you can adjust the offset and tiling (the TCMove and TCScale inputs). It will offset and tile the color maps, but not the alpha maps. So you can adjust your color maps for more detail without effecting the blending.

Let me know if that's what you were looking for. :)

15022

hth

Post by Tiles // Sep 10, 2008, 11:49pm

Tiles
Total Posts: 1037
pic
Yup, that's what i was looking for. Many thanks :)

Post by RichLevy // Oct 4, 2008, 6:01am

RichLevy
Total Posts: 1140
pic
Just a note to say thanks for this liitle plugin, it works great!...

You mentioned a fog shader, am I missing that somewhere? That sounds worth playing with also.


Rich

Post by Délé // Oct 4, 2008, 11:27pm

Délé
Total Posts: 1374
pic
The fog shader is really more of trick. It fades the object that it's applied to from it's texture to a solid color. If you have a big inverted cube that encompasses the entire scene textured with a constant shader of the same color, then the object will appear to fade off into the distance.


So it does take a little work to set up. It's not nearly as good as real DX Fog, but it can be useful in some situations, like having the ground fade off into the distance.


I was going to make a video for it, but haven't got around to it yet. I will one of these days. :rolleyes:


Here's where you can find it though:

http://forums1.caligari.com/truespace/showthread.php?t=5348

Post by RichLevy // Oct 5, 2008, 5:49am

RichLevy
Total Posts: 1140
pic
Very nice, and reasonably painless to get up to speed in. This was a basic plane ,primitive that I subdivided till it looked good enought. I did some basic soft selections and than just hooked up the shader to the materials node. To spice up the default textures I added a road thru the plane and than just made it a texture for a road thru the uve and material editor. very painless, far less work than Vue Infinite requires to do something similiar (though admitedly vue does add some wonderful vegitation, water and clouds :) )


Include this free viewer and texture map generator with this great script and you should have a wealth of great terrains for many, many years... http://www.spiralgraphics.biz/viewer/


Very nice work Dele.


Rich

Post by Délé // Oct 10, 2008, 1:53am

Délé
Total Posts: 1374
pic
I just uploaded a new Splend RGB shader in the first post. I learned how to write some HLSL, so now you don't need to press a button to separate the RGB map into the alpha maps anymore. It does everything on the fly and is more efficient than the previous version. :)

It should work ok, but let me know if you run into any problems. ;)
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn