1
0
forked from cgvr/DeltaVR

deltavr multiplayer 2.0

This commit is contained in:
Toomas Tamm
2023-05-08 15:56:10 +03:00
parent 978809a002
commit 07b9b9e2f4
10937 changed files with 2968397 additions and 1521012 deletions

View File

@@ -0,0 +1,72 @@
// Small tweak to a basic unlit shader to cheat crosshair depth to render on top of targets.
Shader "Custom/CrosshairZCheat"
{
Properties
{
_MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {}
_Color ("Main Color", Color) = (0.5,0.5,0.5,0.5)
}
SubShader
{
Tags { "Queue" = "Transparent" }
Cull Off
Lighting Off
ZTest Off
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _Color;
v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
// Cheat the post-mvp transformed z towards the camera.
o.vertex = UnityObjectToClipPos(v.vertex);
o.vertex.z -= 0.01;
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.color = v.color;
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col = tex2D(_MainTex, i.texcoord) * i.color * _Color;
return col;
}
ENDCG
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 322c8bbfbbd774b33a90cac7d144bfe7
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,95 @@
// Custom shader to draw our toy cubes and balls with an outline around them.
Shader "Custom/ToyCubeOutline"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo", 2D) = "white" {}
[PerRendererData] _OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline width", Range (.002, 0.03)) = .005
[HideInInspector] _Mode ("__mode", Float) = 0.0
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
[HideInInspector] _ZWrite ("__zw", Float) = 1.0
}
CGINCLUDE
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 pos : SV_POSITION;
fixed4 color : COLOR;
UNITY_VERTEX_OUTPUT_STEREO
};
uniform float _OutlineWidth;
uniform float4 _OutlineColor;
uniform float4x4 _ObjectToWorldFixed;
// Pushes the verts out a little from the object center.
// Lets us give an outline to objects that all have normals facing away from the center.
// If we can't assume that, we need to tweak the math of this shader.
v2f vert(appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
// MTF TODO
// 1. Fix batching so that it actually occurs.
// 2. See if batching causes problems,
// if it does fix this line by adding that component that sets it.
//float4 objectCenterWorld = mul(_ObjectToWorldFixed, float4(0.0, 0.0, 0.0, 1.0));
float4 objectCenterWorld = mul(unity_ObjectToWorld, float4(0.0, 0.0, 0.0, 1.0));
float4 vertWorld = mul(unity_ObjectToWorld, v.vertex);
float3 offsetDir = vertWorld.xyz - objectCenterWorld.xyz;
offsetDir = normalize(offsetDir) * _OutlineWidth;
o.pos = UnityWorldToClipPos(vertWorld+offsetDir);
o.color = _OutlineColor;
return o;
}
ENDCG
SubShader
{
Tags { "Queue" = "Transparent" }
Pass
{
Name "OUTLINE"
// To allow the cube to render entirely on top of the outline.
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
fixed4 frag(v2f i) : SV_Target
{
// Just draw the _OutlineColor from the vert pass above.
return i.color;
}
ENDCG
}
// Standard forward render.
UsePass "Standard/FORWARD"
}
Fallback Off
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 05483dbea409e4cc8853dced3eb9f5dc
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant: