Skip to content

Instantly share code, notes, and snippets.

@supereggbert
supereggbert / __init__.py
Last active November 15, 2023 05:28
Yet Another Parallax Mapping Addon
bl_info = {
"name": "Yet Anonther POM Addon",
"description": "Adds a Parallax Occlution Mapping Node to the shader editor",
"version": (1,0,0),
"blender": (3, 0, 0),
"category": "Material",
}
import bpy
from bpy.types import ShaderNodeCustomGroup, Image
@supereggbert
supereggbert / pseudorandom.js
Last active July 25, 2019 12:44
pseudorandom
var seed=Math.random()
var random3=function(x,y,z){
var f=(Math.abs(x)+1e4)*(Math.abs(y)+2e4)*(Math.abs(z)+3e4);
var a=(f%seed)/seed;
var b=(f%a)/a;
return b;
};
@supereggbert
supereggbert / gaussianRandom.js
Created April 26, 2018 15:43
Simple Random Gaussian Function in Javascript
function gaussianRandom(mean,sigma){
var u = Math.random();
return (u%1e-8>5e-9?1:-1)*Math.sqrt(-Math.log(Math.max(1e-9,u)))*sigma+mean;
}
@supereggbert
supereggbert / index.html
Created August 17, 2014 06:44
Diamond-square Algorithm
<!doctype html>
<html>
<head>
<title>Diamond-square</title>
</head>
<body>
<script>
// PRNG
function random(i) {
return (Math.sin(Math.sin(1e9*i)*1e6)+1)*0.5;
@supereggbert
supereggbert / index.html
Last active October 15, 2023 23:19
3D Surface Plot in D3.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body{
font-family: sans;
padding: 10px;
}
svg path{
@supereggbert
supereggbert / gist:1104419
Created July 25, 2011 15:43
Defining a car through the API
var wheel1 = new GLGE.PhysicsWheel();
wheel1.setRadius(0.5).setLocX(1.4).setLocY(-0.2).setLocY(0.9);
var wheel1Obj=new GLGE.Collada();
wheel1Obj.setDocument("wheel.dae");
wheel1.addCollada(wheel1Obj);
var wheel2 = new GLGE.PhysicsWheel();
wheel2.setRadius(0.5).setLocX(1.4).setLocY(-0.2).setLocY(-0.9);
var wheel2Obj=new GLGE.Collada();
wheel2Obj.setDocument("wheel.dae");
@supereggbert
supereggbert / gist:1104371
Created July 25, 2011 15:21
XML definition of a car in GLGE
<physics_car id="car" loc_y="5.5" mass="15" width="4" depth="0.5" height="1">
<collada document="car.dae" id="carObject" scale="0.3" scale_y="-0.3" />
<physics_wheel id="wheel1" loc_x="1.4" loc_z="0.9" loc_y="-0.2" radius="0.5" travel="0.6" spring="150" side_friction="3" front_friction="10">
<collada document="wheel.dae" id="wheel1obj" scale="0.3" scale_y="-0.3" />
</physics_wheel>
<physics_wheel id="wheel2" loc_x="1.4" loc_z="-0.9" loc_y="-0.2" radius="0.5" travel="0.6" spring="150" side_friction="3" front_friction="10">
<collada document="wheel.dae" id="wheel2obj" scale="0.3" />
</physics_wheel>
<physics_wheel id="wheel3" powered="TRUE" loc_x="-1.7" loc_z="0.9" loc_y="-0.2" radius="0.5" travel="0.6" spring="150" side_friction="3" front_friction="10">
<collada document="wheel.dae" id="wheel3obj" scale="0.3" scale_y="-0.3" />
@supereggbert
supereggbert / getAbsolutePath
Created April 19, 2011 09:48
Work out path
var getAbsolutePath=function(path,relativeto){
if(!relativeto) relativeto=window.location.href;
if(!relativeto) return path;
//remove ? and # from relative to
if(~relativeto.indexOf("?")){
relativeto=relativeto.substr(0,relativeto.indexOf("?"));
}else if(~relativeto.indexOf("#")){
relativeto=relativeto.substr(0,relativeto.indexOf("#"));
}
var pathParts=path.split("/");
<material id="water" specular="1.0" shininess="2">
<texture id="waterheight" src="waterheight.jpg" />
<material_layer texture="#waterheight" mapinput="UV1" frame_rate="25" height="0.07" animation="#flow" mapto="M_HEIGHT" scale_x="0.8" scale_y="0.8" />
<texture id="waternormal" src="waternormal.jpg" />
<material_layer texture="#waternormal" mapinput="UV1" mapto="M_NOR" scale_x="0.5" scale_y="0.5" />
<texture_camera camera="#mainCamera" id="watercolor1" clip_axis="POS_ZAXIS" />
<material_layer texture="#watercolor1" mapinput="MAP_VIEW" mapto="M_COLOR" />
<material id="skyMat">
<texture_cube id="sky" src_pos_x="posx.png" src_neg_x="negx.png" src_pos_y="posy.png" src_neg_y="negy.png" src_pos_z="posz.png" src_neg_z="negz.png" />
<material_layer texture="#sky" mapinput="MAP_ENV" mapto="M_COLOR" />
</material>