Skip to content

Instantly share code, notes, and snippets.

View travm's full-sized avatar
😱

Travis Maynard travm

😱
View GitHub Profile
@OrionReed
OrionReed / dom3d.js
Last active May 5, 2024 14:09
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯

During the past days, this great article by Sam Pruden has been making the rounds around the gamedev community. While the article provides an in-depth analysis, its a bit easy to miss the point and exert the wrong conclusions from it. As such, and in many cases, users unfamiliar with Godot internals have used it points such as following:

  • Godot C# support is inefficient
  • Godot API and binding system is designed around GDScript
  • Godot is not production ready

In this brief article, I will shed a bit more light about how the Godot binding system works and some detail on the Godot

@itspacchu
itspacchu / handle_smear.gd
Created September 4, 2022 15:27
Smear effect in godot
extends MeshInstance
var mat;
var prev_position;
var zpos = 10;
func _ready() -> void:
mat = self.get_active_material(0)
prev_position = translation
print(mat)
@WolfgangSenff
WolfgangSenff / gist:168cb0cbd486c8c9cd507f232165b976
Last active April 15, 2024 22:14
Godot 4.0 Migration/Upgrade guide
## For a beginner-friendly version of the following (more advanced users likely will get better use of the below,
## if you're just starting out...), see this new gist:
## https://gist.github.com/WolfgangSenff/0a9c1d800db42a9a9441b2d0288ed0fd
This document represents the beginning of an upgrade or migration document for GDScript 2.0 and Godot 4.0. I'm focusing on 2D
at the moment as I'm upgrading a 2D game, but will hopefully have more to add for 3D afterward.
## If you want more content like this, please help fund my cat's medical bills at https://ko-fi.com/kyleszklenski - thank you very much! On to the migration guide.
@nicolaskopp
nicolaskopp / ios-fixed-scrolling-fix.css
Last active April 4, 2024 04:30
Fix scrolling bug on iOS Safari with fixed elements and bottom bar
/* Fix scrolling bug on iOS Safari with fixed elements and bottom bar */
body.noscroll {
height: 100%;
overflow: hidden; /* make sure iOS does not try to scroll the body first */
}
/* your wrapper, most likely mobile menu */
.fixed-wrapper {
width: 100%;
@t-karcher
t-karcher / curved_fragment.shader
Last active August 24, 2023 15:08
Godot shader bending a flat 2d world (e.g. a platformer) to a tiny planet.
shader_type canvas_item;
uniform sampler2D screen_texture : hint_screen_texture, filter_nearest;
uniform float radius = 3.0;
void fragment() {
vec2 uv = SCREEN_UV;
uv.y = 1.0 - uv.y; // seems like the origin changed in Godot 4.
vec2 surface = vec2(0.5, 0.2);
vec2 center = surface - vec2(0, radius);
shader_type canvas_item;
uniform vec4 color_1 = vec4(.0, .0, .0, 1.0);
uniform vec4 color_2 = vec4(0.5, 0.5, 0.5, 1.0);
void fragment() {
vec4 colors[2] = {color_1, color_2};
float min_diff = -1.0;
shader_type canvas_item;
uniform sampler2D spritesheet; // Should be a slice image as exported from Magica Voxel
uniform int slice_count = 1; // The number of slices
uniform vec2 camera_vec = vec2( 1., 1. ); // Recomend using (1,1) or (1,1.5)
uniform float camera_ang = 0.0; // change this to change the view angle of the object
uniform bool flip_stack_order = true;
const int MAX_SLICE_COUNT = 1000;
shader_type canvas_item;
uniform sampler2D spritesheet; // Should be a slice image as exported from Magica Voxel
uniform int slice_count = 1; // The number of slices
uniform vec2 camera_vec = vec2( 1., 1. ); // Recomend using (1,1) or (1,1.5)
uniform float camera_ang = 0.0; // change this to change the view angle of the object
const vec2 center = vec2( 0.5 );
bool scale_and_rotate_with_offset( inout vec2 uv, vec2 sxy, float ang, vec2 cent, vec2 offset )
@aggregate1166877
aggregate1166877 / GodotCleanFisheyeBarrelDistortion.shader
Last active April 13, 2024 23:00
Godot fisheye / barrel distortion shader with minimal pixelation
/**
* This shader creates fisheye or barrel distortion by sliding values in the
* desired direction. It aims to have a minimal amount of pixelation, and was
* originally conceived of to procedurally generate cartoon planets and bodies
* from easily generatable flat textures.
*
* Thanks to user Dan (6145) on Stack Overflow for providing the math. I also
* stole some code from here for the texture placement:
* https://gist.github.com/quiglemj/971f4cec1b128c58b4864c5200bfc579
* This shader differs from the above gist in that it does not stretch the