Rendering DirectX Shader 3dsMax

Hey All,

We are using a DX shader in our engine here, and we have modified that to work inside max using an extension of the DX material in order to view what our materials will look like inside max. However we are running into the problem where we cannot render using that material, which is a problem when trying to generate lightmaps, or cubemaps.

Is this a difficult task to achieve? If so, does someone know who may be interested in tackling this for us, and possibly potentially help us out with some other max related programming?

Feel free to PM me if someone is interested or you know of anyone that would be able to take a look at this.

The Max and Mental Ray renderers do not support rendering of DX shaders. The best you could do would be to use Mental Mill, Node Joe, or the new schematic material editor in Max 2011 to create equivalent materials that will work in Max’s renderers.

Is it possible to create a shader in c++ that is an extension of the dx shader to work with the max renderers? Our shader is an extension of that class already, are you saying its not possible to fiddle with it more to get it to work?

In theory, yes its possible.
In reality, it took Mental Images a long time to develop metaSL to create both hardware and software shaders outof the same code (and its still far from flawless).

One hacky way to do it would be to ‘unfold’ the directx material/object in UV space and save that as texture.

But that requires cleanly unwrapped models with no overlapping or repeating uvs.

So its quite a hack, but i do use it from time to time myself.

If you’re shader is nothing fancy, you should try just creating a standard material stand-in and use that instead of your DX material when rendering.

You can also screen grab the viewport. I know this might not be ideal but there are some extra things you can do to help.

Use [B]gw.setPos/B which allows you set the viewport size. You can actually set it bigger than your screen! (it may be worth saving the current viewport size using gw.getWinSizeY() and gw.getWinSizeY() to set them back later)

Use gw.getViewportDib() to screen grab the viewport at this higher resolution.

Thanks for those tips Mr. Harwood, it made me bump something to the top of my list which I haven’t been prioritising, so now I have a large format viewport grabber in my toolkit - thanks again!

If anyone tries this stuff, don’t forget to call CompleteRedraw() after setting the gw size, or the screen doesnt get refreshed properly. :smiley:

This may be something of use for you. OZ Toggle DirectX (MXS) this script will automate the process explained here >>> HowTo Setup a DirectX Shader to display as a Standard 3DsMax Shader in Max’s Viewport
This will force the software renderer without having to reassign your directX shader and vice versus. Although, it may not be the support you need for generating lightmaps…and would then follow suit to Rob’s suggestion.

The only limitations i found, if i remember correctly, is that only 1 map is supported by the standard shader (in the above case, the diffuse map is used) when used in this setup. Don’t quote me…its been a while, but i believe recalling no support for the transparency map when coupled with the diffuse. Could possibly even be an error on my part.

Hopefully i’ll stand corrected. Please follow up if so. :slight_smile:
-Jason