Aetheria/Assets/Shaders/Compute/Slime/Slime.shader
Reinier Vens 11a9365f91 Trailer Stuff & More
Changed title font to Montserrat
Added trailer-specific camera transitions
Added key to hide UI
Fixed input listening while console is open
Added animated zone reveal effect in galaxy map
Added Ping action for sensors
Added debug console commands (e.g. give command to get any item in legendary+ quality)
Temporarily disabled wwise
Fixed infinite loop in weapon penetration code
Guided missiles now predict target position
Fixed hitscan weapons
Fixed invisible enemies bug
Fixed various loadout generator issues (can now generate turrets!)
Fixed wormhole crash when enemy is targeted
Saving/loading current zone time when exiting game (planets keep their positions)
Created slime simulation in test scene - WIP
2021-03-27 10:03:24 +00:00

159 lines
No EOL
5.1 KiB
GLSL

Shader "Aetheria/Stardust (Compute)"
{
Properties {
[HDR] _TintColor("Tint Color", Color) = (0.5,0.5,0.5,0.5)
_EmissionGain("Emission Gain", Range(0, 1)) = 0.3
_Power("Power", Float) = 2
}
SubShader {
Tags { "Queue"="AlphaTest" "RenderType"="TransparentCutout" "IgnoreProjector"="True" }
Pass {
CGPROGRAM
#pragma vertex particle_vertex
#pragma fragment frag
#pragma target 5.0
#include "UnityCG.cginc"
#include "Assets/Shaders/Dither Functions.cginc"
struct Particle
{
float3 position;
float3 color;
float size;
};
StructuredBuffer<Particle> particles;
StructuredBuffer<float3> quadPoints;
float4 _TintColor;
float _EmissionGain;
float _Power;
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float4 screenPos : TEXCOORD1;
float4 color : COLOR;
};
//Vertex shader with no inputs
//Uses the system values SV_VertexID and SV_InstanceID to read from compute buffers
v2f particle_vertex(uint id : SV_VertexID, uint inst : SV_InstanceID)
{
v2f o;
//Only transform world pos by view matrix
//To Create a billboarding effect
float3 worldPosition = particles[inst].position;
float4 cameraSpacePosition = mul(UNITY_MATRIX_V, float4(worldPosition, 1.0f));
float3 quadPoint = float3(quadPoints[id].xy, 0.0f) * particles[inst].size;
o.pos = mul(UNITY_MATRIX_P, cameraSpacePosition + float4(quadPoint, 0.0f));
//Shift coordinates for uvs
o.uv = quadPoints[id] + 0.5f;
//transfer color of particle and global tint to vertex
o.color = float4(particles[inst].color, 1) * _TintColor;
o.screenPos = ComputeScreenPos(o.pos);
return o;
}
float powerPulse( float x, float power )
{
x = saturate(abs(x));
return pow((x + 1.0f) * (1.0f - x), power);
}
float4 frag(v2f i) : COLOR
{
float emission = powerPulse(length(i.uv-float2(.5,.5))*2,_Power);
float2 screenUV = i.screenPos.xy / i.screenPos.w;
ditherClip(screenUV, emission * i.color.a);
return i.color * emission * (exp(_EmissionGain * 5.0f));
}
ENDCG
}
Pass
{
Name "ShadowCaster"
Tags { "LightMode" = "ShadowCaster" }
CGPROGRAM
#pragma vertex particle_vertex
#pragma fragment frag
#pragma target 5.0
#include "UnityCG.cginc"
#include "Assets/Shaders/Dither Functions.cginc"
struct Particle
{
float3 position;
float3 color;
float size;
};
StructuredBuffer<Particle> particles;
StructuredBuffer<float3> quadPoints;
float4 _TintColor;
float _EmissionGain;
float _Power;
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float4 screenPos : TEXCOORD1;
float4 color : COLOR;
};
//Vertex shader with no inputs
//Uses the system values SV_VertexID and SV_InstanceID to read from compute buffers
v2f particle_vertex(uint id : SV_VertexID, uint inst : SV_InstanceID)
{
v2f o;
//Only transform world pos by view matrix
//To Create a billboarding effect
float3 worldPosition = particles[inst].position;
float4 cameraSpacePosition = mul(UNITY_MATRIX_V, float4(worldPosition, 1.0f));
float3 quadPoint = float3(quadPoints[id].xy, 0.0f) * particles[inst].size;
o.pos = mul(UNITY_MATRIX_P, cameraSpacePosition + float4(quadPoint, 0.0f));
//Shift coordinates for uvs
o.uv = quadPoints[id] + 0.5f;
//transfer color of particle and global tint to vertex
o.color = float4(particles[inst].color, 1) * _TintColor;
o.screenPos = ComputeScreenPos(o.pos);
return o;
}
float powerPulse( float x, float power )
{
x = saturate(abs(x));
return pow((x + 1.0f) * (1.0f - x), power);
}
float4 frag(v2f i) : COLOR
{
float emission = powerPulse(length(i.uv-float2(.5,.5))*2,_Power);
float2 screenUV = i.screenPos.xy / i.screenPos.w;
ditherClip(screenUV, emission * i.color.a);
SHADOW_CASTER_FRAGMENT(i)
}
ENDCG
}
}
}