Skip to content

Instantly share code, notes, and snippets.

@partybusiness
partybusiness / chrome_with_viewshadow.gdshader
Last active April 24, 2025 01:40
fake chrome using cubemap for reflection, with a black blob shadow superimposed over the viewer's position
shader_type spatial;
uniform samplerCube sky_cube:source_color;
uniform sampler2D shadow_texture:source_color, repeat_disable, hint_default_white;
uniform vec2 shadow_scale = vec2(2.0, 1.0);
uniform vec2 shadow_offset = vec2(0.5,0.2);
@partybusiness
partybusiness / pixel_size.gdshader
Created March 27, 2025 02:48
Gets the size of a texel on-screen in pixels
shader_type spatial;
// quick test for how large a texel in on-screen in pixels
uniform sampler2D test_texture:filter_nearest;
void fragment() {
vec2 uv_per_texel = vec2(1.0, 1.0) / vec2(textureSize(test_texture, 0));
vec2 dfx = dFdx(UV);
vec2 dfy = dFdy(UV);
vec2 uv_per_pixel = vec2(length(vec2(dfx.x, dfy.x)), length(vec2(dfx.y, dfy.y)));
@partybusiness
partybusiness / moon_sky.gdshader
Created March 26, 2025 22:35
Godot sky shader that displays the moon based on light direction
shader_type sky;
uniform sampler2D moon_texture:source_color, repeat_disable;
// updirection of moon texture will try to align with this
uniform vec3 north = vec3(0, 0, -1);
void sky() {
vec3 light_dir = normalize(-LIGHT0_DIRECTION);
vec3 side_dir = normalize(cross(light_dir, north));
@partybusiness
partybusiness / snakes_and_ladder_board.csv
Last active May 5, 2025 01:07
Snakes and ladders analysis using a transition matrix in R
start end
73 1
46 5
55 7
8 26
48 9
52 11
59 17
83 19
21 82
shader_type canvas_item;
// draws black dots at corners
uniform float dot_size = 30; // size of dots at vertices
varying vec2 vertex_uv; // used to pass fake UV since real UV wasn't behaving as expected
void vertex() {
vertex_uv = COLOR.rg; // using vertex colour because UV array from Polygon2D wasn't working for me?
//vertex_uv = UV;
#Based on Procedural Toolkit by Syomus (https://github.com/Syomus/ProceduralToolkit)
@tool
extends PrimitiveMesh
class_name SuperSphere
# generates a supersphere
## size of the supersphere
@export var radius : float = 1.0:
get:
@partybusiness
partybusiness / fake_ground_plane.gdshader
Last active January 9, 2025 18:53
Displays a fake ground plane that doesn't need to correspond to geometry. Useful for creating a ground plane that extends to the horizon without requiring infinite geometry.
shader_type spatial;
uniform sampler2D ground_texture:source_color, repeat_enable, filter_linear_mipmap;
uniform float ground_height = -1.0;
uniform float scale = 2.0;
varying vec3 world_position;
varying vec3 cam_pos;
@partybusiness
partybusiness / compress_effect.gd
Last active March 20, 2025 16:20
CompositorEffect that applies a JPEG-inspired bad compression.
@tool
extends CompositorEffect
class_name CompressEffect
#
#@tool
const shrink_shader_path:String = "res://compression/compress_shrink_effect.glsl"
const block_shader_path:String = "res://compression/compress_final_effect.glsl"
@partybusiness
partybusiness / bright_star_lst.csv
Last active January 8, 2025 18:49
Two methods of displaying a starry sky. One generates a star map as a 64x64 png file using star position data and then uses that star map to display a sky shader. The other just displays random star positions along vertical strips.
RA DEC V B-V
00 08.2 +29 04 2.1 -0.11
00 09.0 +59 08 2.3 0.34
00 13.1 +15 10 2.8 -0.23
00 25.4 -77 17 2.8 0.62
00 26.2 -42 20 2.39 1.09
00 39.2 +30 50 3.27 1.28
00 40.3 +56 31 2.23 1.17
00 43.5 -18 01 2.04 1.02
00 49.0 +57 48 3.44 0.57
@partybusiness
partybusiness / shuffle_tester.gd
Last active February 25, 2025 19:12
Shuffle node in Godot that uses crypto.generate_random_bytes if I want to be pedantic that every possible shuffle is possible
extends Node
class_name ShuffleTester
var deck:Array
@export var shuffler:Shuffler
@export var simple_shuffler:SimpleShuffler
@export var shuffler_mod:ShufflerMod