浏览代码

Changes to make the feathered plane grid more visible and tweakable.

Add tint color to feathered plane texture. Changed the tint to blue.
Changed the color of the geometric gird to white from blue.
/1.5-preview
John Sietsma 6 年前
当前提交
7e1397f9
共有 5 个文件被更改,包括 363 次插入674 次删除
  1. 4
      Assets/Materials/FeatheredPlaneMaterial.mat
  2. 6
      Assets/Scenes/FeatheredPlaneScene.unity
  3. 15
      Assets/Scripts/ARFeatheredPlaneMeshVisualizer.cs
  4. 13
      Assets/Shaders/FeatheredPlaneShader.shader
  5. 999
      Assets/Textures/PlaneGeometricGrid.png

4
Assets/Materials/FeatheredPlaneMaterial.mat


Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: FeatheredPlaneMaterial
m_Shader: {fileID: 4800000, guid: 38661a2f93c3bf34a8aeab0082c6ce64, type: 3}

- _Color: {r: 0.99215686, g: 0.72156864, b: 0.07450981, a: 0.32941177}
- _ColorTint: {r: 1, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _PlaneColor: {r: 0.99215686, g: 0.72156864, b: 0.07450981, a: 0.32941177}
- _TexTintColor: {r: 0, g: 0.07612944, b: 1, a: 1}
- _TintColor: {r: 0.99215686, g: 0.72156864, b: 0.07450981, a: 0.32941177}

6
Assets/Scenes/FeatheredPlaneScene.unity


m_Script: {fileID: 11500000, guid: 816b289ef451e094f9ae174fb4cf8db0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_OverrideMaterial: 0
m_Material: {fileID: 0}
m_UseCustomMaterial: 0
m_CustomMaterial: {fileID: 0}
--- !u!20 &282840813
Camera:
m_ObjectHideFlags: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1335839533}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7ab0e80cee9cc1d44928bfe488dd1e2d, type: 3}
m_Name:

15
Assets/Scripts/ARFeatheredPlaneMeshVisualizer.cs


[Tooltip("The width of the texture feathering (in world units).")]
public float m_FeatheringWidth = 0.2f;
private ARPlaneMeshVisualizer m_PlaneMeshVisualizer;
private ARPlane m_ARPlane;
private Material m_FeatheredPlaneMaterial;
ARPlaneMeshVisualizer m_PlaneMeshVisualizer;
ARPlane m_ARPlane;
Material m_FeatheredPlaneMaterial;
private void Awake()
{

// Figure out where the plane center is in plane-local space (it's in session-local space)
BoundedPlane boundedPlane = m_ARPlane.boundedPlane;
Pose planePose = boundedPlane.Pose;
Vector3 planeCenter = boundedPlane.Center;
Vector3 centerInPlaneSpace = planePose.InverseTransformPosition(boundedPlane.Center);
Pose planePose = boundedPlane.Pose;
Vector3 centerInPlaneSpace = planePose.InverseTransformPosition(boundedPlane.Center);
mesh.GetVertices(s_Vertices);

mesh.UploadMeshData(false);
}
private static List<Vector3> s_FeatheringUVs = new List<Vector3>();
private static List<Vector3> s_Vertices = new List<Vector3>();
static List<Vector3> s_FeatheringUVs = new List<Vector3>();
static List<Vector3> s_Vertices = new List<Vector3>();
}

13
Assets/Shaders/FeatheredPlaneShader.shader


Properties
{
_MainTex ("Texture", 2D) = "white" {}
_TintColor("Tint Color", Color) = (1,1,1,1)
_TexTintColor("Texture Tint Color", Color) = (1,1,1,1)
_PlaneColor("Plane Color", Color) = (1,1,1,1)
}
SubShader
{

sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _TintColor;
fixed4 _TexTintColor;
fixed4 _PlaneColor;
float _ShortestUVMapping;
v2f vert (appdata v)

fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv);
col.rgb = lerp( _TintColor.rgb, col.rgb, col.a);
fixed4 col = tex2D(_MainTex, i.uv) * _TexTintColor;
col = lerp( _PlaneColor, col, col.a);
// Fade out from as we pass the edge.
// uv2.x stores a mapped UV that will be "1" at the beginning of the feathering.
// We fade until we reach at the edge of the shortest UV mapping.

col.a = 1-smoothstep(1, _ShortestUVMapping, i.uv2.x);
col.a *= _TintColor.a;
col.a *= 1-smoothstep(1, _ShortestUVMapping, i.uv2.x);
return col;
}
ENDCG

999
Assets/Textures/PlaneGeometricGrid.png
文件差异内容过多而无法显示
查看文件

正在加载...
取消
保存