Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Uniform and extern, hlsl

4: Adsense

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   

4964
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.


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

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


#2 Hodgman   Moderators   

50612
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   

4964
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?

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

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





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.