You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
2.3 KiB
113 lines
2.3 KiB
Shader "UltraCombos/Frozen/ParticleUnlitPoint"
|
|
{
|
|
Properties
|
|
{
|
|
_Color("Color", Color) = (1,1,1,1)
|
|
_MainTex("Albedo (RGB)", 2D) = "white" {}
|
|
_Emission("Emission", Range(0, 5)) = 0.0
|
|
_Size("Size", Range(0, 1)) = 0.1
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags{ "RenderType" = "Opaque" }
|
|
LOD 100
|
|
Blend One One
|
|
|
|
Pass
|
|
{
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma geometry geom
|
|
#pragma fragment frag
|
|
#pragma multi_compile_fog
|
|
|
|
#include "../../ParticleWorks/Shader/Inc/Defines.cginc"
|
|
#include "UnityCG.cginc"
|
|
|
|
struct v2g
|
|
{
|
|
float4 vertex : SV_POSITION;
|
|
};
|
|
|
|
struct g2f
|
|
{
|
|
float4 vertex : SV_POSITION;
|
|
float2 uv : TEXCOORD;
|
|
UNITY_FOG_COORDS(1)
|
|
};
|
|
|
|
sampler2D _MainTex;
|
|
float4 _MainTex_ST;
|
|
|
|
fixed4 _Color;
|
|
half _Emission;
|
|
half _Size;
|
|
float4x4 model_matrix;
|
|
|
|
#ifdef SHADER_API_D3D11
|
|
StructuredBuffer<Particle> ssbo;
|
|
#endif
|
|
|
|
v2g vert(appdata_base v, uint vid : SV_VertexID)
|
|
{
|
|
v2g o = (v2g)0;
|
|
#ifdef SHADER_API_D3D11
|
|
o.vertex = mul(model_matrix, float4(ssbo[vid].position, ssbo[vid].life));
|
|
#endif
|
|
return o;
|
|
}
|
|
|
|
[maxvertexcount(6)]
|
|
void geom(point v2g input[1], inout TriangleStream<g2f> OutputStream)
|
|
{
|
|
float3 position = input[0].vertex.xyz;
|
|
position = UnityObjectToViewPos(position);
|
|
float size = _Size * pow(saturate(1.0f - input[0].vertex.w), 1.0f / 2.2f);
|
|
const int side = 4;
|
|
float3 vertices[side];
|
|
float2 uvs[side];
|
|
|
|
float delta_a = UNITY_PI * 2.0f / side;
|
|
for (int i = 0; i < side; i++)
|
|
{
|
|
float a = delta_a * i;
|
|
float x = cos(-a);
|
|
float y = sin(-a);
|
|
vertices[i] = position + float3(x * size, y * size, 0);
|
|
uvs[i] = float2(x, y) * 0.5f + 0.5f;
|
|
}
|
|
|
|
g2f o = (g2f)0;
|
|
|
|
int index;
|
|
for (int k = 0; k < side - 2; k++)
|
|
{
|
|
for (int j = 0; j < 3; j++)
|
|
{
|
|
index = (j == 0) ? 0 : (k + j);
|
|
|
|
o.vertex = mul(UNITY_MATRIX_P, float4(vertices[index], 1.0f));
|
|
o.uv = TRANSFORM_TEX(uvs[index], _MainTex);
|
|
UNITY_TRANSFER_FOG(o, o.vertex);
|
|
OutputStream.Append(o);
|
|
}
|
|
|
|
OutputStream.RestartStrip();
|
|
}
|
|
|
|
}
|
|
|
|
fixed4 frag(g2f i) : SV_Target
|
|
{
|
|
clip(0.5f / sqrt(2.0f) - length(i.uv - float2(0.5f, 0.5f)));
|
|
|
|
fixed4 col = tex2D(_MainTex, i.uv) * _Color;
|
|
col.rgb *= 1 + _Emission;
|
|
UNITY_APPLY_FOG(i.fogCoord, col);
|
|
return col;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
}
|
|
|