Skip to content

Instantly share code, notes, and snippets.

View AlegriaSoftware's full-sized avatar

AlegriaSoftware

View GitHub Profile
@Chikanut
Chikanut / SeeThroughMask.hlsl
Last active September 20, 2022 01:22
This is HLSL code of See Through feature, all parameters of shader must be globally seted.
float2 WorldToScreenPos(float3 pos){
pos = normalize(pos - _WorldSpaceCameraPos)*(_ProjectionParams.y + (_ProjectionParams.z - _ProjectionParams.y))+_WorldSpaceCameraPos;
float2 uv =0;
float3 toCam = mul(unity_WorldToCamera, pos);
float camPosZ = toCam.z;
float height = 2 * camPosZ / unity_CameraProjection._m11;
float width = _ScreenParams.x / _ScreenParams.y * height;
uv.x = (toCam.x + width / 2)/width;
uv.y = (toCam.y + height / 2)/width;
return uv;
@aras-p
aras-p / DebugNode.hlsl
Created January 3, 2020 10:37
"Print a value" custom function node code for Unity ShaderGraph
// Quick try at doing a "print value" node for Unity ShaderGraph.
// Tested on Unity 2019.2.17 with ShaderGraph 6.9.2.
//
// Use with CustomFunction node, with two inputs:
// - Vector1 Value, the value to display,
// - Vector2 UV, the UVs of area to display at.
// And one output:
// - Vector4 Color, the color.
// Function name is DoDebug.
@elringus
elringus / RenderMyCustomPass.cs
Last active September 27, 2024 03:44
Example for adding custom render passes via renderer features for lightweight render pipeline (LWRP)
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.LWRP;
// Inheriting from `ScriptableRendererFeature` will add it to the
// `Renderer Features` list of the custom LWRP renderer data asset.
public class RenderMyCustomPass : ScriptableRendererFeature
{
private class MyCustomPass : ScriptableRenderPass
{
@DanielJenkyn
DanielJenkyn / install_obb.sh
Last active February 12, 2024 09:00
Script to install .apk and .obb (Split binary) onto Android device
#!/bin/bash
project_name= com.jenkyncorp.bestapp
reinstall=
# Takes the most recent .apk and .obb (If you have multiple files)
OBB=$(ls -t *.obb | head -n1)
APK=$(ls -t *.apk | head -n1)
while [ "$1" != "" ]; do
@aras-p
aras-p / InfiniteSky.shader
Created February 1, 2019 16:54
"Infinite sky" shader for unity
Shader "Unlit/InfiniteSky"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
// make this render super early inside transparencies
Tags { "RenderType"="Transparent-400" }
@krzys-h
krzys-h / SaveRenderTextureToFile.cs
Last active December 26, 2024 08:44
[Unity] Save RenderTexture to image file
using UnityEngine;
using UnityEditor;
public class SaveRenderTextureToFile {
[MenuItem("Assets/Save RenderTexture to file")]
public static void SaveRTToFile()
{
RenderTexture rt = Selection.activeObject as RenderTexture;
RenderTexture.active = rt;