Hey guys,
I've been working on my first cgfx shader to help previewing blended materials in Maya.
It is very similar to the one you can find in this tutorial (UDK) :
http://eat3d.com/free/vertex_painting
Basically 2 texture inputs with their normal maps LERPed together with an inverted heightmap used as a blend mask to spice things up.
Vertex colors need to be RGBA. The alpha channel of the vertex colors is used to blend the textures together while the RGB channels can be used to either paint color variation on your meshes or bake AO,GI etc...
I've been building this mainly for CE3 usage since it pretty much has the same setup as the one you can find in the SDK.
Its still not finished yet considering that I'm planning to sync the results in maya with CE3 so that the results translate seamlessly.
On the other hand the UI for the shader isn't very organized yet but it should be very straight forward.
I'm also planning to add support for the following features :
- Detail Normal maps (added in v0.3)
- Specularity (added in v0.3)
- Offset bump mapping
- Image based reflections
- IBL (added in v0.3)
v0.1 :
https://dl.dropbox.com/u/53969153/Texturing_Workflow/BlendMasked_vertexcolor_shader_Maya_v0.1.zip
v0.2 :
https://dl.dropbox.com/u/53969153/Shaders/vertex_blend_03_colors_CE3.zip
Change log :
-Synced Blend Factor and Falloff values with CE3 blendlayer shader.
v0.3 :
https://dl.dropbox.com/u/53969153/Shaders/Cryengine3_VertexBlend_Maya1Light.zip
Change log :
- Rewrote the code from scratch replacing all existing shaderFX generated code.
- Added blinn-phong specular support, with gloss and specular multiplier. The specular map is stored in alpha channel of diffuse.
- Added texture tiling for Diffuse, Normals, Blend Mask, and Detail map
- Added IBL/Cubemap support
- Added option to multiply diffuse color onto the diffuse textures(see "Color Diffuse Textures") & option to multiply vertex colors to diffuse textures;
- Added detail bump mapping(work in progress)
Replies
Edit:
Just tried it out on OsX Maya 2013. Works great. The gradient blends are only viewable on Viewport 2.0. Otherwise it works great though. Thanks! Can't wait for the updates to this.
Here's a thread on that vertex paint issue: http://www.polycount.com/forum/showthread.php?t=54590
Download link : https://dl.dropbox.com/u/53969153/Shaders/vertex_blend_03_colors_CE3.zip
Thats weird because it working in all my viewports in maya 2009/2012/2013.
Might be a graphics card issue. What hardware are you using ? I could try recompiling the shader to add full support for ATI and nvidia graphics cards.
1. Controls the tiling of "Diffusemap_01_sampler" and "Normalmap_01_sampler"
2.This is where you put the diffuse map (in the screenshot its the moss floor texture for example).
3.Controls the tiling of "Diffusemap_02_sampler" and "Normalmap_02_sampler"
4.This is where you put the other diffuse to blend with diffuse_01 (in the screenshot its the floor tiles texture ).
5.This is where you put your blend mask which can be a heightmap or a handpainted mask texture (grayscale).
Usually you would want to use a heightmap generated from the Diffuse_02 texture (floor tiles).
6. quote from crydev wiki : Blend Factor: Changes the overall blend factor. Use this to fade in and out the blend layer.
7.quote from crydev wiki : Blend Falloff: Specifies how smooth the transition between the layers should be. Use a high value for a sharp transition.
8. Shows full vertex color output (RGBA) RGB vertex colors values are multiplied by the blended textures.
9. Normal sampler for Diffuse_01 texture.
10. Normal sampler for Diffuse_02 texture.
11. Obsolete (will be removed in future releases).
12. This is where you can define the point light in your scene to be used as main light source. Just copy the name of your point light and past it in there.
13. Color of your light source.
14. Obsolete (will be removed in future releases).
15. This is where you define which set of vertex color the shader needs to read.
Just right click on the empty box and chose the proper vertex color set.
Change log :
- Rewrote the code from scratch replacing all existing shaderFX generated code.
- Added blinn-phong specular support, with gloss and specular multiplier. The specular map is stored in alpha channel of diffuse.
- Added texture tiling for Diffuse, Normals, Blend Mask, and Detail map
- Added IBL/Cubemap support
- Added option to multiply diffuse color onto the diffuse textures(see "Color Diffuse Textures") & option to multiply vertex colors to diffuse textures;
- Added detail bump mapping(work in progress)
Download v0.3 : https://dl.dropbox.com/u/53969153/Shaders/Cryengine3_VertexBlend_Maya1Light.zip
Some screenshots :
I'm gonna test it right now ! It will be be really useful !
http://wiki.polycount.com/CategoryShaders#Maya_Shaders
Also, I can't seem to get cube maps to display in 3DS Max right now... Both texCUBE, and texCUBElod won't work. No compiler issues. I have not tried using a separate pass for cube map / IBL stuff yet, that might work.
If anyone has some knowledge on this, give me a holler!
cubemap should work fine in max viewport.
what max version etc. are you working with - make sure viewport is not set to nitrous, but directx. send me your code if you like I can test it here.
Is the IBL blur based on pre-blurred mips in the cubemap or how did you approach this?
I think he's using the texCubeLOD function. Anywho nice stuff!
Using 2010 in this, so there's no Nitrous viewport yet... I tried it in another pass, and it doesn't work there either. Not sure what the problem is since it works in Maya CGFX...
I'm having someone test it, and if it doesn't work I'll PM you the shader
Making this an individual post in case anyone else is having 3DS Max shader issues. :thumbup:
Changes in Version 0.4:
- New version for 3DS Max
- Added support for 3 lights
- (MAYA) added support for ATI/AMD GPUs. Unfortunately, Maya users lose the ability to blur cubemaps for IBL. Instead, load a pre-blurred cubemap. ( problem with texCUBElod not being supported )
- Maya users note: Tangents in Viewport 2.0 may be broken, so use standard render, or high quality.
Grab it here for Max and Maya
http://drewwatts.net/shaders/CryEngine3_VertexBlend_MayaMax.0.4.zip
or
https://dl.dropbox.com/u/8510078/CryEngine3_VertexBlend_MayaMax.0.4.zip
3 Light Support (3DS Max & Maya)
Vertex Color ( Multiply )
Max Shader Parameters:
Maya Shader Parameters:
Just post here with any problems you guys have.
Thanks!
Now...
Any chance to have similar thing for Maya <-> Unity?
I would pay (group pay maybe?)
Cheers
I made a simple variation of it about a year ago. You can download the .shader and the Strumpy Shader Editor graph in the video description if you wanna take a closer look at it.
[ame="http://www.youtube.com/watch?v=HDXwSEUYrbI"]Unity Vertex Blend Material - YouTube[/ame]
And if you wanna make your own there are plenty of tutorials on how do do it for UDK, and the exact same principles apply to unity. Like this one: http://www.laurenscorijn.com/vertex-blending-snow.html
Keep in mind though, Unity doesn't have a built in vertex painter so you will have to look for a plugin on the Asset Store. The one I used was fairly primitive and I'm sure there are better ones out now.
Thank you very much.
Will give it a closer look.
Could someone (if it works in 2014) describe his workflow to get it in Maya? I need to work with this shader yesterday, and can't wait to test it
So you paint the alpha channel on those vertex to tell the shader where to blend the materials ? So to have a result with high quality more vertex is needed right ?
Or i'am thinking bananas ?
You are thinking right. It needs more vertex for a higher resolution, but realtime engines these days can cope better with more geometry than with more materials. With vertex painting you can create a basic material and paint the extra attributes by using the color channels (RGB/A). In a way it is like you are applying masks in Photoshop.
And with this tool you can blend them nicely and preview them in one take. I'd really like to mess with it, but I guess we won't get a 2014 release - which is a shame. I just want to create awesome art, and that would be an excellent tool for my needs!
I just tried it with Maya 2014 and it's working! Tried it on Viewport 2.0.
-- Maybe don't use Hypershade, and instead just right click and "Assign New Material" and choose CgFX Shader.
Also, under Window>Settings/Preferences>Plug-in Manager, make sure cgfxShader.mll is loaded!
Really? That is awesome!
Could you tell us where you place the shader or how you loaded it? I mean after you download it, where did you put everything in order to make it work?
Great news! Thanks man.
Can't someone just put up an image of where to put the shader and how to load it? I know I should be more knowledgable about this, and I know shader networks from UDK and XSI, but I don't know where anything is stored and loaded in Maya. And I do research (Digital Tutors forums had some info), but a lot of it is contradictory or "Maya 4.0" and the kind. I need fresh info, yo' feel me ?
AND THIS IS AMAZING ^^!
Yes - the cgfx shader wasn't loaded ~ facepalm.
>>EDIT<< I just can't seem to figure out the export with the cgfx material parameters. I have imagined the *.mtl file would write the shader settings into my Sandbox file. But the blending looks different to that in Maya. Is there a way to export the parameters into Sandbox, i.e. have the material look the same as in Maya?<<
I am on Maya 2015.
Shader loads fine, I can load up my diffuse maps and a blend map. However, it doesn't seem to recognize any vertex painting I do.
I also noticed this warning:
// Warning: cgfxShader : Can't find the source named "" for vertex attribute "vertcol". //
Here are some screens:
What my vert paints look like
My settings
What the final product is (notice my vert painting has no visible effect)
This would allow more powerful control in UDK / Unity with terrain shaders that call vertex colors.
When I worked at Sucker Punch we had RGB controls and it was awesome to be able to have that 3rd texture avilable to paint with.
Red was considered the "base" diffuse
Blue was the main second texture that utilized a height map
Green was the third texture, which just applied in an overlay fashion and did not utilize the blend map (ups and downs to this... would like the ability to choose)
Is there any chance this shader will get continued work?
I'm used to painting actual color.
This was made to match the vertex alpha CryEngine blending in CryEngine 3, as well as some of the other shader options; so you need to paint vertex alpha to blend between two materials. Vertex color is there as a multiplier to the material color. It doesn't affect blending in any way.
Btw, using maya 2015 here.
If i load my normal maps and check the box "enable normal maps" my maps are loaded... but looks like whenever i move the view, my normals get messed up.
When i first plug the maps, or reload the shader, or select the plane, the view seams to refresh and the normal map is displayed correctly.
But when i move the view, maps are displayed wrong.
any advice ?
Thanks in advance.
EDIT: tried the older versions, same thing. Maybe something with maya 2015 viewport 2.0 ?
-does it break Crytek or any other (c)?
-do the authors allow to use this shader in commercial projects?