nick at January 7th, 2010 09:47 — #1
How can I declare global temporaries (i.e. variables accessible to all functions within a shader) in HLSL?
Trying to do this the straightforward way gives a compiler error. The manual also mentions that global variables are considered uniforms (i.e. shader constants). Is there any way to declare them to be temporaries? Is there some convenient alternative approach? I'm trying to translate some C/C++ to HLSL...
oisyn at January 7th, 2010 11:21 — #2
Shouldn't the static modifier on a global be enough?
static - Mark a local variable so that it is initialized one time and persists between function calls. If the declaration does not include an initializer, the value is set to zero. A global variable marked static is not visible to an application.
.edit: just tried, static indeed seems to work
nick at January 8th, 2010 08:00 — #3