Skip to content

Instantly share code, notes, and snippets.

View shole's full-sized avatar
🎩

Paavo Happonen shole

🎩
View GitHub Profile
@shole
shole / OVRViewCone.cs
Last active August 29, 2015 14:13
Oculus DK2 tracking camera fustrum script updated for 0.4.3+ ( https://forums.oculus.com/viewtopic.php?f=37&t=11779&p=168201 )
using UnityEngine;
using System.Collections;
using Ovr;
public class OVRViewCone : MonoBehaviour
{
private GameObject viewConeMesh;
public OVRManager camController;
// Shader created with Shader Forge Beta 0.23
// Shader Forge (c) Joachim Holmer - http://www.acegikmo.com/shaderforge/
// Note: Manually altering this data may prevent you from opening it in Shader Forge
/*SF_DATA;ver:0.23;sub:START;pass:START;ps:lgpr:1,nrmq:1,limd:0,blpr:3,bsrc:0,bdst:6,culm:2,dpts:2,wrdp:False,uamb:True,mssp:True,ufog:False,aust:True,igpj:True,qofs:0,lico:0,qpre:3,flbk:,rntp:2,lmpd:False,lprd:False,enco:False,frtr:True,vitr:True,dbil:False,rmgx:True,hqsc:False,hqlp:False,fgom:False,fgoc:False,fgod:False,fgor:False,fgmd:0,fgcr:0.5,fgcg:0.5,fgcb:0.5,fgca:1,fgde:0.01,fgrn:0,fgrf:300,ofsf:0,ofsu:0;n:type:ShaderForge.SFN_Final,id:1,x:32719,y:32712|emission-636-OUT,disp-1907-OUT,tess-1649-OUT;n:type:ShaderForge.SFN_Tex2dAsset,id:19,x:34366,y:33219,ptlb:depthmap,tex:0a70c16c7b47ab048bc9e03b588c24f6;n:type:ShaderForge.SFN_Tex2d,id:20,x:33638,y:32490,tex:e976c6d3ebc1e4a85aa7186a3192d8c5,ntxv:0,isnm:False|TEX-903-TEX;n:type:ShaderForge.SFN_Tex2d,id:25,x:34184,y:33197,tex:0a70c16c7b47ab048bc9e03b588
#!/bin/bash
if [ "`php isdbalive.php`" != "ok" ] ; then
echo "restart mysql"
# service mysql restart
fi
echo "done"
uniform vec3 viewVector;
uniform float c;
uniform float p;
varying float intensity;
void main()
{
intensity=c-(normalMatrix*normal).z;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}
@shole
shole / SteamVR_TrackedController2.cs
Created March 1, 2016 16:57
improved SteamVR_TrackedController with held down events
using UnityEngine;
using System.Collections;
public class SteamVR_TrackedController2 : MonoBehaviour {
public uint controllerIndex;
public Valve.VR.VRControllerState_t controllerState;
public bool triggerPressed = false;
public bool steamPressed = false;
public bool menuPressed = false;
public bool padPressed = false;
@shole
shole / Conditionals.inc
Created November 9, 2017 21:17
Branchless shader logic
/*
Branchless shader logic made sane with macros;
usage;
if (depth>pointdepth){
col=tex2D(_CameraColorTextureP,o.uv);
}else{
col=tex2D(_MainTex,o.uv);
}
using System;
using System.Collections;
using System.Collections.Generic;
public class CombinedRefList<T> : IEnumerable {
public List<IList<T>> lists = new List<IList<T>>();
public T this[int index] {
get {
Shader "Hidden/CopyDepth2Color" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
Cull Off ZWrite On ZTest Always
Pass {
CGPROGRAM
#pragma vertex vert
using UnityEngine;
using UnityEditor;
using System.Threading;
// Unity randomly loads wrong culture which breaks decimal symbols and
// C# file parsing functions.... Fix it manually cause unity is a dick
[InitializeOnLoad]
public class Startup {
static Startup() {
@shole
shole / Conditionals.inc
Created October 8, 2019 13:18
shader branchless conditionals
/*
Branchless shader logic made sane with macros;
usage;
if (depth>pointdepth){
col=tex2D(_CameraColorTextureP,o.uv);
}else{
col=tex2D(_MainTex,o.uv);
}