hi bgolus,
thats great thanks!
ive got some way to where i need to get to- ive got a working billboard shader, and also a working surface shader for transparency and emmision. they are both short and sweet and work great, but i need to combine them together into one shader. ive tried several times but with no success. btw im going to use star billboards/quads for the whole lot, because thats all i need for the effect im after - and then i’ll focus on the minimum size later i think - hopefully using quads will lower gpu and cpu and allow more stars…
if you can help in any way with combining these 2 simple shaders, that would be awesome. i think they may be different kinds of shaders - one is a vert/frag, and one is a surface shader - can these be combined? im on a steep learning curve and ill learning a lot by seeing it done… im going to make a seperate post about combining these shaders, but any help you can give me would be awesome!
the two shaders ill post below…
paul uk
billboard shader:
Shader “Cg shader for billboards” {
Properties {
_MainTex (“Texture Image”, 2D) = “white” {}
_ScaleX (“Scale X”, Float) = 1.0
_ScaleY (“Scale Y”, Float) = 1.0
}
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// User-specified uniforms
uniform sampler2D _MainTex;
uniform float _ScaleX;
uniform float _ScaleY;
struct vertexInput {
float4 vertex : POSITION;
float4 tex : TEXCOORD0;
};
struct vertexOutput {
float4 pos : SV_POSITION;
float4 tex : TEXCOORD0;
};
vertexOutput vert(vertexInput input)
{
vertexOutput output;
output.pos = mul(UNITY_MATRIX_P,
mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0))
- float4(input.vertex.x, input.vertex.y, 0.0, 0.0)
- float4(_ScaleX, _ScaleY, 1.0, 1.0));
output.tex = input.tex;
return output;
}
float4 frag(vertexOutput input) : COLOR
{
return tex2D(_MainTex, float2(input.tex.xy));
}
ENDCG
}
}
}
transparent/ emmisive shader:
Shader “Transparent/AlphaSelfIllum3” {
Properties {
_Color (“Main Color”, Color) = (1,1,1,1)
_MainTex (“Base (RGB) Trans (A)”, 2D) = “white” {}
_EmissionLM (“Emission (Lightmapper)”, Float) = 0
}
SubShader {
Tags {“Queue”=“Transparent” “IgnoreProjector”=“True” “RenderType”=“Transparent”}
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha
sampler2D _MainTex;
sampler2D _Illum;
fixed4 _Color;
struct Input {
float2 uv_MainTex;
float2 uv_Illum;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a;
o.Alpha = c.a;
}
ENDCG
}
Fallback “Transparent/VertexLit”
}