To set alpha value?

Hi!

I am on a shader for iphone and the last part is about changing the transparency of my object with a cursor like that one in the material :

_Alpha ("Transparency", Range (0.01, 1)) = 0.7

But I really do not understand what function I am supposed to use for it…

I checked many exemple but I found only 2 way : alpha channel of my texture or Vtx color.

My current shader is ’

  • Diffuse RGB,
  • lightmap with alpha
  • “constantColor” on the diffuse.

Or maybe there is way to access to the object’s transparent directly from my code?

Does someone knows if this is possible and what function I am supposed to work with in my shader… or code O_o>?

Thanks! :?

I don’t understand what you are saying / asking. Perhaps more of your code would help.

haha sorry X_X

I would like my object disappears progressively with distance from the camera.

Then I though setting dynamically the opacity value of my shader could be a good idea.

And the programer will just need to interact with this value from his code.

But I do not success to add it in my current shader.

A very simple example showing how to change the transparency of my object with a cursor in the material option could help to understand how to connect it on my shader.

I hope the explanation is better :cry:

Is fog not good enough for you?

Nop already tried :frowning:

There is a cube map and this is very important the object “blend” with the cube map with distance from the camera.

You can imagine the cube map as background textured with lot of different colors.

Problem is the fog is only about one color!

For that reason I am first trying to understand if I can set a simple shader with transparency using a float range 0-1.

After that I can connect it to my current shader.

You certainly can. This is the key to what you need; there is no such thing as transparency; it’s all about blending.

Blend SrcAlpha OneMinusSrcAlpha // Alpha blending

Here is a very simple example:

Shader "Transparent Color" {

Properties 
{
	_Color ("Color (A = Opacity)", Color) = (1,1,1,1)
}

SubShader
{
	Tags {Queue = Transparent}
	Blend SrcAlpha OneMinusSrcAlpha
	Color [_Color]
	Pass {}
}

}

I made a video which might be helpful to you.

361841–12567–$transparent_color_415.shader (200 Bytes)

Really thank you Jessy :shock:

To simple lines :

Tags {Queue = Transparent}
Blend SrcAlpha OneMinusSrcAlpha

And it resolves the problem :expressionless:

Thanks again! :slight_smile: