Skip to content

Instantly share code, notes, and snippets.

View julhe's full-sized avatar

Julian Heinken julhe

View GitHub Profile
@julhe
julhe / tweakable_value.c
Created June 25, 2023 22:17
Example tweakable_value in raylib. Requieres stb_ds.h Doesn't work out of the box, needs a function that gets the current frame.
//TODO: support multiple files!
#include "raylib.h"
#include <string.h>
#include <stdlib.h>
#include "stb_ds.h"
static char* _MainFile_text;
static long _MainFile_lastModTime;
@julhe
julhe / Unity Project - Open.bat
Last active December 20, 2022 13:36
Opens a Unity project, installs Unity if missing and (optionally) does SVN and Git automations, all with a single (double) click.
@Echo Off
rem === One-Click-Unity ===
rem Intendet to make lifes easier for less tech-savy people (and yourself) in your team by automating these tasks.
rem Features:
rem * Open a Unity project with one click.
rem * Can install specfic Unity versions if missing with a single key-stroke.
rem * (optional) SVN and Git related automation, check the comments down below.
rem Install:
@julhe
julhe / DoubleIntTest.cs
Created June 16, 2021 09:50
A simple test if all Int32 can be mapped into double.
using System;
using System.Threading.Tasks;
namespace DoubleIntTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Start...");
@julhe
julhe / UniversalPipelineTemplateShader.shader
Last active August 20, 2020 12:40 — forked from phi-lira/UniversalPipelineTemplateShader.shader
Template shader to use as guide to create Universal Pipeline ready shaders. This shader works with Universal Render Pipeline 7.1.x and above.
// When creating shaders for Universal Render Pipeline you can you the ShaderGraph which is super AWESOME!
// However, if you want to author shaders in shading language you can use this teamplate as a base.
// Please note, this shader does not necessarily match perfomance of the built-in URP Lit shader.
// This shader works with URP 7.1.x and above
Shader "Universal Render Pipeline/Custom/Physically Based Example"
{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
@julhe
julhe / buildAndroidLibs.sh
Created June 11, 2020 10:55
Build script for Rust + SDL2 that outputs android libraries
#NOTE: Dont't forget to modify these vars to your setup
JNI_LIBS=./android-project/app/src/main/jniLibs
LIB_NAME=libmain.so
SDL2_LIBS=SDL2-2.0.12Copy/libs
BUILD_MODE=release
#copy sdl2 libs into rusts build dir
mkdir -p ./target/aarch64-linux-android/$BUILD_MODE/deps/
mkdir -p ./target/armv7-linux-androideabi/$BUILD_MODE/deps/
mkdir -p ./target/i686-linux-android/$BUILD_MODE/deps/
@julhe
julhe / .cs
Created April 6, 2020 16:51
LogXRStatus
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
public class LogXRStatus : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
@julhe
julhe / SimpleVoronoiWithBurst.cs
Last active October 11, 2019 20:03
A simple Voronoi Generator and visualizer for Unity with Burst.
/*
* A simple Voronoi Generator and visualizer for Unity with Burst.
* USAGE: Place on any empty Game Object.
* @schneckerstein
*/
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
@julhe
julhe / shadowacne.hlsl
Last active October 7, 2019 13:09
shadowacne.hlsl
//based on:
//http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/
float biasScale = abs(unity_WorldToShadow[0][2][2]);
float NdotL_Sat_sqr = NdotL_Sat * NdotL_Sat;
float bias = rsqrt(NdotL_Sat_sqr / (1.0 - NdotL_Sat_sqr)); //suggested by @TastyTexel: https://twitter.com/TastyTexel/status/1180983378394439681?s=20
bias *= biasScale * 0.25; //adjust 0.25 to personal need
#if UNITY_REVERSED_Z
o._ShadowCoord.z += bias;
@julhe
julhe / SimpleSDF.hlsl
Created August 12, 2019 17:12
Simple Filtering for SDFs Masks
#define inverseLerp(a,b,x) ((x-a)/(b-a))
...
half rawSdf = _Mask.Sample(sampler_Mask, i.uv).r ;
half texelCoverage = fwidth(i.uv) * _Mask_TexelSize.zw; // calculate texelCoverage
texelCoverage = saturate(texelCoverage); //clamp texelCoverage to [0..1]
// you can also use smoothstep(), but inverseLerp uses less instructions
half filteredSdf = saturate(inverseLerp(-texelSize, texelSize, rawSdf * 2.0 - 1.0));
@julhe
julhe / DotVSAdd.shader
Last active December 28, 2018 18:57
dot vs. add
Shader "Unlit/MadVsDot"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_TestVector("_TestVector", Vector) = (0,1,2,3)
[Toggle(DOT_VARIANT)] _DOT_VARIANT("DOT_VARIANT", Int) = 0
}
SubShader