浏览代码
Merge pull request #67 from unity/add-depth-gradient-shader
Merge pull request #67 from unity/add-depth-gradient-shader
Improve the depth images scene/4.1
GitHub Enterprise
4 年前
当前提交
f291d393
共有 14 个文件被更改,包括 1721 次插入 和 74 次删除
-
932Assets/Scenes/Depth/DepthImages.unity
-
457Assets/Scripts/DisplayDepthImage.cs
-
2ProjectSettings/ProjectSettings.asset
-
4ProjectSettings/ProjectVersion.txt
-
80Assets/Materials/DepthGradientMaterial.mat
-
8Assets/Materials/DepthGradientMaterial.mat.meta
-
78Assets/Materials/HumanStencil.mat
-
8Assets/Materials/HumanStencil.mat.meta
-
115Assets/Shaders/DepthGradient.shader
-
9Assets/Shaders/DepthGradient.shader.meta
-
93Assets/Shaders/HumanStencil.shader
-
9Assets/Shaders/HumanStencil.shader.meta
-
0/Assets/Scripts/DisplayDepthImage.cs.meta
-
0/Assets/Scripts/DisplayDepthImage.cs
932
Assets/Scenes/Depth/DepthImages.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
m_EditorVersion: 2020.1.0f1 |
|||
m_EditorVersionWithRevision: 2020.1.0f1 (2ab9c4179772) |
|||
m_EditorVersion: 2020.1.1f1 |
|||
m_EditorVersionWithRevision: 2020.1.1f1 (2285c3239188) |
|
|||
%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: DepthGradientMaterial |
|||
m_Shader: {fileID: 4800000, guid: 1aab677bdaaa5470588b1194d3f271be, type: 3} |
|||
m_ShaderKeywords: |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _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} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 1 |
|||
- _Glossiness: 0.5 |
|||
- _GlossyReflections: 1 |
|||
- _MaxDistance: 8 |
|||
- _Metallic: 0 |
|||
- _MinDistance: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 1 |
|||
- _SrcBlend: 1 |
|||
- _TextureRotation: 0 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 1, g: 1, b: 1, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1822b099f6c09434b97c31e70184ff72 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%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: HumanStencil |
|||
m_Shader: {fileID: 4800000, guid: 100cb03e868ab4dd78fa474037e0f92c, type: 3} |
|||
m_ShaderKeywords: |
|||
m_LightmapFlags: 4 |
|||
m_EnableInstancingVariants: 0 |
|||
m_DoubleSidedGI: 0 |
|||
m_CustomRenderQueue: -1 |
|||
stringTagMap: {} |
|||
disabledShaderPasses: [] |
|||
m_SavedProperties: |
|||
serializedVersion: 3 |
|||
m_TexEnvs: |
|||
- _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} |
|||
m_Floats: |
|||
- _BumpScale: 1 |
|||
- _Cutoff: 0.5 |
|||
- _DetailNormalMapScale: 1 |
|||
- _DstBlend: 0 |
|||
- _GlossMapScale: 1 |
|||
- _Glossiness: 0.5 |
|||
- _GlossyReflections: 1 |
|||
- _Metallic: 0 |
|||
- _Mode: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _Parallax: 0.02 |
|||
- _SmoothnessTextureChannel: 0 |
|||
- _SpecularHighlights: 1 |
|||
- _SrcBlend: 1 |
|||
- _TextureRotation: 0 |
|||
- _UVSec: 0 |
|||
- _ZWrite: 1 |
|||
m_Colors: |
|||
- _Color: {r: 1, g: 1, b: 1, a: 1} |
|||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
|
|||
fileFormatVersion: 2 |
|||
guid: c0be8d44aefaa41a79f40f503f63619b |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "Unlit/DepthGradient" |
|||
{ |
|||
Properties |
|||
{ |
|||
_MainTex ("Main Texture", 2D) = "black" {} |
|||
_MinDistance ("Min Distance", Float) = 0.0 |
|||
_MaxDistance ("Max Distance", Float) = 8.0 |
|||
} |
|||
SubShader |
|||
{ |
|||
Tags |
|||
{ |
|||
"Queue" = "Geometry" |
|||
"RenderType" = "Opaque" |
|||
"ForceNoShadowCasting" = "True" |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Cull Off |
|||
ZTest Always |
|||
ZWrite Off |
|||
Lighting Off |
|||
LOD 100 |
|||
Tags |
|||
{ |
|||
"LightMode" = "Always" |
|||
} |
|||
|
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
#include "UnityCG.cginc" |
|||
|
|||
#define real half |
|||
#define real3 half3 |
|||
#define real4 half4 |
|||
#define TransformObjectToHClip UnityObjectToClipPos |
|||
|
|||
#define DECLARE_TEXTURE2D_FLOAT(texture) UNITY_DECLARE_TEX2D_FLOAT(texture) |
|||
#define DECLARE_SAMPLER_FLOAT(sampler) |
|||
#define SAMPLE_TEXTURE2D(texture,sampler,texcoord) UNITY_SAMPLE_TEX2D(texture,texcoord) |
|||
|
|||
|
|||
struct appdata |
|||
{ |
|||
float3 position : POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
|
|||
struct v2f |
|||
{ |
|||
float4 position : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
|
|||
struct fragment_output |
|||
{ |
|||
real4 color : SV_Target; |
|||
}; |
|||
|
|||
|
|||
CBUFFER_START(DisplayRotationPerFrame) |
|||
float4x4 _DisplayRotationPerFrame; |
|||
CBUFFER_END |
|||
|
|||
|
|||
v2f vert (appdata v) |
|||
{ |
|||
v2f o; |
|||
o.position = TransformObjectToHClip(v.position); |
|||
o.texcoord = mul(float3(v.texcoord, 1.0f), _DisplayRotationPerFrame).xy; |
|||
return o; |
|||
} |
|||
|
|||
|
|||
real3 HSVtoRGB(real3 arg1) |
|||
{ |
|||
real4 K = real4(1.0h, 2.0h / 3.0h, 1.0h / 3.0h, 3.0h); |
|||
real3 P = abs(frac(arg1.xxx + K.xyz) * 6.0h - K.www); |
|||
return arg1.z * lerp(K.xxx, saturate(P - K.xxx), arg1.y); |
|||
} |
|||
|
|||
|
|||
DECLARE_TEXTURE2D_FLOAT(_MainTex); |
|||
DECLARE_SAMPLER_FLOAT(sampler_MainTex); |
|||
|
|||
real _MinDistance; |
|||
real _MaxDistance; |
|||
|
|||
fragment_output frag (v2f i) |
|||
{ |
|||
// Sample the environment depth (in meters). |
|||
float envDistance = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord).r; |
|||
|
|||
real lerpFactor = (envDistance - _MinDistance) / (_MaxDistance - _MinDistance); |
|||
real hue = lerp(0.70h, -0.15h, saturate(lerpFactor)); |
|||
if (hue < 0.0h) |
|||
{ |
|||
hue += 1.0h; |
|||
} |
|||
real3 color = real3(hue, 0.9h, 0.6h); |
|||
|
|||
fragment_output o; |
|||
o.color = real4(HSVtoRGB(color), 1.0h); |
|||
return o; |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1aab677bdaaa5470588b1194d3f271be |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "Unlit/HumanStencil" |
|||
{ |
|||
Properties |
|||
{ |
|||
_MainTex ("Main Texture", 2D) = "black" {} |
|||
} |
|||
SubShader |
|||
{ |
|||
Tags |
|||
{ |
|||
"Queue" = "Geometry" |
|||
"RenderType" = "Opaque" |
|||
"ForceNoShadowCasting" = "True" |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Cull Off |
|||
ZTest Always |
|||
ZWrite Off |
|||
Lighting Off |
|||
LOD 100 |
|||
Tags |
|||
{ |
|||
"LightMode" = "Always" |
|||
} |
|||
|
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
#include "UnityCG.cginc" |
|||
|
|||
#define real half |
|||
#define real3 half3 |
|||
#define real4 half4 |
|||
#define TransformObjectToHClip UnityObjectToClipPos |
|||
|
|||
#define DECLARE_TEXTURE2D_FLOAT(texture) UNITY_DECLARE_TEX2D_FLOAT(texture) |
|||
#define DECLARE_SAMPLER_FLOAT(sampler) |
|||
#define SAMPLE_TEXTURE2D(texture,sampler,texcoord) UNITY_SAMPLE_TEX2D(texture,texcoord) |
|||
|
|||
|
|||
struct appdata |
|||
{ |
|||
float3 position : POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
|
|||
struct v2f |
|||
{ |
|||
float4 position : SV_POSITION; |
|||
float2 texcoord : TEXCOORD0; |
|||
}; |
|||
|
|||
struct fragment_output |
|||
{ |
|||
real4 color : SV_Target; |
|||
}; |
|||
|
|||
|
|||
CBUFFER_START(DisplayRotationPerFrame) |
|||
float4x4 _DisplayRotationPerFrame; |
|||
CBUFFER_END |
|||
|
|||
|
|||
v2f vert (appdata v) |
|||
{ |
|||
v2f o; |
|||
o.position = TransformObjectToHClip(v.position); |
|||
o.texcoord = mul(float3(v.texcoord, 1.0f), _DisplayRotationPerFrame).xy; |
|||
return o; |
|||
} |
|||
|
|||
|
|||
DECLARE_TEXTURE2D_FLOAT(_MainTex); |
|||
DECLARE_SAMPLER_FLOAT(sampler_MainTex); |
|||
|
|||
fragment_output frag (v2f i) |
|||
{ |
|||
float stencilValue = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord).r; |
|||
|
|||
fragment_output o; |
|||
o.color = real4(stencilValue, stencilValue, stencilValue, 1.0h); |
|||
return o; |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 100cb03e868ab4dd78fa474037e0f92c |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue