Horde3D
http://www.horde3d.org/forums/

Terrain texturing, shaders & tiles
http://www.horde3d.org/forums/viewtopic.php?f=2&t=590
Page 1 of 1

Author:  PuG [ 01.01.2009, 12:42 ]
Post subject:  Terrain texturing, shaders & tiles

Good morning, ive just been looking through the Wiki at the section on using a detail texture controlled by RGBA channels within an image. I was wondering whether this could be adapted to instead of controlling one detail texture, to simply tile four textures, one for each channel. So the RGBA image would effectively become an attributes/blend map.

http://www.horde3d.org/wiki/index.php5?title=Shading_Technique_-_Dot_Product_Detail_Texturing

Slightly more useful agai would be not to use a combined RGBA image, rather instead split them into individual grey scale textures, so you can stack as many as you wish (and easier to edit and work with) rather than one image and four channels, which is a pain... (later enhancement would be again perhaps to add tile parallax mapping).

Example:

Code:
vec4 blendMap1 = texture2D(tex1, texCoords).gray;
vec4 blendTex1 = texture2D(tex2, texCoords * 300.0).rgb;
vec4 blendMap2 = texture2D(tex3, texCoords).gray;
vec4 blendTex2 = texture2D(tex4, texCoords * 300.0).rgb;
vec4 blendMap3 = texture2D(tex5, texCoords).gray;
vec4 blendTex3 = texture2D(tex6, texCoords * 300.0).rgb;
... and so on

I would have ago myself but don't know the first thing about shaders, and coding in general other than copying and pasting.

If it could be done, would be very useful for terrains. Anyone willing todo it?

Author:  AcidFaucet [ 01.01.2009, 22:50 ]
Post subject:  Re: Terrain texturing, shaders & tiles

That would be normal texture blending. The dot product technique is a texture unit saver, you can do it with vec2's using only one texture to get two that are splatted, or if index based (no blending) you can squeeze three detail maps out of one texture.

What you're mentioning is a good place to learn shading (except for parallax, which isn't trivial to add in).

Pseudo-code:
Code:
vec4 blendA = texture2D(blendMapA,texCoords);
vec4 outModifier;
outModifier.r = texture2D(blendTexA,texCoords*300.0).r;
outModifier.g = texture2D(blendTexB,texCoords*300.0).r;
outModifier.b = texture2D(blendTexC,texCoords*300.0).r;
outModifier.a = texture2D(blendTexD,texCoords*300.0).r;
float multFactor = dot(outModifier, blendA);
return out.rgba * multFactor;

Author:  swiftcoder [ 02.01.2009, 02:24 ]
Post subject:  Re: Terrain texturing, shaders & tiles

PuG wrote:
Slightly more useful agai would be not to use a combined RGBA image, rather instead split them into individual grey scale textures, so you can stack as many as you wish (and easier to edit and work with) rather than one image and four channels, which is a pain...
The reason they are stored as channels of a single RGBA texture is performance. Texture accesses are *very* expensive, so using a single RGBA texture saves 3 fetches, over using 4 greyscale textures

As for editing, you can of course edit them separately, and then combine into one image just before use (perhaps automated with an ImageMajik script), or you can edit the individual channels in Photoshop (disable 'channels in own colour' preference).

Author:  PuG [ 02.01.2009, 09:38 ]
Post subject:  Re: Terrain texturing, shaders & tiles

ah right, I understand. Ive used them before quiet heavily with another engine, I thought their must have been a reason why their normally combined :)

AcidFaucet - Thanks, I wouldn't even know where to start on learning how to write shaders - I can fiddle with most things. Do you guys normally use an IDE?

Best Regards,

Author:  swiftcoder [ 02.01.2009, 12:36 ]
Post subject:  Re: Terrain texturing, shaders & tiles

PuG wrote:
I wouldn't even know where to start on learning how to write shaders - I can fiddle with most things. Do you guys normally use an IDE?
Plain old text editor, FTW! ;)

Author:  AcidFaucet [ 02.01.2009, 23:23 ]
Post subject:  Re: Terrain texturing, shaders & tiles

Plain old text editor, forever.

Author:  Volker [ 03.01.2009, 11:53 ]
Post subject:  Re: Terrain texturing, shaders & tiles

I didn't wrote much shaders till now, but in this rare cases I'm using Notepad++ and the Horde3D Editor with instant reloading. This way I can test the shaders very fast (just by saving the file) and can check error messages of the compiler using the editor's log window.

Author:  marciano [ 04.01.2009, 14:33 ]
Post subject:  Re: Terrain texturing, shaders & tiles

For more complex projects like my skin rendering, I also used Notepad++ in combination with the Horde editor. That worked very well.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/