animated fractals
This commit is contained in:
parent
6a85beb4f6
commit
2e8a235d49
|
@ -8,12 +8,14 @@ import {initVertexAttribs} from './vertexattrib';
|
||||||
* @param {any} buffers the buffers to draw
|
* @param {any} buffers the buffers to draw
|
||||||
* @param {number} params various parameterss
|
* @param {number} params various parameterss
|
||||||
* @param {any} texture the texture to load
|
* @param {any} texture the texture to load
|
||||||
|
* @param {number} now the current time
|
||||||
*/
|
*/
|
||||||
export function drawScene(gl: any,
|
export function drawScene(gl: any,
|
||||||
programInfo: any,
|
programInfo: any,
|
||||||
buffers: any,
|
buffers: any,
|
||||||
params: any,
|
params: any,
|
||||||
texture: any) {
|
texture: any,
|
||||||
|
now: number) {
|
||||||
gl.clearColor(0.0, 0.0, 0.0, 1.0);
|
gl.clearColor(0.0, 0.0, 0.0, 1.0);
|
||||||
gl.clearDepth(1.0);
|
gl.clearDepth(1.0);
|
||||||
gl.enable(gl.DEPTH_TEST);
|
gl.enable(gl.DEPTH_TEST);
|
||||||
|
@ -26,6 +28,7 @@ export function drawScene(gl: any,
|
||||||
gl.activeTexture(gl.TEXTURE0);
|
gl.activeTexture(gl.TEXTURE0);
|
||||||
gl.bindTexture(gl.TEXTURE_2D, texture);
|
gl.bindTexture(gl.TEXTURE_2D, texture);
|
||||||
gl.uniform1i(programInfo.uniformLocations.uSampler, 0);
|
gl.uniform1i(programInfo.uniformLocations.uSampler, 0);
|
||||||
|
gl.uniform1f(programInfo.uniformLocations.time, now);
|
||||||
|
|
||||||
const [
|
const [
|
||||||
projectionMatrix,
|
projectionMatrix,
|
||||||
|
|
|
@ -71,6 +71,8 @@ export function setProgramInfo(context: any) {
|
||||||
context.shaderProgram, 'unormalModelMatrix'),
|
context.shaderProgram, 'unormalModelMatrix'),
|
||||||
uSampler: context.gl.getUniformLocation(
|
uSampler: context.gl.getUniformLocation(
|
||||||
context.shaderProgram, 'uSampler'),
|
context.shaderProgram, 'uSampler'),
|
||||||
|
time: context.gl.getUniformLocation(
|
||||||
|
context.shaderProgram, 'time'),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,8 @@ async function main() {
|
||||||
context.programInfo,
|
context.programInfo,
|
||||||
context.buffers,
|
context.buffers,
|
||||||
context.params,
|
context.params,
|
||||||
context.texture);
|
context.texture,
|
||||||
|
now);
|
||||||
requestAnimationFrame(render);
|
requestAnimationFrame(render);
|
||||||
}
|
}
|
||||||
uiUpdateParams(context.params);
|
uiUpdateParams(context.params);
|
||||||
|
|
|
@ -4,6 +4,7 @@ varying highp vec2 vTextureCoord;
|
||||||
varying highp vec4 vNormal;
|
varying highp vec4 vNormal;
|
||||||
varying highp vec3 vPosition;
|
varying highp vec3 vPosition;
|
||||||
uniform sampler2D uSampler;
|
uniform sampler2D uSampler;
|
||||||
|
uniform float time;
|
||||||
|
|
||||||
vec2 cinv(in vec2 z)
|
vec2 cinv(in vec2 z)
|
||||||
{
|
{
|
||||||
|
@ -37,20 +38,21 @@ vec3 extremize(vec3 v, float n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 a0 = vec2(sin(16.) * 1.0 + 5., 0.);
|
float slowTime = time / 20.;
|
||||||
vec2 a1 = vec2(sin(17.) * 2.0, 0.);
|
vec2 a0 = vec2(sin(16. * slowTime) * 1.0 + 5., 0.);
|
||||||
vec2 a2 = vec2(sin(18.) * 3.0, 0.);
|
vec2 a1 = vec2(sin(17. * slowTime) * 2.0, 0.);
|
||||||
vec2 a3 = vec2(sin(19.) * 4.0, 0.);
|
vec2 a2 = vec2(sin(18. * slowTime) * 3.0, 0.);
|
||||||
vec2 a4 = vec2(sin(1.1) * 5.0, 0.);
|
vec2 a3 = vec2(sin(19. * slowTime) * 4.0, 0.);
|
||||||
vec2 a5 = vec2(sin(1.2) * 6.0, 0.);
|
vec2 a4 = vec2(sin(1.1 * slowTime) * 5.0, 0.);
|
||||||
vec2 a6 = vec2(sin(1.3) * 7.0, 0.);
|
vec2 a5 = vec2(sin(1.2 * slowTime) * 6.0, 0.);
|
||||||
vec2 a7 = vec2(sin(1.4) * 8.0, 0.);
|
vec2 a6 = vec2(sin(1.3 * slowTime) * 7.0, 0.);
|
||||||
vec2 a8 = vec2(sin(15.) * 9.0, 0.);
|
vec2 a7 = vec2(sin(1.4 * slowTime) * 8.0, 0.);
|
||||||
vec2 a9 = vec2(sin(16.) * 10.0, 0.);
|
vec2 a8 = vec2(sin(15. * slowTime) * 9.0, 0.);
|
||||||
vec2 a10 = vec2(sin(17.) * 11.0, 1.);
|
vec2 a9 = vec2(sin(16. * slowTime) * 10.0, sin(slowTime));
|
||||||
|
vec2 a10 = vec2(sin(17. * slowTime) * 11.0, 1. + sin(slowTime) * 0.2);
|
||||||
|
|
||||||
vec2 a = vec2(1.0, 1. + sin(0.16) * 0.002);
|
vec2 a = vec2(1.0, 1. + sin(0.16 * slowTime) * 0.002);
|
||||||
vec2 c = vec2(0.01, 0.1);
|
vec2 c = vec2(0.01, sin(slowTime) / 10.);
|
||||||
// Normalized pixel coordinates (from 0 to 1)
|
// Normalized pixel coordinates (from 0 to 1)
|
||||||
vec2 z = cmul((vTextureCoord/vec2(1., 1.) - 0.5), vec2(4., 0.));
|
vec2 z = cmul((vTextureCoord/vec2(1., 1.) - 0.5), vec2(4., 0.));
|
||||||
vec2 init_z = z;
|
vec2 init_z = z;
|
||||||
|
|
Loading…
Reference in New Issue