Dan
5 年前
当前提交
dcd36516
共有 15 个文件被更改,包括 1339 次插入 和 7 次删除
-
7Assets/Common/Materials/PlacedSphereMat.mat
-
5ProjectSettings/EditorBuildSettings.asset
-
3ProjectSettings/GraphicsSettings.asset
-
101Assets/Shaders/Materials/ARKitFogMat.mat
-
8Assets/Shaders/Materials/ARKitFogMat.mat.meta
-
1001Assets/Shaders/Scenes/Fog.unity
-
7Assets/Shaders/Scenes/Fog.unity.meta
-
8Assets/Shaders/Scripts.meta
-
8Assets/Shaders/Shaders.meta
-
18Assets/Shaders/Scripts/ApplyFog.cs
-
11Assets/Shaders/Scripts/ApplyFog.cs.meta
-
160Assets/Shaders/Shaders/ARKitFogBackground.shader
-
9Assets/Shaders/Shaders/ARKitFogBackground.shader.meta
|
|||
%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: ARKitFogMat |
|||
m_Shader: {fileID: 4800000, guid: f10bd4466a3844ae6b63ecfa080b9a57, 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} |
|||
- _EmissionMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _EnvironmentDepth: |
|||
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} |
|||
- _SpecGlossMap: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _textureCbCr: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
- _textureY: |
|||
m_Texture: {fileID: 0} |
|||
m_Scale: {x: 1, y: 1} |
|||
m_Offset: {x: 0, y: 0} |
|||
m_Floats: |
|||
- _AlphaClip: 0 |
|||
- _Blend: 0 |
|||
- _BumpScale: 1 |
|||
- _Cull: 2 |
|||
- _Cutoff: 0.5 |
|||
- _DstBlend: 0 |
|||
- _EnvironmentReflections: 1 |
|||
- _GlossMapScale: 0 |
|||
- _Glossiness: 0 |
|||
- _GlossyReflections: 0 |
|||
- _Metallic: 0 |
|||
- _OcclusionStrength: 1 |
|||
- _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} |
|||
--- !u!114 &2593910778208443215 |
|||
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: 1 |
|
|||
fileFormatVersion: 2 |
|||
guid: 07cf155ddd7aa4bd6b10047c7dde5a19 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
Assets/Shaders/Scenes/Fog.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 0e21c82866efe438fa962dbed0b66a7f |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: eaed2eb4dbb934e57a4f266f0ece0cf8 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: b285878a647bb40ed920cef680c7789e |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Text; |
|||
using Unity.Collections.LowLevel.Unsafe; |
|||
using UnityEngine; |
|||
using UnityEngine.UI; |
|||
using UnityEngine.XR.ARFoundation; |
|||
using UnityEngine.XR.ARSubsystems; |
|||
|
|||
namespace UnityEngine.XR.ARFoundation.Samples |
|||
{ |
|||
public class ApplyFog : MonoBehaviour |
|||
{ |
|||
public void OnSliderValueChanged(Slider slider) |
|||
{ |
|||
RenderSettings.fogEndDistance = slider.value; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ca8044bf0ec4943a59c25d210733b43c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
Shader "Unlit/ARKitFogBackground" |
|||
{ |
|||
Properties |
|||
{ |
|||
_textureY ("TextureY", 2D) = "white" {} |
|||
_textureCbCr ("TextureCbCr", 2D) = "black" {} |
|||
_EnvironmentDepth ("EnvironmentDepth", 2D) = "black" {} |
|||
} |
|||
SubShader |
|||
{ |
|||
Tags |
|||
{ |
|||
"Queue" = "Background" |
|||
"RenderType" = "Background" |
|||
"ForceNoShadowCasting" = "True" |
|||
} |
|||
|
|||
Pass |
|||
{ |
|||
Cull Off |
|||
ZTest Always |
|||
ZWrite On |
|||
Lighting Off |
|||
LOD 100 |
|||
Tags |
|||
{ |
|||
"LightMode" = "Always" |
|||
} |
|||
|
|||
|
|||
HLSLPROGRAM |
|||
|
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
|
|||
#pragma multi_compile_local __ ARKIT_ENVIRONMENT_DEPTH_ENABLED |
|||
#pragma multi_compile_fog |
|||
|
|||
#include "UnityCG.cginc" |
|||
|
|||
#define real4 half4 |
|||
#define real4x4 half4x4 |
|||
#define TransformObjectToHClip UnityObjectToClipPos |
|||
#define FastSRGBToLinear GammaToLinearSpace |
|||
|
|||
#define ARKIT_TEXTURE2D_HALF(texture) UNITY_DECLARE_TEX2D_HALF(texture) |
|||
#define ARKIT_SAMPLER_HALF(sampler) |
|||
#define ARKIT_TEXTURE2D_FLOAT(texture) UNITY_DECLARE_TEX2D_FLOAT(texture) |
|||
#define ARKIT_SAMPLER_FLOAT(sampler) |
|||
#define ARKIT_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; |
|||
float depth : SV_Depth; |
|||
}; |
|||
|
|||
|
|||
CBUFFER_START(UnityARFoundationPerFrame) |
|||
// Device display transform is provided by the AR Foundation camera background renderer. |
|||
float4x4 _UnityDisplayTransform; |
|||
CBUFFER_END |
|||
|
|||
|
|||
v2f vert (appdata v) |
|||
{ |
|||
// Transform the position from object space to clip space. |
|||
float4 position = TransformObjectToHClip(v.position); |
|||
|
|||
// Remap the texture coordinates based on the device rotation. |
|||
float2 texcoord = mul(float3(v.texcoord, 1.0f), _UnityDisplayTransform).xy; |
|||
|
|||
v2f o; |
|||
o.position = position; |
|||
o.texcoord = texcoord; |
|||
return o; |
|||
} |
|||
|
|||
|
|||
CBUFFER_START(ARKitColorTransformations) |
|||
static const real4x4 s_YCbCrToSRGB = real4x4( |
|||
real4(1.0h, 0.0000h, 1.4020h, -0.7010h), |
|||
real4(1.0h, -0.3441h, -0.7141h, 0.5291h), |
|||
real4(1.0h, 1.7720h, 0.0000h, -0.8860h), |
|||
real4(0.0h, 0.0000h, 0.0000h, 1.0000h) |
|||
); |
|||
CBUFFER_END |
|||
|
|||
|
|||
inline float ConvertDistanceToDepth(float d) |
|||
{ |
|||
// Clip any distances smaller than the near clip plane, and compute the depth value from the distance. |
|||
return (d < _ProjectionParams.y) ? 0.0f : ((0.5f / _ZBufferParams.z) * ((1.0f / d) - _ZBufferParams.w)); |
|||
} |
|||
|
|||
|
|||
ARKIT_TEXTURE2D_HALF(_textureY); |
|||
ARKIT_SAMPLER_HALF(sampler_textureY); |
|||
ARKIT_TEXTURE2D_HALF(_textureCbCr); |
|||
ARKIT_SAMPLER_HALF(sampler_textureCbCr); |
|||
ARKIT_TEXTURE2D_FLOAT(_EnvironmentDepth); |
|||
ARKIT_SAMPLER_FLOAT(sampler_EnvironmentDepth); |
|||
|
|||
|
|||
fragment_output frag (v2f i) |
|||
{ |
|||
// Sample the video textures (in YCbCr). |
|||
real4 ycbcr = real4(ARKIT_SAMPLE_TEXTURE2D(_textureY, sampler_textureY, i.texcoord).r, |
|||
ARKIT_SAMPLE_TEXTURE2D(_textureCbCr, sampler_textureCbCr, i.texcoord).rg, |
|||
1.0h); |
|||
|
|||
// Convert from YCbCr to sRGB. |
|||
real4 videoColor = mul(s_YCbCrToSRGB, ycbcr); |
|||
|
|||
#if !UNITY_COLORSPACE_GAMMA |
|||
// If rendering in linear color space, convert from sRGB to RGB. |
|||
videoColor.xyz = FastSRGBToLinear(videoColor.xyz); |
|||
#endif // !UNITY_COLORSPACE_GAMMA |
|||
|
|||
// Assume the background depth is the back of the depth clipping volume. |
|||
float depthValue = 0.0f; |
|||
|
|||
#if ARKIT_ENVIRONMENT_DEPTH_ENABLED |
|||
|
|||
// Sample the environment depth (in meters). |
|||
float envDistance = ARKIT_SAMPLE_TEXTURE2D(_EnvironmentDepth, sampler_EnvironmentDepth, i.texcoord).r; |
|||
|
|||
// Convert the distance to depth. |
|||
depthValue = ConvertDistanceToDepth(envDistance); |
|||
|
|||
#if defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2) |
|||
UNITY_CALC_FOG_FACTOR(depthValue); |
|||
UNITY_FOG_LERP_COLOR(videoColor, unity_FogColor, unityFogFactor); |
|||
#endif // defined(FOG_LINEAR) || defined(FOG_EXP) || defined(FOG_EXP2) |
|||
|
|||
#endif // ARKIT_ENVIRONMENT_DEPTH_ENABLED |
|||
|
|||
fragment_output o; |
|||
o.color = videoColor; |
|||
o.depth = depthValue; |
|||
return o; |
|||
} |
|||
|
|||
ENDHLSL |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f10bd4466a3844ae6b63ecfa080b9a57 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue