Skip to content

Instantly share code, notes, and snippets.

function ScreenScalar(props = { p1:1, p2:1 }) {
const compute = () => this.value = 1 - Object.values(props).reduce((r, v) => r * (1 - v), 1)
compute()
for (const key of Object.keys(props)) {
Object.defineProperty(this, key, {
get: () => props[key],
set: value => {
@Allov
Allov / Dutch.md
Last active April 6, 2024 08:05
Règles du jeu Dutch

Dutch

Dutch

Le jeu Dutch se joue avec des cartes à jouer standards, sans les jokers. Il est recommandé de jouer avec deux paquets, soit 104 cartes.

Nombre de joueur: 2 à 10

Temps approximatif d'une partie: 30 minutes

@smkplus
smkplus / UnityShaderCheatSheet.md
Last active May 7, 2024 07:34
Controlling fixed function states from materials/scripts in Unity

16999105_467532653370479_4085466863356780898_n

Shader "MaterialPropertyDrawer"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
 
[HideInInspector] _MainTex2("Hide Texture", 2D) = "white" {}
#version 130
uniform float opacity;
uniform bool invert_color;
uniform sampler2D tex;
const float cornerRadius = 10.0;
void main() {
vec4 c = texture2D(tex, gl_TexCoord[0].xy);
@kodai100
kodai100 / Toggle.shader
Created August 8, 2017 03:01
Unity Shader Bool Property Example
Shader "Custom/ToggleTest" {
Properties{
_BackgroundTex("Background Texture", 2D) = "white"{}
[Toggle(USE_TEXTURE)] _UseTexture("Use Texture", Float) = 0
}
SubShader{
Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
@keijiro
keijiro / ToggleTest.shader
Last active March 24, 2023 00:43
Shows how to use the Toggle material property drawer in a shader. See the reference manual for further details: http://docs.unity3d.com/ScriptReference/MaterialPropertyDrawer.html
Shader "ToggleTest"
{
Properties
{
[Toggle(FILL_WITH_RED)]
_FillWithRed ("Fill With Red", Float) = 0
}
SubShader
{
Pass
@joshwyatt
joshwyatt / how_to_make_a_script.md
Last active January 22, 2024 20:41
How to make scripts you can access globally from the terminal

How to make a globally available executable script in the scripting language of your choice

  • Locate the path to the interpreter for the language you are writing in with the which command.

      which node
      which python
      which bash
      which ruby
    
  • Add that path as an interpreter directive (using #!) on the first line of your script. For example if you want to write a node script and which node returned /usr/local/bin/node, the first line of your script should be:

@blixt
blixt / prng.js
Last active January 14, 2024 07:01
A very simple, seedable JavaScript PRNG. NOTE: Please read comments on why this is not a good choice.
// NOTICE 2020-04-18
// Please see the comments below about why this is not a great PRNG.
// Read summary by @bryc here:
// https://github.com/bryc/code/blob/master/jshash/PRNGs.md
// Have a look at js-arbit which uses Alea:
// https://github.com/blixt/js-arbit
/**
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active May 16, 2024 21:20
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@frarees
frarees / MinMaxSliderAttribute.cs
Last active April 4, 2024 12:13
MinMaxSlider for Unity
// https://frarees.github.io/default-gist-license
using System;
using UnityEngine;
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
public class MinMaxSliderAttribute : PropertyAttribute
{
public float Min { get; set; }
public float Max { get; set; }