Skip to content

Instantly share code, notes, and snippets.

@Fonserbc
Fonserbc / Oklab.cs
Last active November 5, 2024 18:11
An implementation of the transformations to and from Oklab, along with color lerping using Oklab including unity's Gradient evaluation. For more information about Oklab by Björn Ottosson check https://bottosson.github.io/posts/oklab/
using UnityEngine;
/*
* Oklab Unity implementation by Ferran Bertomeu Castells @fonserbc
*
* Oklab by Björn Ottosson https://bottosson.github.io/posts/oklab/
* under Public Domain
*
* For the conversions, I understand unity's Color as a gamma-space color
*/
@erwincoumans
erwincoumans / BasicDemo.cpp
Created October 21, 2020 23:13
Kinematic btRigidBody example
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2015 Google Inc. http://bulletphysics.org
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
@memononen
memononen / biasgaininf.c
Last active February 2, 2022 10:09
bias gain inflection point
float evalCurve(float x, float tx, float ty, float sa, float sb)
{
const float EPS = 1e-6f;
if (x < tx) {
return (ty * x) / (x + sa * (tx - x) + EPS);
} else {
return ((1-ty) * (x-1)) / ((1-x) - sb * (tx - x) + EPS) + 1.0f;
}
}
@travisstaloch
travisstaloch / fields.zig
Last active May 12, 2024 23:19
zig iterate over struct fields and print
const std = @import("std");
test "fields" {
const U1s = packed struct {
a: u1,
b: u1,
c: u1,
};
const x = U1s{ .a = 1, .b = 0, .c = 0 };
@jeffvella
jeffvella / RaycastUnderPointerSystem.cs
Created July 16, 2019 07:18
Unity Physics in ECS Raycasting
using BovineLabs.Entities.Systems;
using Unity.Burst;
using Unity.Entities;
using Unity.Jobs;
using Unity.Collections;
using Unity.Physics;
using Unity.Physics.Systems;
using UnityEngine;
[UpdateAfter(typeof(BuildPhysicsWorld)), UpdateBefore(typeof(EndFramePhysicsSystem))]
@aras-p
aras-p / example.shader
Created May 31, 2019 05:23
DX10 HLSL style textures and samplers in Unity
// Example of using DX10-style HLSL texture and sampler objects in
// Unity shaders
Shader "Unlit/Example"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
@podgorskiy
podgorskiy / FrustumCull.h
Created July 12, 2017 10:33
Ready to use frustum culling code. Depends only on GLM. The input is only bounding box and ProjectionView matrix. Based on Inigo Quilez's code.
#include <glm/matrix.hpp>
class Frustum
{
public:
Frustum() {}
// m = ProjectionMatrix * ViewMatrix
Frustum(glm::mat4 m);
using UnityEngine;
using UnityEditor;
using System.Reflection;
using Type = System.Type;
public class InlineCurveEditor
{
private object curveEditor;
private Type curveType;
@1995eaton
1995eaton / regex_utils.cc
Created April 21, 2015 04:46
Regex Utils for C++11
#include <iostream>
#include <algorithm>
#include <vector>
#include <regex>
std::regex::flag_type parse_flags(const std::string& flag_str) {
std::regex::flag_type grammar = std::regex::ECMAScript;
std::regex::flag_type flags = grammar ^ grammar;
for (const auto& c: flag_str) {
switch (c) {
@Alexanderallenbrown
Alexanderallenbrown / pydugoff.py
Last active January 4, 2024 11:49
simply python/numpy Dugoff tire model
from numpy import *
from matplotlib.pyplot import *
# A Dugoff Tire model implementation in python/numpy
#Alexander Brown, Ph.D.
# [email protected]
class DugoffTire:
""" This python class implements the Dugoff tire model based on friction coefficients, cornering stiffnesses.
Forces are applied in same sign as slip angle, so be aware of this when you implement.