I’m creating a skybox with physical spheres. And I duplicated the Unlit>Transparent shader to create a skybox shader.
I have a color for brightness and a slider to control the alpha (from 0 to 1). The idea is manipulate the slider in other scripts to create the blend effect and see the other skybox through the first one.
But I have no idea how to script shaders. I look around and learned a bit from the manual and other sites but still don’t really understand how the code must be written.
In properties I have the slider, brightness color(or tint) and the texture:
_MainTex (“Base (RGB) Trans (A)”, 2D) = “white” {}
_Brightness (“Brightness”, Color) = (.5, .5, .5, 0.5)
_Alpha (“Alpha”, Range(0.0,1.0)) = 1
But then I don’t know how to apply the value of the slider to the alpha of the texture.
The alpha should be the same on the whole image, there is no gradient or anything.
Thanks!
I have it changing color based on the brightness color. It's more like a tint color. But still, the alpha doesn't work. I change it in the color palette to 0 but the sky is still fully visible.
– SuIXo3you change what? it's very unclear what you are actually doing.. To change the tint, in the above linked script, you could likewise say: renderer.material.color.r = someValue; renderer.material.color.g = someValue; renderer.material.color.b = someValue; if you are accessing the color.a but it is not affecting alpha, you may need to access a different material than the one you are trying... either way, it seems you are adding extra unnecessary properties, the _Color property inherently handles all of what you are trying to do
– Seth-BergmanI tried with the Transparent/Diffuse shader. It seems to work fine. The problem is that shader is affected by fog and light. I want the same visual result as the "Unlit" shader, with the transparency working as the Transparent/Diffuse shader. I know I have to add Fog{Mode off}, lighting Off, etc, within the Pass{} block. But this shader doesn't have one. And when I add it, it just stops working and show black.
– SuIXo3Did you notice the LINK in my answer???!!!!!??!?? http://forum.unity3d.com/threads/115455-Unlit-with-adjustable-Alpha
– Seth-Bergmanhere is a nice one too, in general: http://wiki.unity3d.com/index.php?title=Shaders
– Seth-Bergman