Skip to content

Commit

Permalink
Updated copyright notice
Browse files Browse the repository at this point in the history
  • Loading branch information
rougier committed Dec 27, 2015
1 parent 6122ab9 commit 764f9a9
Show file tree
Hide file tree
Showing 146 changed files with 633 additions and 715 deletions.
6 changes: 3 additions & 3 deletions examples/regular-grid.frag
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ----------------------------------------------------------------------------
// Copyright (c) 2014, Nicolas P. Rougier. All Rights Reserved.
// -----------------------------------------------------------------------------
// Copyright (c) 2009-2016 Nicolas P. Rougier. All rights reserved.
// Distributed under the (new) BSD License.
// ----------------------------------------------------------------------------
// -----------------------------------------------------------------------------

// Constants
// ------------------------------------
Expand Down
56 changes: 28 additions & 28 deletions examples/smoke/advect.frag
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);
}
68 changes: 34 additions & 34 deletions examples/smoke/buoyancy.frag
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);
}
}
6 changes: 3 additions & 3 deletions examples/smoke/divergence.frag
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ----------------------------------------------------------------------------
// Copyright (c) 2014, Nicolas P. Rougier. All Rights Reserved.
// -----------------------------------------------------------------------------
// 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
// -----------------------------------------------------------------------------
Expand Down
26 changes: 13 additions & 13 deletions examples/smoke/fill.frag
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;
}
6 changes: 3 additions & 3 deletions examples/smoke/gradient.frag
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ----------------------------------------------------------------------------
// Copyright (c) 2014, Nicolas P. Rougier. All Rights Reserved.
// -----------------------------------------------------------------------------
// 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
// -----------------------------------------------------------------------------
Expand Down
100 changes: 50 additions & 50 deletions examples/smoke/jacobi.frag
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;
}
24 changes: 12 additions & 12 deletions examples/smoke/smoke.vert
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);
}
44 changes: 22 additions & 22 deletions examples/smoke/splat.frag
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);
}
}

0 comments on commit 764f9a9

Please sign in to comment.