23
2014
Explosion Effect (shader)
Testing some big explosion effect with shader. Still missing most particle effects..
Info:
– Vertex extrusion using noise texture & timer/distance..
– Explosion cloud + shockwave is from particle system
Webplayer:
http://unitycoder.com/upload/demos/ExplosionEffectShader/
Reference:
Armageddon (explosions) video : http://youtu.be/Tq4o-B5vWYk?t=2m25s
Shader source:
Shader "unitycoder/GroundExplo" { Properties { _MainTex ("Texture", 2D) = "white" {} _Color ("Color", Color) = (1,1,1,1) _ExtrudeTex ("Extrusion Texture", 2D) = "white" {} _Amount ("Extrusion Multiplier", Range(0,5)) = 0 _Pos ("Pos", Vector) = (0,0,0,0) } SubShader { // Pass { // Cull Off // ZWrite On // ZTest Always Tags { "RenderType" = "Opaque" "Queue" = "Geometry" } CGPROGRAM #pragma target 3.0 #pragma surface surf Lambert vertex:vert #include "UnityCG.cginc" struct Input { float2 vpos; float2 uv_MainTex; }; float4 _Color; float4 _Pos; float _Amount; sampler2D _ExtrudeTex; float4 _ExtrudeTex_ST; void vert (inout appdata_full v, out Input o) { float t = _Time.y*2; #if !defined(SHADER_API_OPENGL) float tex = tex2Dlod(_ExtrudeTex, float4(float2(v.texcoord.x,v.texcoord.y),0.0,0.0)).r; float3 worldPos = mul (_Object2World, v.vertex).xyz; float dist = distance(worldPos,_Pos.xyz); float3 dir = -normalize(_Pos.xyz-worldPos)*0.25f; if (t>dist) { float3 extrude = (v.normal+dir)*tex.r* sqrt(_Amount * (t-dist)); v.vertex.xyz += extrude; } o.vpos = v.vertex.xy; #endif } sampler2D _MainTex; void surf (Input IN, inout SurfaceOutput o) { half4 tex1 = tex2D (_MainTex, IN.uv_MainTex); half4 tex2 = tex2D (_MainTex, IN.uv_MainTex*5-_Time.yy*0.5f)+_Color; half4 col = lerp(tex1,tex2,IN.vpos.y); o.Albedo = col;//*(1-_Color*IN.vpos.y); } ENDCG } Fallback "Diffuse" }
Related Posts
5 Comments + Add Comment
Leave a comment to Kashyap
Recent posts
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
- Check if point is inside polygon 2D (using line intersection)
- UnityHub: Enable Create Project Button (without having to select Cloud Organization)
- UI: Make Tooltip background fit Text content length
- Pong-Wars in Unity
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub)
- UnityHub: Add support for custom project title (instead of folder name) or use ProductName
- Testing Unity MUSE AI
Hi,
It looks great, can you share with us how you do it. Some points on shaders or snippets of the code.
source added, use it on highres mesh.
Hi,
I’ve go a Shader error in ‘unitycoder/GroundExplo’: ‘vert’: output parameter ‘o’ not completely initialized at line 40
is it because i use unity 4.6 ?
Best Regards
daniel
Nice Blog!! lot’s to explorer
Disable DX11 mode,
or need to fix the vertex shader part, this could work:
http://forum.unity3d.com/threads/unity-4-shader-fails-under-dx11-works-under-dx9.157276/#post-1078218
shockwave shader
https://github.com/MdIqubal/Matrix-Shockwave-Shader