Home Technical Talk

normals material

polycounter lvl 15
Offline / Send Message
arrangemonk polycounter lvl 15
i always had a material showing the vertexnormals of an object (since max4)
looks like this in the render
QuantizedVertexNormalsLG.jpg
but i cant fine one for 3dsmax9 (64) bit

these things ere very usefull for rendering normalmaps from the viewports (for walls and stuff for example)

so, does anyone know how to get one of these materials for max9?

Replies

  • Tumerboy
    Options
    Offline / Send Message
    Tumerboy polycounter lvl 16
    I looked a while ago and couldn't find a good material. I just use lights on a white material, and it works fine.
  • Eric Chadwick
    Options
    Offline / Send Message
    John Burnett's InfoTexture, though it might be render-only.
    Ben Cloward has a HLSL shader in here.
  • KikiAlex
    Options
    Offline / Send Message
    float4x4 wvp : WorldViewProjection < string UIWidget = "None"; >;
    float4x4 World : World	< string UIWidget = "None"; >;
    
    struct app2vertex
    {
        float4 position        : POSITION;
        float3 normala				 : NORMAL;
    };
    
    struct vertex2pixel
    {
            float4 position        : POSITION;
            float3 normala				 : TEXCOORD01;
    };
    
    vertex2pixel vertex(app2vertex In)
    {
        vertex2pixel Out = (vertex2pixel)0;
        Out.position = mul(In.position, wvp);    // transform vert position to homogeneous clip space
        Out.normala = mul(In.normala,World);
        return Out;
    }
    
    float4 pixel(vertex2pixel In) : COLOR
    {
    		float3 N = ((normalize(In.normala)) +1)/2 ;
        return float4(N,1);
    }
    
    technique WithCulling
    { 
        pass simple 
        {       
        VertexShader = compile vs_1_1 vertex();
        ZEnable = true;
        ZWriteEnable = true;
        CullMode = cw;
        AlphaBlendEnable = false;
        PixelShader = compile ps_1_1 pixel();
        } 
    }
    technique NoCulling
    { 
        pass simple 
        {       
        VertexShader = compile vs_1_1 vertex();
        ZEnable = true;
        ZWriteEnable = true;
        CullMode = none;
        AlphaBlendEnable = false;
        PixelShader = compile ps_1_1 pixel();
        } 
    }
    

    copy this in a text file and name it something .fx and then open it from max as a
    "DirectX Shader"
  • Tumerboy
    Options
    Offline / Send Message
    Tumerboy polycounter lvl 16
    C:\Program Files (x86)\Autodesk\3ds Max 9\maps\fx\normals.fx(26): warning X4707: texcoord inputs used directly (that is, other than sampling from textures) in shader body in ps_1_1 are always clamped from 0 to 1
    C:\Program Files (x86)\Autodesk\3ds Max 9\maps\fx\normals.fx(26): error X4532: cannot map expression to pixel shader instruction set
    C:\Program Files (x86)\Autodesk\3ds Max 9\maps\fx\normals.fx(51): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
    ID3DXEffectCompiler: Compilation failed
  • arrangemonk
    Options
    Offline / Send Message
    arrangemonk polycounter lvl 15
    the infotexture worked fine (i only forgot to install those dlls too) :D
  • KikiAlex
    Options
    Offline / Send Message
    Sorry I tested that shader in max 2008, this version works on max 9 to.
    float4x4 wvp : WorldViewProjection < string UIWidget = "None"; >;
    float4x4 World : World	< string UIWidget = "None"; >;
    
    struct app2vertex
    {
        float4 position        : POSITION;
        float3 normala				 : NORMAL;
    };
    
    struct vertex2pixel
    {
            float4 position        : POSITION;
            float3 normala				 : TEXCOORD0;
    };
    
    vertex2pixel vertex(app2vertex In)
    {
        vertex2pixel Out = (vertex2pixel)0;
        Out.position = mul(In.position, wvp);    // transform vert position to homogeneous clip space
        Out.normala = mul(In.normala,World);
        return Out;
    }
    
    float4 pixel(vertex2pixel In) : COLOR
    {
    		float3 N = ((normalize(In.normala)) +1)/2 ;
        return float4(N,1);
    }
    
    technique WithCulling
    { 
        pass simple 
        {       
        VertexShader = compile vs_1_1 vertex();
        ZEnable = true;
        ZWriteEnable = true;
        CullMode = cw;
        AlphaBlendEnable = false;
        PixelShader = compile ps_2_0 pixel();
        } 
    }
    technique NoCulling
    { 
        pass simple 
        {       
        VertexShader = compile vs_1_1 vertex();
        ZEnable = true;
        ZWriteEnable = true;
        CullMode = none;
        AlphaBlendEnable = false;
        PixelShader = compile ps_2_0 pixel();
        } 
    }
    
  • Tumerboy
    Options
    Offline / Send Message
    Tumerboy polycounter lvl 16
    that works great, thanks.

    Have anything that will actually render?

    Or ideally, draw in viewport AND render?
  • Eric Chadwick
    Options
    Offline / Send Message
    InfoTexture should.
Sign In or Register to comment.