Skip to content

Instantly share code, notes, and snippets.

View cecilemuller's full-sized avatar

Cecile Muller cecilemuller

View GitHub Profile
@cecilemuller
cecilemuller / index.html
Created June 17, 2024 16:25
ESM Import Map for NPM-installed packages
<script type="importmap">
{
"imports": {
"lil-gui": "./node_modules/lil-gui/dist/lil-gui.esm.js",
"three": "./node_modules/three/src/Three.js",
"three/addons/": "./node_modules/three/examples/jsm/",
"three/nodes": "./node_modules/three/examples/jsm/nodes/Nodes.js"
}
}
</script>
@cecilemuller
cecilemuller / fresnel.frag
Created June 10, 2024 10:07
Albedo Alpha from Rim for Marmoset Toolbag 4
#include "data/shader/mat/state.frag"
uniform float uOpacity; //name "Opacity" default 1.0 min 0.0 max 2.0
uniform float uExponent; //name "Exponent" default 1.0 min 0.0 max 4.0
void RimOpacity( inout FragmentState s )
{
#ifdef Emissive
Emissive(s);
#endif
@cecilemuller
cecilemuller / imageComplete.mjs
Created June 5, 2024 01:34
Async image complete
function imageComplete(img) {
return new Promise((resolve) => {
if (img.complete) {
resolve();
} else {
img.onerror = img.onload = () => { resolve() };
}
});
}
@cecilemuller
cecilemuller / triplanar.frag
Last active June 3, 2024 23:44
Triplanar Mapping shader for Marmoset Toolbag 4
#include "data/shader/mat/state.frag"
uniform float uScale; //name "Scale" default 1.0 min 0.0 max 5.0
USE_TEXTURE2D(tTexture0);
void TriplanarEmissive( inout FragmentState s )
{
vec3 uvw = fract(s.vertexPosition / 100.0 * uScale);
vec3 blend = abs(s.normal);
@cecilemuller
cecilemuller / neuro.frag
Last active June 10, 2024 09:28
Neuro shader for Marmoset Toolbag 4
#include "data/shader/mat/state.frag"
#include "data/shader/mat/other/customExtras.sh"
uniform int uIterations; //name "Iterations" default 15 min 5 max 30
uniform float uSpeed; //name "Speed" default 1.0 min 0.0 max 10.0
uniform float uFactor; //name "Factor" default 8.0 min 4.0 max 10.0
// Based on https://codepen.io/wildpeaks/pen/gOJmzdo
float neuro(float ratio, vec2 uv, float t) {
mat2 rotate = mat2(0.540302, 0.841470, -0.841470, 0.540302);
@cecilemuller
cecilemuller / crosshatching.frag
Last active June 3, 2024 15:20
Cross-hatching shader for Marmoset Toolbag 4
// Based on http://research.microsoft.com/en-us/um/people/hoppe/hatching.pdf
// and https://github.com/spite/cross-hatching
#include "data/shader/mat/state.frag"
USE_TEXTURE2D(tHatch0);
USE_TEXTURE2D(tHatch1);
USE_TEXTURE2D(tHatch2);
USE_TEXTURE2D(tHatch3);
USE_TEXTURE2D(tHatch4);
USE_TEXTURE2D(tHatch5);
@cecilemuller
cecilemuller / reset.mjs
Created May 12, 2024 01:51
three.js: press ESC to reset view
import gsap from "gsap";
const defaultPosition = {x: 40, y: 20, z: 40};
const defaultTarget = {x: 0, y: 2, z: 0};
// ...
window.addEventListener("keyup", (e) => {
if (controls.enabled && (e.key.toLowerCase() === "escape")) {
e.preventDefault();
@cecilemuller
cecilemuller / package.json
Last active April 16, 2024 17:59
Subpath Imports:
{
"imports": {
"#components/*": "./src/components/*",
"#functions/*": "./src/functions/*"
}
}
@cecilemuller
cecilemuller / prettierPlugin.ts
Created April 15, 2024 07:35
Vite Plugin: Prettier
import type {PluginOption} from "vite";
import {format} from "prettier";
/**
* Format HTML pages using Prettier.
*/
export function prettierPlugin(): PluginOption {
return {
name: "prettier",
transformIndexHtml: {
@cecilemuller
cecilemuller / vite.config.js
Created April 4, 2024 15:51
Vite: multiple entries, independant output paths
/* eslint-env node */
import {fileURLToPath} from "node:url";
/**
* @returns {import("vite").PluginOption}
*/
function buildPlugin(pages) {
return {
name: "change-html-output",
enforce: "post",