HLSL / .FX Post Effect Shaders in 3dsmax

shaders

#1

Hey everyone,

for the record, we are not a gamedeveloper and i have only VERY limited knowlege of HSLS and alike.

I am trying to create a diagnostic shader highlighting backfacing faces. The implementation provided by xview seems cumbersome (only selected objects) and rather slow (at least in our scenes).

I tried starting from the samples. But none of them seems to use the Normals. I took the post_output sample and added the normal by guessing. This leads to the shader not displaying anything anymore. There is no debugging/feedback whatsoever tho, so it is reall tough to get anything to work (besides tinting the output as a whole :wink: ).
Anyone happen to know a spot to find more samples or is able to lend a hand?

The Max docs and Maxscript docs do not really mention the feature at all so i am a bit lost.

Kind Regards and thanks in advance,
Thorsten


#2

I’m no expert but I believe you can only use the winding order to determine which direction a face draws in rather than having access to normals . You do this per pass

Here’s a snippet from a shader I’m writing at the moment.

CullMode = cw draws the “front” faces



     pass light01F
    <
        string Script= "RenderColorTarget0=;"
        "Draw=Geometry;";
    >
     {
 	  VertexShader = compile vs_3_0 VS(g_LightPos);
 	  CullMode = cw;
 	  ZEnable = true;
 	  ZWriteEnable = true;
 	  ZFunc = lessEqual;
 	  AlphaBlendEnable = true;
 	  SrcBlend = one; 
 	  DestBlend = one;
       PixelShader  = compile ps_3_0 PS(g_LightCol, 1);
     }

 

#3

Hey there, thanks for the input. I was under the impression you could access the normals as this is beeing done in some of the material samples. Anyways. I’ll look into that. I want a 2-pass effect rendering different col per pass i guess.

Thanks again!
Thorsten


#4

I did say I was no expert :wink:

You can use normals for lots of stuff in the pixel/vertex shaders but I don’t think its normals in the same sense you think of them as a modeller. to be honest, it all gets a bit fuzzy in this sort of area for me.

so yeah like you say , what I would do is have the pass for each “side” calling a different pixel shader - whether this is correct or not I have no idea but it’d probably work


#5

Try mocking it up with ShaderFX?


#6

What are you trying to diagnose with this shader?


#7

Flipped faces in CAD geometry. This can be done by turning off backface culling and two sided lighting to make the appear black. But it still does not really stand out. Essentially i want what xview for flipped faces does. Just for all objects not only selected, and faster.

Regards,
Thorsten


#8

@Rob: I tried taking a look with ShaderFX, it seems to support Objectshaders only tho, not scene effects.