Skip to content

Instantly share code, notes, and snippets.

@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
shader_type sky;
uniform sampler2D skyTexture:source_color;
void sky() {
COLOR = textureLod(skyTexture, SKY_COORDS, 0.0).rgb;
}
@tool
extends EditorScript
# converts an equirectangular panoramic texture to a skyamid format
var source_panorama:String = "res://skybox_example_pano_left.png"
var target_skyamid:String = "res://skyamid.png"
func _run() -> void:
# load source
@tool
extends EditorScript
class_name GenerateCubemapEditorScript
# collection of helper scripts for generating cubemaps
# file you wish to output the generated cubemap to
var cubemap_filename:String = "color_test_cubemap.tres"