diff --git a/Assets/Shaders/Compute/Stardust/Stardust.compute b/Assets/Shaders/Compute/Stardust/Stardust.compute index 84bb19606..1330115b9 100644 --- a/Assets/Shaders/Compute/Stardust/Stardust.compute +++ b/Assets/Shaders/Compute/Stardust/Stardust.compute @@ -135,7 +135,8 @@ void UpdateParticles(uint3 id : SV_DispatchThreadID, int3 groupID : SV_GroupThre float noise; const float3 flowDir = flow(particles[id.x].position, noise); particles[id.x].position += flowDir * (lifetime * noise); + const float fade = smoothstep(0,ceilingHeight, particles[id.x].position.y); const float d = pow(density(particles[id.x].position) + .01, 0.1); - particles[id.x].size = lerp(minimumSize, maximumSize, saturate(RandomValue())) * parabola(lifetime, 2); + particles[id.x].size = lerp(minimumSize, maximumSize, saturate(RandomValue()*fade)) * parabola(lifetime, 2); particles[id.x].color = HueTexture.SampleLevel(samplerHueTexture, float2(RandomValue(), 0.0f), 0.0f).rgb * d; } \ No newline at end of file diff --git a/Assets/Shaders/DitheredParticles.shader b/Assets/Shaders/DitheredParticles.shader index d7e2f97b3..d8389ebbe 100644 --- a/Assets/Shaders/DitheredParticles.shader +++ b/Assets/Shaders/DitheredParticles.shader @@ -8,66 +8,83 @@ Shader "Aetheria/Dithered Particles" { [HDR]_Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo (RGB)", 2D) = "white" {} - _Glossiness ("Smoothness", Range(0,1)) = 0.5 - _Metallic ("Metallic", Range(0,1)) = 0.0 } + + CGINCLUDE + + #include "UnityCG.cginc" + #include "Dither Functions.cginc" + + struct appdata_particles { + float4 vertex : POSITION; + float4 color : COLOR; + float4 texcoord : TEXCOORD0; + }; + + struct v2f + { + float4 position : SV_POSITION; + float4 color : COLOR; + float2 texcoord : TEXCOORD0; + float2 ditherOffset : TEXCOORD1; + float4 screenPos : TEXCOORD2; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + float4 _Color; + float _Cutoff; + + v2f vert(appdata_particles v) + { + v2f o; + o.position = UnityObjectToClipPos(v.vertex); + o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); + o.ditherOffset = v.texcoord.zw; + o.color = v.color; + o.screenPos = ComputeScreenPos(o.position); + return o; + } + + float4 frag(v2f i) : COLOR + { + float4 c = tex2D(_MainTex, i.texcoord) * _Color * i.color; + // Apply screen space dithering + float2 screenUV = i.screenPos.xy / i.screenPos.w; + ditherClip(screenUV + i.ditherOffset, c.a); + return c; + } + + float4 frag_shadow(v2f i) : COLOR + { + float4 c = tex2D(_MainTex, i.texcoord) * _Color.a * i.color.a; + // Apply screen space dithering + float2 screenUV = i.screenPos.xy / i.screenPos.w; + ditherClip(screenUV + i.ditherOffset, c.a); + SHADOW_CASTER_FRAGMENT(i) + } + + ENDCG + SubShader { - Tags { "RenderType"="Opaque" } - LOD 200 - Cull Off - - CGPROGRAM - #include "Dither Functions.cginc" - // Physically based Standard lighting model, and enable shadows on all light types - #pragma surface surf Standard vertex:vert - - // Use shader model 3.0 target, to get nicer looking lighting - #pragma target 3.0 - - sampler2D _MainTex; - - struct appdata_particles { - float4 vertex : POSITION; - float3 normal : NORMAL; - float4 color : COLOR; - float4 texcoord : TEXCOORD0; - }; - - struct Input { - float2 uv_MainTex; - float2 ditherOffset; - float4 color; - float4 screenPos; - }; - - void vert(inout appdata_particles v, out Input o) { - UNITY_INITIALIZE_OUTPUT(Input,o); - o.uv_MainTex = v.texcoord.xy; - o.ditherOffset = v.texcoord.zw; - o.color = v.color; - } - - half _Glossiness; - half _Metallic; - fixed4 _Color; - - void surf (Input IN, inout SurfaceOutputStandard o) + Tags { "Queue"="AlphaTest" "RenderType"="TransparentCutout" "IgnoreProjector"="True" } + Pass { - // Albedo comes from a texture tinted by color - fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color * IN.color; - - // Apply screen space dithering - float2 screenUV = IN.screenPos.xy / IN.screenPos.w; - ditherClip(screenUV + IN.ditherOffset, c.a); - o.Emission = c.rgb; - - // Metallic and smoothness come from slider variables - o.Metallic = _Metallic; - o.Smoothness = _Glossiness; - o.Alpha = 1; + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG } - ENDCG - } + Pass + { + Name "ShadowCaster" + Tags { "LightMode" = "ShadowCaster" } + CGPROGRAM + #pragma vertex vert + #pragma fragment frag_shadow + ENDCG + } + } FallBack "Diffuse" } diff --git a/GameData/PlayerSettings.msgpack b/GameData/PlayerSettings.msgpack index a87fce39e..4b59a1305 100644 --- a/GameData/PlayerSettings.msgpack +++ b/GameData/PlayerSettings.msgpack @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:43d52e27f11b38826769943bdcb454cdaa399243180c8527ad8a04a0b0312be4 -size 6916 +oid sha256:dc6b519f0ee15e522179e90da142ec860e942f3d9bb16d7ec8c85fb703f834f3 +size 31022 diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index f33a7228f..fb93f74d9 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:447234e8c4d8ad0cbbdc75de56e2d314a113b5969f4fe0e37f1012457f829739 +oid sha256:642cf805309acafa4b513535bd41e7af6a774bd8002dd6096c9a774a1c66369d size 1687