Due to a certain person continously asking for a shader that multiplies Vertex Color, i put one on the wiki:
http://www.unifycommunity.com/wiki/index.php?title=VertexColor
Due to a certain person continously asking for a shader that multiplies Vertex Color, i put one on the wiki:
http://www.unifycommunity.com/wiki/index.php?title=VertexColor
That script multipy constant color and texture, right?
How can I multiply alpha vertex color and texture?
You do want an Alpha/VertexLit equivalent that takes vertex colors into account? Or is it something else?
I have a mesh with a rgb texture and argb vertex colors. I need a shader to draw it that takes into account all vertices color components, alpha included.
Thanks
Is there a “2 detail texture” Shader at all?
Just Curious…
AC
No. I have only one texture and no detail texture.
Here it is: AlphaVertexColor on Unify wiki. This will multiply texture with per-vertex colors, so you can have alpha in the texture, in vertex colors or in both. Enjoy!
Hi i am not an shader expert. but in wich area can i use this shader.
Norby
It’s just like the builtin Alpha/VertexLit, only adds per-vertex color support. That is, if you have a mesh that has per-vertex colors (painted in your 3D application, or set from script) then this shader supports them.
Thanks Aras!
A question about shaders in general: is it possible to rewrite a shader that require 4-texture video card for a 2 texture video card adding more passes?
If yes, can you convert the wiki’s TwoLayerTerrain in 2 passes?
I can’t get it work…
Wow! I get it! (or I’ve got?? damn english! )
Shader "TwoLayerTerrain" {
Properties {
_MainTex ("Main Texture (RGB)", 2D) = "white" {}
_PathTex ("Path Texture (RGB)", 2D) = "white" {}
_PathMask ("Path Mask (A)", 2D) = "white" {}
}
SubShader {
Lighting On
Pass {
SetTexture [_PathTex]
SetTexture [_PathMask]{
combine previous * texture
}
}
Pass {
Blend one one
SetTexture [_MainTex]
SetTexture [_PathMask]{
combine previous - texture
}
}
}
}
Instead of alpa channel of _PathMask it use the rgb channel.
What video card texture does it require? 2 texture video card?
Hey, that’s a good idea for a subshader.
Pretty close - What you want to do is probably more like:
2nd pass is a bit different: rather than subtracting the pathmask from the PathTex (which will oversaturate the colors), multiplying by the inverse gives the correct result.
I also removed the Lightng On - since the lighting wasn’t used anywhere, there’s no need to tell the graphic card to calculate it.
Shader "TwoLayerTerrain" {
Properties {
_MainTex ("Main Texture (RGB)", 2D) = "white" {}
_PathTex ("Path Texture (RGB)", 2D) = "white" {}
_PathMask ("Path Mask (A)", 2D) = "white" {}
}
SubShader {
Pass {
SetTexture [_PathTex]
SetTexture [_PathMask]{
combine previous * texture
}
}
Pass {
Blend one one
SetTexture [_MainTex]
SetTexture [_PathMask]{
combine previous * one - texture
}
}
}
}
yeah - it requires a 2 texture video card. This means an nvidia TNT (the one before a geforce) or an ATI Rage - so you should be safe
If you want to use alpha rather than RGB for the pathmask, just throw an ‘alpha’ after the ‘texture’ eg:
SetTexture [_PathMask]{
combine previous * one - texture
}
becomes:
SetTexture [_PathMask]{
combine previous * one - texture alpha
}
Thanks Nicholas!
I was using a grayscale texture, colors were correct but “combine previous * one - texture” is what I was looking for.
I prefer to avoid the alpha channel and utilize a 8 bit bw texture.
I need lighting, how can I add it?
doing the lighting basically involves two things: configuring the vertex lighting pipeline, and then getting the lighting into the texture combiners.
Look here for setting up the lighting
http://unity3d.com/Documentation/Manual/SL-Material.html
The combiners you want are:
....
SubShader {
Pass {
SetTexture [_PathTex] {
combine primary * texture
SetTexture [_PathMask]{
combine previous * texture
}
}
Pass {
Blend one one
SetTexture [_MainTex] {
combine primary * texture
}
SetTexture [_PathMask]{
combine previous * one - texture
}
}
As you can see, when you’ve set up lighting, the color can be used in the combiners as ‘primary’.
If this looks too dark, try adding a ‘double’ at the end of one of your combiner states. (or ‘quad’ if you want to go wild)
About grayscaleRGB vs alpha, what we do in GC:Palestine is to use alpha to control blending (as that fits better on combiners), and then use the color channels as a color map. Gives a fair amount of variation without being too evil.
Thanks!
I was missing the Material part.