Login using your username or email. You don't have an account yet? No worries, joining is easy.

Hello,
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().
Greetings Chris

UrbanFuturistic

03-28-2007, 03: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().

beuzel

03-28-2007, 04: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

rendermaniac

03-29-2007, 12: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.

Simon

UrbanFuturistic

03-29-2007, 01: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.

CGTalk Moderation

03-29-2007, 01: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.

Follow Us On:

The CGSociety

The CGSociety is the most respected and accessible global organization for creative digital artists. The CGS supports artists at every level by offering a range of services to connect, inform, educate and promote digital artists worldwide. More about us on TheArtSociety.com