Topic: Passing variable value to shader question?

Hi. Is it possible by some way to pass variable to shader by script? For examle time.

Re: Passing variable value to shader question?

Not right now, but it can be done in c++ :

    float time = 0.0f;

    MMaterial * material = mesh->getMaterial(0);
    if(material)
    {
        MFXRef * FXRef = material->getFXRef();
        if(FXRef)
        {
            unsigned int fxId = FXRef->getFXId();
            render->bindFX(fxId);

            // send uniform variable
            render->sendUniformFloat(fxId, "time", &time);

            render->bindFX(0);
        }
    }

Or you can use a trick :
- in Blender, animate a material variable you don't use in your shader : "MaterialShininess" for example
- use "uniform float MaterialShininess;" as your time variable

Re: Passing variable value to shader question?

So as far as i understand i have to create a "Game.ll" and create a behaviour?
One more question-how do you get "mesh" and "render"?

Last edited by Skywriter (2014-07-17 14:49:40)