Uniform and extern, hlsl

Started by
1 comment, last by cozzie 10 years, 10 months ago

Hi,

Can someone give me some explanation on when to use uniform and extern with global variables in my effects/hlsl shaders?

As I understand, they mean:

- Uniform: input to be both initalized and updated from outside the effect, i.e. from my application

- Extern: input to be updated/ changed from outside the effect, i.e. from my application

Which gives me the feeling that I could say that all my globals for matrices, lightsources, directions, colors etc, can be uniform or extern, or even both. But I'm curious what would be the reason to use either one of them or both.

For now I've set all non array globals to 'uniform extern' (world/worldinvtransp/viewproj matrices, ambient lighting, material parameters).

And all directional and point light parameters (vars) and my texture, to 'extern' (even though they're initialized from outside the shader, in my application).

I hope someone can clarify this.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Advertisement

Note that here, the docs say that "[extern] is the default marking for all global variables" and that "global variables are considered uniform by default."

So, whenever you do make a global matrix/lightsource/direction/colour/etc, it is already extern uniform without you needing to do/type anything wink.png

Thanks, then probably the only reason to do it, would be to distinct from statics/ only local in the shader used globals (not controlled from the application). I first thought it might help on optimization when compiling etc.

Ps; did you receive my PM a few weeks ago on my engine design?

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

This topic is closed to new replies.

Advertisement