Self Illuminated Vertexlit Shader with Vertex Alpha

Hello,

I’m looking to extend the Self Illumin/Vertexlit shader to support vertex alpha and I don’t seem to be able to find the right combination of blending methods. I don’t quite understand the different passes and how they interact because I can either get one or the other, but not combined. Has anyone done this or knows if its possible?

Thanks

Shader "Vertex/VertexLit Colored Alpha" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
	_BumpMap ("Illumin (A)", 2D) = "bump" {}
}

SubShader {
    ZWrite On
    Alphatest Greater 0
    Tags {Queue=Transparent}
    Blend SrcAlpha OneMinusSrcAlpha 
    ColorMask RGB
    Pass {
        ColorMaterial AmbientAndDiffuse
        Lighting On
        SetTexture [_Bump] {
			Combine texture * constant DOUBLE, previous * primary
        } 
        SetTexture [_MainTex] {
            constantColor [_Color]
            Combine texture * primary DOUBLE, previous * constant
        } 		
    }
	Pass {
        ColorMaterial AmbientAndDiffuse
        Lighting On
        SetTexture [_MainTex] {
            constantColor [_Color]
            Combine texture * constant DOUBLE, previous * texture
        } 
		
    }
}

Fallback "Alpha/VertexLit", 1
}

196379--7085--$glow_532.jpg

Hi Graphicalgeek,

Thank you very much for sharing! :smile:

I have a probably stupid noob question. I saw you are handling _bump in the code.

Does this mean I can use bump-maps for iPhone, is there a performance cost?

Thanks so much,
Leander.

No, iPhone can’t render per pixel.

iPhone will do the dot3 combiner, which can be used for crappy object-space normal mapping.

on unanimated models only (on acceptable performance and correctness) due to the lack of cubemapping

Object space normal mapping doesn’t handle mesh deformation. It’s nothing to do with cube maps, though. Tangent space normal mapping requires a matrix multiplication per fragment, which can’t be done without fragment shaders.

thanks everyone for clarifying - highly appreciated :slight_smile: