Skip to content

Instantly share code, notes, and snippets.

@belzecue
belzecue / true_parallax.gd
Created June 17, 2025 14:16 — forked from nklbdev/true_parallax.gd
True parallax script for Godot 4
## This script adds parallax functionality to any Node2D.
## But be careful, some Node2D descendants may work in a special way
## with the position and global_position properties,
## or have other conflicts with the logic of this script.[br]
##
## [b]How to use[/b]: Add this script to any [Node2D],
## such as [TileMapLayer] or [Sprite2D], or to [Node2D] itself.
## Or move the main sections of the code to your own script.[br]
## After that, this node will have new properties that allow you
## to configure parallax and see it working in the editor just like in the game.[br]
@belzecue
belzecue / AmbientOcclusionDirection.osl
Created June 3, 2025 15:00 — forked from simonbroggi/AmbientOcclusionDirection.osl
Calculates AO and the average direction where the ambient light came from.
/*
* Ambient Occlusion and Direction.
*
* Calculates AO and the average direction where the ambient light came from.
*
* Original AO code from https://github.com/sambler/osl-shaders/blob/master/ramps/BaAmbientOcclusion/BaAmbientOcclusion.osl
*
*/
void rng_seed(output int rng, int seed)
@belzecue
belzecue / material_selector.gd
Created February 24, 2025 00:43 — forked from levidavidmurray/material_selector.gd
_get_property_list example usage to populate an enum dropdown in the inspector based on dynamic array values
@tool
class_name MaterialSelector
extends Node3D
##############################
## EXPORT VARIABLES
##############################
@export var mesh: MeshInstance3D
@export var materials: Array[Material] = []:
@tool
class_name ProceduralBridge
extends Node3D
##############################
## EXPORT VARIABLES
##############################
@export var physics_server: bool = false:
set(value):
@belzecue
belzecue / fractal_texturing_godot3.shader
Created February 15, 2025 13:25
Fractal texturing lets you use one texture to efficiently cover a large mesh and will stay sharp at any distance, especially close up. It also solves the problem of texture repetition really well. Give it a try below. I've even used it with a 64-pixel texture and it works great.
/*
Godot 3 shader version by Belzecue [https://bsky.app/profile/belzecue.bsky.social].
Based on XorDev's ShaderToy.
"Fractal Texturing" by @XorDev
While creating a 3D game (https://twitter.com/XorDev/status/1578947873550389248),
I came across a problem with my texture quality. I needed something that looked good up close
or far away. That's when I developed what I call "fractal texturing". I'm sure it's been done
shader_type spatial;
// alpha for tex1 and tex2 is the heightmap
uniform sampler2D tex1 : hint_black_albedo;
uniform sampler2D tex2 : hint_black_albedo;
uniform vec2 tex1_scale = vec2(1.);
uniform vec2 tex2_scale = vec2(1.);
uniform float height_offset = 0.;
uniform float contrast = 1.;
@belzecue
belzecue / 2d_dropshadow.shader
Created January 25, 2025 08:27
Remove branching from drop-shadow shader
// based on https://godotshaders.com/shader/drop-shadow/
shader_type canvas_item;
uniform vec4 drop_shadow_color : hint_color = vec4(0,0,0,0.5);
uniform vec2 shadow_offset = vec2(0.1);
varying float max_offset;
void vertex() {
@belzecue
belzecue / 1-pico8-godot-shader.shader
Created November 28, 2024 15:29 — forked from stephanbogner/1-pico8-godot-shader.shader
PICO-8 color palette (or any other) shader for Godot (with the .html file below you can easily adjust the shader to any color palette)
// Adapted from "How to Limit Color Output with Shaders in Godot"
// By TheBuffED
// On https://www.youtube.com/watch?v=Scrdv4oSeNw
// Type of shader https://docs.godotengine.org/en/3.0/tutorials/shading/shading_language.html#shader-types
shader_type canvas_item;
// The shader strength which between 0 (not applied) and 1 (fully applied) because I want to fade the shader in and out
// Can be changed from node via `get_material().set_shader_param("shaderStrength", newValue)`
uniform float shaderStrength = 1.0;
@belzecue
belzecue / bake_morph_textures.py
Created November 21, 2024 14:38 — forked from alexmalyutindev/bake_morph_textures.py
Vertex animation baker for Blender.
# Source
# Vertex animation textures, beanbags and boneless animations
# by Martin Donald
# https://www.youtube.com/watch?v=NQ5Dllbxbz4
import bpy
import bmesh
import mathutils
"""
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!