Home Technical Talk

3ds Max, Shader FX, wind effect?

I made a shader in Shader Forge in Unity, and I'm trying to replicate it using Shader FX in 3ds Max 2015. This is to help me (and an outsource team) to create content that works well with our shader.

I have everything working great, except for the vertex shader part, which applies a wind effect to vertices with blue vertex color on them.

Is there a way to plug this into the Shader FX material to get it to deform live in the viewport?

I tried Object Vertex Position, but that turns the triangles invisible (wireframe is visible, but not the faces). I tried Displacement, doesn't seem to do anything though. I tried pressing the Play button too, for both hookups, nada.

Anyone do this successfully in Max?

CPGqTcQ.png

Replies

  • shaderfx
    Options
    Offline / Send Message
    shaderfx polycounter lvl 9
    the vertex position input expects the position to be in 'object' space.

    if you take a step back and plug in the "vertex position" node that you find (in advanced mode) then it should work.

    Then e.g. multiply the vertex position output with 2 and you will see the object expand around its pivot.

    That works for me here.

    It is possible you either have the position in the wrong space, or you are plugging something into the 'vertex position' input that makes the shader not compile and therefor the object does not render (though usually it would spit out a compile error if that was the case)
  • Eric Chadwick
    Options
    Offline / Send Message
    Thanks Kees. Which vertex position node?

    I moved my nodes into the Material group, but the triangles are invisible again.
    9ecwj4k.png

    I also drilled into the Vertex Shader group inside the Material group, and moved my nodes into there. The triangles are visible now but not moving.
    t1pOUdr.png
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 19
    When doing funky animated shader effects earlier this week in Maya I just added values to the stream between the "node" and "AifBempty" in that network (one step to the right of where you've plugged in your solution now). Worked well for me.

    The Vertex Shader Grp node looks similar(identical?) in Maya.
  • Eric Chadwick
    Options
    Offline / Send Message
    Thanks kodde! I'll try this out.
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 19
    Here's what it looks like on my side in Maya:

    uCaTpb.jpg
  • Eric Chadwick
    Options
    Offline / Send Message
    Hmm, still not working for me. Not sure what I'm doing wrong. :( Node turns red, but no errors appear.

    I get an error message only when I try to plug the original Vertex Position node back into the Default input for AifBempty (the cursor in this screenshot is about to do just that). Which is very weird, since nothing upstream has changed, I'm just trying to reconnect it back to the way it was before.

    ZdaIIJG.png


    Here I'm trying a layout like what you have there kodde, using an Add. But no go.

    8TUVpRO.png
  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 19
    There's both a "Vertex World Position" and a "Vertex Position" node/prefab. I'm guessing you're using one, while the network needs the other one.

    naXZlt.jpg
  • shaderfx
    Options
    Offline / Send Message
    shaderfx polycounter lvl 9
    Yes, the first one is the one you want.
    Pos Object Space one
  • shaderfx
    Options
    Offline / Send Message
    shaderfx polycounter lvl 9
    @Eric: you can also try to save the hlsl to disk and just see if the code gives you some suggestion of what might be wrong.

    E.g. if you are in the wrong space, or if you are using a node that is not working properly inside the vertex shader.
  • Eric Chadwick
    Options
    Offline / Send Message
    I looked at the HLSL, but I'm not great at figuring out what the code should be. I can't see anything glaringly wrong, but I'm not sure what I'm looking for either. That's why I'm using a node-based editor. :D
    // -------------------------------------- ShaderVertex --------------------------------------
    SHADERDATA ShaderVertex(APPDATA IN)
    {
    	SHADERDATA OUT;
    
    	float3 MulOp = mul(IN.Normal, ((float3x3)world));
    	float3 NormalN = normalize(MulOp);
    	float4 WorldNormal = float4(NormalN.x, NormalN.y, NormalN.z, 1.0);
    	OUT.Normal = WorldNormal;
    	float3 NormOp = normalize(OUT.Normal.xyz);
    	float3 AddOp = (float3(1.0, 0.5, 0.5) + NormOp);
    	float3 SinOp = sin((IN.Position + (time/4800.0)));
    	OUT.colorSet = IN.colorSet.zyxw;
    	float3 VectorConstruct = float3(OUT.colorSet.z, OUT.colorSet.z, OUT.colorSet.z);
    	float3 MulOp1392 = (normalize(AddOp) * SinOp * VectorConstruct.xyz * float3(0.05, 0.05, 0.05));
    	float4 VectorConstruct1397 = float4(MulOp1392.x, MulOp1392.y, MulOp1392.z, 1.0);
    	OUT.Position = float4(0, 0, 0, 0);
    	float4 OutUVs = float4(IN.map1.x, IN.map1.y, 0.0, 0.0);
    	OUT.map1 = OutUVs;
    	OUT.colorSet1 = IN.colorSet1;
    	float4 WorldPos = mul(OUT.Position, world);
    	OUT.WorldPosition = WorldPos;
    	float4 WVSpace = mul(OUT.Position, wvp);
    	OUT.Position = WVSpace;
    
    	return OUT;
    }
    

    Also I noticed Shader FX tends to corrupt the nodes. If I wire a couple float1's into a Mult, then try to re-wire the Mult with a couple float2's it will reject them. But if I delete the Mult and drag in a new one, it will wire them OK.

    The AifBempty node seems to be in a similar state. So I killed the whole graph, and pasted my nodes back in (minus the custom vertex position nodes).

    I'll try to tackle this again another day. Deadlines looming.

    Thanks for your help guys!
  • shaderfx
    Options
    Offline / Send Message
    shaderfx polycounter lvl 9
    OUT.Position = float4(0, 0, 0, 0);

    That line is your problem.

    Whatever is connected to position is not considered to be valid, so it reverts toma defailt float4 value


    Consider attaching your .sfx file
Sign In or Register to comment.