-
-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
146 changed files
with
633 additions
and
715 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
// ---------------------------------------------------------------------------- | ||
// Copyright (c) 2014, Nicolas P. Rougier. All Rights Reserved. | ||
// Distributed under the (new) BSD License. | ||
// ---------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
uniform sampler2D VelocityTexture; | ||
uniform sampler2D SourceTexture; | ||
uniform sampler2D Obstacles; | ||
|
||
uniform vec2 InverseSize; | ||
uniform float TimeStep; | ||
uniform float Dissipation; | ||
|
||
void main() | ||
{ | ||
vec2 fragCoord = InverseSize*gl_FragCoord.xy; | ||
float solid = texture2D(Obstacles, fragCoord).x; | ||
if (solid > 0.0) { | ||
gl_FragColor = vec4(0); | ||
return; | ||
} | ||
|
||
vec2 u = texture2D(VelocityTexture, fragCoord).xy; | ||
vec2 coord = fragCoord - InverseSize * TimeStep * u; | ||
gl_FragColor = Dissipation * texture2D(SourceTexture, coord); | ||
} | ||
// ----------------------------------------------------------------------------- | ||
// Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved. | ||
// Distributed under the (new) BSD License. | ||
// ----------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
uniform sampler2D VelocityTexture; | ||
uniform sampler2D SourceTexture; | ||
uniform sampler2D Obstacles; | ||
|
||
uniform vec2 InverseSize; | ||
uniform float TimeStep; | ||
uniform float Dissipation; | ||
|
||
void main() | ||
{ | ||
vec2 fragCoord = InverseSize*gl_FragCoord.xy; | ||
float solid = texture2D(Obstacles, fragCoord).x; | ||
if (solid > 0.0) { | ||
gl_FragColor = vec4(0); | ||
return; | ||
} | ||
|
||
vec2 u = texture2D(VelocityTexture, fragCoord).xy; | ||
vec2 coord = fragCoord - InverseSize * TimeStep * u; | ||
gl_FragColor = Dissipation * texture2D(SourceTexture, coord); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
// ---------------------------------------------------------------------------- | ||
// Copyright (c) 2014, Nicolas P. Rougier. All Rights Reserved. | ||
// Distributed under the (new) BSD License. | ||
// ---------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
uniform sampler2D Velocity; | ||
uniform sampler2D Temperature; | ||
uniform sampler2D Density; | ||
uniform float AmbientTemperature; | ||
uniform float TimeStep; | ||
uniform float Sigma; | ||
uniform float Kappa; | ||
uniform vec2 InverseSize; | ||
|
||
vec4 texelFetch(sampler2D sampler, ivec2 P, int lod) | ||
{ | ||
return texture2D(sampler, vec2(P)*InverseSize); | ||
} | ||
|
||
void main() | ||
{ | ||
ivec2 TC = ivec2(gl_FragCoord.xy); | ||
float T = texelFetch(Temperature, TC, 0).r; | ||
vec2 V = texelFetch(Velocity, TC, 0).xy; | ||
|
||
gl_FragColor.rg = V; | ||
|
||
if (T > AmbientTemperature) { | ||
float D = texelFetch(Density, TC, 0).x; | ||
gl_FragColor.rg += (TimeStep * (T - AmbientTemperature) * Sigma - D * Kappa ) * vec2(0, 1); | ||
} | ||
} | ||
// ----------------------------------------------------------------------------- | ||
// Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved. | ||
// Distributed under the (new) BSD License. | ||
// ----------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
uniform sampler2D Velocity; | ||
uniform sampler2D Temperature; | ||
uniform sampler2D Density; | ||
uniform float AmbientTemperature; | ||
uniform float TimeStep; | ||
uniform float Sigma; | ||
uniform float Kappa; | ||
uniform vec2 InverseSize; | ||
|
||
vec4 texelFetch(sampler2D sampler, ivec2 P, int lod) | ||
{ | ||
return texture2D(sampler, vec2(P)*InverseSize); | ||
} | ||
|
||
void main() | ||
{ | ||
ivec2 TC = ivec2(gl_FragCoord.xy); | ||
float T = texelFetch(Temperature, TC, 0).r; | ||
vec2 V = texelFetch(Velocity, TC, 0).xy; | ||
|
||
gl_FragColor.rg = V; | ||
|
||
if (T > AmbientTemperature) { | ||
float D = texelFetch(Density, TC, 0).x; | ||
gl_FragColor.rg += (TimeStep * (T - AmbientTemperature) * Sigma - D * Kappa ) * vec2(0, 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
// ---------------------------------------------------------------------------- | ||
// Copyright (c) 2014, Nicolas P. Rougier. All Rights Reserved. | ||
// Distributed under the (new) BSD License. | ||
// ---------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
uniform vec2 InverseSize; | ||
uniform sampler2D Sampler; | ||
void main() | ||
{ | ||
gl_FragColor.rgb = texture2D(Sampler, gl_FragCoord.xy*InverseSize).rgb; | ||
} | ||
// ----------------------------------------------------------------------------- | ||
// Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved. | ||
// Distributed under the (new) BSD License. | ||
// ----------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
uniform vec2 InverseSize; | ||
uniform sampler2D Sampler; | ||
void main() | ||
{ | ||
gl_FragColor.rgb = texture2D(Sampler, gl_FragCoord.xy*InverseSize).rgb; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
// ---------------------------------------------------------------------------- | ||
// Copyright (c) 2014, Nicolas P. Rougier. All Rights Reserved. | ||
// Distributed under the (new) BSD License. | ||
// ---------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
uniform sampler2D Pressure; | ||
uniform sampler2D Divergence; | ||
uniform sampler2D Obstacles; | ||
uniform vec2 InverseSize; | ||
uniform float Alpha; | ||
uniform float InverseBeta; | ||
|
||
vec4 texelFetchOffset(sampler2D sampler, ivec2 P, int lod, ivec2 offset) | ||
{ | ||
return texture2D(sampler, vec2(P+offset)*InverseSize); | ||
} | ||
vec4 texelFetch(sampler2D sampler, ivec2 P, int lod) | ||
{ | ||
return texture2D(sampler, vec2(P)*InverseSize); | ||
} | ||
|
||
|
||
void main() | ||
{ | ||
ivec2 T = ivec2(gl_FragCoord.xy); | ||
|
||
// Find neighboring pressure: | ||
vec4 pN = texelFetchOffset(Pressure, T, 0, ivec2(0, 1)); | ||
vec4 pS = texelFetchOffset(Pressure, T, 0, ivec2(0, -1)); | ||
vec4 pE = texelFetchOffset(Pressure, T, 0, ivec2(1, 0)); | ||
vec4 pW = texelFetchOffset(Pressure, T, 0, ivec2(-1, 0)); | ||
vec4 pC = texelFetch(Pressure, T, 0); | ||
|
||
// Find neighboring obstacles: | ||
vec3 oN = texelFetchOffset(Obstacles, T, 0, ivec2(0, 1)).xyz; | ||
vec3 oS = texelFetchOffset(Obstacles, T, 0, ivec2(0, -1)).xyz; | ||
vec3 oE = texelFetchOffset(Obstacles, T, 0, ivec2(1, 0)).xyz; | ||
vec3 oW = texelFetchOffset(Obstacles, T, 0, ivec2(-1, 0)).xyz; | ||
|
||
// Use center pressure for solid cells: | ||
if (oN.x > 0.0) pN = pC; | ||
if (oS.x > 0.0) pS = pC; | ||
if (oE.x > 0.0) pE = pC; | ||
if (oW.x > 0.0) pW = pC; | ||
|
||
vec4 bC = texelFetch(Divergence, T, 0); | ||
gl_FragColor = (pW + pE + pS + pN + Alpha * bC) * InverseBeta; | ||
} | ||
// ----------------------------------------------------------------------------- | ||
// Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved. | ||
// Distributed under the (new) BSD License. | ||
// ----------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
uniform sampler2D Pressure; | ||
uniform sampler2D Divergence; | ||
uniform sampler2D Obstacles; | ||
uniform vec2 InverseSize; | ||
uniform float Alpha; | ||
uniform float InverseBeta; | ||
|
||
vec4 texelFetchOffset(sampler2D sampler, ivec2 P, int lod, ivec2 offset) | ||
{ | ||
return texture2D(sampler, vec2(P+offset)*InverseSize); | ||
} | ||
vec4 texelFetch(sampler2D sampler, ivec2 P, int lod) | ||
{ | ||
return texture2D(sampler, vec2(P)*InverseSize); | ||
} | ||
|
||
|
||
void main() | ||
{ | ||
ivec2 T = ivec2(gl_FragCoord.xy); | ||
|
||
// Find neighboring pressure: | ||
vec4 pN = texelFetchOffset(Pressure, T, 0, ivec2(0, 1)); | ||
vec4 pS = texelFetchOffset(Pressure, T, 0, ivec2(0, -1)); | ||
vec4 pE = texelFetchOffset(Pressure, T, 0, ivec2(1, 0)); | ||
vec4 pW = texelFetchOffset(Pressure, T, 0, ivec2(-1, 0)); | ||
vec4 pC = texelFetch(Pressure, T, 0); | ||
|
||
// Find neighboring obstacles: | ||
vec3 oN = texelFetchOffset(Obstacles, T, 0, ivec2(0, 1)).xyz; | ||
vec3 oS = texelFetchOffset(Obstacles, T, 0, ivec2(0, -1)).xyz; | ||
vec3 oE = texelFetchOffset(Obstacles, T, 0, ivec2(1, 0)).xyz; | ||
vec3 oW = texelFetchOffset(Obstacles, T, 0, ivec2(-1, 0)).xyz; | ||
|
||
// Use center pressure for solid cells: | ||
if (oN.x > 0.0) pN = pC; | ||
if (oS.x > 0.0) pS = pC; | ||
if (oE.x > 0.0) pE = pC; | ||
if (oW.x > 0.0) pW = pC; | ||
|
||
vec4 bC = texelFetch(Divergence, T, 0); | ||
gl_FragColor = (pW + pE + pS + pN + Alpha * bC) * InverseBeta; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
// ---------------------------------------------------------------------------- | ||
// Copyright (c) 2014, Nicolas P. Rougier. All Rights Reserved. | ||
// Distributed under the (new) BSD License. | ||
// ---------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
attribute vec2 Position; | ||
void main() | ||
{ | ||
gl_Position = vec4(Position,0.0,1.0); | ||
} | ||
// ----------------------------------------------------------------------------- | ||
// Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved. | ||
// Distributed under the (new) BSD License. | ||
// ----------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
attribute vec2 Position; | ||
void main() | ||
{ | ||
gl_Position = vec4(Position,0.0,1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
// ---------------------------------------------------------------------------- | ||
// Copyright (c) 2014, Nicolas P. Rougier. All Rights Reserved. | ||
// Distributed under the (new) BSD License. | ||
// ---------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
uniform vec2 Point; | ||
uniform float Radius; | ||
uniform vec3 FillColor; | ||
|
||
void main() | ||
{ | ||
float d = distance(Point, gl_FragCoord.xy); | ||
if (d < Radius) { | ||
float a = (Radius - d) * 0.5; | ||
a = min(a, 1.0); | ||
gl_FragColor = vec4(FillColor, a); | ||
} else { | ||
gl_FragColor = vec4(0); | ||
} | ||
} | ||
// ----------------------------------------------------------------------------- | ||
// Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved. | ||
// Distributed under the (new) BSD License. | ||
// ----------------------------------------------------------------------------- | ||
// From Fluid demo by Philip Rideout | ||
// Originals sources and explanation on http://prideout.net/blog/?p=58 | ||
// ----------------------------------------------------------------------------- | ||
uniform vec2 Point; | ||
uniform float Radius; | ||
uniform vec3 FillColor; | ||
|
||
void main() | ||
{ | ||
float d = distance(Point, gl_FragCoord.xy); | ||
if (d < Radius) { | ||
float a = (Radius - d) * 0.5; | ||
a = min(a, 1.0); | ||
gl_FragColor = vec4(FillColor, a); | ||
} else { | ||
gl_FragColor = vec4(0); | ||
} | ||
} |
Oops, something went wrong.