Simple emissive alphablended texture

Except for some experiments with GLSL shaders many years ago, I’ve always used very simple FFP stuff, so it’ll take me some time to get into the shader stuff.

What I need is an emissive shader that uses both the alpha channel of the texture and the alpha value of the Emissive color for blending. No bumps, speculars, no nothing except that.

I’ve searched the default library, but can’t find anything quite right. Could someone give me a pointer to a shader that does the equivalent of the following FFP?

RenderState.AlphaBlendEnable = true;
RenderState.SourceBlend = Blend.SourceAlpha;
RenderState.DestinationBlend = Blend.InvSourceAlpha;
if (Diffuse.A != 255)
{
  TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
  TextureState[0].AlphaArgument2 = TextureArgument.Diffuse;
  TextureState[0].AlphaOperation = TextureOperation.Modulate;

  TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
  TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
  TextureState[0].ColorOperation = TextureOperation.Modulate;

  TextureState[1].AlphaOperation = TextureOperation.Disable;
  TextureState[1].ColorOperation = TextureOperation.Disable;
}

Something like this maybe?

–Eric

That’s what you’d think, but it only uses the alpha channel, and ignores the RGB values, replacing them with _Color.

I tried removing “constantColor [_Color]” but it just makes it all disappear.

ShaderLab looks nothing at all like what I remember of HLSL, I feel very uncomfortable around it…

Other ideas?

just make _Color basing on a second texture instead of a color and adapt the code at the bottom to it.
All the default shaders that unity has can be downloaded in the source form in the resource category, they should give you a great headstart

I have no idea why yet, but removing

constantColor [_Color]
Combine texture * constant, texture * constant

from the GUI shader seems to have fixed it.

BTW, is there a way to take control of the rendering pipeline and draw stuff in the order I want? Or will Unity always sort into passes based on some internal logic?

Wait, this makes no sense. I’ve read up a bit, and

constantColor [_Color] 
Combine texture * constant, texture * constant

should do what I want, but the result makes it look like “texture”'s RGB is always 1,1,1.
Any ideas how this could happen?

Hi all, last few days I’m trying to list out what Unity shader will be supported by iPhone? Is this the default of all with iPhone Unity? It will be great if we can make a list out of it.

I didn’t find any specific thread on it, this is why I started it. If I re-do it, please bring me there.

Thanks

oops! wrong post. Sorry.

Damn, I got 2 notifications and thought someone was bringing me clarity to the matter!

I really don’t get ShaderLab. Yet (I haven’t read all the docs though). HLSL and GLSL make sense to me, but ShaderLab seems like a higher-level abstraction that removes a lot of the control. E.g. how do I get texels at another coordinate than the default? And how to do arithmetics on channels separately?
If not, is it possible to define HLSL/GLSL implementations instead?

Ah, found CGPROGRAM. Does that mean the statements in SetTexture are all FFP-compatible?