[] GLSL |
100
. , . , Next . Display Mode, , , .//W =
//H =
//f = /
// newGrid, ,
for(var r=1; rcode>
f
1. 4, .[1,1]
) . , f
0.1
:0.1 * (100+100+100+100-4*100) = 0.1 * (400-400) = 0
0
):0.1 * (100+100+0+0-4*0) = 0.1 * (200) = 20
0.1 * (70+70+70+70-4*100) = 0.1 * (280 - 400) = -12
uniform vec2 res;
void main() {
vec2 pixel = gl_FragCoord.xy / res.xy;
gl_FragColor = vec4(0.0,0.0,0.0,1.0);
}
res
pixel
. res
uniform-. ( , .), .
.
uniform vec2 res;
uniform sampler2D texture;
void main() {
vec2 pixel = gl_FragCoord.xy / res.xy;
gl_FragColor = texture2D( tex, pixel );//
gl_FragColor.r += 0.01;//
}
0.01
. , , . , , .uniform vec2 res; //
uniform sampler2D bufferTexture; //
void main() {
vec2 pixel = gl_FragCoord.xy / res.xy;
gl_FragColor = texture2D( bufferTexture, pixel );
}
gl_FragColor.r += 0.01;
gl_FragColor.r += pixel.x;
, ? , , .//
float dist = distance(gl_FragCoord.xy, res.xy/2.0);
if(dist < 15.0){ // 15
gl_FragColor.rgb = vec3(1.0);
}
//
float dist = distance(gl_FragCoord.xy, res.xy/2.0);
if(dist < 15.0){ // 15
gl_FragColor.rgb += 0.01;
}
//
uniform vec2 res;
//
uniform sampler2D bufferTexture;
// x,y - . z - /
uniform vec3 smokeSource;
void main() {
vec2 pixel = gl_FragCoord.xy / res.xy;
gl_FragColor = texture2D( bufferTexture, pixel );
//
float dist = distance(smokeSource.xy,gl_FragCoord.xy);
// ,
if(smokeSource.z > 0.0 && dist < 15.0){
gl_FragColor.rgb += smokeSource.z;
}
}
//
float xPixel = 1.0/res.x; //
float yPixel = 1.0/res.y;
vec4 rightColor = texture2D(bufferTexture,vec2(pixel.x+xPixel,pixel.y));
vec4 leftColor = texture2D(bufferTexture,vec2(pixel.x-xPixel,pixel.y));
vec4 upColor = texture2D(bufferTexture,vec2(pixel.x,pixel.y+yPixel));
vec4 downColor = texture2D(bufferTexture,vec2(pixel.x,pixel.y-yPixel));
//
gl_FragColor.rgb +=
14.0 * 0.016 *
(
leftColor.rgb +
rightColor.rgb +
downColor.rgb +
upColor.rgb -
4.0 * gl_FragColor.rgb
);
f
. (0.016
, 1/60, 60 fps), , 14
, . :float factor = 14.0 * 0.016 * (leftColor.r + rightColor.r + downColor.r + upColor.r - 4.0 * gl_FragColor.r);
//
float minimum = 0.003;
if (factor >= -minimum && factor < 0.0) factor = -minimum;
gl_FragColor.rgb += factor;
r
rgb
, , ( ).0.003
, . , . , ://
float factor = 8.0 * 0.016 *
(
leftColor.r +
rightColor.r +
downColor.r * 3.0 +
upColor.r -
6.0 * gl_FragColor.r
);
6.0
5.0
, ). , - , , .diffuse_advanced()
.0
://
//
if(pixel.y <= yPixel){
downColor.rgb = vec3(0.0);
}
0
. ( , )