He saw what he had created and knew . . . it was a MONSTER - dum dum dum
Goals:
1. Create a useful Maya viewport shader with many functions and techniques to showcase a wide range of surface properties
2. Write a Shader with a compartmentalized structure that is easy to read and dissect for people learning to code.
This shader is very large and complex - and not performance optimized by design to allow for better readability - performance is not necessarily an issue when targeting the Maya viewport anyways.
I really recomend that if you use this shader you use it in conjunction with this MEL script I also wrote:
http://boards.polycount.net/showthread.php?t=70032Download:lcUberShader_1.2.cgfxlcUberShader_1.1.cgfxlcUberShader_1.0.cgfxlcBasicShaderComponents.cgfx - for learning - a basic stub
BasicTextures.zip - (i dont quite remember where these all came from, but thank you)
Known Issues:
* Although i provide 8-bit alpha support, Maya has transparency sorting issues when in this mode.
* Because there are so many attributes the Attribute Editor can sometimes stall momentarily when updating / opening / switching techniques
* Only has an input for 1 environment cubemap (serves for both Reflection and Ambient) - the shader assumes this is a properly filtered cubemap made with ATI's CubeMapGen Tool
Please use this as inspiration for writing your own shaders, the code is very easy to take apart, rearrange and unfold. I have tried to comment the code in key places of interest. I also included a more basic shader with the same coding structure as a starting point for people interested in learing.
Replies
Seems to be some sweet features. Ill be back with a bunch of questions later. ^^
Had a play and there's seems to be some update issues with the lighting.
Should I be able to move them around and see the lighting direction change?
It seems like its not happening at home so I might have gimped something at work.
This is the 4 week culmination of all my shader knowledge - ask all the questions you like, hopefully I'll be able to answer some.
@Malus
The shader expects directional lights to be linked into its light slots - i have noticed that cgfx shaders can momentarily lag sometimes when moving/rotating lights. I really recomend you interact with the shader using my lcRTShaderTools.mel script as it automates many things.
Don't scale your lights or any group your lights are a part of, scale / inherited scale increases the magnitude of the light vector and gives incorrect results.
normalizing the light vector would fix this issue but I'm not sure its a good idea to do that - if anyone wants to chime in with ideas/comments please feel free.
// Error: CG ERROR : The compile returned an error. //
// Error: (879) : warning C7011: implicit cast from "float4" to "float3"
(662) : warning C7011: implicit cast from "float3" to "float"
(662) : warning C7011: implicit cast from "float3" to "float"
(862) : error C5051: profile does not support conditional returns
(893) : error C5051: profile does not support conditional returns
//
Also, I can only choose Toon_Ramp, Lit_Sphere and World_Normals
Any idea?
( WinXP, Quadro 3450 w/ last drivers )
for whatever reason your system is being extremely picky with code semantics at compile. Probably something to do with the Quadro and its fancier OpenGL drivers. I can defiantly fix those errors, although its a bit hard to test since no system I have gives those.
The reason you can still choose some of the Techniques is because those are much simpler and don't use any of the functions returning errors.
No conditional returns! sheesh how am i supposed to get anything done around here.
What about the Cg Core runtime library ( cg.dll ) ?
I remembered that I have updated it in the past and the cgfx shader I have been testing worked better...
I will try...
Actually, my version is 1.50.0605.238
after some more thought I'm thinking its probably some slight differences in cgc.exe (Cg Compiler) between Maya versions - I only have 2009 for testing
Anyway - upadate to v1.1 download link in first post - probably will still give you at least one blocking compile error (crosses fingers)
Oh btw, I just saw the Maya 2011 press release today. Wouldn't it be awesome if they also ovehauled the UI capabilities of CGFX shaders? *crossing fingers*
Thats quite a compliment, thanks - Xoliul's shader is really finely tuned (and 3dsmax's shadow support is a killer feature). I see this shader more as a technical exploration and as a learning tool, which is why I've separated all the core shading functions out into compact sections to help other people learn the nuts and bolts.
Thanks!
@Kodde
If Autodesk overhauls the CGFX integration int 2011 to be more stable that would be awesome - if they extended it to allow access to the already existing shared shadow buffer that would be amazing. I have heard of some people re-writing the cgfxShader.mll plug-in for in house use, if i could even just get my hands on that, ohhhh boy.
// Error: CG ERROR : Invalid parameter handle. //
// Error: (132) : error C8001: Unknown state 'MaxAnisotropy'
(314) : error C8001: Unknown state 'MaxAnisotropy'
(662) : warning C7011: implicit cast from "float3" to "float"
(1066) : warning C7011: implicit cast from "float4" to "float3"
(1067) : warning C7011: implicit cast from "float4" to "float3"
(1068) : warning C7011: implicit cast from "float4" to "float3"
//
Works fine in maya 2009
Nice shader!
About the Toon shader, would it be possible to multiply the diffuse map with the shading ( toon ramp ) ?
edit : ah! and as you can see, there is a wireframe issue with the toon shader ( maybe something I need to uncheck? )
Fixed some more typecasting issues
Toon and LitSphere update - now they multiply by the diffuse texture - you can modulate the amount of diffuse texture by changing the diffuse color value (0-1 B&W only, no tinting). The multiplication operation of the toon ramp and diffuse texture looks best with a greyscale toon ramp with harsh transitions between colors.
download link in first post
@funshark
* I fixed some more of those typecasting errors - the 'MaxAnisotropy' error is unusual - you can comment out those flags on the diffuseMapSampler and normalMapSampler - but they work in other versions of Maya and I won't remove them by default.
* Ambient Hemispherical Lighting is multiplied by the Ambient Color Attr - make sure its something other than black - the effect can be subtle - its most pronounced when the sky color is very bright and the ground color is very dark or black.
* I can't reproduce the 'Wireframe' issue you seem to be having so i don't know what to change to fix it. - do you have Anti-Aliasing forced to ON in your driver settings? Thats my best guess.
Pass that Chronic!!
This Shader makes my D H!!
Everything is nice now !
The wireframe issue seems to be something related to Maya... I didn't reproduce this time.
Good job!
I have downloaded the shader but I can't get it to work at all and I'm in need of a little help.
Firstly, I am using Maya 2011. win xp. ATI card. (dunno if that makes a difference)
I can create a cgfx shader, and point it to the cgfx file. but anything I do after that has no effect it seems. I tell it I want to use a diffuse texture. and then point it to a .tga file but nothing happens, the shader just stays the default pink colour. I have tried linking lights but still nothing. I am in hardware textured mode. Is there something I am missing here?
I haven't had much luck so far with cgfx shaders, so any help would really be appreciated as this shader looks like it could be ace
cheers
I'll try the shader out at work tomorrow to find out if it is the card.
I have noticed some strangeness in maya 2011 with the cgfx plugin, havent had much time to experiment - hopefully we are not moving backwards in terms of support.
I think my card would be good enough to process the shader. But even with the Nvidia card there still seems to be some error. No matter which technique you select, it keeps going back to the bottom technique. That's in Maya 2011.
cheers
If you change the name of the shader after linking to the cgfx file a lot of the options don't work, for example tick boxes don't tick.
Rename it back to the original and it all works again.
Change the name before linking ot the cgfx file and its all fine.
Happened on a couple of PC's at work (win7, Nvidia cards)
maya 2011 seems to have a problem with the interface radio buttons and selecting techniques, this is probably related to the QT ui switch and/or the cgfx shader's AE template scripts - my work around has been to add a dummy technique to the end of the list, that way you can switch between all techniques even if the last one always appears selected.
The shader looks really good, but I have to stick to your HLSL shader for the moment. And I'm having trouble getting that one's environment reflection to work, dont know if its me or not but I can't seem to find any other related option. Basically theres no environment reflection, even after cubemaps applied and option checked.
Everything else works really well tho. Thanks again.
FYI - they might be a little raw - code is fresh off the grill and not thoroughly tested.
also had a problem getting them to work on an ati card, will try on my laptop when i get a chance.
Blog Post: http://blog.leocov.com/2010/09/maya-realtime-shaders-big-update.html
Download Link: http://blog.leocov.com/p/downloads.html
Have Fun!
Liking the results of the hair shader a lot. Also had a look at gamma correcting the shaders I'm working with. Gonna look into tone mapping as well.
http://miketon.posthaven.com/tag/shaders
It's available on github at :
https://github.com/miketon/Maya_Tools/tree/master/Shaders/Toon_xrd
I really appreciate the dirLight hookup; previously when I was building cgfx shaders years ago, I used to grab it directly from the openGL context...which wasn't great form .
-Mike