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 / Different shader values for multiple objects

Author
Message
TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 24th Feb 2011 17:45 Edited at: 24th Feb 2011 17:46
How can I use different shader values for multiple objects? I have many types of glass, and some of them reflect light more than others, but I don't want to create new .fx shader file with different reflection values for every object.

Problem is that I know only how to change settings globally, but I don't know how to change shader variables for each object, or is it even possible?
Blobby 101
20
Years of Service
User Offline
Joined: 17th Jun 2006
Location: England, UK
Posted: 24th Feb 2011 17:51
I think if you just load the shader multiple times as different shader numbers, then you could each version different values using "Set effect constant vector" and "Set effect constant float"

TuPP3
19
Years of Service
User Offline
Joined: 26th Jan 2007
Location: [+--]FINLAND
Posted: 24th Feb 2011 17:57 Edited at: 24th Feb 2011 17:57
Oh, how I didn't think of that? Seems okay solution if it is not possible to change settings of the shader for multiple objects, I mean that loading the same shader again takes some memory space.

I guess it might be slower to use different settings in one shader than use another shader for every object...
Blobby 101
20
Years of Service
User Offline
Joined: 17th Jun 2006
Location: England, UK
Posted: 24th Feb 2011 18:04
Yeah, i'm not sure TBH - the other only way I could think is to duplicate the shader's HLSL INSIDE the shader file and change the names of the tweaks and texture paths for each instance, though I imagine it'd have a similar memory usage.

Login to post a reply

Server time is: 2026-07-17 13:59:44
Your offset time is: 2026-07-17 13:59:44