Skip to content

Instantly share code, notes, and snippets.

View adritake's full-sized avatar

Adrián de la Torre Rodríguez adritake

View GitHub Profile
@adritake
adritake / remap.osl
Created June 1, 2023 08:24
OSL remap function
point remap(point origFrom, point origTo, point targetFrom, point targetTo, point value)
{
return targetFrom + (value - origFrom) * (targetTo - targetFrom) / (origTo - origFrom);
}
@adritake
adritake / 84-Shader__UI Shader-NewUIShader.shader.txt
Last active July 13, 2023 09:07
Unity template to creat UI shaders
Shader "Unlit/#NAME#"
{
Properties
{
[MainTexture][HideInInspector]_MainTex ("Texture", 2D) = "white" {}
// Stencil comparison to make UI mask work
[HideInInspector]_StencilComp ("Stencil Comparison", Float) = 8
[HideInInspector]_Stencil ("Stencil ID", Float) = 0
[HideInInspector]_StencilOp ("Stencil Operation", Float) = 0
@adritake
adritake / 84-Shader__No Fog Unlit Shader-NewUnlitShader.shader.txt
Last active June 6, 2023 15:34
Unity template to create a shader that don't use the Unity fog
Shader "Unlit/#NAME#"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
@adritake
adritake / UISmoke_shader.shader
Last active June 6, 2023 15:25
UI Smoke shader for Unity
Shader "UI/UISmoke_shader"
{
Properties
{
[Header(Textures)]
_NoiseTex ("Noise texture", 2D) = "white" { }
_MaskTex ("Mask texture", 2D) = "white" { }
[Header(Noise)]
_NoiseTexScale("Noise scale", float) = 1
@adritake
adritake / Environment_shader.shader
Created July 18, 2023 10:31
Environment terraforming shader
Shader "SW/Environment_shader"
{
Properties
{
[Header(Textures)]
[MainTexture] _MainTex ("Main texture", 2D) = "white" { }
_TerraformTex ("Terraform texture", 2D) = "white" { }
[Header(World parameters)]
_TerrainSize ("Terrain size", Vector) = (0, 0, 0, 0)
@adritake
adritake / BlurPostProcess.shader
Created December 14, 2023 17:04
Blur shader for Unity
Shader "PostProcess/BlurPostProcess"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_BlurQuality("Blur quality", float) = 2
_BlurDirections("Blur directions", int) = 6
_BlurRadius("Blur radius", Range(0, 0.1)) = 1
}
SubShader
@adritake
adritake / 85-Shader__ShaderFunction-NewShaderFunction.hlsl.txt
Created March 6, 2024 11:12
Unity script template to create custom shader files with functions to be included in shaders
#ifndef #NAME#_INCLUDED
#define #NAME#_INCLUDED
// Remember to put the previous name in capital letters
float Function()
{
return 0;
}
@adritake
adritake / OpenByExtensionEditor.cs
Created February 6, 2025 08:05
Unity script to open an asset with the system's default program
using UnityEditor;
using UnityEngine;
#if UNITY_EDITOR
public class OpenByExtensionEditor : Editor
{
[MenuItem("Assets/Open with default program")]
private static void OpenAssetByDefaultProgram()
{
var selected = Selection.activeObject;
Shader "Unlit/PostProcessingCRT"
{
Properties
{
}
SubShader
{
Tags
{