Skip to content

Instantly share code, notes, and snippets.

@DanMillerDev
DanMillerDev / FeatheredPlaneShader.shader
Created March 19, 2020 14:50
shader for feathering the edges of planes in AR Foundation
Shader "Unlit/FeatheredPlaneShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_TexTintColor("Texture Tint Color", Color) = (1,1,1,1)
_PlaneColor("Plane Color", Color) = (1,1,1,1)
}
SubShader
{
@DanMillerDev
DanMillerDev / MobileOcclusion.shader
Created July 30, 2019 05:52
Occlusion shader for Unity. Can be used for mobile AR Occlusion
Shader "Custom/MobileOcclusion"
{
SubShader {
Pass {
// Render the Occlusion shader before all
// opaque geometry to prime the depth buffer.
Tags { "Queue"="Geometry" }
ZWrite On
ZTest LEqual
@DanMillerDev
DanMillerDev / MobileARShadow.shader
Created July 30, 2019 05:48
Shadows on transparent geometry shader for Unity
//This is based on a shader from https://alastaira.wordpress.com/2014/12/30/adding-shadows-to-a-unity-vertexfragment-shader-in-7-easy-steps/
Shader "Custom/MobileARShadow"
{
SubShader {
Pass {
// 1.) This will be the base forward rendering pass in which ambient, vertex, and
// main directional light will be applied. Additional lights will need additional passes
// using the "ForwardAdd" lightmode.
#ifndef LIGHTWEIGHT_SIMPLE_LIT_PASS_INCLUDED
#define LIGHTWEIGHT_SIMPLE_LIT_PASS_INCLUDED
#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.lightweight/ShaderLibrary/Shadows.hlsl"
struct Attributes
{
float4 positionOS : POSITION;
float3 normalOS : NORMAL;
// Shader targeted for low end devices. Single Pass Forward Rendering.
Shader "Custom/Shadows Only"
{
// Keep properties of StandardSpecular shader for upgrade reasons.
Properties
{
_Alpha("Shadow Alpha", float) = 0.5
// Blending state
@DanMillerDev
DanMillerDev / LightEstimation.cs
Created July 31, 2018 18:03
Light Estimation for ARFoundation
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.XR;
using UnityEngine.UI;
using UnityEngine.XR.ARFoundation;
[RequireComponent(typeof(Light))]
public class LightEstimation : MonoBehaviour
{
@DanMillerDev
DanMillerDev / ExampleClass
Created March 9, 2018 03:51
load texture from web on android
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
public string url = "https://docs.unity3d.com/uploads/Main/ShadowIntro.png";
IEnumerator Start()
{
Texture2D tex;
@DanMillerDev
DanMillerDev / BlendShapeObjectSwitcher.cs
Last active April 15, 2020 20:10
Unity ARKit Blend shape object activator
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.iOS;
public class BlendShapeObjectSwitcher : MonoBehaviour {
private static float THRESHOLD = 0.4f;
bool enabled = false;