How to change shader code variable dynamically?

Posted By: vlau

How to change shader code variable dynamically? - 10/27/07 18:48

Is there any way to change the shader code variable
at runtime? Here is an example :

// main.c
float myValue = 0.65; // this value may change at runtime

void main()
{
.....
.....
}

// Here is the part of the shader code copied
// from Terrain multitexture of mtlFX.c
//....
//....
// Add the vertex light and shadow map
#ifdef SHADOWMAP
//entry: Shadow Map Offset
//cntl: spin 0 1.0 0.05
//help: Light offset (0..1) to be subtracted from the shadow map

float offset = myValue;

FinalColor *= In.Color + (MaskColor.b - offset);

Thanks for any help.
Posted By: vlau

Re: How to change shader code variable dynamically? - 10/29/07 05:55

I've succeed to pass "myValue" variable via vecSkill1,
but still looking for other easier solutions.

Thanks again!
Posted By: JibbSmart

Re: How to change shader code variable dynamically - 10/29/07 06:11

check here for some ideas on a useful DLL. go down to Matt's first reply. no, it isn't easier than using vecSkill1 or something, but if you need to use more values later i'm sure it can help.

once you establish a useful function (i haven't given it a go) it could be a very clean solution which allows you a lot of flexibility.

i hope this is of some use.

julz
Posted By: vlau

Re: How to change shader code variable dynamically - 10/29/07 14:01

Thanks for your link Julz. Not more than 2 variables to be
passed right now, I would like to use vecSkill1... at the
moment but keep Matt's method in my HDD for future use.

Thanks!
© 2024 lite-C Forums