Skip to content

Instantly share code, notes, and snippets.

@patriciogonzalezvivo
patriciogonzalezvivo / image3.json
Last active February 3, 2026 11:48
glslViewer Shader: image3
{
"frag": "#ifdef GL_ES\nprecision mediump float;\n#endif\n\nuniform sampler2D u_tex0;\nuniform vec2 u_tex0Resolution;\n\nuniform float u_time;\nuniform vec2 u_resolution;\n\nvoid main() {\n vec2 st = gl_FragCoord.xy/u_resolution.xy;\n st.x *= u_resolution.x/u_resolution.y;\n\n vec3 color = vec3(0.0);\n color = texture2D(u_tex0, st).rgb;\n\n gl_FragColor = vec4(color,1.0);\n}\n",
"vert": "#ifdef GL_ES\nprecision mediump float;\n#endif\n\nattribute vec4 a_position;\nvarying vec4 v_position;\n\nvoid main() {\n v_position = a_position;\n gl_Position = a_position;\n}\n",
"assets": {
"image.png": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAnJnpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjavZxZkly5kUX/sYpeAuZhORgcZr0DLb/PRSRZRRalLkpmYorMrIyIN8Dd7+DwJ2f/+N/r/oc/I8Tqcmm9jlo9f/LII05+6P7zZ75/g8/v329/4tdvf/i9+/5C5FeJ7+nzQq+f7+Hb778d6Ot7mPxU/nSgvr9eWD++MPLX6ftPB/qc1iddkX4+XwcaXwdK8fNC+DrA/NyWr6O3P9/Css/38+1G++ev0z+5/3jZf/nvxuqdwnlSjJZC8vyb0tcFJP2NLk1eCO/fyBtDKvyc37
@patriciogonzalezvivo
patriciogonzalezvivo / image2.json
Created February 3, 2026 11:38
glslViewer Shader: image2
{
"frag": "#ifdef GL_ES\nprecision mediump float;\n#endif\n\nuniform sampler2D u_tex0;\nuniform vec2 u_tex0Resolution;\n\nuniform float u_time;\nuniform vec2 u_resolution;\n\nvoid main() {\n vec2 st = gl_FragCoord.xy/u_resolution.xy;\n st.x *= u_resolution.x/u_resolution.y;\n\n vec3 color = vec3(0.0);\n color = texture2D(u_tex0, st).rgb;\n\n gl_FragColor = vec4(color,1.0);\n}\n",
"vert": "#ifdef GL_ES\nprecision mediump float;\n#endif\n\nattribute vec4 a_position;\nvarying vec4 v_position;\n\nvoid main() {\n v_position = a_position;\n gl_Position = a_position;\n}\n",
"assets": {
"image.png": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAnJnpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjavZxZkly5kUX/sYpeAuZhORgcZr0DLb/PRSRZRRalLkpmYorMrIyIN8Dd7+DwJ2f/+N/r/oc/I8Tqcmm9jlo9f/LII05+6P7zZ75/g8/v329/4tdvf/i9+/5C5FeJ7+nzQq+f7+Hb778d6Ot7mPxU/nSgvr9eWD++MPLX6ftPB/qc1iddkX4+XwcaXwdK8fNC+DrA/NyWr6O3P9/Css/38+1G++ev0z+5/3jZf/nvxuqdwnlSjJZC8vyb0tcFJP2NLk1eCO/fyBtDKvyc37
@patriciogonzalezvivo
patriciogonzalezvivo / circle.json
Created February 3, 2026 11:27
glslViewer Shader: circle
{
"frag": "#ifdef GL_ES\nprecision mediump float;\n#endif\n\nuniform float u_time;\nuniform vec2 u_resolution;\n\n#include \"lygia/draw/circle.glsl\"\nvoid main() {\n vec2 st = gl_FragCoord.xy/u_resolution.xy;\n st.x *= u_resolution.x/u_resolution.y;\n\n vec3 color = vec3(0.0);\n color += circle(st, 0.5, 0.1);\n\n gl_FragColor = vec4(color,1.0);\n}\n",
"vert": "#ifdef GL_ES\nprecision mediump float;\n#endif\n\nattribute vec4 a_position;\nvarying vec4 v_position;\n\nvoid main() {\n v_position = a_position;\n gl_Position = a_position;\n}\n"
}

How to setup a Conda/Pytorch enviroment for using ComfyUI's 3D-Pack

Spoiler allert the solution was to target CUDA 11.8 (PyTorch 2.2.0+)

  1. Make sure you have git, git-lfs, mesa and CUDA-11-8 installed at a OS level
sudo apt install git git-lfs cuda-11-8 mesa-utils mesa-common-dev libegl1-mesa-dev libgles2-mesa-dev 
I am attesting that this GitHub handle patriciogonzalezvivo is linked to the Tezos account tz1NqueFctvNCQrsELm6k4N6XfwAYu5Qp5LN for tzprofiles
sig:edsigtyGKhQWuzB73dYzJfELSjYJt7LwbFEsKD61WF3oVH7Lhok5dgXu3bdZth1U19QwCts7xXwaDyCh7Auqr9Cov1xTXz9Lv4s
// Great example of the use of Lygia samplers functions https://github.com/patriciogonzalezvivo/lygia/tree/main/sample
// and GlslViewer https://github.com/patriciogonzalezvivo/glslViewer
// on the Looking Glass Display
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D u_buffer0;
uniform sampler2D u_buffer1;
@patriciogonzalezvivo
patriciogonzalezvivo / include.py
Last active January 14, 2024 23:38
Resolve includes for GLSL, HLSL and metal on Python
import re
from os.path import join, abspath, dirname, basename
def load_source( folder: str, filename: str, dependencies = []):
path = abspath( join(folder, filename) )
if path in dependencies:
return ""
else:
dependencies.append( path )
@patriciogonzalezvivo
patriciogonzalezvivo / index.html
Last active February 14, 2017 16:17
territory
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Territory</title>
<!-- 3rd party libraries -->
<!-- Leaflet -->
@patriciogonzalezvivo
patriciogonzalezvivo / toGif.sh
Created February 12, 2017 14:57
Frag Shader to gif
#!/bin/bash
SHADER=$1
SEC=$1
COUNTER=0
for i in `seq -w 0.01 .031 $SEC`; do
echo $i
`glslViewer $SHADER -s $i -o frame-$COUNTER.png`
let COUNTER=COUNTER+1
@patriciogonzalezvivo
patriciogonzalezvivo / multistep functions
Last active December 5, 2016 18:43
Multistep functions
```glsl
float mix4smoothstep(float a, float b, float c, float d, float x ) {
return mix(mix(a,b,smoothstep(0.,.33,x)),
mix(b,
mix(c,d,smoothstep(.66,.99,x)),
smoothstep(.33,.66,x)),
step(.33,x));
}
float mix4linear(float a, float b, float c, float d, float x ) {