Skip to content

Instantly share code, notes, and snippets.

View marioecg's full-sized avatar

Mario Carrillo marioecg

View GitHub Profile
@marioecg
marioecg / index.js
Created January 14, 2022 17:44
ogl scene setup
import { Renderer, Camera, Transform, Orbit } from 'ogl'
import { Events } from '../events'
import { qs, bindAll } from '../util'
import store from '../store'
export default new (class {
constructor() {
I am attesting that this GitHub handle marioecg is linked to the Tezos account tz1PePWi2eLdbr57Hqjr4soyNvNJFN9s5MHk for tzprofiles
sig:edsigtoyYVrbBx4pw7okYzosNm8ANJoDhZJaYh758Nj56AVkU9wxndifPZTrcxYqWZ4RD6Q8PSVMJFZmdt7LqeoFrb29ysdFSE9
#define PI 3.1415926538
uniform float time;
varying vec2 vUv;
float map(float value, float inMin, float inMax, float outMin, float outMax) {
return outMin + (outMax - outMin) * (value - inMin) / (inMax - inMin);
}
// https://iquilezles.org/www/articles/distgradfunctions2d/distgradfunctions2d.htm
@marioecg
marioecg / scene.js
Created March 1, 2021 00:19
Threejs renderer setup
import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
import { Events } from '../events';
import store from '../store';
export default new class {
constructor() {
this.renderer = new THREE.WebGLRenderer({
antialias: true,
@marioecg
marioecg / Renderer.js
Created February 27, 2021 00:48
OGL class renderer setup
import { Renderer, Camera, Transform, Orbit } from 'ogl';
import store from '../store';
import { Events } from '../events';
import * as dat from 'dat.gui';
export default new class {
constructor() {
this.renderer = new Renderer({
mat2 rotation2d(float angle) {
float s = sin(angle);
float c = cos(angle);
return mat2(
c, -s,
s, c
);
}
@marioecg
marioecg / collection.glsl
Last active December 14, 2021 01:48
Collection of GLSL code throughout my learning journey
#define PI 3.1415926538
#define TWO_PI 6.28318530718
vec2 scaleFromCenter = (uv - 0.5) + 0.5;
mat2 scale(vec2 scale){
return mat2(scale.x, 0.0,
0.0, scale.y);
}
@marioecg
marioecg / backgroundCoverUv.glsl
Last active January 20, 2021 02:26
Make texture image in a plane behave like background cover in CSS
vec2 backgroundCoverUv(vec2 screenSize, vec2 imageSize, vec2 uv) {
float screenRatio = screenSize.x / screenSize.y;
float imageRatio = imageSize.x / imageSize.y;
vec2 newSize = screenRatio < imageRatio
? vec2(imageSize.x * screenSize.y / imageSize.y, screenSize.y)
: vec2(screenSize.x, imageSize.y * screenSize.x / imageSize.x);
vec2 newOffset = (screenRatio < imageRatio
? vec2((newSize.x - screenSize.x) / 2.0, 0.0)
const int AMOUNT = 25;
void main () {
float TIME = uTime * 1.0;
vec2 uv = scale * (gl_FragCoord.xy - .5 * uResolution.xy) / uResolution.y;
// uv *= rotate(uv, angle1);
uv.x *= 0.85;
uv.y += 10.;
vec3 palette(in float t, in vec3 a, in vec3 b, in vec3 c, in vec3 d) {
return a + b * cos(6.28318 * (c * t + d));
}