Materials with Both Transparency and Self-Illumination?

Is it possible to create a Unity material that has both transparent and self-illuminated pixels in it?

I can make materials with alpha transpraency, and self-illuminated materials, but don't see how I can get both. Is there a multi-texturing solution? Or some other way to do this?

TIA

Well Marty give this a whirl, I think this is what you want

[Edit: ZWrite should be off, fixed]

Code :

Shader "AlphaSelfIllum" {
    Properties {
        _Color ("Color Tint", Color) = (1,1,1,1)
        _MainTex ("SelfIllum Color (RGB) Alpha (A)", 2D) = "white"
    }
    Category {
       Lighting On
       ZWrite Off
       Cull Back
       Blend SrcAlpha OneMinusSrcAlpha
       Tags {Queue=Transparent}
       SubShader {
            Material {
               Emission [_Color]
            }
            Pass {
               SetTexture [_MainTex] {
                      Combine Texture * Primary, Texture * Primary
                }
            }
        } 
    }
}

And the shader:

PS: David can you allow .shader as a extension? Thanks.

10094--366--$alphaselfillum.shader_211.zip (463 Bytes)

2 Likes

Cool!

Thanks, Bill.

Let's give this whirl ...

Wow! It's perfect.

And what a great intro to shader programming your script makes!

You should post it on the Unify Wiki (http://unify.bluegillweb.com/scriptwiki/index.php/Main_Page) so it can belong to the ages.

Awesome work, Bill. Thanks!

Thanks that was a easy shader. Hard part was getting it before peter did.

<.< | >.>

He always nabs them before I do... :wink:

...and you are very welcome :smile:

Bill

Thanks for the heads-up, .shader now allowed in the forum.

... cool shader by the way.

d.

1 Like

Yay for resurrecting old threads!

Sorry, but obviously I can't get this shader to work in 3.2

Anyone know an easy way to make this kind of shader, but for use in 3.2?

I created a shader that does that very thing using this free utility:

http://forum.unity3d.com/threads/56180-Strumpy-Shader-Editor-4.0a-Massive-Improvements

What doesn't work about it? Are you trying to use it with lightmapping? It's not equipped for that, but otherwise, it ought to work fine.

Rise ye dead thread! Sync1B's shader is great! When I build my project using this shader for Android, I get this warning:

Shader is using clip instruction (usually caused by alpha test). It might cause problems on some Qualcomm/Adreno drivers.
UnityEditor.HostView:OnGUI()

I was wondering if any shader that uses transparency will warn me about this, or if there is something about this particular shader's design that is wrong for mobile devices? Everything runs fine on the Android hardware I have access to, and virtual devices. If it isn't obvious, I have a long way to go before I'll be writing my own shaders.

Is there a better Alpha-Self-Illuminated to use on mobiles? My current project is a side scroller, with lots of flat planes to simulate depth, so I'm surprised this shader isn't in the standard assets... or did I have a synapse-lapse and just overlook something? Thanks!

on further testing, I think I'm wrong about this being the shader that was causing the complaint. I'll update this I figure anything else out about it. For now it looks like this is fine.

This thread appears when googling this shader so i'm posting a working version here. The version posted above it's not working in newer versions of Unity.

Cheers,

Max.

995842--36875--$AlphaSelfIllum.shader (812 Bytes)

1 Like

I know this is an old thread, but in response to the "shader is using clip instruction" warning, I have observed that this is given when using transparent CUTOUT, but regular transparency shaders do not throw this warning

not sure exactly how this relates to custom shaders though

@MaxSilva, that one's not working for me, I get:

shader has errors or is not supported by your graphics card

and I KNOW my graphics card is good

@Seth Bergman What graphics card model you have? It's a PC or Mac? OS?
I used this shader in various machines with Nvidia chipsets. The shader it's just a modification of the Transparent/Diffuse built-in shader without the light calculation, it should work as well as the built-in shader.

Maybe it's a compilation error but i just downloaded it and it works fine. Did someone else tried it out?

@Seth Bergman
You may try again, i uploaded a new version because i was doing something veeery wrong before. It is coded in CG rather than being a ShaderLab surface shader.

Wow, thank you for posting this shader. Does exactly what I needed.

Is there a way to make the illumination brighter? I had a look at the source and didn't see any numbers to change...

[quote=“MadRobot”, post:16, topic: 374107]
Is there a way to make the illumination brighter? I had a look at the source and didn’t see any numbers to change…
[/quote]

You could multiply the color in the fragment shader by a vector

e.g

half4 frag (v2f i) : COLOR
{
    half4 texcol = tex2D (_MainTex, i.uv);
    return texcol * _Color * intensity; // This is the final color
}

intensity must be a float4 vector. Refer to HLSL docs for more information.

It may saturate with a high number though.
You may also do the calculation directly in the vertex shader and pass the final color for performance, i guess.

Old topic but I figure I might get lucky.

I'm trying to used this AlphaSelfIllum on particles. But the alpha doesn't seem to work. I have my particles set to fade out over time but they stay constant until they die. Is there any change that needs to be done in order for it to work with Particles? Using Unity 4 Pro.

If you have a problem with shader due to building adk.

Try to build Android with Texture compression : Adreon ATC that is in the build setting
you won't find any more " Shader is using clip instruction (usually caused by alpha test).
It might cause problems on some Qualcomm/Adreno drivers."

This sounds exactly what I'm looking for also, however I'm not sure what to do with the "shader" file.
I found other shader files and put it in the same directory. Do I also have to import it ??? Would I need Pro to be able to do this?

Thank you.

Doh, after a bit-o-fiddlin you just import new asset into a reasonable folder in unity, no pro required.

For the nuubs like me :)