I believe these are the lights that Unity considers not "Important" and thus vertex lit. Perhaps someone will be able to find a better use for these in the future.
Unity SHADER File:
vertexlitlamberttexturemultilightsonepass.shader |
Cross-Origin-Embedder-Policy="require-corp" Cross-Origin-Opener-Policy="same-origin"
One quick demonstration i wanted to make before moving on is multiple vertex lights in a single pass. Unity provides an array of 4 light positions which can be accessed in the vertex shader. By utilizing these, it is possible to run multiple lighting calculations in the Forward Base pass. However, this is not the most reliable system unfortunately. The 4 lights provided are the 4 closest point lights, so you may notice issues with dynamic lights ("Shadows" or lights behaving oddly when they move/switch order in terms of which light is closest). However the shadow fidelity is comparable to the multipass vertex lit shader, so this might be useful for mobile so you can avoid multiple passes. I believe these are the lights that Unity considers not "Important" and thus vertex lit. Perhaps someone will be able to find a better use for these in the future. Unity SHADER File:
0 Comments
This is a fairly straightforward extension of the previous shader. It adds support for point lights and multiple light sources. Unfortunately we have 2 diverging paths for lighting that makes things difficult to be 100% the same in either program. As far as i know, i can only access the position data in Maya for the point light, and not the falloff or brightness, so i used the light color alpha to determine brightness and added a custom falloff attribute. In terms of Unity, lighting is done in multiple passes, generally one per light as far as i can tell. This may be behind some of the draw call woes i've dealt with in the past with Unity...perhaps i should work on lightmap support for these at some point to reduce the draw calls. In any case, both examples are available for download. Maya CGFX File:
Unity SHADER File:
I decided to start out the lit shaders with a Vertex Lit Lambert Shader, as it was the simplest lighting I could imagine. Technically Pixel Lit shaders aren't any more difficult, but I figured I should cover it before moving on. Vertex Lighting is lower fidelity than Pixel Lighting but they are fast, which means you might want them for mobile. I don't think Maya even has any Vertex Lit shaders these days, so it might be useful for someone working on mobile assets i guess. These shaders utilize a single directional light and feature an Ambient Color as well. Maya CGFX File:
Unity SHADER File:
This is actually a bit trickier than you would think...for Unity at least :/ While Maya has backface culling off by default, Unity does not. You would think you could simply turn it off in Unity but this is not the case. I originally thought it was related to disabling the Z Depth but that didn't make it any better. So i decided to settle for the inelegant but functional solution: Render it twice. The first pass renders the backfaces and the second draws the front faces over them. If you make a fist and imagine your palm as the backfaces you can probably get a sense of why this works. I only included the Unity shader this time since fixing this in maya is a matter of simply commenting out the culling in the previous shader. If anyone has any suggestions for a better way around this please let me know :) |
unlittexturealphadouble.shader | |
File Size: | 2 kb |
File Type: | shader |
unlittexturealpha.cgfx | |
File Size: | 3 kb |
File Type: | cgfx |
unlittexturealpha.shader | |
File Size: | 2 kb |
File Type: | shader |
unlittexture.cgfx | |
File Size: | 2 kb |
File Type: | cgfx |
unlittexture.shader | |
File Size: | 1 kb |
File Type: | shader |
unlitcolor.cgfx | |
File Size: | 1 kb |
File Type: | cgfx |
unlitcolor.shader | |
File Size: | 1 kb |
File Type: | shader |
Shaders I've built as i teach myself CG. Feel free to download and use for whatever. If you like them you can buy me a beer or something.
December 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013