Skip to content

Instantly share code, notes, and snippets.

#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
#[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 = "new_cubemap.tres"
@partybusiness
partybusiness / find_distances.glsl
Last active October 6, 2024 19:21
Godot shader raycast FPS
#[compute]
#version 450
// Invocations in the (x, y, z) dimension
layout(local_size_x = 8, local_size_y = 1, local_size_z = 1) in;
layout(rgba16f, set = 0, binding = 0) uniform restrict image2D distances; //distances to walls along each raycast, as well as data for wall texture
layout(rgba16f, set = 0, binding = 1) uniform restrict image2D map; //map to raycast on
shader_type spatial;
render_mode unshaded, blend_mul, depth_draw_never, depth_test_disabled;
// creates a silhouette that appears when the mesh is behind something else
// you can combine this with another material by assigning this as the Next Pass material
// this might need adjustment to work with 4.3 and later, because of the reversed depth
uniform vec3 shadow_colour:source_color = vec3(0.7,0.7,0.9);
uniform sampler2D depth_texture:hint_depth_texture;
@partybusiness
partybusiness / character_hole.gd
Last active October 15, 2024 15:48
Dithered transparency hole
extends Node3D
# Sets position of hole that makes character visible through walls
func _process(delta):
RenderingServer.global_shader_parameter_set("character_position", global_position)