Skip to content

Instantly share code, notes, and snippets.

@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
@partybusiness
partybusiness / checkers.gd
Last active January 9, 2025 17:17
Generates a checkboard pattern on a texture, which can be used as a generic texture for testing shaders and so on.
@tool
extends ImageTexture
class_name Checkers
# I wanted an example of a custom parameter-controlled texture
# There are other examples that override the _draw funcs but that approach doesn't work if
# assigning as a uniform sampler2D on a shader
@export var size:Vector2i = Vector2i(64,64):
get:
@partybusiness
partybusiness / animated_patch_shader.gdshader
Last active December 20, 2024 21:40
Generates patch from an in-scene camera that can replace a small part of a skybox
shader_type spatial;
render_mode unshaded;
// displays patch as generated by the PatchGeneratingNode
uniform sampler2DArray patch_textures:source_color, repeat_disable;
uniform float frames_per_second:hint_range(1.0, 60.0, 1.0) = 30.0;
uniform vec3 right_vector;
@partybusiness
partybusiness / rotate_scrolling.gdshader
Last active December 16, 2024 21:06
Scrolling and spinning shader
shader_type canvas_item;
render_mode unshaded;
uniform sampler2D image:source_color, repeat_enable;
// size you'd like to display image on-screen, in pixels
uniform float tile_size = 200.0;
// speed of rotation in radians per second
uniform float rotation_speed = 1.0;
#Based on Procedural Toolkit by Syomus (https://github.com/Syomus/ProceduralToolkit)
@tool
extends PrimitiveMesh
class_name DiamondMesh
enum CutType {
Octahedral,
Table,
OldMine,
OldEuropean,
@partybusiness
partybusiness / gem.gdshader
Last active December 4, 2024 23:00
Gem shader in Godot
shader_type spatial;
render_mode blend_add, cull_disabled;
/** amount of influence camera direction has on noise */
uniform float direction_scale = 4.0;
/** amount of influence vertex position has on noise */
uniform float vertex_scale = 1.5;
/** power applied to each channel
Higher values will make edges smoother, low values will make edges sharper
@partybusiness
partybusiness / vhs_blur_effect.glsl
Last active March 3, 2025 16:53
Compositor effect in Godot that makes camera look like a VHS recording.
#[compute]
#version 450
// Invocations in the (x, y, z) dimension
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
layout(rgba16f, set = 0, binding = 0) uniform image2D small_image;
layout(rgba16f, set = 0, binding = 1) uniform image2D color_image;
@partybusiness
partybusiness / code_particle_display.gdshader
Last active November 14, 2024 19:57
Displays square particles that round off their position to the nearest on-screen square and disaplays the computer text
shader_type spatial;
render_mode unshaded, depth_test_disabled;
// will need to assign this in code because I can't get Godot to save it as a property of material
uniform uint tilemap[1024]; // up to 128 8-byte 8x8 tiles
uniform int screenWidth = 168;
uniform int screenHeight = 64;
varying vec4 calcscreen; //calculated screen size and