Skip to content

Instantly share code, notes, and snippets.

View akella's full-sized avatar
🏠
Working from home

Yuri Artiukh akella

🏠
Working from home
View GitHub Profile
@akella
akella / simplex-tsl.js
Created December 5, 2024 20:16
simplex TSL noise
// from https://mameson.com/experiment/glsl/proven_2/proven_2.html
function mm_hash12( iw){ //★ x, y とも 0〜2,000,000 の整数入力。
const w = iw.mul( 0.000303) //★ 入力の 6 ケタとも活かす。
.add( fract( iw.mul( 0.707))); //★ 入力の上位ケタは捨てて下位ケタ拾い上げ。
const a = w.x.add( w.y.mul( 0.3)); //★ 斜めにする。
//★ 最近気に入っているフェイク sin。
a.assign( fract( a));
a.assign( a.sub( a.mul( a)));
@akella
akella / rotation.js
Created November 28, 2024 21:01
tsl rotation
const rotate2D = Fn(({pos,angle})=>{
const s = sin(angle);
const c = cos(angle);
const m = mat2(c, s, s.mul(-1), c);
return m.mul(pos);
})
const rotate3D = Fn(({pos,axis,angle})=>{
const axisNorm = normalize(axis);
const s = sin(angle);
@akella
akella / WebGPU.js
Created November 18, 2024 22:29
WebGL vs WebGPU self shadows
import * as THREE from "three/webgpu";
import {
Fn,
positionLocal,
sin,
positionWorld
} from "three/tsl";
import { OrbitControls } from "three/examples/jsm/Addons.js";
@akella
akella / curl.glsl
Created November 5, 2023 09:03
curl.glsl
#define PI 3.1415926538
const float EPS = 0.001;
vec4 mod289(vec4 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
float mod289(float x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 permute(vec4 x) {
@akella
akella / oklab.glsl
Created October 8, 2023 07:55
oklab.glsl
float fixedpow(float a, float x)
{
return pow(abs(a), x) * sign(a);
}
float cbrt(float a)
{
return fixedpow(a, 0.3333333333);
}
@akella
akella / noise.glsl
Created June 19, 2022 07:43
noise.glsl
//
// GLSL textureless classic 3D noise "cnoise",
// with an RSL-style periodic variant "pnoise".
// Author: Stefan Gustavson ([email protected])
// Version: 2011-10-11
//
// Many thanks to Ian McEwan of Ashima Arts for the
// ideas for permutation and gradient selection.
//
// Copyright (c) 2011 Stefan Gustavson. All rights reserved.
move(orientation, position) {
this.isAnimated = true;
let temp = new THREE.Vector3();
let start = new THREE.Spherical().setFromVector3(this.camera.position);
let finish = new THREE.Spherical().setFromVector3(position);
if(Math.abs(start.theta-finish.theta)>Math.PI){
if( Math.abs(start.theta-finish.theta - 2*Math.PI) <Math.abs(start.theta-finish.theta + 2*Math.PI)){
finish.theta +=2*Math.PI
} else{
finish.theta -=2*Math.PI
import gsap from "gsap";
move(orientation, position) {
this.isAnimated = true;
let temp = new THREE.Vector3();
let start = new THREE.Spherical().setFromVector3(this.camera.position);
let finish = new THREE.Spherical().setFromVector3(position);
gsap.to(this.controls.target, {
duration: 2,
@akella
akella / asd
Created January 11, 2022 14:44
ad
I am attesting that this GitHub handle akella is linked to the Tezos account tz1TyhGTFiCSAS4XXGr21YfDgp37hYVY4x26 for tzprofiles
sig:edsigu3GfoE8g8sKtpjD2mjQkr1uKWUan5rgB94nUL6dHksWbsDUjabDWRbTR33DEGRq2BpBvCetJQHxmLFoz41JLuFZiLxp2qV
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
canvas{
border: 1px solid #000;