July 4, 2010

lcUberShader_1.4.cgfx – maya realtime shader

Download:
lcUberShader_1.4.cgfx

Updates:

Gloss Blurring Amount: – this attribute controls the blurring on the cube map reflections – previously it was default = 1.0, now it is default = 0.0. At 0.0 there is no blurring on the cubemap, even with a specular.a gloss map, but the added benefit is that if you don't have a specular.a gloss map you can still blur your cubemap, whereas before it was not possible.

Shadow Map Texture: - this is for a baked shadow map, and can use its own UV set, by default its the same UV set but you can change this under the shaders ‘Vertex Data’ rollout. Just set TexCoord2 to use something different. This is helpful because you can bake the shadows on a texture sheet that combines all your objects into one UV layout. This avoids the labor of multiple bakes.

texcoord_shadow[1]
shadowMap[1]

Maya 2011: – added an empty dummy technique to the end of the techniques list, this is a temporary hacky fix for a problem in Maya 2011 where the radio buttons don’t work properly for technique selection.

17 comments:

  1. Hi, can this shader be used for getting a realtime game shader in maya?

    ReplyDelete
  2. Thank you, for the shaders and your tutorials =]

    ReplyDelete
  3. Hi, may I know what's the use of the shadow Map texture, and how do you go about using it? I initially tried a bake from a directional light pointing straight down Y, but it doesn;t seems to react to the lights when I assign this map as a shadow map texture.

    Thanks!

    ReplyDelete
  4. the shadow map texture is a baked map, not an interactive feature. think along the lines of an ambient occlusion map. you can bake the shadows for your lights in a certain configuration and tumble around your scene, but you cannot change the position of the lights without baking the shadow map again.

    ReplyDelete
  5. Are you able to give a quick tutorial on the settings needed to bake strong directional shadows like in your example? I can only seem to get an AO like result.

    ReplyDelete
  6. Ive been able to get a shadow map rendering correctly however when I put this in the shadowMapSampler it does nothing. Did you overlay that shadow into your diffuse in the above example?

    ReplyDelete
  7. The point of the baked shadow map is that the shader combines it correctly across all your shading components.

    The shadow map should be white with dark areas of shadows. It is not a 'rendered' image, but a texture bake on your objects' uv set. I use the mip_matteshadow node along with mental ray batch bake to create the shadow map. When dealing with multiple objects, I create a secondary uv set that lays out all the objects on a single sheet.

    ReplyDelete
  8. I have created the shadowmap texure bake using the mip_matteshadow and when i plug this into the diffuse node on your shader it looks fine. However when putting it into the shadowMapSampler nothing shows up. Sometimes i get a solid black mesh after applying it. Other times i get a garbled images as if the uvs are broken. All uv sets are fine and named and referenced correctly. What am i doing wrong?

    on a simple groundplane and cube mesh set up ive applied your shader left it all default and plugged in the baked shadow map and it isnt working.

    ReplyDelete
  9. I'm not sure what the problem is. I have just tested this again from scratch using a cube and a ground plane. The only issue i ran into was the TexCoord2 (under the shaders 'Vertex Data' - which is what the shadowMap looks at) defaulted to the wrong uv set when I first created the shader.

    ReplyDelete
  10. Nice shaders btw, but I seem to be running into a problem with this shader. I keep getting this error? Any ideas? BTW I'm running maya 2008.

    // cgfxShaderNode::cgErrorCallBack //
    // Error: CG ERROR : Invalid parameter handle. //
    // Error: (136) : error C8001: Unknown state 'MaxAnisotropy'
    (303) : error C8001: Unknown state 'MaxAnisotropy'
    (1162) : warning C7011: implicit cast from "float4" to "float3"
    (1164) : warning C7011: implicit cast from "float4" to "float3"
    (1166) : warning C7011: implicit cast from "float4" to "float3"
    (1167) : warning C7011: implicit cast from "float4" to "float3" //

    ReplyDelete
  11. I have (hopefully) fixed the type-cast error. These things are sometimes dependent on drivers and hardware as well as the version of Maya - I dont have 2008 to test with. The 'MaxAnisotropy' error you are getting is dependant on your machine and configuration, most likely your graphics card not supporting the anisotropic texture filtering. I wont remove those lines by default, as they work for most users - but you can comment out the lines indicated and that error will go away (lines 136,303).
    Download link remains the same.

    ReplyDelete
  12. Hi Leo,
    I am not very familiar with shaders in maya, If its possible can u explain how to use that in maya.

    Means if i download ur shader, it is coming like a text file in another browser window ....i dont know how can we execute that shader in maya...how to add that into the hypershade ?

    Sorry ....if this is a very basic thing i am asking...

    I am really curious to use your shaders.

    Thanking u in advance
    Iniyan

    ReplyDelete
  13. this should get you started:
    http://www.cgbootcamp.com/tutorials/2010/1/4/maya-realtime-viewport-shaders.html

    ReplyDelete
  14. Leo, a workaround for the technique selection bug is to disable the layout update after the technique selection, here's a patch that achieves that:

    --- maya/scripts/2011/AEcgfxShaderTemplate.mel Thu Nov 4 19:10:43 2010 (r3497)
    +++ maya/scripts/2011/AEcgfxShaderTemplate.mel Thu Nov 4 19:52:51 2010 (r3498)
    @@ -727,8 +727,8 @@
    // When "technique" attribute is changed, select corresponding button
    // and rebuild our varying parameter list
    $sCmd = "AEcgfxShader_techniqueUpdate " + $gAEcgfxShader_iLayout;
    - $sCmd += "; evalDeferred \"AEcgfxShader_paramLayoutRebuild " + $gAEcgfxShader_iLayout + " 1; " +
    - "AEcgfxShader_vertexAttributeUpdate " + $gAEcgfxShader_iLayout + " 1 0\"";
    + //$sCmd += "; evalDeferred \"AEcgfxShader_paramLayoutRebuild " + $gAEcgfxShader_iLayout + " 1; " +
    + // "AEcgfxShader_vertexAttributeUpdate " + $gAEcgfxShader_iLayout + " 1 0\"";
    scriptJob -parent clTechnique
    -replacePrevious
    -killWithScene

    Technique selection is still broken when the shader is reloaded, so this is not really the root of the problem, just a workaround.

    ReplyDelete
  15. Hello! I tried to incoroprate this beauty into the Softimage pipeline and it works like a charm. All I need to know, how to use pointlights, instead of directionals and spots. I have connected the light direction parameters to light0, light1, light2 in the scene, if they exist, but our artists would like to rather use pointlight, it's easier tothem move pont lights around the scene than rotating directional lights.

    Thanks!

    ReplyDelete
  16. @Jester - I'll post an update in a few hours, I have a version in the works using 3 point lights along with 3 directional lights.

    ReplyDelete