Загрузка PICO Unity OpenXR Integration SDK
This commit is contained in:
@ -0,0 +1,203 @@
|
||||
Shader "PXR/Hand"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[Header(BaseColor)]
|
||||
_InnerColor("内部颜色",Color) = (1,1,1,1)
|
||||
_OutColor("外部颜色",Color) = (1,1,1,1)
|
||||
_FresnelPower("菲涅尔强度",float) = 1
|
||||
|
||||
[Header(Light)][Space(5)]
|
||||
_PressLight("按下光照",Color) = (1,1,1,1)
|
||||
_ClickLight("点击光照",Color) = (1,1,1,1)
|
||||
_PressRange("按压范围",Range(0,1)) = 0.015
|
||||
_ClickRange("点击范围",Range(0,1)) = 0.015
|
||||
_ClickPosition("点击位置",Vector)=(1,1,1,1)
|
||||
_PressIntensity("按压强度",Range(0,1)) = 1
|
||||
|
||||
[Header(Wrist)][Space(10)]
|
||||
_WristFadeRange("腕部渐变范围",Range(0,1)) = 1
|
||||
_MainAlpha("总透明度",Range(0,1)) = 1
|
||||
|
||||
_FadeIn("透明消隐",Range(0,1))=0
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
#include "Lighting.cginc"
|
||||
#pragma target 3.0
|
||||
|
||||
float4 _InnerColor;
|
||||
float4 _OutColor;
|
||||
float _FresnelPower;
|
||||
|
||||
float4 _PressLight;
|
||||
float4 _ClickLight;
|
||||
half _PressIntensity;
|
||||
float4 _ClickPosition;
|
||||
|
||||
float _PressRange;
|
||||
float _ClickRange;
|
||||
|
||||
float _WristFadeRange;
|
||||
float _FadeIn;
|
||||
float _MainAlpha;
|
||||
|
||||
//-----------------描边参数----------------
|
||||
struct OutlineVertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct OutlineVertexOutput
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv:TEXCOORD3;
|
||||
};
|
||||
|
||||
//-------------------------------------------
|
||||
|
||||
//---------------------正常绘制参数-------------------
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
half3 normal : NORMAL;
|
||||
half4 vertexColor : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 worldPos : TEXCOORD1;
|
||||
float3 worldNormal : TEXCOORD2;
|
||||
float2 uv:TEXCOORD3;
|
||||
};
|
||||
|
||||
void CustomRemap(in float4 inValue, float2 inMinMax, float2 outMinMax, out float4 outValue)
|
||||
{
|
||||
outValue = outMinMax.x + (inValue - inMinMax.x) * (outMinMax.y - outMinMax.x) / (inMinMax.y - inMinMax.x);
|
||||
}
|
||||
|
||||
float GetAlpha(float2 uv)
|
||||
{
|
||||
float dis = distance(float2(0.5, 0), uv * float2(0.9, 1) + float2(0.05, 0));
|
||||
float4 s1;
|
||||
CustomRemap(_WristFadeRange, float2(0, 1), float2(0.12, 1), s1);
|
||||
const float s2 = 0.12;
|
||||
float alpha = smoothstep(s2, s1, dis);
|
||||
|
||||
float s3 = 1 - _FadeIn;
|
||||
float4 s4;
|
||||
CustomRemap(s3, float2(0, 0.5), float2(0, 1), s4);
|
||||
s4 = 1.1 * saturate(s4);
|
||||
|
||||
return alpha * smoothstep(s3, s4, dis);
|
||||
}
|
||||
float GetFresnel(float3 viewDir, float3 normal, float power)
|
||||
{
|
||||
return pow(1 - dot(viewDir, normal), power);
|
||||
}
|
||||
|
||||
//-----------------正常绘制------------------------
|
||||
VertexOutput baseVertex(VertexInput v)
|
||||
{
|
||||
VertexOutput o;
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
|
||||
o.worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 baseFragment(VertexOutput v) : SV_Target
|
||||
{
|
||||
float3 normalWS = normalize(v.worldNormal);
|
||||
float3 viewWS = normalize(UnityWorldSpaceViewDir(v.worldPos));
|
||||
float fresnel = saturate(GetFresnel(viewWS, normalWS, _FresnelPower));
|
||||
|
||||
float4 baseColor = lerp(_InnerColor, _OutColor, fresnel);
|
||||
float4 clickColor = lerp(_PressLight, _ClickLight, step(0.99, _PressIntensity));
|
||||
|
||||
|
||||
float3 localClickPos = mul((float3x3)unity_WorldToObject, _ClickPosition);
|
||||
float3 vertexPos = mul((float3x3)unity_WorldToObject, v.worldPos);
|
||||
float dis = distance(localClickPos, vertexPos);
|
||||
|
||||
float2 inMinMax = float2(0, lerp(_PressRange, _ClickRange, _PressIntensity));
|
||||
float2 outMinMax = float2(1, 0);
|
||||
float4 s;
|
||||
CustomRemap(dis, inMinMax, outMinMax, s);
|
||||
float4 r = smoothstep(0, 1, clamp(s, 0, 1));
|
||||
r.a *= _PressIntensity;
|
||||
|
||||
fixed4 finalCol = lerp(baseColor, clickColor, r.a);
|
||||
finalCol.a *= saturate(GetAlpha(v.uv));
|
||||
finalCol.a *= _MainAlpha;
|
||||
return finalCol;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderPipeline" = "UniversalPipeline"
|
||||
"Queue" = "Transparent"
|
||||
"RenderType" = "Transparent"
|
||||
"IgnoreProjector" = "True"
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "Depth"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "SRPDefaultUnlit"
|
||||
}
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "BaseColor"
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "UniversalForward"
|
||||
}
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
Cull Off
|
||||
CGPROGRAM
|
||||
#pragma vertex baseVertex
|
||||
#pragma fragment baseFragment
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"RenderType" = "Transparent"
|
||||
"IgnoreProjector" = "True"
|
||||
}
|
||||
LOD 200
|
||||
Pass
|
||||
{
|
||||
Name "Depth"
|
||||
ZWrite On
|
||||
ColorMask 0
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "Interior"
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite On
|
||||
CGPROGRAM
|
||||
#pragma vertex baseVertex
|
||||
#pragma fragment baseFragment
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ae4d410c1995fa4e8fea1ab6359ea37
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,123 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: UnderlayHole
|
||||
m_Shader: {fileID: 4800000, guid: 4212f1d23993b2640922b428f2748e20, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _Blend: 0
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 0
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 0
|
||||
- _Metallic: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.005
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Surface: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &2824030880348393175
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 5
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7dceaed51abddf64eb52ba3f767eb4dd
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user