Skip to content

Instantly share code, notes, and snippets.

@belzecue
belzecue / RingBufferDic.gd
Created February 24, 2022 15:54
Godot ring buffer using Dictionary. Can pop FIFO or LIFO.
class_name RingBufferDic extends Node
enum PopMode {LIFO, FIFO}
export(int) var maxHistoryEntries := 32
var history := {}
var hwm := 0 # high water mark
var LIFO := -1 # -1 means buffer empty
var FIFO := -1 # -1 means buffer empty
var pop_counter := 0
"""
Based on Calinou's Godot3 movie render script:
https://github.com/Calinou/godot-video-rendering-demo/blob/master/camera.gd
# Copyright © 2019 Hugo Locurcio and contributors - MIT License
# See `LICENSE.md` included in the source distribution for details.
This script asynchronously renders gameplay or camera animation
to PNG files which can then be combined into a video via ffmpeg.
IMPORTANT!
@belzecue
belzecue / catmull-rom.gd
Created June 22, 2024 11:55 — forked from JoelBesada/catmull-rom.gd
Catmull-Rom Spline in GDScript
func catmull_rom_spline(
_points: Array, resolution: int = 10, extrapolate_end_points = true
) -> PackedVector2Array:
var points = _points.duplicate()
if extrapolate_end_points:
points.insert(0, points[0] - (points[1] - points[0]))
points.append(points[-1] + (points[-1] - points[-2]))
var smooth_points := PackedVector2Array()
if points.size() < 4:
@belzecue
belzecue / create_export_pack.sh
Created April 20, 2024 11:41 — forked from pavanpodila/create_export_pack.sh
Export each Git branch as a separate folder
previous_pwd=$PWD
cd $(dirname $0)
PROJECT="$HOME/Desktop/project"
EXPORT_DIR="$HOME/Desktop/export"
rm -rf $EXPORT_DIR
mkdir -p $EXPORT_DIR
/**
* \brief Returns positional offset for a given point as a result of summing 4 gerstner waves
* \param positionWS point in world space
* \param wavelengths wavelength of each of the 4 waves
* \param amplitudes amplitudes of each of the 4 waves
* \param directions direction of each of the 4 waves (each row = one direction). MUST BE NORMALIZED!
* \param speed global speed multiplier. Individual wave speed depends on Wavelength
* \param steepness Gerstner wave 'Steepness' parameter. Modulates the horizontal offset of points
* \param normal returns the normal of given point.
* \return positional offset of the given point
@belzecue
belzecue / ReadOnlyAttribute.cs
Created March 28, 2020 04:05
[Unity] Inspector Read-Only Fields - Shows field data but doesn't allow to modify it
/**
* ReadOnlyAttribute.cs
* Created by: Joao Borks [joao.borks@gmail.com]
* Created on: 05/06/18 (dd/mm//yy)
* Reference from It3ration: https://answers.unity.com/questions/489942/how-to-make-a-readonly-property-in-inspector.html
*/
using UnityEngine;
using System;
@belzecue
belzecue / CameraTrackingRefraction.cs
Created May 21, 2018 19:15 — forked from runevision/CameraTrackingRefraction.cs
Unity CommandBuffer replacement for GrabPass - works with multiple separate cameras.
using UnityEngine;
using UnityEngine.Rendering;
// This script is added to cameras automatically at runtime by the ObjectNeedingRefraction scripts.
public class CameraTrackingRefraction : MonoBehaviour {
[System.NonSerialized]
public int lastRenderedFrame = -1;
Camera cam;
@belzecue
belzecue / GLSL-Noise.md
Last active January 21, 2024 03:20 — forked from patriciogonzalezvivo/GLSL-Noise.md
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);
@belzecue
belzecue / gamepad_debugger.gd
Last active January 16, 2024 02:26 — forked from anthonyec/gamepad_debugger.gd
Godot gamepad input visualisation for debugging (GDScript 2)
# Godot 3.x version of a Godot 4 script written by anthonyec at:
# https://gist.github.com/anthonyec/5342fce79b2b7b22ada748df0ad7f7c0
# This Godot 3.x version available at:
# https://gist.github.com/belzecue/025d8829f69dead512e58f44e990ce30/edit
# Attach script to a Control node.
tool
extends Control
export var device: int = 0
@belzecue
belzecue / text_decal_sdf.shader
Created January 6, 2024 16:39
Godot 3 SDF shader for clear decal edges at low resolutions, as used by Valve
// Generate high-resolution white on black text decal in GIMP and apply Filters > Generic > Distance Map
// then scale down to e.g. 64 pixel height.
// Import decal image into Godot and set:
// Compression mode to lossless
// Filter ON
// Mipmaps ON
// Fix alpha border ON
// Invert color ON (if required)