Skip to content

Instantly share code, notes, and snippets.

Pass {
Name "SHADOWCASTER"
Tags { "LightMode" = "ShadowCaster" }
CGPROGRAM
#pragma target 3.0
#pragma multi_compile_shadowcaster
#pragma multi_compile_instancing
/*
Original file :
Storage for distribution - Lyuma
https://gist.github.com/lyuma
rounded_trail for quest
LICENSE : CC0
*/
// 2019-09-30 customized for quest.
@lyuma
lyuma / SkyboxCubemapDual.shader
Created November 7, 2019 01:16
Skybox picks one of two cubemaps based on the light direction
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
// Edited by Lyuma - Added second skybox if light is below the horizon.
Shader "Skybox/CubemapDual"
{
Properties
{
_Rotation ("Rotation", Range(0, 360)) = 0
[NoScaleOffset] _Tex ("Cubemap Day", Cube) = "grey" {}
[NoScaleOffset] _TexNight ("Cubemap Night", Cube) = "grey" {}
_NightDotThreshold ("Night Dot Threshold", Range(-1, 1)) = 0
// Pixelated font shader by lox9973
// It is a cutout shader, using alpha blending for 1 pixel antialiasing on the edges.
// Intended use is "3D Text" on an opaque object like a sign.
Shader "UI/PixelFont" {
Properties {
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}
SubShader {
// Below Transparent queue. Renders after the skybox, but writes to depth.
@lyuma
lyuma / CubemapTrioSkybox.shader
Created April 16, 2020 08:00
Cubemap shader - Added second and third third skybox if light is at sunset, or below the horizon respectively.
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
// Edited by Lyuma - Added second and third third skybox if light is at sunset, or below the horizon respectively.
Shader "Skybox/CubemapTrio"
{
Properties
{
_Rotation ("Rotation", Range(0, 360)) = 0
[NoScaleOffset] _Tex ("Cubemap Day", Cube) = "grey" {}
[NoScaleOffset] _TexSunset ("Cubemap Sunset", Cube) = "grey" {}
[NoScaleOffset] _TexNight ("Cubemap Night", Cube) = "grey" {}
/* Copyright (c) 2020 Lyuma <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@lyuma
lyuma / tag_dockerhub_image.sh
Created September 4, 2020 14:46
Copies an image tag on DockerHub to another tag (such as latest)
#!/bin/bash
# Thanks to:
# https://dille.name/blog/2018/09/20/how-to-tag-docker-images-without-pulling-them/
# https://hub.docker.com/support/doc/how-do-i-authenticate-with-the-v2-api
# https://gist.github.com/alexanderilyin/8cf68f85b922a7f1757ae3a74640d48a
# for all the help.
# TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'"$(cat ~/.docker/config.json | cut -d\" -f8)"'", "password": "'"$(cat ~/.docker/config.json | cut -d\" -f12)"'"}' https://hub.docker.com/v2/users/login/ | cut -d\" -f4)
# "Authorization: JWT $TOKEN"
@lyuma
lyuma / Parse16BitFloat.shader
Last active September 3, 2022 09:43
Godot Shader to extract the raw 16-bit integer in a FORMAT_RGBAH texture.
shader_type spatial;
render_mode unshaded;
uniform usampler2D data_tex;
/*
Use with the following GDScript code:
var data_img = Image.new()
var data := PoolByteArray()
var indexin = 0x8400
@lyuma
lyuma / GodotToUnitySH9.glsl
Created October 30, 2020 23:49
Convert Godot spherical harmonics to Unity SH9 coefficients (e.g. ShadeSH9)
// Global temporary variables in GLSL, and access to ambient/reflection/SH9 in shaders:
// Requires these patches:
// https://github.com/lyuma/godot/tree/shader_improvements_meta (master)
// https://github.com/lyuma/godot/tree/shader_global_arrays_3.2 (3.2)
// https://github.com/lyuma/godot/tree/shader_npr_lighting_3.2 (3.2)
vec4 unity_SHAr = vec4(0.0);
vec4 unity_SHAg = vec4(0.0);
vec4 unity_SHAb = vec4(0.0);
vec4 unity_SHBr = vec4(0.0);
@lyuma
lyuma / decal_albedo.shader.glsl
Created November 18, 2020 04:47
decal shader for Godot Engine
shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,specular_schlick_ggx;
uniform vec4 albedo : hint_color;
uniform sampler2D texture_albedo : hint_albedo;
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
uniform float specular;
uniform float metallic;
uniform float roughness : hint_range(0,1);