Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Shader Assistance Required (Creating Texture Lookup)

Author
Message
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 24th Dec 2010 15:36
Hello, I'm clueless when it comes to shaders, which is why I "borrow" everyone elses! lol

I have this vertex fur shader (below) which I plan to add to my game engine, but I'm having troubles with setting the color of the fur.

I know that the FurColor vector controls the color, but what I'm after is to replace this with a 1x1 or 2x2 texture lookup so that each object can use the same shader yet be different colours.

Right now, the shader only uses whatever texture is applied to stage 0, (the default) but I'd like to load this lookup texture into stage 1 and use that to set the color instead.

Like I said I'm clueless when it comes to shaders and would like some help! Pointing me in the right direction is fine, but doing it for me is even better! lol



My signature is NOT a moderator plaything! Stop changing it!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Dec 2010 21:30 Edited at: 24th Dec 2010 21:34
A quick glance through that code suggests the final colour is determined by two things which are simply multiplied ("modulated") together, i.e. the base texture and the "diffuse" colour which uses the variable FurColor. I haven't studied Evolved's demo so do you know what the role of the existing texture is? In other words, is the colour solely determined by FurColor or does the texture play a role other than simply brightness?

Once I know that the answer should be simple.

[Edited spelling. ]
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 26th Dec 2010 20:54
No, the color is currently 100% based on the FurColor variable. (Sorry about the delay, it is Christmas and all! lol)

My signature is NOT a moderator plaything! Stop changing it!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Dec 2010 22:50 Edited at: 26th Dec 2010 22:53
Quote: "No, the color is currently 100% based on the FurColor variable."


Explain what you mean with reference to the shader code.

Edit: If you post a simple demo I'll probably be able to see what you mean but at the moment your statement is contradicted by the shader code. I probably won't be able to spend any time on it till Tuesday though.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 26th Dec 2010 23:36
I meant that the color of the fur is only changed by altering the FurColor variable. The texture is only whats used to create the fur effect, it doesn't affect the final color.

Just alter the Red/Green/Blue variables in the code to see the changes in Fur color.



My signature is NOT a moderator plaything! Stop changing it!
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 27th Dec 2010 00:54
So, you basically want to be able to change the texture to achieve the final color and look of the Fur effect, right? And, not alter the FurColor values?
Here, I adjusted the shader effect so that you only need to change the texture to achieve the final result. Just change the texture and you can control the look and color of the Fur effect.
Hope this helps?

Cheers

SLAYER RULES! YEAH, MAN!!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 27th Dec 2010 12:17 Edited at: 27th Dec 2010 12:48
Hmm? Is that really what he had in mind? I think it would help if he posted an example of the base texture that he's using. If it is true that all he wants is FurColor replaced by a texture which can then be changed for different objects then all he needs is a texture declaration and a texture read - plus the texture applied to stage 1 in DBPro. Should be easy. [But I'm still not sure what he means. ]

Edit

@Mobiius

I've just tested your shader with your dba code and it is very obvious, using The Slayer's images, that the final colour is determined by both the base texture and the FurColor variable. I think we need a bit more clarification from you.

Perhaps you want the original texture to be interpreted as greyscale? This would then be modified by FurColor to get the actual hue, but using a texture so each object, or even limb, can have its own hue. That would be easy to do as well, but at the moment your assertions conflict with the way your shader works.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 28th Dec 2010 05:18 Edited at: 28th Dec 2010 05:21
Quote: "Perhaps you want the original texture to be interpreted as greyscale? This would then be modified by FurColor to get the actual hue, but using a texture so each object, or even limb, can have its own hue."

That one.

I just meant that the fur texture I used was a greyscale image. But yes, I'd like to use the greyscale image and a texture lookup to alter the fur colour on a per object basis please. My earlier comments were that the final color was made up of the fur texture which sets the brightness of a pixel, and furcolor which sets the hue.

If only mind reading came as standard! lol

*edit* might help if I provide the texture I've been using. lol


My signature is NOT a moderator plaything! Stop changing it!
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th Dec 2010 12:37
Thanks for the clarification. I'll assume you'll be using a greyscale image. I'll post a working demo version later today (unless someone beats me to it ).
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th Dec 2010 17:10 Edited at: 29th Dec 2010 17:11
Here you go. I've used The Slayer's shader as a starting point as it was easier.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th Dec 2010 17:11
Screenshot for previous post.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 4th Jan 2011 18:27
Sorry for the delay, but that's exactly what I was after! I can now learn from it, and hopefully make my own changes to it in future.

Thanks a lot Slayer & GG!

My signature is NOT a moderator plaything! Stop changing it!
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 4th Jan 2011 18:51
Quote: "Thanks a lot Slayer"

You're welcome. Although my method wasn't exactly like you wanted, it can still become usefull later.

Cheers

SLAYER RULES! YEAH, MAN!!

Login to post a reply

Server time is: 2026-07-18 05:06:11
Your offset time is: 2026-07-18 05:06:11