Vertex color BlendMasked cgfx maya shader

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)

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.

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.

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.

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.

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.

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

Hey guys! I made some changes / fixes to the shader.
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.

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.

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.

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!

The best would be to place the cgfx in your texture folder inside a project (always work with a project in Maya, it's way more clean). This way you shouldn't have problems later when re-opening you scenes.

The problem is I have really little experience with the shaders in Maya. I have my textures/project folder in the CrySDK main directory, so I am already keeping the kind of order you propose. I just don't know where to put the shader files. In textures you say? Seems odd, but if this works it would be cool.

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 ?

Hey - I must say, I asked a lot of questions before actually trying out your replies. I was still modeling and wanted to be sure everything works when I jump into texturing.

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?<<

Also, it's be fucking awesome if this was taken a step further to, instead of B&W, use RGB paint channels.

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)

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.