├── .gitignore ├── Fluid2DBlurImageEffect ├── Assets │ ├── ImageEffects.meta │ ├── ImageEffects │ │ ├── Fluid2DBlur.meta │ │ └── Fluid2DBlur │ │ │ ├── Scripts.meta │ │ │ ├── Scripts │ │ │ ├── Fluid2DBlur.cs │ │ │ └── Fluid2DBlur.cs.meta │ │ │ ├── Shaders.meta │ │ │ └── Shaders │ │ │ ├── Advect.shader │ │ │ ├── Advect.shader.meta │ │ │ ├── ApplyForce.shader │ │ │ ├── ApplyForce.shader.meta │ │ │ ├── ApplyForceByScreenBightness.shader │ │ │ ├── ApplyForceByScreenBightness.shader.meta │ │ │ ├── FluidBlur.shader │ │ │ ├── FluidBlur.shader.meta │ │ │ ├── NewImageEffectShader.shader │ │ │ ├── NewImageEffectShader.shader.meta │ │ │ ├── PressureGradientSubtract.shader │ │ │ ├── PressureGradientSubtract.shader.meta │ │ │ ├── PressureSolve.shader │ │ │ ├── PressureSolve.shader.meta │ │ │ ├── VelocityDivergence.shader │ │ │ └── VelocityDivergence.shader.meta │ ├── Sample.meta │ └── Sample │ │ ├── Fluid2DBlur.unity │ │ ├── Fluid2DBlur.unity.meta │ │ ├── Mat 1.mat │ │ ├── Mat 1.mat.meta │ │ ├── Mat 2.mat │ │ ├── Mat 2.mat.meta │ │ ├── Mat 3.mat │ │ ├── Mat 3.mat.meta │ │ ├── Mat 4.mat │ │ ├── Mat 4.mat.meta │ │ ├── Mat 5.mat │ │ ├── Mat 5.mat.meta │ │ ├── Mat 6.mat │ │ ├── Mat 6.mat.meta │ │ ├── Mat.mat │ │ ├── Mat.mat.meta │ │ ├── Mover.cs │ │ └── Mover.cs.meta └── ProjectSettings │ ├── AudioManager.asset │ ├── ClusterInputManager.asset │ ├── DynamicsManager.asset │ ├── EditorBuildSettings.asset │ ├── EditorSettings.asset │ ├── GraphicsSettings.asset │ ├── InputManager.asset │ ├── NavMeshAreas.asset │ ├── NetworkManager.asset │ ├── Physics2DSettings.asset │ ├── ProjectSettings.asset │ ├── ProjectVersion.txt │ ├── QualitySettings.asset │ ├── TagManager.asset │ ├── TimeManager.asset │ ├── UnityAdsSettings.asset │ └── UnityConnectSettings.asset ├── LICENSE.md ├── README.md └── screenShot.png /.gitignore: -------------------------------------------------------------------------------- 1 | Fluid2DBlurImageEffect/[Ll]ibrary/ 2 | Fluid2DBlurImageEffect/[Tt]emp/ 3 | Fluid2DBlurImageEffect/[Oo]bj/ 4 | Fluid2DBlurImageEffect/[Bb]uild/ 5 | Fluid2DBlurImageEffect/[Bb]uilds/ 6 | Fluid2DBlurImageEffect/Assets/AssetStoreTools* 7 | 8 | # Visual Studio 2015 cache directory 9 | /.vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | 26 | # Unity3D generated meta files 27 | *.pidb.meta 28 | *.pdb.meta 29 | 30 | # Unity3D Generated File On Crash Reports 31 | sysinfo.txt 32 | 33 | # Builds 34 | *.apk 35 | *.unitypackage -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 908d67cc636cd4ed5b64a338e72f3450 3 | folderAsset: yes 4 | timeCreated: 1451479935 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 323185cc1c94f44d0ae2130db3005d11 3 | folderAsset: yes 4 | timeCreated: 1450727324 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 70c1fffc61b514eb08a5e9ce2382b0d5 3 | folderAsset: yes 4 | timeCreated: 1450727330 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Scripts/Fluid2DBlur.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace irishoak.ImageEffects { 5 | 6 | public class Fluid2DBlur : MonoBehaviour { 7 | 8 | [SerializeField] 9 | int _bufferSizeWidth = 512; 10 | [SerializeField] 11 | int _bufferSizeHeight = 512; 12 | 13 | [SerializeField] 14 | int _fluidSimSizeWidth = 512; 15 | [SerializeField] 16 | int _fluidSimSizeHeight = 512; 17 | 18 | const int _fluidSimMaxSize = 512; 19 | 20 | [SerializeField] 21 | [Range (0, 50)] 22 | int _solverIterations = 50; 23 | 24 | [SerializeField] 25 | Shader _advectShader; 26 | [SerializeField] 27 | Shader _divergenceShader; 28 | [SerializeField] 29 | Shader _pressureSolveShader; 30 | [SerializeField] 31 | Shader _pressureGradientSubstractShader; 32 | [SerializeField] 33 | Shader _applyForceShader; 34 | [SerializeField] 35 | Shader _applyForceByScreenBrightnessShader; 36 | [SerializeField] 37 | Shader _fluidBlurShader; 38 | 39 | Material _advectMat; 40 | Material _divergenceMat; 41 | Material _pressureSolveMat; 42 | Material _pressureGradientSubtractMat; 43 | Material _applyForceMat; 44 | Material _applyForceByScreenBrightnessMat; 45 | Material _fluidBlurMat; 46 | 47 | RenderTexture[] _velocityBuffer; 48 | RenderTexture[] _pressureBuffer; 49 | RenderTexture _divergenceBuffer; 50 | 51 | RenderTexture[] _screenBuffer; 52 | 53 | Vector2 _invResolution; 54 | float _RDX; 55 | 56 | [SerializeField] 57 | [Range (0.01f, 1.0f)] 58 | float _accum = 0.01f; 59 | 60 | [SerializeField] 61 | [Range (0.0f, 1.0f)] 62 | float _atten = 0.001f; 63 | 64 | [SerializeField] 65 | float _blurSigma = 0.85f; 66 | 67 | [SerializeField] 68 | float _velocityScale = 0.002f; 69 | 70 | [SerializeField] 71 | [Range (1, 10)] 72 | int _blurIter = 3; 73 | 74 | Matrix4x4 _blurMat; 75 | 76 | const int PASS_ACCUM = 0; 77 | const int PASS_BLUR = 1; 78 | const int PASS_ATTEN = 2; 79 | const int PASS_FLUID = 3; 80 | 81 | [Range (0, 1024)] 82 | public int GUITextureSize = 320; 83 | 84 | [SerializeField] 85 | bool _isLeftMouseButtonDown = false; 86 | Vector2 _currentMousePosition; 87 | Vector2 _previousMousePosition; 88 | 89 | [SerializeField] 90 | bool _isEnableMouseToApplyForce = true; 91 | 92 | [SerializeField] 93 | bool _isDebug = true; 94 | 95 | public RenderTexture GetFlowVelocityFieldTex () { 96 | if (_velocityBuffer != null && _velocityBuffer.Length > 0) { 97 | return _velocityBuffer [0]; 98 | } else { 99 | return null; 100 | } 101 | } 102 | 103 | void Start () { 104 | 105 | Setup (); 106 | 107 | } 108 | 109 | void Update () { 110 | 111 | if (_bufferSizeWidth != Screen.width || _bufferSizeHeight != Screen.height) { 112 | Reset (); 113 | } 114 | 115 | if (Input.GetMouseButtonDown (0)) { 116 | _isLeftMouseButtonDown = true; 117 | } 118 | 119 | if (Input.GetMouseButtonUp (0)) { 120 | _isLeftMouseButtonDown = false; 121 | } 122 | 123 | Step (Time.deltaTime * 0.5f); 124 | 125 | } 126 | 127 | void OnRenderImage (RenderTexture src, RenderTexture dest) { 128 | 129 | Material m = _fluidBlurMat; 130 | 131 | _accum = Mathf.Clamp01 (_accum); 132 | _atten = Mathf.Clamp01 (_atten); 133 | _blurSigma = Mathf.Clamp01 (_blurSigma); 134 | _blurIter = Mathf.Clamp (_blurIter, 1, 10); 135 | 136 | var coeff = -1.0f / (2.0f * _blurSigma * _blurSigma); 137 | var f11 = 1.0f; 138 | var f12 = Mathf.Exp (coeff); 139 | var f22 = Mathf.Exp (2.0f * coeff); 140 | var invSum = 1.0f / (f11 + 4 * f12 + 4 * f22); 141 | _blurMat[1, 1] = invSum * f11; 142 | _blurMat[0, 1] = _blurMat[1, 0] = _blurMat[2, 1] = _blurMat[1, 2] = invSum * f12; 143 | _blurMat[0, 0] = _blurMat[2, 0] = _blurMat[0, 2] = _blurMat[2, 2] = invSum * f22; 144 | 145 | m.SetFloat ("_Accum", _accum); 146 | m.SetFloat ("_Atten", _atten); 147 | m.SetMatrix ("_BlurMat", _blurMat); 148 | 149 | _screenBuffer [0].DiscardContents (); 150 | Graphics.Blit(_screenBuffer [0], _screenBuffer [1], m, PASS_ATTEN); 151 | _swapBuffer (_screenBuffer); 152 | 153 | m.SetTexture ("_VelocityMap", GetFlowVelocityFieldTex ()); 154 | m.SetFloat ("_VelocityScale", _velocityScale); 155 | _screenBuffer [1].DiscardContents (); 156 | Graphics.Blit(_screenBuffer [0], _screenBuffer [1], m, PASS_FLUID); 157 | _swapBuffer (_screenBuffer); 158 | 159 | for (var i = 0; i < _blurIter; i++) { 160 | _screenBuffer [1].DiscardContents (); 161 | Graphics.Blit (_screenBuffer [0], _screenBuffer [1], m, PASS_BLUR); 162 | _swapBuffer (_screenBuffer); 163 | } 164 | 165 | Graphics.Blit (src, _screenBuffer [0], m, PASS_ACCUM); 166 | 167 | Graphics.Blit (_screenBuffer [0], dest); 168 | 169 | } 170 | 171 | void OnDestroy () { 172 | 173 | _destroyBuffers (); 174 | _destroyMaterials (); 175 | 176 | } 177 | 178 | 179 | public void Setup () { 180 | 181 | _createMaterials (); 182 | 183 | Reset (); 184 | 185 | } 186 | 187 | public void Reset () { 188 | 189 | _destroyBuffers (); 190 | 191 | _bufferSizeWidth = Screen.width; 192 | _bufferSizeHeight = Screen.height; 193 | 194 | _fluidSimSizeWidth = _bufferSizeWidth < _fluidSimMaxSize ? _bufferSizeWidth : _fluidSimMaxSize; 195 | _fluidSimSizeHeight = Mathf.FloorToInt (_fluidSimSizeWidth * (_bufferSizeHeight / (_bufferSizeWidth * 1.0f))); 196 | 197 | _RDX = 1.0f / (_fluidSimSizeWidth * 1.0f); 198 | _invResolution = new Vector2 (1.0f / (_fluidSimSizeWidth * 1.0f), 1.0f / (_fluidSimSizeHeight * 1.0f)); 199 | 200 | _createBuffers (); 201 | _resetBuffers (); 202 | 203 | } 204 | 205 | public void Step (float dt_) { 206 | 207 | float aspectRatio = _fluidSimSizeWidth / (_fluidSimSizeHeight * 1.0f); 208 | Shader.SetGlobalFloat ("_Fluid2D_AspectRatio", aspectRatio); 209 | 210 | Vector3 mp = Input.mousePosition; 211 | //mp.x *= _aspectRatio; 212 | _currentMousePosition = Camera.main.ScreenToViewportPoint (mp); 213 | 214 | _advect (ref _velocityBuffer, dt_); 215 | 216 | _applyForces (dt_); 217 | _applyForcesByScreen (dt_); 218 | 219 | _computeDivergence (); 220 | _solvePressure (); 221 | _subtractPressureGradient (); 222 | 223 | _previousMousePosition = _currentMousePosition; 224 | } 225 | 226 | void _advect (ref RenderTexture[] targetBuffer_, float dt_) { 227 | 228 | _advectMat.SetFloat ("_Dt", dt_); 229 | _advectMat.SetFloat ("_RDX", _RDX); 230 | _advectMat.SetVector ("_Invresolution", _invResolution); 231 | _advectMat.SetTexture ("_Target", targetBuffer_ [0]); 232 | _advectMat.SetTexture ("_Velocity", _velocityBuffer [0]); 233 | Graphics.Blit (null, targetBuffer_ [1], _advectMat); 234 | _swapBuffer (targetBuffer_); 235 | } 236 | 237 | void _applyForces (float dt_) { 238 | if (_applyForceMat == null) 239 | return; 240 | //set uniforms 241 | _applyForceMat.SetTexture ("_Velocity", _velocityBuffer [0]); 242 | _applyForceMat.SetFloat ("_Dt", dt_); 243 | _applyForceMat.SetFloat ("_Dx", _fluidSimSizeWidth); 244 | if (_isEnableMouseToApplyForce) { 245 | _applyForceMat.SetFloat ("_IsMouseDown", _isLeftMouseButtonDown ? 1 : 0); 246 | _applyForceMat.SetVector ("_MouseClipSpace", _currentMousePosition); 247 | _applyForceMat.SetVector ("_LastMouseClipSpace", _previousMousePosition); 248 | } 249 | //render 250 | Graphics.Blit (null, _velocityBuffer [1], _applyForceMat); 251 | _swapBuffer (_velocityBuffer); 252 | 253 | } 254 | 255 | void _applyForcesByScreen (float dt_) { 256 | if (_applyForceByScreenBrightnessMat == null) 257 | return; 258 | //set uniforms 259 | _applyForceByScreenBrightnessMat.SetTexture ("_Velocity", _velocityBuffer [0]); 260 | _applyForceByScreenBrightnessMat.SetTexture ("_ScreenTex", _screenBuffer [1]); 261 | _applyForceByScreenBrightnessMat.SetFloat ("_Dt", dt_); 262 | _applyForceByScreenBrightnessMat.SetFloat ("_Dx", _fluidSimSizeWidth); 263 | _applyForceByScreenBrightnessMat.SetFloat ("_TexelSizeScale", 0.1f); 264 | _applyForceByScreenBrightnessMat.SetFloat ("_BumpHeightScale", 0.1f); 265 | 266 | //render 267 | Graphics.Blit (null, _velocityBuffer [1], _applyForceByScreenBrightnessMat); 268 | _swapBuffer (_velocityBuffer); 269 | 270 | } 271 | 272 | void _computeDivergence () { 273 | 274 | _divergenceMat.SetTexture ("_Velocity", _velocityBuffer [0]); 275 | 276 | _divergenceMat.SetFloat ("_HalfRDX", 0.5f * _RDX); 277 | _divergenceMat.SetVector ("_Invresolution", _invResolution); 278 | Graphics.Blit (null, _divergenceBuffer, _divergenceMat); 279 | } 280 | 281 | void _solvePressure () { 282 | 283 | _pressureSolveMat.SetTexture ("_Divergence", _divergenceBuffer); 284 | _pressureSolveMat.SetFloat ("_Alpha", -(_fluidSimSizeWidth * _fluidSimSizeWidth)); 285 | _pressureSolveMat.SetVector ("_Invresolution", _invResolution); 286 | 287 | for (int i = 0; i < _solverIterations; i++) { 288 | _pressureSolveMat.SetTexture ("_Pressure", _pressureBuffer [0]); 289 | Graphics.Blit (null, _pressureBuffer [1], _pressureSolveMat); 290 | _swapBuffer (_pressureBuffer); 291 | } 292 | } 293 | 294 | void _subtractPressureGradient () { 295 | 296 | _pressureGradientSubtractMat.SetTexture ("_Pressure", _pressureBuffer [0]); 297 | _pressureGradientSubtractMat.SetTexture ("_Velocity", _velocityBuffer [0]); 298 | _pressureGradientSubtractMat.SetFloat ("_HalfRDX", 0.5f * _RDX); 299 | _pressureGradientSubtractMat.SetVector ("_Invresolution", _invResolution); 300 | Graphics.Blit (null, _velocityBuffer [1], _pressureGradientSubtractMat); 301 | 302 | _swapBuffer (_velocityBuffer); 303 | } 304 | 305 | void _createBuffers () { 306 | 307 | _createBuffer (ref _velocityBuffer, _fluidSimSizeWidth, _fluidSimSizeHeight); 308 | _createBuffer (ref _pressureBuffer, _fluidSimSizeWidth, _fluidSimSizeHeight); 309 | _createBuffer (ref _divergenceBuffer, _fluidSimSizeWidth, _fluidSimSizeHeight); 310 | 311 | _createBuffer (ref _screenBuffer, _bufferSizeWidth, _bufferSizeHeight ); 312 | } 313 | 314 | void _resetBuffers () { 315 | 316 | _resetBuffer (ref _velocityBuffer); 317 | _resetBuffer (ref _pressureBuffer); 318 | _resetBuffer (ref _divergenceBuffer); 319 | 320 | _resetBuffer (ref _screenBuffer); 321 | 322 | } 323 | 324 | void _destroyBuffers () { 325 | 326 | _destroyBuffer (ref _velocityBuffer); 327 | _destroyBuffer (ref _pressureBuffer); 328 | _destroyBuffer (ref _divergenceBuffer); 329 | 330 | _destroyBuffer (ref _screenBuffer); 331 | 332 | } 333 | 334 | void _createMaterials () { 335 | 336 | _createMaterial (ref _advectMat, _advectShader); 337 | _createMaterial (ref _divergenceMat, _divergenceShader); 338 | _createMaterial (ref _pressureSolveMat, _pressureSolveShader); 339 | _createMaterial (ref _pressureGradientSubtractMat, _pressureGradientSubstractShader); 340 | _createMaterial (ref _applyForceMat, _applyForceShader); 341 | 342 | _createMaterial (ref _applyForceByScreenBrightnessMat, _applyForceByScreenBrightnessShader); 343 | _createMaterial (ref _fluidBlurMat, _fluidBlurShader); 344 | } 345 | 346 | void _destroyMaterials () { 347 | 348 | _destroyMaterial (ref _advectMat); 349 | _destroyMaterial (ref _divergenceMat); 350 | _destroyMaterial (ref _pressureSolveMat); 351 | _destroyMaterial (ref _pressureGradientSubtractMat); 352 | _destroyMaterial (ref _applyForceMat); 353 | 354 | _destroyMaterial (ref _applyForceByScreenBrightnessMat); 355 | _destroyMaterial (ref _fluidBlurMat); 356 | 357 | } 358 | 359 | void _createBuffer (ref RenderTexture[] rt_, int bufferWidth_, int bufferHeight_) { 360 | 361 | rt_ = new RenderTexture[2]; 362 | rt_ [0] = new RenderTexture (bufferWidth_, bufferHeight_, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear); 363 | rt_ [0].filterMode = FilterMode.Bilinear; 364 | rt_ [0].wrapMode = TextureWrapMode.Clamp; 365 | rt_ [0].hideFlags = HideFlags.DontSave; 366 | rt_ [0].Create (); 367 | RenderTexture.active = rt_ [0]; 368 | GL.Clear (false, true, new Color (0,0,0,0)); 369 | RenderTexture.active = null; 370 | rt_ [1] = new RenderTexture (bufferWidth_, bufferHeight_, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear); 371 | rt_ [1].filterMode = FilterMode.Bilinear; 372 | rt_ [1].wrapMode = TextureWrapMode.Clamp; 373 | rt_ [1].hideFlags = HideFlags.DontSave; 374 | rt_ [1].Create (); 375 | RenderTexture.active = rt_ [1]; 376 | GL.Clear (false, true, new Color (0,0,0,0)); 377 | RenderTexture.active = null; 378 | } 379 | 380 | void _createBuffer (ref RenderTexture rt_, int bufferWidth_, int bufferHeight_) { 381 | 382 | rt_ = new RenderTexture (bufferWidth_, bufferHeight_, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear); 383 | rt_.filterMode = FilterMode.Bilinear; 384 | rt_.wrapMode = TextureWrapMode.Clamp; 385 | rt_.hideFlags = HideFlags.DontSave; 386 | rt_.Create (); 387 | RenderTexture.active = rt_; 388 | GL.Clear (false, true, new Color (0,0,0,0)); 389 | RenderTexture.active = null; 390 | } 391 | 392 | void _resetBuffer (ref RenderTexture[] rt_) { 393 | 394 | RenderTexture.active = rt_ [0]; 395 | GL.Clear (false, true, Color.black); 396 | RenderTexture.active = null; 397 | 398 | RenderTexture.active = rt_ [1]; 399 | GL.Clear (false, true, Color.black); 400 | RenderTexture.active = null; 401 | 402 | } 403 | 404 | void _resetBuffer (ref RenderTexture rt_) { 405 | 406 | RenderTexture.active = rt_; 407 | GL.Clear (false, true, Color.black); 408 | RenderTexture.active = null; 409 | 410 | } 411 | 412 | void _destroyBuffer (ref RenderTexture[] buffer_) { 413 | 414 | if (buffer_ != null && buffer_.Length > 0) { 415 | for (int i = 0; i < buffer_.Length; i++) { 416 | DestroyImmediate (buffer_ [i]); 417 | } 418 | } 419 | 420 | } 421 | 422 | void _destroyBuffer (ref RenderTexture buffer_) { 423 | 424 | if (buffer_ != null) { 425 | DestroyImmediate (buffer_); 426 | } 427 | 428 | } 429 | 430 | void _swapBuffer (RenderTexture[] buffer_) { 431 | 432 | RenderTexture temp = buffer_ [0]; 433 | buffer_ [0] = buffer_ [1]; 434 | buffer_ [1] = temp; 435 | 436 | } 437 | 438 | void _createMaterial (ref Material mat_, Shader shader_) { 439 | 440 | if (mat_ == null) mat_ = new Material (shader_); 441 | 442 | } 443 | 444 | void _destroyMaterial (ref Material mat_) { 445 | 446 | if (mat_ != null) DestroyImmediate (mat_); 447 | 448 | } 449 | 450 | void OnGUI () { 451 | int size = GUITextureSize; 452 | Rect r00 = new Rect (size * 0, size * 0, size, size); 453 | Rect r10 = new Rect (size * 1, size * 0, size, size); 454 | Rect r01 = new Rect (size * 0, size * 1, size, size); 455 | Rect r11 = new Rect (size * 1, size * 1, size, size); 456 | //Rect r02 = new Rect (size * 0, size * 2, size, size); 457 | //Rect r12 = new Rect (size * 1, size * 2, size, size); 458 | //Rect r03 = new Rect (size * 0, size * 3, size, size); 459 | //Rect r13 = new Rect (size * 1, size * 3, size, size); 460 | //Rect r04 = new Rect (size * 0, size * 4, size, size); 461 | //Rect r14 = new Rect (size * 1, size * 4, size, size); 462 | Rect r20 = new Rect (size * 2, size * 0, size, size); 463 | //Rect r21 = new Rect (size * 2, size * 1, size, size); 464 | //Rect r30 = new Rect (size * 3, size * 0, size, size); 465 | //Rect r31 = new Rect (size * 3, size * 1, size, size); 466 | Rect r40 = new Rect (size * 4, size * 0, size, size); 467 | Rect r41 = new Rect (size * 4, size * 1, size, size); 468 | 469 | //GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), _dyeBuffer [0]); 470 | 471 | GUI.DrawTexture (r00, _velocityBuffer [0]); 472 | GUI.Label (r00, "_velcotiyBuffer [0]"); 473 | GUI.DrawTexture (r01, _velocityBuffer [1]); 474 | GUI.Label (r01, "_velcotiyBuffer [1]"); 475 | 476 | GUI.DrawTexture (r10, _pressureBuffer [0]); 477 | GUI.Label (r10, "_pressureBuffer [0]"); 478 | GUI.DrawTexture (r11, _pressureBuffer [1]); 479 | GUI.Label (r11, "_pressureBuffer [1]"); 480 | 481 | GUI.DrawTexture (r20, _divergenceBuffer); 482 | GUI.Label (r20, "_divergenceBuffer"); 483 | 484 | GUI.DrawTexture (r40, _screenBuffer [0]); 485 | GUI.Label (r40, "_screenBuffer [0]"); 486 | GUI.DrawTexture (r41, _screenBuffer [1]); 487 | GUI.Label (r41, "_screenBuffer [1]"); 488 | 489 | 490 | } 491 | } 492 | } -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Scripts/Fluid2DBlur.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e74c1e19119046edb8f1abcd0358632 3 | timeCreated: 1451481921 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _advectShader: {fileID: 4800000, guid: 33e0cd26dfdcc4bcda08eb96dc45ce73, type: 3} 9 | - _divergenceShader: {fileID: 4800000, guid: 128968673999a4264a3a39714288de63, type: 3} 10 | - _pressureSolveShader: {fileID: 4800000, guid: 42a4f2e2ea12c499e971be5629a47673, 11 | type: 3} 12 | - _pressureGradientSubstractShader: {fileID: 4800000, guid: 8854fa981500a4468949ee85febc1ad4, 13 | type: 3} 14 | - _applyForceShader: {fileID: 4800000, guid: 308d37780250c483d8432cffe23fa755, type: 3} 15 | - _applyForceByScreenBrightnessShader: {fileID: 4800000, guid: a3be2521bd8744ed59b6852e242715f9, 16 | type: 3} 17 | - _fluidBlurShader: {fileID: 4800000, guid: ad300f7c755ec4f05b5e6366544d978a, type: 3} 18 | executionOrder: 0 19 | icon: {instanceID: 0} 20 | userData: 21 | assetBundleName: 22 | assetBundleVariant: 23 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f119b84e749544b1bbd63ec45c46d6b4 3 | folderAsset: yes 4 | timeCreated: 1450727332 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/Advect.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/GPGPU/Fluid2D/Advect" { 2 | Properties { 3 | _MainTex ("-", 2D) = "" {} 4 | } 5 | 6 | CGINCLUDE 7 | 8 | #include "UnityCG.cginc" 9 | 10 | uniform float _Fluid2D_AspectRatio; 11 | uniform float2 _Invresolution; 12 | 13 | uniform sampler2D _MainTex; 14 | uniform float2 _MainTex_TexelSize; 15 | 16 | uniform sampler2D _Velocity; 17 | uniform sampler2D _Target; 18 | 19 | uniform float _Dt; 20 | uniform float _RDX; // reciprocal of grid scale, used to scale velocity int simulation domain 21 | 22 | 23 | float2 simToTexelSpace(float2 simSpace){ 24 | return float2(simSpace.x / _Fluid2D_AspectRatio + 1.0 , simSpace.y + 1.0) * 0.5; 25 | } 26 | 27 | float4 frag (v2f_img i) : SV_Target 28 | { 29 | 30 | float2 u = tex2D (_Velocity, i.uv.xy).xy; 31 | float2 tracedPos = i.uv.xy - (u * _Invresolution * _Dt); 32 | float4 result = 0.999 * tex2D (_Target, tracedPos.xy); 33 | 34 | return float4(result.xyz, 1.0); 35 | 36 | } 37 | 38 | ENDCG 39 | 40 | 41 | SubShader { 42 | 43 | Pass { 44 | Fog { Mode off } 45 | CGPROGRAM 46 | #pragma target 3.0 47 | //#pragma glsl 48 | #pragma vertex vert_img 49 | #pragma fragment frag 50 | ENDCG 51 | } 52 | } 53 | FallBack "Diffuse" 54 | } -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/Advect.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33e0cd26dfdcc4bcda08eb96dc45ce73 3 | timeCreated: 1450727406 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/ApplyForce.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/GPGPU/Fluid2D/ApplyForce" { 2 | Properties { 3 | _MainTex ("-", 2D) = "" {} 4 | } 5 | 6 | CGINCLUDE 7 | 8 | #include "UnityCG.cginc" 9 | 10 | uniform float _Fluid2D_AspectRatio; 11 | 12 | uniform sampler2D _MainTex; 13 | float2 _MainTex_TexelSize; 14 | 15 | uniform sampler2D _Velocity; 16 | uniform float _Dt; 17 | uniform float _Dx; 18 | 19 | uniform bool _IsMouseDown; 20 | uniform float2 _MouseClipSpace; 21 | uniform float2 _LastMouseClipSpace; 22 | 23 | float2 clipToSimSpace(float2 clipSpace){ 24 | return float2(clipSpace.x * _Fluid2D_AspectRatio, clipSpace.y); 25 | } 26 | 27 | //Segment 28 | float distanceToSegment(float2 a, float2 b, float2 p, out float fp){ 29 | float2 d = p - a; 30 | float2 x = b - a; 31 | 32 | fp = 0.0; //fractional projection, 0 - 1 in the length of vec2(b - a) 33 | float lx = length(x); 34 | 35 | if(lx <= 0.0001) return length(d);//#! needs improving; hot fix for normalization of 0 vector 36 | 37 | float projection = dot(d, x / lx); //projection in pixel units 38 | 39 | fp = projection / lx; 40 | 41 | if(projection < 0.0) { 42 | return length(d); 43 | } else if (projection > length(x)) { 44 | return length(p - b); 45 | } 46 | return sqrt(abs(dot(d, d) - projection * projection)); 47 | } 48 | 49 | float distanceToSegment(float2 a, float2 b, float2 p){ 50 | float fp; 51 | return distanceToSegment(a, b, p, fp); 52 | } 53 | 54 | float4 frag (v2f_img i) : SV_Target 55 | { 56 | 57 | float2 v = tex2D(_Velocity, i.uv.xy).xy; 58 | 59 | v.xy *= 0.999; 60 | 61 | if(_IsMouseDown){ 62 | float2 mouse = clipToSimSpace(_MouseClipSpace); 63 | float2 lastMouse = clipToSimSpace(_LastMouseClipSpace); 64 | float2 mouseVelocity = -(lastMouse - mouse) / _Dt; 65 | 66 | //compute tapered distance to mouse line segment 67 | float fp; //fractional projection 68 | float l = distanceToSegment(mouse, lastMouse, i.uv.xy, fp); 69 | float taperFactor = 0.6;//1 => 0 at lastMouse, 0 => no tapering 70 | float projectedFraction = 1.0 - clamp(fp, 0.0, 1.0) * taperFactor; 71 | 72 | float R = 0.015; 73 | float m = exp(-l/R); //drag coefficient 74 | m *= projectedFraction * projectedFraction; 75 | 76 | float2 targetVelocity = mouseVelocity * _Dx; 77 | v += (targetVelocity - v) * m; 78 | } 79 | 80 | float4 result = float4(v, 0, 1.); 81 | return result; 82 | } 83 | 84 | ENDCG 85 | 86 | 87 | SubShader { 88 | 89 | Pass { 90 | Fog { Mode off } 91 | CGPROGRAM 92 | #pragma target 3.0 93 | //#pragma glsl 94 | #pragma vertex vert_img 95 | #pragma fragment frag 96 | ENDCG 97 | } 98 | } 99 | FallBack "Diffuse" 100 | } -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/ApplyForce.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 308d37780250c483d8432cffe23fa755 3 | timeCreated: 1450727407 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/ApplyForceByScreenBightness.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/GPGPU/Fluid2D/ApplyForceByScreenBrightness" { 2 | Properties { 3 | _MainTex ("-", 2D) = "" {} 4 | _ScreenTex ("-", 2D) = "" {} 5 | _Velocity ("-", 2D) = "" {} 6 | } 7 | 8 | CGINCLUDE 9 | 10 | #include "UnityCG.cginc" 11 | 12 | sampler2D _Velocity; 13 | 14 | sampler2D _MainTex; 15 | float2 _MainTex_TexelSize; 16 | 17 | sampler2D _ScreenTex; 18 | float4 _ScreenTex_TexelSize; 19 | 20 | float _TexelSizeScale; 21 | float _BumpHeightScale; 22 | 23 | 24 | float4 frag (v2f_img i) : SV_Target 25 | { 26 | 27 | float2 v = tex2D(_Velocity, i.uv).xy; 28 | 29 | float2 uv = i.uv; 30 | float2 uvE = uv + fixed2(_ScreenTex_TexelSize.x * _TexelSizeScale, 0.0); 31 | float2 uvN = uv + fixed2(0.0, _ScreenTex_TexelSize.y * _TexelSizeScale); 32 | 33 | float3 st = tex2D(_ScreenTex, uv ).xyz; 34 | float3 stE = tex2D(_ScreenTex, uvE).xyz; 35 | float3 stU = tex2D(_ScreenTex, uvN).xyz; 36 | 37 | st = st / length(st == 0 ? 0.0001 : st ); 38 | stE = stE / length(stE == 0 ? 0.0001 : stE); 39 | stU = stU / length(stU == 0 ? 0.0001 : stU); 40 | 41 | fixed height = (st.x + st.y + st.z ) * 0.3333333 * _BumpHeightScale; 42 | fixed heightE = (stE.x + stE.y + stE.z) * 0.3333333 * _BumpHeightScale; 43 | fixed heightN = (stU.x + stU.y + stU.z) * 0.3333333 * _BumpHeightScale; 44 | 45 | // BiNormal Vector 46 | fixed3 bv = fixed3(uvN.x, uvN.y, heightN) - fixed3(uv.x, uv.y, height); 47 | fixed3 tv = fixed3(uvE.x, uvE.y, heightE) - fixed3(uv.x, uv.y, height); 48 | 49 | bv = normalize(bv); 50 | tv = normalize(tv); 51 | 52 | fixed3 norm = normalize(cross(tv, bv)); 53 | //norm.xyz *= 0.0001; 54 | float4 result = float4(v.x + norm.x, v.y + norm.y, 0, 1); 55 | //float4 result = float4(v.x, v.y, 0, 1); 56 | return result; 57 | } 58 | 59 | ENDCG 60 | 61 | 62 | SubShader { 63 | 64 | Pass { 65 | Fog { Mode off } 66 | CGPROGRAM 67 | #pragma target 3.0 68 | //#pragma glsl 69 | #pragma vertex vert_img 70 | #pragma fragment frag 71 | ENDCG 72 | } 73 | } 74 | FallBack "Diffuse" 75 | } -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/ApplyForceByScreenBightness.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a3be2521bd8744ed59b6852e242715f9 3 | timeCreated: 1450774417 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/FluidBlur.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Hidden/ImageEffects/FluidBlur" { 4 | Properties { 5 | _MainTex ("-", 2D) = "" {} 6 | _VelocityMap ("VelocityMap", 2D) = "" {} 7 | _VelocityScale ("Velocity Scale", Float) = 0.001 8 | _Accum ("Accumulation", Range(0.01, 1.0)) = 0.01 9 | _Atten ("Attenuation", Range(0, 1)) = 0.01 10 | } 11 | 12 | CGINCLUDE 13 | 14 | #include "UnityCG.cginc" 15 | 16 | sampler2D _MainTex; 17 | float4 _MainTex_TexelSize; 18 | sampler2D _VelocityMap; 19 | float _VelocityScale; 20 | float4x4 _BlurMat; 21 | float _Accum; 22 | float _Atten; 23 | 24 | struct appdata 25 | { 26 | float4 vertex : POSITION; 27 | float2 uv : TEXCOORD0; 28 | }; 29 | 30 | struct v2f 31 | { 32 | float2 uv : TEXCOORD0; 33 | float4 vertex : SV_POSITION; 34 | }; 35 | 36 | v2f vert (appdata v) 37 | { 38 | v2f o; 39 | o.vertex = UnityObjectToClipPos(v.vertex); 40 | o.uv = v.uv; 41 | return o; 42 | } 43 | 44 | // Accumulation 45 | fixed4 frag_accumulation (v2f i) : SV_Target 46 | { 47 | fixed4 c = tex2D(_MainTex, i.uv); 48 | return fixed4(c.rgb, c.a * _Accum); 49 | } 50 | 51 | // Blur 52 | fixed4 frag_blur (v2f i) : SV_Target 53 | { 54 | float2 d = _MainTex_TexelSize.xy; 55 | 56 | fixed4 c = fixed4(0,0,0,0); 57 | for (int y = 0; y <= 2; y++) { 58 | for (int x = 0; x <= 2; x++) { 59 | float2 uv = i.uv + float2 (x-1, y-1) * d; 60 | c += _BlurMat [y][x] * tex2D(_MainTex,uv); 61 | } 62 | } 63 | return c; 64 | } 65 | 66 | // Attenuation 67 | fixed4 frag_attenuation (v2f i) : SV_Target 68 | { 69 | return (1.0 - _Atten) * tex2D(_MainTex, i.uv.xy); 70 | } 71 | 72 | // Fluid 73 | fixed4 frag_fluid (v2f i) : SV_Target 74 | { 75 | float2 d = _MainTex_TexelSize.xy; 76 | float2 duv = tex2D(_VelocityMap, i.uv); 77 | return tex2D(_MainTex, i.uv - d * duv * _VelocityScale); 78 | } 79 | 80 | 81 | ENDCG 82 | 83 | 84 | SubShader { 85 | 86 | Cull Off ZWrite Off ZTest Always// No culling or depth 87 | 88 | // Pass 0: Accumulation 89 | Pass { 90 | Blend SrcAlpha OneMinusSrcAlpha 91 | 92 | Fog { Mode off } 93 | CGPROGRAM 94 | #pragma target 3.0 95 | //#pragma glsl 96 | #pragma vertex vert 97 | #pragma fragment frag_accumulation 98 | ENDCG 99 | } 100 | 101 | // Pass 1: Blur 102 | Pass { 103 | Fog { Mode off } 104 | CGPROGRAM 105 | #pragma target 3.0 106 | //#pragma glsl 107 | #pragma vertex vert 108 | #pragma fragment frag_blur 109 | ENDCG 110 | } 111 | 112 | // Pass 2: Attenuation 113 | Pass { 114 | Fog { Mode off } 115 | CGPROGRAM 116 | #pragma target 3.0 117 | //#pragma glsl 118 | #pragma vertex vert 119 | #pragma fragment frag_attenuation 120 | ENDCG 121 | } 122 | 123 | // Pass 3: Fluid 124 | Pass { 125 | Fog { Mode off } 126 | CGPROGRAM 127 | #pragma target 3.0 128 | //#pragma glsl 129 | #pragma vertex vert 130 | #pragma fragment frag_fluid 131 | ENDCG 132 | } 133 | 134 | } 135 | FallBack "Diffuse" 136 | } -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/FluidBlur.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ad300f7c755ec4f05b5e6366544d978a 3 | timeCreated: 1450750093 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/NewImageEffectShader.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Hidden/NewImageEffectShader" 4 | { 5 | Properties 6 | { 7 | _MainTex ("Texture", 2D) = "white" {} 8 | } 9 | SubShader 10 | { 11 | // No culling or depth 12 | Cull Off ZWrite Off ZTest Always 13 | 14 | Pass 15 | { 16 | CGPROGRAM 17 | #pragma vertex vert 18 | #pragma fragment frag 19 | 20 | #include "UnityCG.cginc" 21 | 22 | struct appdata 23 | { 24 | float4 vertex : POSITION; 25 | float2 uv : TEXCOORD0; 26 | }; 27 | 28 | struct v2f 29 | { 30 | float2 uv : TEXCOORD0; 31 | float4 vertex : SV_POSITION; 32 | }; 33 | 34 | v2f vert (appdata v) 35 | { 36 | v2f o; 37 | o.vertex = UnityObjectToClipPos(v.vertex); 38 | o.uv = v.uv; 39 | return o; 40 | } 41 | 42 | sampler2D _MainTex; 43 | 44 | fixed4 frag (v2f i) : SV_Target 45 | { 46 | fixed4 col = tex2D(_MainTex, i.uv); 47 | // just invert the colors 48 | col = 1 - col; 49 | return col; 50 | } 51 | ENDCG 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/NewImageEffectShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5811d5957a516564db37c0c19241e0a8 3 | timeCreated: 1452525176 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/PressureGradientSubtract.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/GPGPU/Fluid2D/PressureGradientSubtract" { 2 | Properties { 3 | _MainTex ("-", 2D) = "" {} 4 | } 5 | 6 | CGINCLUDE 7 | 8 | #include "UnityCG.cginc" 9 | 10 | #define PRESSURE_BOUDARY 11 | 12 | uniform float2 _Invresolution; 13 | 14 | uniform sampler2D _MainTex; 15 | float2 _MainTex_TexelSize; 16 | 17 | uniform sampler2D _Pressure; 18 | uniform sampler2D _Velocity; 19 | 20 | uniform float _HalfRDX; 21 | 22 | //sampling pressure texture factoring in boundary conditions 23 | float samplePressue(sampler2D pressure, float2 coord){ 24 | 25 | float2 cellOffset = float2(0.0, 0.0); 26 | 27 | //pure Neumann boundary conditions: 0 pressure gradient across the boundary 28 | //dP/dx = 0 29 | //walls 30 | #ifdef PRESSURE_BOUNDARY 31 | if(coord.x < 0.0) cellOffset.x = 1.0; 32 | else if(coord.x > 1.0) cellOffset.x = -1.0; 33 | if(coord.y < 0.0) cellOffset.y = 1.0; 34 | else if(coord.y > 1.0) cellOffset.y = -1.0; 35 | #endif 36 | 37 | return tex2D(pressure, coord + cellOffset * _Invresolution).x; 38 | } 39 | 40 | 41 | float4 frag (v2f_img i) : SV_Target 42 | { 43 | float L = samplePressue(_Pressure, i.uv.xy - float2(_Invresolution.x, 0)); 44 | float R = samplePressue(_Pressure, i.uv.xy + float2(_Invresolution.x, 0)); 45 | float B = samplePressue(_Pressure, i.uv.xy - float2(0, _Invresolution.y)); 46 | float T = samplePressue(_Pressure, i.uv.xy + float2(0, _Invresolution.y)); 47 | 48 | float2 v = tex2D (_Velocity, i.uv.xy).xy; 49 | 50 | float4 finalColor = float4 (v - _HalfRDX * float2 (R-L, T-B), 0.0, 1.0); 51 | 52 | return finalColor; 53 | } 54 | 55 | ENDCG 56 | 57 | 58 | SubShader { 59 | 60 | Pass { 61 | Fog { Mode off } 62 | CGPROGRAM 63 | #pragma target 3.0 64 | //#pragma glsl 65 | #pragma vertex vert_img 66 | #pragma fragment frag 67 | ENDCG 68 | } 69 | } 70 | FallBack "Diffuse" 71 | } -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/PressureGradientSubtract.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8854fa981500a4468949ee85febc1ad4 3 | timeCreated: 1450727449 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/PressureSolve.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/GPGPU/Fluid2D/PressureSolve" { 2 | Properties { 3 | _MainTex ("-", 2D) = "" {} 4 | } 5 | 6 | CGINCLUDE 7 | 8 | #include "UnityCG.cginc" 9 | 10 | #define PRESSURE_BOUNDARY 11 | 12 | uniform float2 _Invresolution; 13 | 14 | uniform sampler2D _MainTex; 15 | 16 | uniform sampler2D _Pressure; 17 | uniform sampler2D _Divergence; 18 | uniform float _Alpha; // alpha = -(dx)^2, where dx = grid cell size 19 | 20 | //sampling pressure texture factoring in boundary conditions 21 | float samplePressue(sampler2D pressure, float2 coord){ 22 | 23 | float2 cellOffset = float2(0.0, 0.0); 24 | 25 | //pure Neumann boundary conditions: 0 pressure gradient across the boundary 26 | //dP/dx = 0 27 | //walls 28 | #ifdef PRESSURE_BOUNDARY 29 | if(coord.x < 0.0) cellOffset.x = 1.0; 30 | else if(coord.x > 1.0) cellOffset.x = -1.0; 31 | if(coord.y < 0.0) cellOffset.y = 1.0; 32 | else if(coord.y > 1.0) cellOffset.y = -1.0; 33 | #endif 34 | 35 | return tex2D(pressure, coord + cellOffset * _Invresolution).x; 36 | } 37 | 38 | float4 frag (v2f_img i) : SV_Target 39 | { 40 | 41 | // left, right, bottom, and top x samples 42 | //texelSize = 1./resolution; 43 | float L = samplePressue (_Pressure, i.uv.xy - float2 (_Invresolution.x, 0)); 44 | float R = samplePressue (_Pressure, i.uv.xy + float2 (_Invresolution.x, 0)); 45 | float B = samplePressue (_Pressure, i.uv.xy - float2 (0, _Invresolution.y)); 46 | float T = samplePressue (_Pressure, i.uv.xy + float2 (0, _Invresolution.y)); 47 | 48 | float bC = tex2D (_Divergence, i.uv.xy).x; 49 | 50 | float4 finalColor = float4( (L + R + B + T + _Alpha * bC) * 0.25, 0, 0, 1 );//rBeta = .25 51 | 52 | return finalColor; 53 | } 54 | 55 | ENDCG 56 | 57 | 58 | SubShader { 59 | 60 | Pass { 61 | Fog { Mode off } 62 | CGPROGRAM 63 | #pragma target 3.0 64 | //#pragma glsl 65 | #pragma vertex vert_img 66 | #pragma fragment frag 67 | ENDCG 68 | } 69 | } 70 | FallBack "Diffuse" 71 | } -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/PressureSolve.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 42a4f2e2ea12c499e971be5629a47673 3 | timeCreated: 1450727469 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/VelocityDivergence.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/GPGPU/Fluid2D/VelocityDivergence" { 2 | Properties { 3 | _MainTex ("-", 2D) = "" {} 4 | } 5 | 6 | CGINCLUDE 7 | 8 | #include "UnityCG.cginc" 9 | 10 | #define VELOCITY_BOUNDARY 11 | 12 | uniform float2 _Invresolution; 13 | 14 | uniform sampler2D _MainTex; 15 | float2 _MainTex_TexelSize; 16 | 17 | uniform sampler2D _Velocity; //vector fields 18 | uniform float _HalfRDX; // .5*1/gridscale 19 | 20 | //sampling velocity texture factoring in boundary conditions 21 | float2 sampleVelocity(sampler2D velocity, float2 coord){ 22 | float2 cellOffset = float2 (0.0, 0.0); 23 | float2 multiplier = float2 (1.0, 1.0); 24 | 25 | //free-slip boundary: the average flow across the boundary is restricted to 0 26 | //avg(uA.xy, uB.xy) dot (boundary normal).xy = 0 27 | //walls 28 | #ifdef VELOCITY_BOUNDARY 29 | if(coord.x < 0.0){ 30 | cellOffset.x = 1.0; 31 | multiplier.x = -1.0; 32 | }else if(coord.x > 1.0){ 33 | cellOffset.x = -1.0; 34 | multiplier.x = -1.0; 35 | } 36 | if(coord.y < 0.0){ 37 | cellOffset.y = 1.0; 38 | multiplier.y = -1.0; 39 | }else if(coord.y > 1.0){ 40 | cellOffset.y = -1.0; 41 | multiplier.y = -1.0; 42 | } 43 | #endif 44 | 45 | return multiplier * tex2D (velocity, coord + cellOffset * _Invresolution).xy; 46 | } 47 | 48 | float4 frag (v2f_img i) : SV_Target 49 | { 50 | //compute the divergence according to the finite difference formula 51 | //texelSize = 1/resolution 52 | float2 L = sampleVelocity (_Velocity, i.uv.xy - float2 (_Invresolution.x, 0)); 53 | float2 R = sampleVelocity (_Velocity, i.uv.xy + float2 (_Invresolution.x, 0)); 54 | float2 B = sampleVelocity (_Velocity, i.uv.xy - float2 (0, _Invresolution.y)); 55 | float2 T = sampleVelocity (_Velocity, i.uv.xy + float2 (0, _Invresolution.y)); 56 | 57 | float4 result = float4 (_HalfRDX * ((R.x - L.x) + (T.y - B.y)), 0, 0, 1); 58 | return result; 59 | } 60 | 61 | ENDCG 62 | 63 | 64 | SubShader { 65 | 66 | Pass { 67 | Fog { Mode off } 68 | CGPROGRAM 69 | #pragma target 3.0 70 | //#pragma glsl 71 | #pragma vertex vert_img 72 | #pragma fragment frag 73 | ENDCG 74 | } 75 | } 76 | FallBack "Diffuse" 77 | } -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/ImageEffects/Fluid2DBlur/Shaders/VelocityDivergence.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 128968673999a4264a3a39714288de63 3 | timeCreated: 1450727487 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0407c365e06eb44048739b5c563396d7 3 | folderAsset: yes 4 | timeCreated: 1451479959 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Fluid2DBlur.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/Assets/Sample/Fluid2DBlur.unity -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Fluid2DBlur.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1915d886b8da64d5ca68c90714803462 3 | timeCreated: 1450932228 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/Assets/Sample/Mat 1.mat -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73bbe83bc58264c0093ad3bb68a68566 3 | timeCreated: 1451626058 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/Assets/Sample/Mat 2.mat -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 2.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: edd21d5a5e96a452b904b5750a408fee 3 | timeCreated: 1451626060 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 3.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/Assets/Sample/Mat 3.mat -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 3.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19e8eec28dfde4e3f9ee667ce2efebfe 3 | timeCreated: 1451626065 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 4.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/Assets/Sample/Mat 4.mat -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 4.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eeb16a4001d4a4a66b97b7b73cfe2d89 3 | timeCreated: 1451629236 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 5.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/Assets/Sample/Mat 5.mat -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 5.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb84d231a38324f0e82c7c68ba158256 3 | timeCreated: 1451629237 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 6.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/Assets/Sample/Mat 6.mat -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat 6.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45b89afd0d85c4b108937757e7beb6c6 3 | timeCreated: 1451629282 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/Assets/Sample/Mat.mat -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 785aa9b0facb94b0e9b12f9cacb5bd2b 3 | timeCreated: 1451480145 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mover.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Mover : MonoBehaviour { 5 | 6 | Vector3 _position = Vector3.right; 7 | float _speed = 1.0f; 8 | 9 | void Start () { 10 | 11 | _position = Random.insideUnitSphere * Random.Range (4.0f, 4.0f); 12 | transform.localPosition = _position; 13 | transform.localEulerAngles = Random.insideUnitSphere * 360.0f; 14 | 15 | _speed = Random.Range (50.0f, 100.0f); 16 | } 17 | 18 | void Update () { 19 | 20 | transform.RotateAround (Vector3.zero, Vector3.Cross (Vector3.right, _position), Time.deltaTime * _speed); 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/Assets/Sample/Mover.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60491e0a86711466797efde0ce2c28f6 3 | timeCreated: 1451480969 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2017.1.0f3 2 | -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /Fluid2DBlurImageEffect/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/Fluid2DBlurImageEffect/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnityFluid2DBlurImageEffect 2 | Fluid2D Blur Post Processing Effect for Unity 3 | 4 | ![screenShot](https://github.com/hiroakioishi/UnityFluid2DBlurImageEffect/blob/master/screenShot.png) 5 | 6 | Demo 7 | https://vimeo.com/150463085 8 | 9 | Fluid2D algorithm in this Project is ported from GPU-Fluid-Experiments. 10 | https://github.com/haxiomic/GPU-Fluid-Experiments 11 | 12 | Blur Post Processing Effect in this Project: 13 | https://github.com/nobnak/SmokeBlur 14 | 15 | # Usage 16 | Add Fluid2DBlur.cs to your camera. And also please set camera ClearFlags to Solid Color. 17 | 18 | # License 19 | This Unity Project is licensed by GPL 3.0 license. 20 | 21 | -------------------------------------------------------------------------------- /screenShot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiroakioishi/UnityFluid2DBlurImageEffect/7e126c1a8a24a19c5c9a88c2ef6eef29727d1b1f/screenShot.png --------------------------------------------------------------------------------