Home Technical Talk

Free Maya Shader: Easy normal map edition

polycounter lvl 19
Offline / Send Message
Brice Vandemoortele polycounter lvl 19
Hi everyone :)
Here's a little something I've been working on. As usual I'd like you polycounters to test it out :)

There's numerous tool out there in various package that allow you to transfer maps from one UV set to another. Unfortunately it never works with normal map and you end up rebaking most of the time.
I developed that simple technique that will allow you - just using your lowpoly and a normal map - to transform that normal map from/into world space normal map, rotate and distort UVs, all in realtime.
You can download the shader there: http://www.mentalwarp.com/~brice/download/NormalMapEdit.cgfx

and have a look at this short tutorial:
NormalMapEdit_tuto1.jpg

The main problem is that the output has no padding, but you can easily recreate those using common photoshop scripts (xNormal has one right?) or even the warp image itself in maya.

If you only need to convert a normal from world space to tangent or the opposite you just need to link twice the same vertex data :)
The shader alternatively allow you to use the normal map with no initial UVs but to generate them on the fly using a tri-planar projection. Especially useful to bake a tiling pattern all over a complex shape.

I used Dmitriy Parkin's awesome model for DWIII, thanks to him you can dl on his website
http://www.parkparkin.com/personal_art/imrod.htm

Enjoy ! and feedback please :) (only tested on maya 2008, 9800gtx+)

Replies

  • achmedthesnake
    Offline / Send Message
    achmedthesnake polycounter lvl 17
    sorry for being a imbecile Brice - just confirming this - from my layman's understanding this enables you to basically redo the unwrapping of a segment without having to re-bake the normals?


    - and would this .cgfx work in max?
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    Hi :) There are no dumb questions
    So yes basically. I could transfer regular color maps as well, but there's a bunch of tools that does that pretty well already. The trick with normal maps is that unlike color maps they're dependent on the orientation of the UV shell layout, that layout that we'd often like to change without going trough the whole baking process again.
    You might not always have that luxury either, like porting old assets or an outsourcing going horribly bad ^^
    The trick with maya is that hardware rendering is done on the gpu. It allows you to render super-sampled cgfx as they would look in the viewport at a fixed size (1024, etc). If max can render hlsl offline or precisely fix the size of the viewport then it should not be a problem. You could easily create the same shader in shaderFX I think. v3 allows you to do vertex shader which is all you need to project the mesh into UV space.

    cheers
  • pior
    Offline / Send Message
    pior grand marshal polycounter
    Now I know what I am going to play with this evening!!
  • MoP
    Offline / Send Message
    MoP polycounter lvl 18
    That's very cool, Brice!
  • InProgress
    Offline / Send Message
    InProgress polycounter lvl 14
    I forsee that it's going to be extremely useful in the very near future. Thanks a lot!
  • arshlevon
    Offline / Send Message
    arshlevon polycounter lvl 18
    nice!

    i was just looking into baking a map from a real time shader.

    i was wanting to blend multiple normal maps with vertex colors and bake the final result. how exactly are you rendering the uv space with hardware rendering?
  • SHEPEIRO
    Offline / Send Message
    SHEPEIRO polycounter lvl 17
    arshlevon, i had the same thought about the application of this, way of pre baking landscape blends for megatexture style stuff. looks like a really usefull tool anyway, cheers
  • arshlevon
    Offline / Send Message
    arshlevon polycounter lvl 18
    this is pretty awesome! played with it a bit at work, i would love this for blending textures via vertex colors and baking out the result. haven't had a chance to look at the code, but its pretty clever how you get the uv flats to render to the camera.
  • pior
    Offline / Send Message
    pior grand marshal polycounter
    Just tried it and I couldn't get to step 4, I don't see a 'Vertex data' rollout in the shader properties. This is Maya 8 on a 7600GT.

    http://img.photobucket.com/albums/v242/pior_ubb/normalsedit-shader_error.jpg

    Will try it tomorrow on more up-to-date hardware and software!
  • Brice Vandemoortele
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    hello

    @arshlevon
    funny you have the same idea, i initially wrote the shader for the auto unwrap on a job with variations of rocks. i used the vertex color to control the bump scale and the blend between two tiles. would that be interesting to publish? maybe more maps available would be nicer.

    @pior same problem as here:
    http://boards.polycount.net/showthread.php?p=898414#post898414

    with:
    float4 Position : POSITION;
    float3 Normal : NORMAL;
    float2 SourceUV : TEXCOORD0;
    float2 DestUV : TEXCOORD1;
    float3 SourceTgt : TEXCOORD2;
    float3 SourceBtg : TEXCOORD3;
    float3 DestTgt : TEXCOORD4;
    float3 DestBtg : TEXCOORD5;
  • arshlevon
    Offline / Send Message
    arshlevon polycounter lvl 18
    i think it would be really useful if you could blend 4 shaders with vertex colors. i was wanting to make a base human and have different muscle normals and veins and fat, and just interactively paint the areas you want what and output a final map. i was thinking of using it for rapid npc generation. i have a pretty janky setup that involves using the uvs as a morph target of the base mesh and rendering that out, but this solution would be much better. and would not require you to switch shaders before you render as mine currently does.
Sign In or Register to comment.