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 / Duplicate effect or set different constants on different objects?

Author
Message
Inflictive
17
Years of Service
User Offline
Joined: 16th Jun 2009
Location: Altis
Posted: 26th Sep 2013 09:19
In my game there are a lot of objects which use the same shader however with different constant parameters set on each one. I've noticed that it adds a ton of loading time when it has to compile the same effect over and over for each object. Is there a way to either, duplicate a compiled effect, or set different constants on each object the effect is applied to?

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Sep 2013 13:29
The first thing to check is whether your shader is using tangents and binormals. If not then, if I recall correctly, you can speed up things enormously by using the donotgenerateextradata flag in the load effect command:

Quote: "LOAD EFFECT Filename, Effect Number, Texture Flag, DoNotGenerateExtraData"


Otherwise the only way I know of, to set different constants in DBPro for different objects using the same copy of a shader, is to store the object specific data in a texture and read that in the shader. That works because you can apply different textures to each object. A trifle awkward but it works. Not sure offhand whether that helps the speed issue. Another solution would be to have an extra set of UV coordinates which contain the desired data - but that would be wasteful since the UV data would probably need to be the same for each vertex. Depends on what effect you are trying to achieve though.



Powered by Free Banners

Login to post a reply

Server time is: 2026-07-06 13:43:30
Your offset time is: 2026-07-06 13:43:30