Skip to content

Instantly share code, notes, and snippets.

View edap's full-sized avatar

Davide Prati edap

View GitHub Profile
@edap
edap / Shadow.cs
Created May 9, 2024 15:19 — forked from tattyd/Shadow.cs
Soft shadow control for Unity UI Toolkit
/* MIT License
Copyright (c) 2022 David Tattersall
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@edap
edap / sampling_multisampled_2dtexture.wgsl
Created March 17, 2022 08:04
Sampling multisampled 2d texture
struct FragmentOutput {
[[location(0)]] out_color: vec4<f32>;
};
[[block]]
struct Data {
time: f32;
};
[[group(0), binding(0)]]
// A demonstration of drawing to a very large texture, capturing the texture in its original size
// as a PNG and displaying a down-scaled version of the image within the window each frame.
use nannou::prelude::*;
fn main() {
nannou::app(model).update(update).run();
}
struct Model {
@edap
edap / example.js
Created April 20, 2017 12:05
load .ply files exported from magicavoxel into threejs
//THREE.PLYLoader returns a BufferGeometry
createMesh(buffGeometry){
let geometry = new THREE.Geometry().fromBufferGeometry( buffGeometry );
var material = new THREE.MeshPhongMaterial( { specular: 0x111111, shininess: 200, vertexColors: THREE.VertexColors } );
var mesh = new THREE.Mesh( geometry, material );
mesh.scale.multiplyScalar( 0.5 );
return mesh;
}
Tech Toolbox
http://www.gdcvault.com/play/1024145/Tech
Practical Procedural Generation for Everyone
http://www.gdcvault.com/play/1024213/Practical-Procedural-Generation-for
Building Worlds Using Math(s)
http://www.gdcvault.com/play/1024514/Building-Worlds-Using
(defn leaf
[n-stripes width]
(let [
end (mg/scale-edge :ab :x
:scale 0.02
:out [(make-stripes n-stripes)])
middle (mg/reflect :s :out[{}
(mg/scale-edge :bc :z
:len width
:out [(mg/extrude
(defn scale-side
[hex distorsion]
(mg/scale-edge :ef :y
:scale distorsion
:out [hex]))
(defn displace-ring
[& {:keys [offset scale] :or {offset 0.2 scale 1.0}}]
(let [displace-it (mg/split-displace :y :z :offset offset :out [nil {}])
scale-it (mg/scale-edge :bc :z :scale scale :out [displace-it])]
@edap
edap / spritz.clj
Last active August 25, 2016 04:33
(defn punch
{:op :sd-inset, :args {:dir :w, :inset 0.999}, :out [{} {} {} {} nil]}
[dir w & [out]]
(mg/subdiv-inset :dir dir :inset w :out (or out {4 nil})))
(defn petal
[scale offset punch-y]
(let [punch-it (mg/skew :e :e :offset offset
:out [(punch :y punch-y)])
tree (mg/scale-edge :ef :y :scale scale
@edap
edap / star.cljs
Last active August 11, 2016 21:02
(defn star
[]
(let [side (mg/apply-recursively (mg/reflect :e) 13 [1] 1)
seed (mg/sphere-lattice-seg 6 0.355 0.0955 0.2)
skewed-side (mg/skew
:n
:e
:offset 0.3
:out [side])
tree (mg/scale-edge
(defn morphogen-mesh
[seed tree]
(-> seed
(mg/seed-box)
(mg/generate-mesh tree)
(g/center)))
(def strip-quad
"Arrangement of quads"
(let [quad (mg/apply-recursively (mg/reflect :e) 4 [1] 1)