effect_load for string content

Posted By: HeelX

effect_load for string content - 05/02/11 19:50

Hi,

I consider compiling shaders during runtime and I wanted to ask you, if you could modify effect_load or create a new funtion for loading shaders from STRING* or char* data. This way, I could add dynamic code in front of the first line of a .fx file, for instance #define's, which are being added due to Lite-C compiler defines (like disabling specific sections of a shader, because it is disabled in a Lite-C header file or in a options menu, e.g. low/high shader quality).

Is that a reasonable feature suggestion? I hope so smile

best regards,
-Christian
Posted By: DJBMASTER

Re: effect_load for string content - 05/02/11 20:33

Passing a string containing shader code to effect_load() in place of the filename will run that shader code too grin
Posted By: Quad

Re: effect_load for string content - 05/02/11 23:03

also, you could compile low and high versions of shaders to .fxo files(like ssao_low.fxo and ssao_high.fxo) and then define materials for each of them and select the according material according to shader quality settings.
Posted By: HeelX

Re: effect_load for string content - 05/03/11 07:46

The user has to do this, because I rely on default.fx, which is different for A7 and A8 - so, if he uses A8, he can simply compile the shaders by himself. Also, I intend to concatenate a dynamically composed preamble of defines with a shader stub, that react on these defines. This way, Lite-C defines can be passed on startup to the shader code and optimized version can be compiled then. Also, if I pass static variables (like blur radius, blur samples, AO approximation passes, etc.) this way to a shader, things will get optimized, too.

I also intend to design my framework so that if some values change, shaders are getting re-compiled, like blur quality, etc. This way, I write a shader once and if the gamers wants a different shader quality (for, e.g, speed reasons), the user can pass this through a function to my solution and the very special shader gets re-compiled with the new settings. I also target to replace the different object shaders for my extra render views with one file for all and compile them differently for each object type.
© 2024 lite-C Forums