Skip to content

Commit 3894881

Browse files
committed
feat(Pointer): update default pointer material
Default WorldPointer material uses a custom shader with a fresnel rim and transparency.
1 parent de6358c commit 3894881

File tree

3 files changed

+195
-121
lines changed

3 files changed

+195
-121
lines changed

Assets/VRTK/Materials/Resources/WorldPointer.mat

Lines changed: 119 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -7,132 +7,130 @@ Material:
77
m_PrefabParentObject: {fileID: 0}
88
m_PrefabInternal: {fileID: 0}
99
m_Name: WorldPointer
10-
m_Shader: {fileID: 4800000, guid: 4c84081e4523a5646919b30697cfccb8, type: 3}
10+
m_Shader: {fileID: 4800000, guid: 2da0089da6324ed4abd8da04795831be, type: 3}
1111
m_ShaderKeywords:
1212
m_LightmapFlags: 5
13-
m_CustomRenderQueue: 3000
13+
m_CustomRenderQueue: -1
1414
stringTagMap: {}
1515
m_SavedProperties:
1616
serializedVersion: 2
1717
m_TexEnvs:
18-
data:
19-
first:
20-
name: _MainTex
21-
second:
22-
m_Texture: {fileID: 0}
23-
m_Scale: {x: 1, y: 1}
24-
m_Offset: {x: 0, y: 0}
25-
data:
26-
first:
27-
name: _BumpMap
28-
second:
29-
m_Texture: {fileID: 0}
30-
m_Scale: {x: 1, y: 1}
31-
m_Offset: {x: 0, y: 0}
32-
data:
33-
first:
34-
name: _DetailNormalMap
35-
second:
36-
m_Texture: {fileID: 0}
37-
m_Scale: {x: 1, y: 1}
38-
m_Offset: {x: 0, y: 0}
39-
data:
40-
first:
41-
name: _MetallicGlossMap
42-
second:
43-
m_Texture: {fileID: 0}
44-
m_Scale: {x: 1, y: 1}
45-
m_Offset: {x: 0, y: 0}
46-
data:
47-
first:
48-
name: _ParallaxMap
49-
second:
50-
m_Texture: {fileID: 0}
51-
m_Scale: {x: 1, y: 1}
52-
m_Offset: {x: 0, y: 0}
53-
data:
54-
first:
55-
name: _OcclusionMap
56-
second:
57-
m_Texture: {fileID: 0}
58-
m_Scale: {x: 1, y: 1}
59-
m_Offset: {x: 0, y: 0}
60-
data:
61-
first:
62-
name: _EmissionMap
63-
second:
64-
m_Texture: {fileID: 0}
65-
m_Scale: {x: 1, y: 1}
66-
m_Offset: {x: 0, y: 0}
67-
data:
68-
first:
69-
name: _DetailMask
70-
second:
71-
m_Texture: {fileID: 0}
72-
m_Scale: {x: 1, y: 1}
73-
m_Offset: {x: 0, y: 0}
74-
data:
75-
first:
76-
name: _DetailAlbedoMap
77-
second:
78-
m_Texture: {fileID: 0}
79-
m_Scale: {x: 1, y: 1}
80-
m_Offset: {x: 0, y: 0}
18+
- first:
19+
name: _BumpMap
20+
second:
21+
m_Texture: {fileID: 0}
22+
m_Scale: {x: 1, y: 1}
23+
m_Offset: {x: 0, y: 0}
24+
- first:
25+
name: _DetailAlbedoMap
26+
second:
27+
m_Texture: {fileID: 0}
28+
m_Scale: {x: 1, y: 1}
29+
m_Offset: {x: 0, y: 0}
30+
- first:
31+
name: _DetailMask
32+
second:
33+
m_Texture: {fileID: 0}
34+
m_Scale: {x: 1, y: 1}
35+
m_Offset: {x: 0, y: 0}
36+
- first:
37+
name: _DetailNormalMap
38+
second:
39+
m_Texture: {fileID: 0}
40+
m_Scale: {x: 1, y: 1}
41+
m_Offset: {x: 0, y: 0}
42+
- first:
43+
name: _EmissionMap
44+
second:
45+
m_Texture: {fileID: 0}
46+
m_Scale: {x: 1, y: 1}
47+
m_Offset: {x: 0, y: 0}
48+
- first:
49+
name: _MainTex
50+
second:
51+
m_Texture: {fileID: 0}
52+
m_Scale: {x: 1, y: 1}
53+
m_Offset: {x: 0, y: 0}
54+
- first:
55+
name: _MetallicGlossMap
56+
second:
57+
m_Texture: {fileID: 0}
58+
m_Scale: {x: 1, y: 1}
59+
m_Offset: {x: 0, y: 0}
60+
- first:
61+
name: _OcclusionMap
62+
second:
63+
m_Texture: {fileID: 0}
64+
m_Scale: {x: 1, y: 1}
65+
m_Offset: {x: 0, y: 0}
66+
- first:
67+
name: _ParallaxMap
68+
second:
69+
m_Texture: {fileID: 0}
70+
m_Scale: {x: 1, y: 1}
71+
m_Offset: {x: 0, y: 0}
72+
- first:
73+
name: _RampTex
74+
second:
75+
m_Texture: {fileID: 0}
76+
m_Scale: {x: 1, y: 1}
77+
m_Offset: {x: 0, y: 0}
78+
- first:
79+
name: _SurfaceTex
80+
second:
81+
m_Texture: {fileID: 0}
82+
m_Scale: {x: 1, y: 1}
83+
m_Offset: {x: 0, y: 0}
8184
m_Floats:
82-
data:
83-
first:
84-
name: _SrcBlend
85-
second: 1
86-
data:
87-
first:
88-
name: _DstBlend
89-
second: 0
90-
data:
91-
first:
92-
name: _Cutoff
93-
second: 0.5
94-
data:
95-
first:
96-
name: _ZWrite
97-
second: 1
98-
data:
99-
first:
100-
name: _Glossiness
101-
second: 0.5
102-
data:
103-
first:
104-
name: _Metallic
105-
second: 0
106-
data:
107-
first:
108-
name: _BumpScale
109-
second: 1
110-
data:
111-
first:
112-
name: _Parallax
113-
second: 0.02
114-
data:
115-
first:
116-
name: _OcclusionStrength
117-
second: 1
118-
data:
119-
first:
120-
name: _DetailNormalMapScale
121-
second: 1
122-
data:
123-
first:
124-
name: _UVSec
125-
second: 0
126-
data:
127-
first:
128-
name: _Mode
129-
second: 0
85+
- first:
86+
name: _BumpScale
87+
second: 1
88+
- first:
89+
name: _Cutoff
90+
second: 0.5
91+
- first:
92+
name: _DetailNormalMapScale
93+
second: 1
94+
- first:
95+
name: _DstBlend
96+
second: 0
97+
- first:
98+
name: _FPOW
99+
second: 1.11
100+
- first:
101+
name: _Glossiness
102+
second: 0.5
103+
- first:
104+
name: _Metallic
105+
second: 0
106+
- first:
107+
name: _Mode
108+
second: 0
109+
- first:
110+
name: _OcclusionStrength
111+
second: 1
112+
- first:
113+
name: _Offset
114+
second: 0
115+
- first:
116+
name: _Parallax
117+
second: 0.02
118+
- first:
119+
name: _R0
120+
second: 0.38
121+
- first:
122+
name: _SrcBlend
123+
second: 1
124+
- first:
125+
name: _UVSec
126+
second: 0
127+
- first:
128+
name: _ZWrite
129+
second: 1
130130
m_Colors:
131-
data:
132-
first:
133-
name: _EmissionColor
134-
second: {r: 0, g: 0, b: 0, a: 1}
135-
data:
136-
first:
137-
name: _Color
138-
second: {r: 0, g: 0.5, b: 0, a: 1}
131+
- first:
132+
name: _Color
133+
second: {r: 1, g: 1, b: 1, a: 1}
134+
- first:
135+
name: _EmissionColor
136+
second: {r: 0, g: 0, b: 0, a: 1}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
Shader "Custom/TransparentFresnel"
2+
{
3+
Properties{
4+
_Color("Rim Color", Color) = (0.5,0.5,0.5,0.5)
5+
_FPOW("FPOW Fresnel", Float) = 5.0
6+
_R0("R0 Fresnel", Float) = 0.05
7+
_MainTex("Bumpmap", 2D) = "bump" {}
8+
}
9+
10+
Category{
11+
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
12+
Blend SrcAlpha OneMinusSrcAlpha
13+
ZWrite Off
14+
15+
SubShader{
16+
Pass{
17+
18+
CGPROGRAM
19+
#pragma vertex vert
20+
#pragma fragment frag
21+
#include "UnityCG.cginc"
22+
23+
sampler2D _MainTex;
24+
fixed4 _Color;
25+
float _FPOW;
26+
float _R0;
27+
28+
29+
struct appdata_t {
30+
float4 vertex : POSITION;
31+
fixed4 color : COLOR;
32+
float2 texcoord : TEXCOORD0;
33+
float3 normal : NORMAL;
34+
};
35+
36+
struct v2f {
37+
float4 vertex : POSITION;
38+
fixed4 color : COLOR;
39+
float2 texcoord : TEXCOORD0;
40+
};
41+
42+
float4 _MainTex_ST;
43+
44+
v2f vert(appdata_t v)
45+
{
46+
v2f o;
47+
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
48+
o.color = v.color;
49+
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
50+
51+
float3 viewDir = normalize(ObjSpaceViewDir(v.vertex));
52+
half fresnel = saturate(1.0 - dot(v.normal, viewDir));
53+
fresnel = pow(fresnel, _FPOW);
54+
fresnel = _R0 + (1.0 - _R0) * fresnel;
55+
o.color *= fresnel;
56+
return o;
57+
}
58+
59+
fixed4 frag(v2f i) : COLOR
60+
{
61+
return 2.0f * i.color * _Color * tex2D(_MainTex, i.texcoord);
62+
}
63+
ENDCG
64+
}
65+
}
66+
}
67+
}

Assets/VRTK/Scripts/Shaders/TransparentFresnelBehind.shader.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)