View Full Version : Shader name conflict
03-28-2007, 04:01 PM
Here something stupid happens: The shader uses the HLSL function "clamp()" which fits a variable in a specifc range. But there is a extern variable defined called "clamp" which is set by the game engine. That is a name conflict, the shader will not work. To rename the variable the engine, the export tool, all exported meshes with material and all maya files need to be edited. That a big effort. So is there a way with a namespace like teh double points (::) in c++? Currently we are writing a HLSL small function which emulated the build in clamp().
03-28-2007, 04:31 PM
I don't know a great deal about HLSL, but I do know that namespaces are applicable in C as much as they are in C++, if you've ever programmed outside windows you may even have to specify 'using namespace std' at the start of your code (or 'using std::cout; using std::time();' etc if you want to be more specific).
It's possible that HLSL has its own namespace that's included automatically by VC++ but this is a top example of why you should always either create your own namespaces or add a unique prefix to your own functions, like tiMy... for tiMyClamp().
03-28-2007, 05:11 PM
Thanks for answer. In c++ namespace resolver work but I do want to know in HLSL. I cannot rename the clamp-function because it is build in the language HLSL. Greets Chris
03-29-2007, 01:17 PM
I am pretty sure that there aren't namespaces in HLSL (although I don't know a huge amount about it).
Could you come at this the other way and rename the shader parameter, but have a wrapper function around the code that calls your shader which copies the clamp value into shader_clamp? This would mean only changing it in the engine.
It's a bit of a hack of course, but it does save changing everything.
I know this comes up quite a lot with renderman when someone decides to call their shader "shadow" and then it never compiles because the shader name conflicts with a reserved name.
03-29-2007, 02:51 PM
Actually there are namespaces al over directX with the base namespace as Microsoft.DirectX and additional ones such as Microsoft.DirectX.Direct3D. I have no idea what clamp() is in though.
Have a poke around http://mindview.net/ and download the Thinking in C book to learn more about namespaces.
03-29-2007, 02:51 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.