Jump to content

  • Log In with Google      Sign In   
  • Create Account


Uniform and extern, hlsl


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 cozzie   Members   -  Reputation: 1445

Like
0Likes
Like

Posted 21 June 2013 - 03:35 AM

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.



Sponsor:

#2 Hodgman   Moderators   -  Reputation: 27585

Like
0Likes
Like

Posted 21 June 2013 - 06:10 AM

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



#3 cozzie   Members   -  Reputation: 1445

Like
0Likes
Like

Posted 21 June 2013 - 07:49 AM

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?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS