Horde3D

Next-Generation Graphics Engine
It is currently 21.04.2025, 03:36

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: 01.01.2009, 12:42 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
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?

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
PostPosted: 01.01.2009, 22:50 
Offline

Joined: 19.11.2007, 19:35
Posts: 218
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;


Top
 Profile  
Reply with quote  
PostPosted: 02.01.2009, 02:24 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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).

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 02.01.2009, 09:38 
Offline

Joined: 11.06.2008, 10:34
Posts: 119
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,

_________________

Let's bring 'em out! Any old iron! Any old iron!
A door opens and a homewife brings out a rather sophisticated-looking ground-to-air missile system, and dumps it on the cart.
Thank you.


Top
 Profile  
Reply with quote  
PostPosted: 02.01.2009, 12:36 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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! ;)

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 02.01.2009, 23:23 
Offline

Joined: 19.11.2007, 19:35
Posts: 218
Plain old text editor, forever.


Top
 Profile  
Reply with quote  
PostPosted: 03.01.2009, 11:53 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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.


Top
 Profile  
Reply with quote  
PostPosted: 04.01.2009, 14:33 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
For more complex projects like my skin rendering, I also used Notepad++ in combination with the Horde editor. That worked very well.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 39 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group