NEW CLOUDS NEW CLOUDS NEW CLOUDS WHOOO
Added new clouds shader with improved raymarching loop Currently only being used in main menu (rest is coming right up!) Removed WWise (it's nice, but all it's doing is throwing exceptions rn since we ain't about to get a license)
This commit is contained in:
parent
4a369a1266
commit
b08423b936
1066 changed files with 9806 additions and 58766 deletions
|
|
@ -8,7 +8,7 @@ public class MainMenuMusic : MonoBehaviour
|
|||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
AkSoundEngine.RegisterGameObj(gameObject);
|
||||
ActionGameManager.PlayMusic(ActionGameManager.SoundBanksInfo.GetSoundBank(MusicSoundbankName).Id, gameObject);
|
||||
// TODO: SFX: Menu Music
|
||||
//ActionGameManager.PlayMusic(ActionGameManager.SoundBanksInfo.GetSoundBank(MusicSoundbankName).Id, gameObject);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ Material:
|
|||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 1
|
||||
- _Depth: 1
|
||||
- _Depth: 0.1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 6.2832
|
||||
|
|
@ -78,6 +78,6 @@ Material:
|
|||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 0.17647058, g: 0.5897114, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ Material:
|
|||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 1
|
||||
- _Depth: 2.9
|
||||
- _Depth: 2
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 6.2832
|
||||
|
|
@ -70,7 +70,7 @@ Material:
|
|||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Phase: 0
|
||||
- _Power: 0.5
|
||||
- _Power: 2
|
||||
- _SinePower: 1.25
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
|
|
@ -78,6 +78,6 @@ Material:
|
|||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 0.60475, b: 0.411, a: 1}
|
||||
- _Color: {r: 1, g: 0.39424297, b: 0.09900004, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ Material:
|
|||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Constant: 13
|
||||
- _Constant: -2.3
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: -30
|
||||
- _Depth: 10
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 0.005
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ Material:
|
|||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Constant: 9
|
||||
- _Constant: -2.2
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: -30
|
||||
- _Depth: 11.4
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 0.01
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ Material:
|
|||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.1
|
||||
- _Cutoff: 0.153
|
||||
- _Depth: 2000
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ Material:
|
|||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 1
|
||||
- _Depth: 3
|
||||
- _Depth: 8
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 6.2832
|
||||
|
|
@ -70,7 +70,7 @@ Material:
|
|||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Phase: 0
|
||||
- _Power: 12
|
||||
- _Power: 124.97
|
||||
- _SinePower: 1.25
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
|
|
@ -78,6 +78,6 @@ Material:
|
|||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 0.53900003, b: 0.86855793, a: 1}
|
||||
- _Color: {r: 1, g: 0.24800003, b: 0.7833221, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ Material:
|
|||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: 24
|
||||
- _Depth: 33.9
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 2
|
||||
|
|
@ -74,7 +74,7 @@ Material:
|
|||
- _SinePower: 1.25
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _Speed: 10
|
||||
- _Speed: 15
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ Material:
|
|||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Scale: 0.5
|
||||
- _Scale: 4.8001804
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 427395ce555f40649b294dbc76cd84b4
|
||||
guid: 4a05bb7e252ad90438c47651bf01d639
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d20256cc7e82c41409096d0f7337479b
|
||||
guid: 1160bd9542584c24f9b140d6356fd375
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
544
Assets/Plugins/AtmosphereScattering/Example/New Scene.unity
Normal file
544
Assets/Plugins/AtmosphereScattering/Example/New Scene.unity
Normal file
|
|
@ -0,0 +1,544 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 8
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 1147614136}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.056427088, g: 0.12670922, b: 0.296874, a: 1}
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 11
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_TemporalCoherenceThreshold: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 9
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_TextureWidth: 1024
|
||||
m_TextureHeight: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ShowResolutionOverlay: 1
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_UseShadowmask: 1
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &7102893
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 7102896}
|
||||
- component: {fileID: 7102895}
|
||||
- component: {fileID: 7102894}
|
||||
- component: {fileID: 7102898}
|
||||
- component: {fileID: 7102897}
|
||||
- component: {fileID: 7102899}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &7102894
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &7102895
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 10000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 0
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &7102896
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -172.5}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &7102897
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ff26db721962cdf4a8edcdfa9a767d2a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
profile: {fileID: 0}
|
||||
--- !u!114 &7102898
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 45d85419f2e23c540999c1a1fee6ed90, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
distance: 10
|
||||
center: {x: 0, y: 0, z: 0}
|
||||
scale: 1
|
||||
distanceSpeed: 0.1
|
||||
rotationSpeed: 0.1
|
||||
--- !u!114 &7102899
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b535dacf702e20c4b9ef528e42081835, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
volumeTexSize: {x: 128, y: 128, z: 32}
|
||||
--- !u!1 &74323546
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 74323548}
|
||||
- component: {fileID: 74323547}
|
||||
- component: {fileID: 74323549}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &74323547
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 74323546}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 8
|
||||
m_Type: 1
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_Lightmapping: 4
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &74323548
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 74323546}
|
||||
m_LocalRotation: {x: -0.03515344, y: -0.86159647, z: 0.50277907, w: 0.060241405}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 59.559002, y: -164.05801, z: 13.835001}
|
||||
--- !u!114 &74323549
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 74323546}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 325c269146dc2ac49b190f730a961573, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
basePosition: {x: 0, y: 50, z: 0}
|
||||
--- !u!1 &297555710
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 297555712}
|
||||
- component: {fileID: 297555711}
|
||||
m_Layer: 0
|
||||
m_Name: GameObject
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &297555711
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 297555710}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e16dd2ddbdfa7ea4f87a3cfb032ffd0f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
progressiveUpdate: 1
|
||||
computeShader: {fileID: 7200000, guid: 2d4396a54b390d742b84d4bb4a122e54, type: 3}
|
||||
outputDebug: 0
|
||||
lutConfig:
|
||||
transmittanceSize: {x: 256, y: 128}
|
||||
scatteringSize: {x: 32, y: 128, z: 32}
|
||||
irradianceSize: {x: 64, y: 32}
|
||||
cameraVolumeSize: {x: 128, y: 128, z: 32}
|
||||
atmosphereConfig: {fileID: 11400000, guid: 8e73e89daf00b8447b2410427953df25, type: 2}
|
||||
--- !u!4 &297555712
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 297555710}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 2.736024, y: 2.8123064, z: -0.70711327}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!21 &1147614136
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Skybox/AtmosphereScatteringPrecomputed
|
||||
m_Shader: {fileID: 4800000, guid: e2088dd19a71d1244976cd0de1ff68a7, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs: []
|
||||
m_Floats: []
|
||||
m_Colors: []
|
||||
--- !u!1 &1729729729
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 1996505793}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 1729729730}
|
||||
m_Layer: 0
|
||||
m_Name: Missing Prefab
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1729729730
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 1996505793}
|
||||
m_GameObject: {fileID: 1729729729}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1764631964
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 1764631968}
|
||||
- component: {fileID: 1764631967}
|
||||
- component: {fileID: 1764631966}
|
||||
- component: {fileID: 1764631965}
|
||||
m_Layer: 0
|
||||
m_Name: Cube
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!23 &1764631965
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1764631964}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_Materials:
|
||||
- {fileID: 10302, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_PreserveUVs: 1
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 0
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!65 &1764631966
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1764631964}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &1764631967
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1764631964}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &1764631968
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1764631964}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -969, y: 1, z: 7922}
|
||||
m_LocalScale: {x: 2000, y: 2000, z: 2000}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &1996505793
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 474104, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 474104, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 474104, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 474104, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 474104, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 474104, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 474104, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 474104, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
propertyPath: m_RootOrder
|
||||
value: 4
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 474104, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 474104, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
propertyPath: m_LocalScale.y
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 474104, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
propertyPath: m_LocalScale.z
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 100100000, guid: d5335c8f26bfe754b960f5d390edcb98, type: 2}
|
||||
m_IsPrefabParent: 0
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 425cca07b3c798944847d3d20dfa7ecb
|
||||
guid: dacf033ff4744d446a53da2400fe27bc
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f6bd1e7de98f4ec42bd5f8801681e5e9
|
||||
guid: 11b97a229abf2df46a16432582b9f95d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Yangrc.AtmosphereScattering {
|
||||
|
||||
public class AerialPerspective : MonoBehaviour {
|
||||
private new Camera camera;
|
||||
private void Start() {
|
||||
camera = GetComponent<Camera>();
|
||||
if ((camera.depthTextureMode & DepthTextureMode.Depth) == 0)
|
||||
camera.depthTextureMode |= DepthTextureMode.Depth;
|
||||
material = new Material(Shader.Find("Hidden/Yangrc/AerialPerspective"));
|
||||
}
|
||||
|
||||
private Material material;
|
||||
|
||||
[ImageEffectOpaque]
|
||||
private void OnRenderImage(RenderTexture source, RenderTexture destination) {
|
||||
material.SetVector("_ProjectionExtents", camera.GetProjectionExtents());
|
||||
Graphics.Blit(source, destination, material, 0);
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
//Control sun intensity.
|
||||
}
|
||||
|
||||
private RenderTexture transmittanceVolume;
|
||||
private RenderTexture scatteringVolume;
|
||||
public Vector3Int volumeTexSize = new Vector3Int(128, 128, 32);
|
||||
|
||||
Vector3[] _FrustumCorners = new Vector3[4];
|
||||
//Generate camera volume texture.
|
||||
private void OnPreRender() {
|
||||
if (RenderSettings.sun == null)
|
||||
return;
|
||||
// get four corners of camera frustom in world space
|
||||
// bottom left
|
||||
_FrustumCorners[0] = camera.ViewportToWorldPoint(new Vector3(0, 0, camera.farClipPlane));
|
||||
// bottom right
|
||||
_FrustumCorners[1] = camera.ViewportToWorldPoint(new Vector3(1, 0, camera.farClipPlane));
|
||||
// top left
|
||||
_FrustumCorners[2] = camera.ViewportToWorldPoint(new Vector3(0, 1, camera.farClipPlane));
|
||||
// top right
|
||||
_FrustumCorners[3] = camera.ViewportToWorldPoint(new Vector3(1, 1, camera.farClipPlane));
|
||||
|
||||
//Render camera volume texture.
|
||||
var projection_matrix = GL.GetGPUProjectionMatrix(camera.projectionMatrix, false);
|
||||
AtmLutHelper.CreateCameraAlignedVolumeTexture(ref transmittanceVolume, ref scatteringVolume, volumeTexSize);
|
||||
AtmLutHelper.UpdateCameraVolume(
|
||||
transmittanceVolume,
|
||||
scatteringVolume,
|
||||
volumeTexSize,
|
||||
transform.position,
|
||||
-RenderSettings.sun.transform.forward,
|
||||
_FrustumCorners,
|
||||
new Vector2(camera.nearClipPlane, camera.farClipPlane)
|
||||
);
|
||||
|
||||
//Set it.
|
||||
Shader.SetGlobalTexture("_CameraVolumeTransmittance", transmittanceVolume);
|
||||
Shader.SetGlobalTexture("_CameraVolumeScattering", scatteringVolume);
|
||||
var vp_matrix = projection_matrix * camera.worldToCameraMatrix;
|
||||
Shader.SetGlobalMatrix("_Camera_VP", vp_matrix);
|
||||
}
|
||||
|
||||
private void OnDisable() {
|
||||
Shader.SetGlobalTexture("_CameraVolumeTransmittance", null);
|
||||
Shader.SetGlobalTexture("_CameraVolumeScattering", null);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CameraExtension {
|
||||
public static Vector4 GetProjectionExtents(this Camera camera, float texelOffsetX, float texelOffsetY) {
|
||||
if (camera == null)
|
||||
return Vector4.zero;
|
||||
|
||||
float oneExtentY = camera.orthographic ? camera.orthographicSize : Mathf.Tan(0.5f * Mathf.Deg2Rad * camera.fieldOfView);
|
||||
float oneExtentX = oneExtentY * camera.aspect;
|
||||
float texelSizeX = oneExtentX / (0.5f * camera.pixelWidth);
|
||||
float texelSizeY = oneExtentY / (0.5f * camera.pixelHeight);
|
||||
float oneJitterX = texelSizeX * texelOffsetX;
|
||||
float oneJitterY = texelSizeY * texelOffsetY;
|
||||
|
||||
return new Vector4(oneExtentX, oneExtentY, oneJitterX, oneJitterY);// xy = frustum extents at distance 1, zw = jitter at distance 1
|
||||
}
|
||||
|
||||
public static Vector4 GetProjectionExtents(this Camera camera) {
|
||||
return GetProjectionExtents(camera, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7d727add5552d4f429e0497a8d6f4cb3
|
||||
guid: b535dacf702e20c4b9ef528e42081835
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
568
Assets/Plugins/AtmosphereScattering/Scripts/AtmLutHelper.cs
Normal file
568
Assets/Plugins/AtmosphereScattering/Scripts/AtmLutHelper.cs
Normal file
|
|
@ -0,0 +1,568 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
namespace Yangrc.AtmosphereScattering {
|
||||
|
||||
public static class HighResolutionDateTime {
|
||||
public static bool IsAvailable { get; private set; }
|
||||
|
||||
[DllImport("Kernel32.dll", CallingConvention = CallingConvention.Winapi)]
|
||||
private static extern void GetSystemTimePreciseAsFileTime(out long filetime);
|
||||
|
||||
public static DateTime UtcNow {
|
||||
get {
|
||||
if (!IsAvailable) {
|
||||
throw new InvalidOperationException(
|
||||
"High resolution clock isn't available.");
|
||||
}
|
||||
|
||||
long filetime;
|
||||
GetSystemTimePreciseAsFileTime(out filetime);
|
||||
|
||||
return DateTime.FromFileTimeUtc(filetime);
|
||||
}
|
||||
}
|
||||
|
||||
static HighResolutionDateTime() {
|
||||
try {
|
||||
long filetime;
|
||||
GetSystemTimePreciseAsFileTime(out filetime);
|
||||
IsAvailable = true;
|
||||
} catch (EntryPointNotFoundException) {
|
||||
// Not running Windows 8 or higher.
|
||||
IsAvailable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ProgressiveLutUpdater {
|
||||
|
||||
public void Cleanup() {
|
||||
var allTextures = new List<RenderTexture> {
|
||||
this.groundIrradianceCombine,
|
||||
this.multiScatteringCombine,
|
||||
this.multiScatteringDensity,
|
||||
|
||||
this.singleMie,
|
||||
this.singleRayleigh,
|
||||
this.transmittance,
|
||||
};
|
||||
allTextures.AddRange(
|
||||
this.groundIrradianceTemp);
|
||||
allTextures.AddRange(
|
||||
this.multiScatteringTemp);
|
||||
|
||||
for (int i = 0; i < allTextures.Count; i++) {
|
||||
if (allTextures[i] != null && allTextures[i].IsCreated())
|
||||
allTextures[i].Release();
|
||||
}
|
||||
}
|
||||
|
||||
public interface ITimeLogger {
|
||||
void Log(string itemName);
|
||||
}
|
||||
|
||||
public AtmosphereConfig atmConfigToUse { get; set; }
|
||||
public AtmosphereConfig atmConfigUsedToUpdate { get; private set; }
|
||||
public AtmLutGenerateConfig lutConfig { get; set; }
|
||||
ITimeLogger logger;
|
||||
public ProgressiveLutUpdater(AtmosphereConfig atmConfig, AtmLutGenerateConfig lutConfig, ITimeLogger logger = null) {
|
||||
this.atmConfigToUse = atmConfig;
|
||||
this.lutConfig = lutConfig;
|
||||
this.logger = logger;
|
||||
working = false;
|
||||
atmConfigUsedToUpdate = ScriptableObject.CreateInstance<AtmosphereConfig>();
|
||||
}
|
||||
public const int k_MultiScatteringOrderDepth = 4;
|
||||
|
||||
public RenderTexture[] groundIrradianceTemp = new RenderTexture[k_MultiScatteringOrderDepth + 1];
|
||||
public RenderTexture multiScatteringDensity;
|
||||
public RenderTexture[] multiScatteringTemp = new RenderTexture[k_MultiScatteringOrderDepth + 1];
|
||||
|
||||
public RenderTexture transmittance;
|
||||
public RenderTexture singleRayleigh, singleMie;
|
||||
public RenderTexture multiScatteringCombine, groundIrradianceCombine;
|
||||
internal string name;
|
||||
|
||||
public bool working { get; private set; }
|
||||
|
||||
private void Log(string t) {
|
||||
if (this.logger != null)
|
||||
logger.Log(t);
|
||||
}
|
||||
|
||||
public IEnumerator UpdateCoroutine() {
|
||||
working = true;
|
||||
atmConfigUsedToUpdate.CopyDataFrom(atmConfigToUse);
|
||||
AtmLutHelper.CreateTransmittanceTexture(ref transmittance, lutConfig);
|
||||
using (new ConvenientStopwatch("Complete Lut update timecost", Log)) {
|
||||
//Update transmittance.
|
||||
AtmLutHelper.ApplyComputeShaderParams(lutConfig, atmConfigUsedToUpdate);
|
||||
using (new ConvenientStopwatch("Transmittance ", Log)) {
|
||||
AtmLutHelper.UpdateTransmittance(
|
||||
transmittance,
|
||||
lutConfig,
|
||||
0.0f,
|
||||
1.0f
|
||||
);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
//Update GroundDirect
|
||||
using (new ConvenientStopwatch("GroundDirect", Log)) {
|
||||
AtmLutHelper.ApplyComputeShaderParams(lutConfig, atmConfigUsedToUpdate);
|
||||
AtmLutHelper.CreateGroundIrradianceTexture(ref groundIrradianceTemp[0], 0, lutConfig);
|
||||
AtmLutHelper.UpdateGroundDirectIrradiance(groundIrradianceTemp[0], transmittance, lutConfig, 0.0f, 1.0f);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
//Update SingleRayleigh/Mie
|
||||
using (new ConvenientStopwatch("Single Rayleigh/Mie", Log)) {
|
||||
AtmLutHelper.ApplyComputeShaderParams(lutConfig, atmConfigUsedToUpdate);
|
||||
AtmLutHelper.CreateSingleRayleighMieTexture(ref singleRayleigh, ref singleMie, lutConfig);
|
||||
AtmLutHelper.UpdateSingleRayleighMie(singleRayleigh, singleMie, transmittance, lutConfig);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
AtmLutHelper.CreateMultiScatteringTexture(ref multiScatteringTemp[1], 1, lutConfig); //This texture is not "Meaningful"(Since the 1-st order should be SingleRayleigh and SingleMie, and this tex won't be used in actual computation either), but we need to make an empty one to avoid shader error.
|
||||
|
||||
using (new ConvenientStopwatch("GroundIrradiance 1", Log)) {
|
||||
//Ground irradiance of 1-st order scattering.
|
||||
AtmLutHelper.ApplyComputeShaderParams(lutConfig, atmConfigUsedToUpdate);
|
||||
AtmLutHelper.CreateGroundIrradianceTexture(ref groundIrradianceTemp[1], 1, lutConfig);
|
||||
AtmLutHelper.UpdateGroundIrradiance(groundIrradianceTemp[1], singleRayleigh, singleMie, multiScatteringTemp[1], 1, lutConfig, 0.0f, 1.0f);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
//Real game start.
|
||||
AtmLutHelper.CreateMultiScatteringDensityTexture(ref multiScatteringDensity, lutConfig);
|
||||
|
||||
for (int i = 2; i <= k_MultiScatteringOrderDepth; i++) {
|
||||
using (new ConvenientStopwatch("Multi Scattering Density" + i, Log)) {
|
||||
AtmLutHelper.ApplyComputeShaderParams(lutConfig, atmConfigUsedToUpdate);
|
||||
AtmLutHelper.UpdateMultiScatteringDensity(multiScatteringDensity, transmittance, singleRayleigh, singleMie, multiScatteringTemp[i - 1], groundIrradianceTemp[i - 2], i, lutConfig);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
AtmLutHelper.CreateGroundIrradianceTexture(ref groundIrradianceTemp[i], i, lutConfig);
|
||||
using (new ConvenientStopwatch("Ground Irradiance" + i, Log)) {
|
||||
AtmLutHelper.ApplyComputeShaderParams(lutConfig, atmConfigUsedToUpdate);
|
||||
AtmLutHelper.UpdateGroundIrradiance(groundIrradianceTemp[i], singleRayleigh, singleMie, multiScatteringTemp[i - 1], i - 1, lutConfig);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
AtmLutHelper.CreateMultiScatteringTexture(ref multiScatteringTemp[i], i, lutConfig);
|
||||
using (new ConvenientStopwatch("Multi Scattering " + i, Log)) {
|
||||
AtmLutHelper.ApplyComputeShaderParams(lutConfig, atmConfigUsedToUpdate);
|
||||
AtmLutHelper.UpdateMultiScatteringCombineDensity(multiScatteringTemp[i], transmittance, multiScatteringDensity, lutConfig);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
//Combine our multiscattering texture.
|
||||
AtmLutHelper.CreateFinalCombinedTexture(ref multiScatteringCombine, ref groundIrradianceCombine, lutConfig);
|
||||
AtmLutHelper.ClearFinalCombinedMultiScatter(multiScatteringCombine, lutConfig);
|
||||
AtmLutHelper.ClearFinalCombinedIrradiance(groundIrradianceCombine, lutConfig);
|
||||
|
||||
AtmLutHelper.ApplyComputeShaderParams(lutConfig, atmConfigUsedToUpdate);
|
||||
for (int i = 2; i <= k_MultiScatteringOrderDepth; i++) {
|
||||
AtmLutHelper.UpdateFinalCombinedMultiScatter(multiScatteringCombine, multiScatteringTemp[i], lutConfig);
|
||||
}
|
||||
|
||||
for (int i = 1; i <= k_MultiScatteringOrderDepth; i++) {
|
||||
AtmLutHelper.UpdateFinalCombinedIrradiance(groundIrradianceCombine, groundIrradianceTemp[i], lutConfig);
|
||||
}
|
||||
}
|
||||
//All calculations are done.
|
||||
|
||||
/* DON"T RELEASE TEMP TEXTURES HERE, IT WILL CAUSE GRAPHICS GLITCH(FLASHING) WHEN RENDERING SKYBOX. I DON'T KNOW WHY.(2017.4.11f1) */
|
||||
/* AND THAT GLITCH COST ME 4 HOURS TO FIND OUT, THANK YOU UNITY */
|
||||
/* I guess that after combine dispatch call, the process isn't finished immediately, if we release the textures right now, it will blow up. */
|
||||
/* but I tried to wait for a few frame(yield return null), still doesn't work. */
|
||||
////Release all temp textures. They won't be used in the future.
|
||||
//for (int i = 0; i < groundIrradianceTemp.Length; i++) {
|
||||
// if (groundIrradianceTemp[i] != null) {
|
||||
// groundIrradianceTemp[i].Release();
|
||||
// groundIrradianceTemp[i] = null;
|
||||
// }
|
||||
//}
|
||||
//for (int i = 0; i < multiScatteringTemp.Length; i++) {
|
||||
// if (multiScatteringTemp[i] != null) {
|
||||
// multiScatteringTemp[i].Release();
|
||||
// multiScatteringTemp[i] = null;
|
||||
// }
|
||||
//}
|
||||
|
||||
//Done!
|
||||
working = false;
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class AtmLutGenerateConfig {
|
||||
public Vector2Int transmittanceSize = new Vector2Int(512, 512);
|
||||
public Vector3Int scatteringSize = new Vector3Int(32, 32, 128);
|
||||
public Vector2Int irradianceSize = new Vector2Int(32, 32);
|
||||
public Vector3Int cameraVolumeSize = new Vector3Int(128, 128, 32);
|
||||
private static class Keys {
|
||||
private static readonly int transmittanceSize = Shader.PropertyToID("TransmittanceSize");
|
||||
private static readonly int scatteringSize = Shader.PropertyToID("ScatteringSize");
|
||||
private static readonly int irradianceSize = Shader.PropertyToID("IrradianceSize");
|
||||
}
|
||||
public void Apply(ComputeShader shader) {
|
||||
shader.SetInts("TransmittanceSize", transmittanceSize.x, transmittanceSize.y);
|
||||
shader.SetInts("ScatteringSize", scatteringSize.x, scatteringSize.y, scatteringSize.z);
|
||||
shader.SetInts("IrradianceSize", irradianceSize.x, irradianceSize.y);
|
||||
}
|
||||
}
|
||||
|
||||
public class ConvenientStopwatch : System.IDisposable {
|
||||
public ConvenientStopwatch(string name, System.Action<string> Log = null) {
|
||||
this.name = name;
|
||||
start = HighResolutionDateTime.UtcNow;
|
||||
this.Log = Log;
|
||||
}
|
||||
System.Action<string> Log;
|
||||
DateTime start;
|
||||
string name;
|
||||
public void Dispose() {
|
||||
var timeSpan = HighResolutionDateTime.UtcNow - start;
|
||||
if (Log != null)
|
||||
Log(name + ":" + timeSpan.TotalMilliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AtmLutHelper {
|
||||
|
||||
public static void Init(ComputeShader shader) {
|
||||
if (computeShader == null) {
|
||||
AtmLutHelper.computeShader = shader;
|
||||
SetupKernals(computeShader);
|
||||
}
|
||||
}
|
||||
|
||||
public static ComputeShader computeShader;
|
||||
private static int CalculateTransmittanceLUT;
|
||||
private static int CalculateSingleScatteringLUT;
|
||||
private static int CalculateGroundDirectIrradianceLUT;
|
||||
private static int CalculateGroundIndirectIrradianceLUT;
|
||||
private static int CalculateMultipleScatteringDensityLUT;
|
||||
private static int CalculateMultipleScatteringLUT;
|
||||
private static int SumGroundIrradianceLUT;
|
||||
private static int SumMultipleScatteringLUT;
|
||||
private static int ClearCombineGroundIrradianceLUT;
|
||||
private static int ClearCombineMultipleScatteringLUT;
|
||||
|
||||
private static int CalculateCameraScatteringVolume;
|
||||
|
||||
/// <summary>
|
||||
/// These functions help do all the "SetXXX" stuff.
|
||||
/// So we can focus on how to generate Luts.
|
||||
/// </summary>
|
||||
|
||||
private static void SetupKernals(ComputeShader computeShader) {
|
||||
CalculateTransmittanceLUT = computeShader.FindKernel("CalculateTransmittanceLUT");
|
||||
CalculateSingleScatteringLUT = computeShader.FindKernel("CalculateSingleScatteringLUT");
|
||||
CalculateGroundDirectIrradianceLUT = computeShader.FindKernel("CalculateGroundDirectIrradianceLUT");
|
||||
CalculateGroundIndirectIrradianceLUT = computeShader.FindKernel("CalculateGroundIndirectIrradianceLUT");
|
||||
CalculateMultipleScatteringDensityLUT = computeShader.FindKernel("CalculateMultipleScatteringDensityLUT");
|
||||
CalculateMultipleScatteringLUT = computeShader.FindKernel("CalculateMultipleScatteringLUT");
|
||||
SumGroundIrradianceLUT = computeShader.FindKernel("CombineGroundIrradianceLUT");
|
||||
SumMultipleScatteringLUT = computeShader.FindKernel("CombineMultipleScatteringLUT");
|
||||
ClearCombineGroundIrradianceLUT = computeShader.FindKernel("ClearCombineGroundIrradianceLUT");
|
||||
ClearCombineMultipleScatteringLUT = computeShader.FindKernel("ClearCombineMultipleScatteringLUT");
|
||||
|
||||
CalculateCameraScatteringVolume = computeShader.FindKernel("CalculateCameraScatteringVolume");
|
||||
}
|
||||
|
||||
public static void ApplyComputeShaderParams(AtmLutGenerateConfig lutConfig, AtmosphereConfig atmConfig) {
|
||||
lutConfig.Apply(computeShader);
|
||||
atmConfig.Apply(computeShader);
|
||||
}
|
||||
|
||||
private static void CreateLUT(ref RenderTexture result, string name, int width, int height, int zsize, RenderTextureFormat format, bool forceReplace = false) {
|
||||
if (result != null) {
|
||||
if (!forceReplace && result.name == name && result.width == width && result.height == height && result.volumeDepth == zsize && result.format == format)
|
||||
return;
|
||||
result.Release();
|
||||
}
|
||||
result = new RenderTexture(width, height, 0, format, RenderTextureReadWrite.Linear);
|
||||
result.name = name;
|
||||
result.enableRandomWrite = true;
|
||||
if (zsize > 0) {
|
||||
result.dimension = UnityEngine.Rendering.TextureDimension.Tex3D;
|
||||
result.volumeDepth = zsize;
|
||||
} else {
|
||||
result.dimension = UnityEngine.Rendering.TextureDimension.Tex2D;
|
||||
}
|
||||
result.filterMode = FilterMode.Bilinear;
|
||||
result.wrapMode = TextureWrapMode.Clamp;
|
||||
result.Create();
|
||||
}
|
||||
|
||||
private static void NormalizeProgressPointer(float start, float end, int length, out int startInt, out int endInt) {
|
||||
if (end < start) {
|
||||
var t = start;
|
||||
start = end;
|
||||
end = t;
|
||||
}
|
||||
|
||||
start = Mathf.Clamp01(start);
|
||||
end = Mathf.Clamp01(end);
|
||||
startInt = Mathf.RoundToInt(length * start);
|
||||
endInt = Mathf.RoundToInt(length * end);
|
||||
}
|
||||
|
||||
public static void CreateTransmittanceTexture(
|
||||
ref RenderTexture target,
|
||||
AtmLutGenerateConfig lutconfig) {
|
||||
CreateLUT(ref target, "Transmittance", lutconfig.transmittanceSize.x, lutconfig.transmittanceSize.y, 0, RenderTextureFormat.ARGBFloat);
|
||||
}
|
||||
|
||||
public static void CreateSingleRayleighMieTexture(ref RenderTexture rayleigh, ref RenderTexture mie, AtmLutGenerateConfig lutconfig) {
|
||||
CreateLUT(ref rayleigh, "SingleMie", lutconfig.scatteringSize.x, lutconfig.scatteringSize.y, lutconfig.scatteringSize.z, RenderTextureFormat.ARGBFloat);
|
||||
CreateLUT(ref mie, "SingleRayleigh", lutconfig.scatteringSize.x, lutconfig.scatteringSize.y, lutconfig.scatteringSize.z, RenderTextureFormat.ARGBFloat);
|
||||
}
|
||||
|
||||
public static void CreateGroundIrradianceTexture(ref RenderTexture target, int order, AtmLutGenerateConfig lutconfig) {
|
||||
CreateLUT(ref target, "Ground Irrdiance Order " + order, lutconfig.irradianceSize.x, lutconfig.irradianceSize.y, 0, RenderTextureFormat.ARGBFloat);
|
||||
}
|
||||
|
||||
public static void CreateMultiScatteringDensityTexture(
|
||||
ref RenderTexture result,
|
||||
AtmLutGenerateConfig lutConfig
|
||||
) {
|
||||
CreateLUT(ref result, "MultiScatteringDensity", lutConfig.scatteringSize.x, lutConfig.scatteringSize.y, lutConfig.scatteringSize.z, RenderTextureFormat.ARGBFloat);
|
||||
}
|
||||
|
||||
public static void CreateMultiScatteringTexture(
|
||||
ref RenderTexture result,
|
||||
int order,
|
||||
AtmLutGenerateConfig lutConfig
|
||||
) {
|
||||
CreateLUT(ref result, "MultiScattering " + order, lutConfig.scatteringSize.x, lutConfig.scatteringSize.y, lutConfig.scatteringSize.z, RenderTextureFormat.ARGBFloat);
|
||||
}
|
||||
|
||||
public static void CreateFinalCombinedTexture(
|
||||
ref RenderTexture MultipleScatteringLUT,
|
||||
ref RenderTexture IrradianceLUT,
|
||||
AtmLutGenerateConfig lutConfig
|
||||
) {
|
||||
CreateLUT(ref MultipleScatteringLUT, "Multiple Scattering Combined Final", lutConfig.scatteringSize.x, lutConfig.scatteringSize.y, lutConfig.scatteringSize.z, RenderTextureFormat.ARGBFloat, true);
|
||||
CreateLUT(ref IrradianceLUT, "Irradiance Combined Final", lutConfig.irradianceSize.x, lutConfig.irradianceSize.y, 0, RenderTextureFormat.ARGBFloat, true);
|
||||
}
|
||||
|
||||
public static void CreateCameraAlignedVolumeTexture(
|
||||
ref RenderTexture transmittance,
|
||||
ref RenderTexture scattering,
|
||||
Vector3Int volumeTexSize
|
||||
) {
|
||||
CreateLUT(ref transmittance,
|
||||
"CameraVolumeTransmittance",
|
||||
volumeTexSize.x,
|
||||
volumeTexSize.y,
|
||||
volumeTexSize.z,
|
||||
RenderTextureFormat.ARGBFloat,
|
||||
false);
|
||||
CreateLUT(ref scattering,
|
||||
"CameraVolumeScattering",
|
||||
volumeTexSize.x,
|
||||
volumeTexSize.y,
|
||||
volumeTexSize.z,
|
||||
RenderTextureFormat.ARGBFloat,
|
||||
false);
|
||||
}
|
||||
|
||||
public static void UpdateTransmittance(
|
||||
RenderTexture target,
|
||||
AtmLutGenerateConfig lutConfig,
|
||||
float start = 0.0f,
|
||||
float end = 1.0f
|
||||
) {
|
||||
int xStart, xEnd;
|
||||
NormalizeProgressPointer(start, end, lutConfig.transmittanceSize.x / 32, out xStart, out xEnd);
|
||||
computeShader.SetInts("_ThreadOffset", xStart, 0, 0);
|
||||
computeShader.SetTexture(CalculateTransmittanceLUT, "TransmittanceLUTResult", target);
|
||||
computeShader.Dispatch(CalculateTransmittanceLUT, xEnd - xStart, lutConfig.transmittanceSize.y / 32, 1);
|
||||
}
|
||||
|
||||
public static void UpdateSingleRayleighMie(
|
||||
RenderTexture rayleightarget,
|
||||
RenderTexture mietarget,
|
||||
RenderTexture TransmittanceLUT,
|
||||
AtmLutGenerateConfig lutConfig,
|
||||
float start = 0.0f,
|
||||
float end = 1.0f
|
||||
) {
|
||||
|
||||
int xStart, xEnd;
|
||||
NormalizeProgressPointer(start, end, lutConfig.scatteringSize.x / 8, out xStart, out xEnd);
|
||||
computeShader.SetInts("_ThreadOffset", xStart, 0, 0);
|
||||
|
||||
computeShader.SetTexture(CalculateSingleScatteringLUT, "TransmittanceLUT", TransmittanceLUT);
|
||||
computeShader.SetTexture(CalculateSingleScatteringLUT, "SingleScatteringMieLUTResult", mietarget);
|
||||
computeShader.SetTexture(CalculateSingleScatteringLUT, "SingleScatteringRayleighLUTResult", rayleightarget);
|
||||
|
||||
computeShader.Dispatch(CalculateSingleScatteringLUT, xEnd - xStart, lutConfig.scatteringSize.y / 8, lutConfig.scatteringSize.z / 8);
|
||||
}
|
||||
|
||||
public static void UpdateGroundDirectIrradiance(
|
||||
RenderTexture target,
|
||||
RenderTexture TransmittanceLUT,
|
||||
AtmLutGenerateConfig lutConfig,
|
||||
float start = 0.0f,
|
||||
float end = 1.0f
|
||||
) {
|
||||
int xStart, xEnd;
|
||||
NormalizeProgressPointer(start, end, lutConfig.irradianceSize.x / 32, out xStart, out xEnd);
|
||||
computeShader.SetInts("_ThreadOffset", xStart, 0, 0);
|
||||
|
||||
computeShader.SetTexture(CalculateGroundDirectIrradianceLUT, "TransmittanceLUT", TransmittanceLUT);
|
||||
computeShader.SetTexture(CalculateGroundDirectIrradianceLUT, "GroundDirectIrradianceResult", target);
|
||||
computeShader.Dispatch(CalculateGroundDirectIrradianceLUT, xEnd - xStart, lutConfig.irradianceSize.y / 32, 1);
|
||||
}
|
||||
|
||||
public static void UpdateGroundIrradiance(
|
||||
RenderTexture target,
|
||||
RenderTexture singleRayleigh,
|
||||
RenderTexture singleMie,
|
||||
RenderTexture multiScattering,
|
||||
int scatteringOrder,
|
||||
AtmLutGenerateConfig lutConfig,
|
||||
float start = 0.0f,
|
||||
float end = 1.0f
|
||||
) {
|
||||
int xStart, xEnd;
|
||||
NormalizeProgressPointer(start, end, lutConfig.irradianceSize.x / 32, out xStart, out xEnd);
|
||||
computeShader.SetInts("_ThreadOffset", xStart, 0, 0);
|
||||
|
||||
computeShader.SetInt("ScatteringOrder", scatteringOrder);
|
||||
computeShader.SetTexture(CalculateGroundIndirectIrradianceLUT, "SingleRayleighScatteringLUT", singleRayleigh);
|
||||
computeShader.SetTexture(CalculateGroundIndirectIrradianceLUT, "SingleMieScatteringLUT", singleMie);
|
||||
computeShader.SetTexture(CalculateGroundIndirectIrradianceLUT, "MultipleScatteringLUT", multiScattering);
|
||||
computeShader.SetTexture(CalculateGroundIndirectIrradianceLUT, "GroundIndirectIrradianceResult", target);
|
||||
computeShader.Dispatch(CalculateGroundIndirectIrradianceLUT, xEnd - xStart, lutConfig.irradianceSize.y / 32, 1);
|
||||
}
|
||||
|
||||
public static void UpdateMultiScatteringDensity(
|
||||
RenderTexture target,
|
||||
RenderTexture TransmittanceLUT,
|
||||
RenderTexture SingleScatteringLUTRayleigh,
|
||||
RenderTexture SingleScatteringLUTMie,
|
||||
RenderTexture MultiScatteringOfLastOrder,
|
||||
RenderTexture GroundDirectIrradianceLUT,
|
||||
int scatteringOrder,
|
||||
AtmLutGenerateConfig lutConfig,
|
||||
float start = 0.0f,
|
||||
float end = 1.0f
|
||||
) {
|
||||
int xStart, xEnd;
|
||||
NormalizeProgressPointer(start, end, lutConfig.scatteringSize.x / 8, out xStart, out xEnd);
|
||||
computeShader.SetInts("_ThreadOffset", xStart, 0, 0);
|
||||
|
||||
computeShader.SetTexture(CalculateMultipleScatteringDensityLUT, "TransmittanceLUT", TransmittanceLUT);
|
||||
computeShader.SetTexture(CalculateMultipleScatteringDensityLUT, "SingleRayleighScatteringLUT", SingleScatteringLUTRayleigh);
|
||||
computeShader.SetTexture(CalculateMultipleScatteringDensityLUT, "SingleMieScatteringLUT", SingleScatteringLUTMie);
|
||||
computeShader.SetTexture(CalculateMultipleScatteringDensityLUT, "IrradianceLUT", GroundDirectIrradianceLUT);
|
||||
computeShader.SetTexture(CalculateMultipleScatteringDensityLUT, "MultipleScatteringLUT", MultiScatteringOfLastOrder);
|
||||
computeShader.SetInt("ScatteringOrder", scatteringOrder);
|
||||
computeShader.SetTexture(CalculateMultipleScatteringDensityLUT, "MultipleScatteringDensityResult", target);
|
||||
computeShader.Dispatch(CalculateMultipleScatteringDensityLUT, xEnd - xStart, lutConfig.scatteringSize.y / 8, lutConfig.scatteringSize.z / 8);
|
||||
}
|
||||
|
||||
|
||||
public static void UpdateMultiScatteringCombineDensity(
|
||||
RenderTexture target,
|
||||
RenderTexture TransmittanceLUT,
|
||||
RenderTexture multipleScatteringDensity,
|
||||
AtmLutGenerateConfig lutConfig,
|
||||
float start = 0.0f,
|
||||
float end = 1.0f
|
||||
) {
|
||||
int xStart, xEnd;
|
||||
NormalizeProgressPointer(start, end, lutConfig.scatteringSize.x / 8, out xStart, out xEnd);
|
||||
computeShader.SetInts("_ThreadOffset", xStart, 0, 0);
|
||||
|
||||
computeShader.SetTexture(CalculateMultipleScatteringLUT, "TransmittanceLUT", TransmittanceLUT);
|
||||
computeShader.SetTexture(CalculateMultipleScatteringLUT, "MultipleScatteringDensityLUT", multipleScatteringDensity);
|
||||
computeShader.SetTexture(CalculateMultipleScatteringLUT, "MultipleScatteringResult", target);
|
||||
computeShader.Dispatch(CalculateMultipleScatteringLUT, xEnd - xStart, lutConfig.scatteringSize.y / 8, lutConfig.scatteringSize.z / 8);
|
||||
}
|
||||
|
||||
public static void ClearFinalCombinedMultiScatter(
|
||||
RenderTexture multiScatteringTarget,
|
||||
AtmLutGenerateConfig lutConfig
|
||||
) {
|
||||
computeShader.SetTexture(ClearCombineMultipleScatteringLUT, "ScatteringSumTarget", multiScatteringTarget);
|
||||
computeShader.Dispatch(ClearCombineMultipleScatteringLUT, lutConfig.scatteringSize.x / 8, lutConfig.scatteringSize.y / 8, lutConfig.scatteringSize.z / 8);
|
||||
}
|
||||
|
||||
public static void UpdateFinalCombinedMultiScatter(
|
||||
RenderTexture multiScatteringTarget,
|
||||
RenderTexture multiScatteringOfSingleOrder,
|
||||
AtmLutGenerateConfig lutConfig
|
||||
) {
|
||||
computeShader.SetTexture(SumMultipleScatteringLUT, "ScatteringSumTarget", multiScatteringTarget);
|
||||
computeShader.SetTexture(SumMultipleScatteringLUT, "ScatteringSumAdd", multiScatteringOfSingleOrder);
|
||||
computeShader.Dispatch(SumMultipleScatteringLUT, lutConfig.scatteringSize.x / 8, lutConfig.scatteringSize.y / 8, lutConfig.scatteringSize.z / 8);
|
||||
}
|
||||
|
||||
public static void ClearFinalCombinedIrradiance(
|
||||
RenderTexture target,
|
||||
AtmLutGenerateConfig lutConfig
|
||||
) {
|
||||
computeShader.SetTexture(ClearCombineGroundIrradianceLUT, "GroundIrradianceSumTarget", target);
|
||||
computeShader.Dispatch(ClearCombineGroundIrradianceLUT, lutConfig.irradianceSize.x / 32, lutConfig.irradianceSize.y / 32, 1);
|
||||
}
|
||||
|
||||
public static void UpdateFinalCombinedIrradiance(
|
||||
RenderTexture target,
|
||||
RenderTexture irradianceOfSingleOrder,
|
||||
AtmLutGenerateConfig lutConfig
|
||||
) {
|
||||
computeShader.SetTexture(SumGroundIrradianceLUT, "GroundIrradianceSumTarget", target);
|
||||
computeShader.SetTexture(SumGroundIrradianceLUT, "GroundIrradianceSumAdder", irradianceOfSingleOrder);
|
||||
computeShader.Dispatch(SumGroundIrradianceLUT, lutConfig.irradianceSize.x / 32, lutConfig.irradianceSize.y / 32, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate camera frustrum aligned volume.
|
||||
/// See frostbite slider for more.
|
||||
/// </summary>
|
||||
/// <param name="transmittanceTarget">Target to store transmittance</param>
|
||||
/// <param name="scatteringTarget">Target to store scattering</param>
|
||||
/// <param name="volumeSize">Volume tex size, used to determine dispatch call params</param>
|
||||
/// <param name="cameraPos">Camera world pos</param>
|
||||
/// <param name="sunDirection">Sun direction(pointing towards sun)</param>
|
||||
/// <param name="frustrumCorners">four corners of camera frustrum(bl, br, tl, tr). We can't use projection matrix since we divide depth equal range, so we manually interpolate uvw using these corners and near/far plane</param>
|
||||
/// <param name="nearFarPlane">Near and far plane distance</param>
|
||||
public static void UpdateCameraVolume(
|
||||
RenderTexture transmittanceTarget,
|
||||
RenderTexture scatteringTarget,
|
||||
Vector3Int volumeSize,
|
||||
Vector3 cameraPos,
|
||||
Vector3 sunDirection,
|
||||
Vector3[] frustrumCorners,
|
||||
Vector2 nearFarPlane
|
||||
) {
|
||||
//Here we need calculated lerpable luts. This kinda break the code sepration. Any better idea?
|
||||
AtmosphereScatteringLutManager.instance.UpdateComputeShaderValueForLerpedAp(computeShader, CalculateCameraScatteringVolume);
|
||||
|
||||
computeShader.SetTexture(CalculateCameraScatteringVolume, "CameraVolumeTransmittance", transmittanceTarget);
|
||||
computeShader.SetTexture(CalculateCameraScatteringVolume, "CameraVolumeScattering", scatteringTarget);
|
||||
computeShader.SetVector("_CameraPos", cameraPos);
|
||||
computeShader.SetVector("_SunDir", sunDirection);
|
||||
|
||||
computeShader.SetVector("_CamBotLeft", frustrumCorners[0]);
|
||||
computeShader.SetVector("_CamBotRight", frustrumCorners[1]);
|
||||
computeShader.SetVector("_CamTopLeft", frustrumCorners[2]);
|
||||
computeShader.SetVector("_CamTopRight", frustrumCorners[3]);
|
||||
computeShader.SetVector("_NearFarPlane", nearFarPlane);
|
||||
computeShader.Dispatch(CalculateCameraScatteringVolume, volumeSize.x / 8, volumeSize.y / 8, volumeSize.z / 8);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e339e26fd91eb8c40b1a28af9b70a1ce
|
||||
guid: 31d43eddaa5ab52468dfdf0df4f69d6a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
111
Assets/Plugins/AtmosphereScattering/Scripts/AtmosphereConfig.cs
Normal file
111
Assets/Plugins/AtmosphereScattering/Scripts/AtmosphereConfig.cs
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Yangrc.AtmosphereScattering {
|
||||
[CreateAssetMenu]
|
||||
public class AtmosphereConfig : ScriptableObject {
|
||||
|
||||
static readonly Vector3 OZoneConst = 6e-7f * new Vector3(3.426f, 8.298f, 0.356f);
|
||||
static readonly Vector3 RayleighScatteringConst = 1e-6f * new Vector3(5.8f, 13.5f, 33.1f);
|
||||
static readonly float MieScatteringConst = 2e-6f;
|
||||
|
||||
private static class Keys {
|
||||
public static int atmosphere_top_radius = Shader.PropertyToID("atmosphere_top_radius");
|
||||
public static int atmosphere_bot_radius = Shader.PropertyToID("atmosphere_bot_radius");
|
||||
public static int atmosphere_sun_angular_radius = Shader.PropertyToID("atmosphere_sun_angular_radius");
|
||||
public static int rayleigh_scattering = Shader.PropertyToID("rayleigh_scattering");
|
||||
public static int rayleigh_scale_height = Shader.PropertyToID("rayleigh_scale_height");
|
||||
public static int mie_scattering = Shader.PropertyToID("mie_scattering");
|
||||
public static int mie_extinction = Shader.PropertyToID("mie_extinction");
|
||||
public static int mie_scale_height = Shader.PropertyToID("mie_scale_height");
|
||||
public static int mie_phase_function_g = Shader.PropertyToID("mie_phase_function_g");
|
||||
public static int absorption_extinction = Shader.PropertyToID("absorption_extinction");
|
||||
public static int absorption_extinction_scale_height = Shader.PropertyToID("absorption_extinction_scale_height");
|
||||
public static int lightingScale = Shader.PropertyToID("_LightScale");
|
||||
public static int sunIrradianceOnAtm = Shader.PropertyToID("_SunIrradianceOnAtm");
|
||||
}
|
||||
|
||||
public void Apply(Material mat) {
|
||||
Shader.SetGlobalFloat(Keys.atmosphere_top_radius, atmosphere_top_radius);
|
||||
Shader.SetGlobalFloat(Keys.atmosphere_bot_radius, atmosphere_bot_radius);
|
||||
Shader.SetGlobalFloat(Keys.atmosphere_sun_angular_radius, atmosphere_sun_angular_radius);
|
||||
Shader.SetGlobalVector(Keys.rayleigh_scattering, rayleigh_scattering_spectrum);
|
||||
Shader.SetGlobalFloat(Keys.rayleigh_scale_height, rayleigh_scale_height);
|
||||
Shader.SetGlobalFloat(Keys.mie_scattering, atmosphereDensity * mie_scattering * MieScatteringConst);
|
||||
Shader.SetGlobalFloat(Keys.mie_extinction, mie_extinction_spectrum);
|
||||
Shader.SetGlobalFloat(Keys.mie_scale_height, mie_scale_height);
|
||||
Shader.SetGlobalFloat(Keys.mie_phase_function_g, mie_phase_function_g);
|
||||
Shader.SetGlobalVector(Keys.absorption_extinction, ozone_extinction_spectrum);
|
||||
Shader.SetGlobalFloat(Keys.absorption_extinction_scale_height, ozone_scale_height);
|
||||
Shader.SetGlobalFloat(Keys.lightingScale, LightingScale);
|
||||
Shader.SetGlobalVector(Keys.sunIrradianceOnAtm, sunIrradianceOnAtmosphere);
|
||||
}
|
||||
|
||||
public void Apply(ComputeShader shader) {
|
||||
shader.SetFloat(Keys.atmosphere_top_radius, atmosphere_top_radius);
|
||||
shader.SetFloat(Keys.atmosphere_bot_radius, atmosphere_bot_radius);
|
||||
shader.SetFloat(Keys.atmosphere_sun_angular_radius, atmosphere_sun_angular_radius);
|
||||
shader.SetVector(Keys.rayleigh_scattering, rayleigh_scattering_spectrum);
|
||||
shader.SetFloat(Keys.rayleigh_scale_height, rayleigh_scale_height);
|
||||
shader.SetFloat(Keys.mie_scattering, atmosphereDensity * mie_scattering * MieScatteringConst);
|
||||
shader.SetFloat(Keys.mie_extinction, mie_extinction_spectrum);
|
||||
shader.SetFloat(Keys.mie_scale_height, mie_scale_height);
|
||||
shader.SetFloat(Keys.mie_phase_function_g, mie_phase_function_g);
|
||||
shader.SetVector(Keys.absorption_extinction, ozone_extinction_spectrum);
|
||||
shader.SetFloat(Keys.absorption_extinction_scale_height, ozone_scale_height);
|
||||
shader.SetVector(Keys.sunIrradianceOnAtm, sunIrradianceOnAtmosphere);
|
||||
}
|
||||
|
||||
public float atmosphereDensity = 1.0f;
|
||||
public Vector3 sunIrradianceOnAtmosphere = new Vector3(1.0f, 1.0f, 1.0f);
|
||||
public float LightingScale = 2.0f * 3.1415926f;
|
||||
public float atmosphere_top_radius = 6.36e6f + 6e4f;
|
||||
public float atmosphere_bot_radius = 6.36e6f;
|
||||
public float atmosphere_sun_angular_radius = 0.0087f;
|
||||
public float rayleigh_scattering = 1.0f;
|
||||
public float rayleigh_scale_height = 8000.0f;
|
||||
public Vector3 rayleigh_scattering_spectrum {
|
||||
get {
|
||||
return atmosphereDensity * rayleigh_scattering * RayleighScatteringConst;
|
||||
}
|
||||
}
|
||||
public Vector3 ozone_extinction_spectrum {
|
||||
get {
|
||||
return atmosphereDensity * OZoneConst * ozone_extinction;
|
||||
}
|
||||
}
|
||||
public float mie_scattering = 1.0f;
|
||||
public float mie_extinction {
|
||||
get {
|
||||
return mie_scattering * 1.1f;
|
||||
}
|
||||
}
|
||||
public float mie_extinction_spectrum {
|
||||
get {
|
||||
return atmosphereDensity * mie_extinction * MieScatteringConst;
|
||||
}
|
||||
}
|
||||
public float mie_scale_height = 1200.0f;
|
||||
public float mie_phase_function_g = 0.8f;
|
||||
public float ozone_extinction = 1.0f;
|
||||
public float ozone_scale_height = 1000.0f;
|
||||
|
||||
public void CopyDataFrom(AtmosphereConfig config) {
|
||||
this.atmosphereDensity = config.atmosphereDensity;
|
||||
this.LightingScale = config.LightingScale;
|
||||
this.sunIrradianceOnAtmosphere = config.sunIrradianceOnAtmosphere;
|
||||
this.atmosphere_top_radius = config.atmosphere_top_radius;
|
||||
this.atmosphere_bot_radius = config.atmosphere_bot_radius;
|
||||
this.atmosphere_sun_angular_radius = config.atmosphere_sun_angular_radius;
|
||||
this.rayleigh_scattering = config.rayleigh_scattering;
|
||||
this.rayleigh_scale_height = config.rayleigh_scale_height;
|
||||
this.mie_scattering = config.mie_scattering;
|
||||
this.mie_scale_height = config.mie_scale_height;
|
||||
this.mie_phase_function_g = config.mie_phase_function_g;
|
||||
this.ozone_extinction = config.ozone_extinction;
|
||||
this.ozone_scale_height = config.ozone_scale_height;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: beacbddfe55891249bea826bc322015f
|
||||
guid: a909801085fa7db47939f4858f8f7a1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Yangrc.AtmosphereScattering {
|
||||
[ExecuteInEditMode]
|
||||
public class AtmosphereScatteringLutManager : MonoBehaviour , ProgressiveLutUpdater.ITimeLogger{
|
||||
public static AtmosphereScatteringLutManager instance {
|
||||
get {
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
private static AtmosphereScatteringLutManager _instance;
|
||||
public bool progressiveUpdate;
|
||||
[SerializeField]
|
||||
private ComputeShader computeShader;
|
||||
[SerializeField]
|
||||
private bool outputDebug = false;
|
||||
public AtmLutGenerateConfig lutConfig;
|
||||
public AtmosphereConfig atmosphereConfig;
|
||||
[System.NonSerialized]
|
||||
public Material skyboxMaterial;
|
||||
|
||||
//We prepare 3 updater, the 0-index one is "currently updating", 1-index is "just updated", and 2-index is the oldest one.
|
||||
//During rendering, we interpolate 1 and 2, and updating 0.
|
||||
private ProgressiveLutUpdater[] pingPongUpdaters = new ProgressiveLutUpdater[3];
|
||||
|
||||
public ProgressiveLutUpdater newestLut { get {
|
||||
return pingPongUpdaters[1];
|
||||
} }
|
||||
public ProgressiveLutUpdater oldLut {
|
||||
get {
|
||||
return pingPongUpdaters[2];
|
||||
}
|
||||
}
|
||||
|
||||
//Shift all updater to one right.
|
||||
private void RotatePingpongUpdater() {
|
||||
var temp = pingPongUpdaters[pingPongUpdaters.Length-1];
|
||||
for (int i = pingPongUpdaters.Length - 1; i > 0; i--) {
|
||||
pingPongUpdaters[i] = pingPongUpdaters[i - 1];
|
||||
}
|
||||
pingPongUpdaters[0] = temp;
|
||||
}
|
||||
|
||||
private void Awake() {
|
||||
if (_instance != null) {
|
||||
throw new System.InvalidOperationException("AtmosphereScatteringLutManager already exists!");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable() {
|
||||
if (computeShader == null) {
|
||||
throw new System.InvalidOperationException("Compute shader not set!");
|
||||
}
|
||||
_instance = this;
|
||||
AtmLutHelper.Init(computeShader);
|
||||
for (int i = 0; i < pingPongUpdaters.Length; i++) {
|
||||
pingPongUpdaters[i] = new ProgressiveLutUpdater(null, lutConfig, this);
|
||||
pingPongUpdaters[i].name = "Updater " + i;
|
||||
}
|
||||
|
||||
//Quickly complete two set luts.
|
||||
for (int i = 1; i <= 2; i++) {
|
||||
pingPongUpdaters[i].atmConfigToUse = atmosphereConfig;
|
||||
var t = pingPongUpdaters[i].UpdateCoroutine();
|
||||
while (t.MoveNext()) ;
|
||||
}
|
||||
UpdateSkyboxMaterial(pingPongUpdaters[1], pingPongUpdaters[2]);
|
||||
|
||||
KickOffUpdater(pingPongUpdaters[0]);
|
||||
}
|
||||
|
||||
private void KickOffUpdater(ProgressiveLutUpdater updater) {
|
||||
updater.atmConfigToUse = atmosphereConfig;
|
||||
StartCoroutine(updater.UpdateCoroutine());
|
||||
}
|
||||
|
||||
private float lerpValue = 0.0f;
|
||||
private void Update() {
|
||||
if (!pingPongUpdaters[0].working && progressiveUpdate) {
|
||||
//Use the finished luts.
|
||||
UpdateSkyboxMaterial(pingPongUpdaters[0], pingPongUpdaters[1]);
|
||||
|
||||
lerpValue = 0.0f;
|
||||
|
||||
//Rotate to right.
|
||||
RotatePingpongUpdater();
|
||||
|
||||
//Next updater.
|
||||
KickOffUpdater(pingPongUpdaters[0]);
|
||||
}
|
||||
UpdateLerpValue();
|
||||
}
|
||||
|
||||
private void UpdateLerpValue() {
|
||||
//We now require 19 frames to update
|
||||
|
||||
lerpValue += 1.0f / 19.0f;
|
||||
if (skyboxMaterial != null)
|
||||
Shader.SetGlobalFloat("_LerpValue", lerpValue);
|
||||
}
|
||||
|
||||
private void OnDisable() {
|
||||
for (int i = 0; i < pingPongUpdaters.Length; i++) {
|
||||
pingPongUpdaters[i].Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateComputeShaderValueForLerpedAp(ComputeShader shader, int kernelId) {
|
||||
newestLut.atmConfigUsedToUpdate.Apply(shader);
|
||||
shader.SetTexture(kernelId, "_SingleRayleigh_1", oldLut.singleRayleigh);
|
||||
shader.SetTexture(kernelId, "_SingleMie_1", oldLut.singleMie);
|
||||
shader.SetTexture(kernelId, "_SingleRayleigh_2", newestLut.singleRayleigh);
|
||||
shader.SetTexture(kernelId, "_SingleMie_2", newestLut.singleMie);
|
||||
shader.SetTexture(kernelId, "_MultipleScattering_1", oldLut.multiScatteringCombine);
|
||||
shader.SetTexture(kernelId, "_MultipleScattering_2", newestLut.multiScatteringCombine);
|
||||
shader.SetTexture(kernelId, "_Transmittance_1", oldLut.transmittance);
|
||||
shader.SetTexture(kernelId, "_Transmittance_2", newestLut.transmittance);
|
||||
shader.SetTexture(kernelId, "_GroundIrradiance_1", oldLut.groundIrradianceCombine);
|
||||
shader.SetTexture(kernelId, "_GroundIrradiance_2", newestLut.groundIrradianceCombine);
|
||||
shader.SetVector("_ScatteringSize", (Vector3)lutConfig.scatteringSize);
|
||||
shader.SetVector("_GroundIrradianceSize", (Vector2)lutConfig.irradianceSize);
|
||||
shader.SetVector("_TransmittanceSize", (Vector2)lutConfig.transmittanceSize);
|
||||
}
|
||||
|
||||
public void UpdateSkyboxMaterial(ProgressiveLutUpdater updater, ProgressiveLutUpdater oldUpdater) {
|
||||
if (this.skyboxMaterial==null)
|
||||
this.skyboxMaterial = new Material(Shader.Find("Skybox/AtmosphereScatteringPrecomputed"));
|
||||
updater.atmConfigUsedToUpdate.Apply(skyboxMaterial);
|
||||
Shader.SetGlobalTexture("_SingleRayleigh_1", oldUpdater.singleRayleigh);
|
||||
Shader.SetGlobalTexture("_SingleMie_1", oldUpdater.singleMie);
|
||||
Shader.SetGlobalTexture("_SingleRayleigh_2", updater.singleRayleigh);
|
||||
Shader.SetGlobalTexture("_SingleMie_2", updater.singleMie);
|
||||
Shader.SetGlobalTexture("_MultipleScattering_1", oldUpdater.multiScatteringCombine);
|
||||
Shader.SetGlobalTexture("_MultipleScattering_2", updater.multiScatteringCombine);
|
||||
Shader.SetGlobalTexture("_Transmittance_1", oldUpdater.transmittance);
|
||||
Shader.SetGlobalTexture("_Transmittance_2", updater.transmittance);
|
||||
Shader.SetGlobalTexture("_GroundIrradiance_1", oldUpdater.groundIrradianceCombine);
|
||||
Shader.SetGlobalTexture("_GroundIrradiance_2", updater.groundIrradianceCombine);
|
||||
Shader.SetGlobalVector("_ScatteringSize", (Vector3)lutConfig.scatteringSize);
|
||||
Shader.SetGlobalVector("_GroundIrradianceSize", (Vector2)lutConfig.irradianceSize);
|
||||
Shader.SetGlobalVector("_TransmittanceSize", (Vector2)lutConfig.transmittanceSize);
|
||||
RenderSettings.skybox = this.skyboxMaterial;
|
||||
}
|
||||
|
||||
public void Log(string itemName) {
|
||||
if (outputDebug)
|
||||
Debug.Log(itemName);
|
||||
}
|
||||
|
||||
public Vector3 GetRadianceAt(float mu_s, Vector3 basePosition) {
|
||||
var t = atmosphereConfig.sunIrradianceOnAtmosphere;
|
||||
var r = basePosition + new Vector3(0.0f, atmosphereConfig.atmosphere_bot_radius, 0.0f);
|
||||
var transmittance = TransmittanceCalculate.GetTransmittanceToSun(atmosphereConfig, r.magnitude, mu_s);
|
||||
t.Scale(transmittance);
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
public static class TransmittanceCalculate {
|
||||
|
||||
static float ClampCosine(float mu) {
|
||||
return Mathf.Clamp(mu, -1.0f, 1.0f);
|
||||
}
|
||||
|
||||
static float ClampDistance(float d) {
|
||||
return Mathf.Max(d, 0.0f);
|
||||
}
|
||||
|
||||
static float ClampRadius(AtmosphereConfig atmosphere, float r) {
|
||||
return Mathf.Clamp(r, atmosphere.atmosphere_bot_radius, atmosphere.atmosphere_top_radius);
|
||||
}
|
||||
|
||||
static float SafeSqrt(float a) {
|
||||
return Mathf.Sqrt(Mathf.Max(a, 0.0f));
|
||||
}
|
||||
|
||||
static float DistanceToTopAtmosphereBoundary(AtmosphereConfig atmosphere,
|
||||
float r, float mu) {
|
||||
float discriminant = r * r * (mu * mu - 1.0f) +
|
||||
atmosphere.atmosphere_top_radius * atmosphere.atmosphere_top_radius;
|
||||
return ClampDistance(-r * mu + SafeSqrt(discriminant));
|
||||
}
|
||||
|
||||
static float GetScaleHeight(float altitude, float scale_height) {
|
||||
return Mathf.Exp(-altitude / scale_height);
|
||||
}
|
||||
|
||||
static float ComputeOpticalLengthToTopAtmosphereBoundary(
|
||||
AtmosphereConfig atmosphere, float r, float mu, float scale_height) {
|
||||
// Number of intervals for the numerical integration.
|
||||
const int SAMPLE_COUNT = 500;
|
||||
// The integration step, i.e. the length of each integration interval.
|
||||
float dx =
|
||||
DistanceToTopAtmosphereBoundary(atmosphere, r, mu) / (float)SAMPLE_COUNT;
|
||||
// Integration loop.
|
||||
float result = 0.0f;
|
||||
for (int i = 0; i <= SAMPLE_COUNT; ++i) {
|
||||
float d_i = (float)i * dx;
|
||||
// Distance between the current sample point and the planet center.
|
||||
float r_i = Mathf.Sqrt(d_i * d_i + 2.0f * r * mu * d_i + r * r);
|
||||
// Number density at the current sample point (divided by the number density
|
||||
// at the bottom of the atmosphere, yielding a dimensionless number).
|
||||
float y_i = GetScaleHeight(r_i - atmosphere.atmosphere_bot_radius, scale_height);
|
||||
// Sample weight (from the trapezoidal rule).
|
||||
float weight_i = i == 0 || i == SAMPLE_COUNT ? 0.5f : 1.0f;
|
||||
result += y_i * weight_i * dx;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Vector3 ComputeTransmittanceToTopAtmosphereBoundary(
|
||||
AtmosphereConfig atmosphere, float r, float mu) {
|
||||
Vector3 rayleigh = atmosphere.rayleigh_scattering_spectrum *
|
||||
ComputeOpticalLengthToTopAtmosphereBoundary(
|
||||
atmosphere, r, mu, atmosphere.rayleigh_scale_height);
|
||||
Vector3 mie = Vector3.one * atmosphere.mie_extinction_spectrum *
|
||||
ComputeOpticalLengthToTopAtmosphereBoundary(
|
||||
atmosphere, r, mu, atmosphere.mie_scale_height);
|
||||
Vector3 ozone = atmosphere.ozone_extinction_spectrum *
|
||||
ComputeOpticalLengthToTopAtmosphereBoundary(
|
||||
atmosphere, r, mu, atmosphere.ozone_scale_height);
|
||||
var sum = rayleigh + mie + ozone;
|
||||
return new Vector3(
|
||||
Mathf.Exp(-sum.x),
|
||||
Mathf.Exp(-sum.y),
|
||||
Mathf.Exp(-sum.z)
|
||||
);
|
||||
}
|
||||
|
||||
public static Vector3 GetTransmittanceToSun(
|
||||
AtmosphereConfig atmosphere,
|
||||
float r, float mu_s) {
|
||||
float sin_theta_h = atmosphere.atmosphere_bot_radius / r;
|
||||
float cos_theta_h = -Mathf.Sqrt(Mathf.Max(1.0f - sin_theta_h * sin_theta_h, 0.0f));
|
||||
|
||||
var transmittanceToCenter = ComputeTransmittanceToTopAtmosphereBoundary(
|
||||
atmosphere, r, mu_s);
|
||||
|
||||
var lower_bound = -sin_theta_h * atmosphere.atmosphere_sun_angular_radius;
|
||||
var upper_bound = sin_theta_h * atmosphere.atmosphere_sun_angular_radius;
|
||||
|
||||
var fraction = (mu_s - cos_theta_h - lower_bound) / (upper_bound - lower_bound);
|
||||
fraction = Mathf.Clamp01(fraction);
|
||||
|
||||
return transmittanceToCenter * fraction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e16dd2ddbdfa7ea4f87a3cfb032ffd0f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- computeShader: {fileID: 7200000, guid: 2d4396a54b390d742b84d4bb4a122e54, type: 3}
|
||||
- atmosphereConfig: {fileID: 11400000, guid: 8e73e89daf00b8447b2410427953df25, type: 2}
|
||||
- skyboxMaterial: {instanceID: 0}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Assets/Plugins/AtmosphereScattering/Scripts/CameraControl.cs
Normal file
46
Assets/Plugins/AtmosphereScattering/Scripts/CameraControl.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraControl : MonoBehaviour {
|
||||
public float distance = 10.0f;
|
||||
public Vector3 center;
|
||||
|
||||
private Vector2 lastFrameMouse;
|
||||
|
||||
public float scale = 1.0f;
|
||||
|
||||
public float distanceSpeed = .1f;
|
||||
public float rotationSpeed = .1f;
|
||||
|
||||
private void Update() {
|
||||
var mouseDelta = (Vector2)Input.mousePosition - lastFrameMouse;
|
||||
lastFrameMouse = Input.mousePosition;
|
||||
|
||||
if (Input.GetMouseButton(2)) {
|
||||
//Translate.
|
||||
center += ((transform.right * mouseDelta.x) + (transform.up * mouseDelta.y)) * scale * distance;
|
||||
}
|
||||
|
||||
if (Input.GetMouseButton(1)) {
|
||||
distance += mouseDelta.x * distanceSpeed * Mathf.Max(1.0f, 0.1f * distance);
|
||||
}
|
||||
|
||||
if (Input.GetMouseButton(0)) {
|
||||
//Rotate.
|
||||
var currentRotation = transform.rotation;
|
||||
var currentYaw = currentRotation.eulerAngles.y;
|
||||
var currentPitch = currentRotation.eulerAngles.x;
|
||||
|
||||
currentPitch -= mouseDelta.y * rotationSpeed;
|
||||
currentYaw += mouseDelta.x * rotationSpeed;
|
||||
currentPitch = Mathf.Max(0, currentPitch);
|
||||
|
||||
var newRotation = Quaternion.Euler(currentPitch, currentYaw, 0.0f);
|
||||
|
||||
transform.rotation = newRotation;
|
||||
}
|
||||
|
||||
transform.position = transform.rotation * Vector3.forward * -distance + center;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 45d85419f2e23c540999c1a1fee6ed90
|
||||
timeCreated: 1547180827
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraVolumeHelper : MonoBehaviour {
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0af3cdd822fb2414fb284a2730bbdb29
|
||||
guid: 0e8391fcc2d8a5144ace172efd446a95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Yangrc.AtmosphereScattering {
|
||||
[RequireComponent(typeof(Light))]
|
||||
public class SunIntensityController : MonoBehaviour {
|
||||
|
||||
private new Light light;
|
||||
|
||||
//This is the "base" position, used to sample transmittance to sun, and set a final intensity.
|
||||
//
|
||||
//In real-life, objects at different position are affected by different sun intensity.
|
||||
//But in Unity all objects share the same sun.
|
||||
//So we need to set a base position, and assume all objects are at this position when affected by sun.
|
||||
public Vector3 basePosition = new Vector3(0.0f, 50.0f, 0.0f);
|
||||
|
||||
private void Awake() {
|
||||
light = GetComponent<Light>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
var t = AtmosphereScatteringLutManager.instance;
|
||||
if (t != null) {
|
||||
//Sun-zenith cos.
|
||||
var mu_s = Vector3.Dot(Vector3.down, transform.forward);
|
||||
var radianceAtZero = t.GetRadianceAt(mu_s, basePosition);
|
||||
|
||||
light.intensity = radianceAtZero.magnitude / (2 * Mathf.PI);
|
||||
var normalized = radianceAtZero.normalized;
|
||||
light.color = new Color(normalized.x, normalized.y, normalized.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 325c269146dc2ac49b190f730a961573
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e1311711456582f45a2141e31ec26132
|
||||
guid: 5252171c9ff51e140b7d257eb101b9e4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
Shader "Hidden/Yangrc/AerialPerspective"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// No culling or depth
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "AerialPerspectiveHelper.cginc"
|
||||
#include "Lighting.cginc"
|
||||
float4 _ProjectionExtents;
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
float4 scrPos: TEXCOORD1;
|
||||
float2 vsray : TEXCOORD2;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.scrPos = ComputeScreenPos(o.vertex);
|
||||
o.vsray = (2.0 * v.uv - 1.0) * _ProjectionExtents.xy + _ProjectionExtents.zw;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _CameraDepthTexture;
|
||||
float _LightScale;
|
||||
|
||||
void CalculateRMuMusForDistancePoint(Length r, Number mu, Number mu_s, Number nu, Number d, OUT(Length) r_d, OUT(Number) mu_d, OUT(Number) mu_s_d);
|
||||
void CalculateRMuMusFromPosViewdir(AtmosphereParameters atm, float3 pos, float3 view_ray, float3 sun_direction, OUT(float) mu, OUT(float) mu_s, OUT(float) nu);
|
||||
float3 GetTransmittanceToTopAtmosphereBoundaryLerped(float r, float mu);
|
||||
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float3 vspos = float3(i.vsray, 1.0);
|
||||
float4 worldPos = mul(unity_CameraToWorld, float4(vspos, 1.0));
|
||||
worldPos /= worldPos.w;
|
||||
|
||||
half4 original = tex2D(_MainTex, i.uv);
|
||||
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
float3 view_ray = normalize(worldPos.xyz - _WorldSpaceCameraPos);
|
||||
float raw_depth = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, i.scrPos);
|
||||
float distance = LinearEyeDepth(raw_depth);
|
||||
if (distance / _ProjectionParams.z > 0.999f) {
|
||||
return original;
|
||||
}
|
||||
float depth = (distance - _ProjectionParams.x) / (_ProjectionParams.z - _ProjectionParams.x);
|
||||
|
||||
float3 pixel_pos = worldPos + distance * view_ray;
|
||||
#if 1
|
||||
float r, mu, mu_s, nu;
|
||||
float r_d, mu_d, mu_s_d; //Current pixel on screen's info
|
||||
CalculateRMuMusFromPosViewdir(atm, _WorldSpaceCameraPos, view_ray, _WorldSpaceLightPos0, r, mu, mu_s, nu);
|
||||
float d1, d2;
|
||||
bool ray_r_mu_intersects_ground = RayIntersectsGround(atm, r, mu, d1, d2);
|
||||
CalculateRMuMusForDistancePoint(atm, r, mu, mu_s, nu, distance, r_d, mu_d, mu_s_d);
|
||||
|
||||
//Transmittance to target point.
|
||||
float3 transmittanceToTarget = GetTransmittanceLerped(r, mu, distance, ray_r_mu_intersects_ground);
|
||||
|
||||
//Here the two ray (r, mu) and (r_d, mu_d) is pointing same direction.
|
||||
//so ray_r_mu_intersects_ground should apply to both of them.
|
||||
//If we do intersect calculation later, some precision problems might appear, causing glitches near horizontal view dir.
|
||||
float3 scatteringBetween =
|
||||
GetTotalScatteringLerped(r, mu, mu_s, nu, ray_r_mu_intersects_ground)
|
||||
- GetTotalScatteringLerped(r_d, mu_d, mu_s_d, nu, ray_r_mu_intersects_ground) * transmittanceToTarget;
|
||||
#else
|
||||
float3 uvw = float3(i.uv, depth);
|
||||
float3 transmittanceToTarget = GetTransmittanceWithCameraVolume(uvw);
|
||||
float3 scatteringBetween = GetScatteringWithCameraVolume(uvw);
|
||||
#endif
|
||||
return half4(original * transmittanceToTarget + scatteringBetween, 1.0);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 228669e43365e55468de0ef0b707a4bd
|
||||
timeCreated: 1437991512
|
||||
licenseType: Pro
|
||||
guid: 312bffdb76c84374bb88d26526be3dae
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
#ifndef __AERIAL_PERSPECTIVE_HELPER__
|
||||
#define __AERIAL_PERSPECTIVE_HELPER__
|
||||
|
||||
#include "Common.cginc"
|
||||
#include "TransmittanceHelper.cginc"
|
||||
#include "GroundHelper.cginc"
|
||||
#include "MultipleScatteringHelper.cginc"
|
||||
#include "SingleScatteringHelper.cginc"
|
||||
|
||||
#define LERP_TEXTURE(dim, name) \
|
||||
sampler ## dim ## D name ## _1; \
|
||||
sampler ## dim ## D name ## _2;
|
||||
|
||||
LERP_TEXTURE(2, _Transmittance)
|
||||
LERP_TEXTURE(2, _GroundIrradiance)
|
||||
LERP_TEXTURE(3, _SingleRayleigh)
|
||||
LERP_TEXTURE(3, _SingleMie)
|
||||
LERP_TEXTURE(3, _MultipleScattering)
|
||||
|
||||
float2 _TransmittanceSize;
|
||||
float3 _ScatteringSize;
|
||||
float2 _GroundIrradianceSize;
|
||||
float3 _SunIrradianceOnAtm;
|
||||
float _LerpValue;
|
||||
|
||||
float3 GetTransmittanceLerped(float r, float mu, float d, bool intersect_ground) {
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
float3 lerp1 = GetTransmittance(
|
||||
atm, _Transmittance_1, _TransmittanceSize, r, mu, d, intersect_ground);
|
||||
float3 lerp2 = GetTransmittance(
|
||||
atm, _Transmittance_2, _TransmittanceSize, r, mu, d, intersect_ground);
|
||||
|
||||
return lerp(lerp1, lerp2, _LerpValue);
|
||||
}
|
||||
|
||||
float3 GetTransmittanceToTopAtmosphereBoundaryLerped(float r, float mu) {
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
float3 lerp1 = GetTransmittanceToTopAtmosphereBoundary(
|
||||
atm, _Transmittance_1, _TransmittanceSize, r, mu);
|
||||
float3 lerp2 = GetTransmittanceToTopAtmosphereBoundary(
|
||||
atm, _Transmittance_2, _TransmittanceSize, r, mu);
|
||||
|
||||
return lerp(lerp1, lerp2, _LerpValue);
|
||||
}
|
||||
|
||||
void CalculateRMuMusFromPosViewdir(AtmosphereParameters atm, float3 pos, float3 view_ray, float3 sun_direction, OUT(float) r, OUT(float) mu, OUT(float) mu_s, OUT(float) nu) {
|
||||
float3 camera = pos + float3(0, atm.bottom_radius, 0);
|
||||
r = max(atm.bottom_radius + 0.5f, length(camera));
|
||||
float rmu = dot(camera, view_ray);
|
||||
mu = rmu / r;
|
||||
mu_s = dot(camera, sun_direction) / r;
|
||||
nu = dot(view_ray, sun_direction);
|
||||
}
|
||||
|
||||
void CalculateRMuMusForDistancePoint(AtmosphereParameters atm, Length r, Number mu, Number mu_s, float nu, Number d, OUT(Length) r_d, OUT(Number) mu_d, OUT(Number) mu_s_d) {
|
||||
|
||||
r_d = ClampRadius(atm, sqrt(d * d + 2.0 * r * mu * d + r * r));
|
||||
r_d = max(atm.bottom_radius + 0.5f, r_d);
|
||||
mu_d = ClampCosine((r * mu + d) / r_d);
|
||||
mu_s_d = ClampCosine((r * mu_s + d * nu) / r_d);
|
||||
}
|
||||
|
||||
float3 InternalGetRayleighLerped(AtmosphereParameters atm, float r, float mu, float mu_s, float nu, bool ray_r_mu_intersects_ground) {
|
||||
|
||||
return SampleScatteringLerped(atm,
|
||||
_SingleRayleigh_1,
|
||||
_SingleRayleigh_2,
|
||||
_LerpValue,
|
||||
_ScatteringSize,
|
||||
r, mu, mu_s,
|
||||
ray_r_mu_intersects_ground) *
|
||||
RayleighPhaseFunction(nu);
|
||||
}
|
||||
|
||||
float3 InternalGetMieLerped(AtmosphereParameters atm, float r, float mu, float mu_s, float nu, bool ray_r_mu_intersects_ground) {
|
||||
return SampleScatteringLerped(atm,
|
||||
_SingleMie_1,
|
||||
_SingleMie_2,
|
||||
_LerpValue,
|
||||
_ScatteringSize,
|
||||
r, mu, mu_s,
|
||||
ray_r_mu_intersects_ground) *
|
||||
MiePhaseFunction(atm.mie_phase_function_g, nu);
|
||||
}
|
||||
|
||||
float3 InternalGetLerpedGroundIrradiance(AtmosphereParameters atm, float r, float mu, float mu_s) {
|
||||
return lerp(GetIrradiance(atm, _GroundIrradiance_1, _GroundIrradianceSize, r, mu_s), GetIrradiance(atm, _GroundIrradiance_2, _GroundIrradianceSize, r, mu_s), _LerpValue);
|
||||
}
|
||||
|
||||
float3 InternalGetMultipleLerped(AtmosphereParameters atm, float r, float mu, float mu_s, float nu, bool ray_r_mu_intersects_ground) {
|
||||
return
|
||||
SampleScatteringLerped(atm,
|
||||
_MultipleScattering_1,
|
||||
_MultipleScattering_2,
|
||||
_LerpValue,
|
||||
_ScatteringSize,
|
||||
r, mu, mu_s,
|
||||
ray_r_mu_intersects_ground);
|
||||
}
|
||||
|
||||
void ComputeSingleScattering(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 texture_size,
|
||||
Length r, Number mu, Number mu_s, Number nu,
|
||||
bool ray_r_mu_intersects_ground,
|
||||
OUT(IrradianceSpectrum) rayleigh, OUT(IrradianceSpectrum) mie);
|
||||
|
||||
float3 GetTotalScatteringLerped(float r, float mu, float mu_s, float nu, bool ray_r_mu_intersects_ground) {
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
return
|
||||
(InternalGetRayleighLerped(atm, r, mu, mu_s, nu, ray_r_mu_intersects_ground)
|
||||
+ InternalGetMieLerped(atm, r, mu, mu_s, nu, ray_r_mu_intersects_ground)
|
||||
+ InternalGetMultipleLerped(atm, r, mu, mu_s, nu, ray_r_mu_intersects_ground)) * _SunIrradianceOnAtm;
|
||||
}
|
||||
|
||||
float3 GetTotalScatteringLerped(float r, float mu, float mu_s, float nu) {
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
bool ray_r_mu_intersects_ground = RayIntersectsGround(atm, r, mu);
|
||||
return GetTotalScatteringLerped(r, mu, mu_s, nu, ray_r_mu_intersects_ground);
|
||||
}
|
||||
|
||||
float3 EvaluateSunDiskRadianceOfUnitRadiance(AtmosphereParameters atm, float r, float mu, float nu) {
|
||||
//Evaluate sun's solid angle by formula omega = 2 * PI * ( 1 - cos(sun_angular_radius)) (https://en.wikipedia.org/wiki/Solid_angle)
|
||||
float cos_sun_angular_radius = cos(atm.sun_angular_radius);
|
||||
float radianceTransmitted = max(0.0f, (nu - cos_sun_angular_radius) / (1.0f - cos_sun_angular_radius));
|
||||
float solidAngle = 2 * 3.1415926 * (1 - cos_sun_angular_radius);
|
||||
return _SunIrradianceOnAtm * radianceTransmitted / solidAngle / 500.0f; //Avoiding it blind your eye.
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============================
|
||||
Camera volume stuff.
|
||||
===============================
|
||||
*/
|
||||
sampler3D _CameraVolumeTransmittance;
|
||||
sampler3D _CameraVolumeScattering;
|
||||
|
||||
float3 GetTransmittanceWithCameraVolume(float3 uvw) {
|
||||
return tex3Dlod(_CameraVolumeTransmittance, float4(uvw, 0.0f)).rgb * _SunIrradianceOnAtm;
|
||||
}
|
||||
|
||||
float3 GetScatteringWithCameraVolume(float3 uvw) {
|
||||
return tex3Dlod(_CameraVolumeScattering, float4(uvw, 0.0f)).rgb * _SunIrradianceOnAtm;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 689759fe522f7ce4eaa6fc304ca996c3
|
||||
timeCreated: 1531897786
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,353 @@
|
|||
|
||||
/*
|
||||
Helper functions. See https://ebruneton.github.io/precomputed_atmospheric_scattering/atmosphere/functions.glsl.html#transmittance_computation
|
||||
*/
|
||||
//Convert (0.0, 1.0) to actual texel position.
|
||||
|
||||
#include "./TransmittanceHelper.cginc"
|
||||
#include "SingleScatteringHelper.cginc"
|
||||
#include "MultipleScatteringHelper.cginc"
|
||||
#include "GroundHelper.cginc"
|
||||
|
||||
#pragma kernel CalculateTransmittanceLUT
|
||||
#pragma kernel CalculateSingleScatteringLUT
|
||||
#pragma kernel CalculateMultipleScatteringDensityLUT
|
||||
#pragma kernel CalculateMultipleScatteringLUT
|
||||
#pragma kernel CalculateGroundDirectIrradianceLUT
|
||||
#pragma kernel CalculateGroundIndirectIrradianceLUT
|
||||
#pragma kernel CombineGroundIrradianceLUT
|
||||
#pragma kernel CombineMultipleScatteringLUT
|
||||
#pragma kernel ClearCombineGroundIrradianceLUT
|
||||
#pragma kernel ClearCombineMultipleScatteringLUT
|
||||
#pragma kernel CalculateCameraScatteringVolume
|
||||
|
||||
/*
|
||||
Common parameters.
|
||||
*/
|
||||
sampler2D TransmittanceLUT;
|
||||
sampler3D SingleRayleighScatteringLUT;
|
||||
sampler3D SingleMieScatteringLUT;
|
||||
sampler3D MultipleScatteringDensityLUT;
|
||||
sampler3D MultipleScatteringLUT;
|
||||
sampler2D IrradianceLUT;
|
||||
int2 TransmittanceSize;
|
||||
int3 ScatteringSize;
|
||||
int2 IrradianceSize;
|
||||
int ScatteringOrder;
|
||||
|
||||
//When only part of results need to be computed, we offset some results.
|
||||
uint3 _ThreadOffset;
|
||||
|
||||
|
||||
/*
|
||||
==================================
|
||||
||Transmittance LUT calculation.||
|
||||
==================================
|
||||
*/
|
||||
|
||||
RWTexture2D<float3> TransmittanceLUTResult;
|
||||
|
||||
DimensionlessSpectrum ComputeTransmittanceToTopAtmosphereBoundaryTexture(
|
||||
IN(AtmosphereParameters) atmosphere, IN(vec2) uv_coord, IN(vec2) tex_size) {
|
||||
Length r;
|
||||
Number mu;
|
||||
GetRMuFromTransmittanceTextureUv(
|
||||
atmosphere, uv_coord, r, mu, tex_size.x, tex_size.y);
|
||||
return ComputeTransmittanceToTopAtmosphereBoundary(atmosphere, r, mu);
|
||||
}
|
||||
|
||||
[numthreads(32, 32, 1)]
|
||||
void CalculateTransmittanceLUT(uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID)
|
||||
{
|
||||
id += _ThreadOffset * uint3(32, 32, 1);
|
||||
|
||||
uint w, h;
|
||||
TransmittanceLUTResult.GetDimensions(w, h);
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
|
||||
float2 uv = vec2((0.5f + id.x) / w, (0.5f + id.y) / h);
|
||||
float r, mu;
|
||||
|
||||
GetRMuFromTransmittanceTextureUv(
|
||||
atm, uv, r, mu, w, h);
|
||||
|
||||
float3 result = ComputeTransmittanceToTopAtmosphereBoundaryTexture(
|
||||
atm, uv, vec2(w, h)
|
||||
);
|
||||
|
||||
TransmittanceLUTResult[id.xy] = result;
|
||||
}
|
||||
|
||||
/*
|
||||
==================================
|
||||
|| SingleScattering ||
|
||||
==================================
|
||||
*/
|
||||
|
||||
RWTexture3D<float3> SingleScatteringRayleighLUTResult;
|
||||
RWTexture3D<float3> SingleScatteringMieLUTResult;
|
||||
|
||||
[numthreads(8, 8, 8)]
|
||||
void CalculateSingleScatteringLUT(uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID)
|
||||
{
|
||||
id += _ThreadOffset * uint3(8, 8, 8);
|
||||
|
||||
uint w, h, d;
|
||||
SingleScatteringRayleighLUTResult.GetDimensions(w, h, d);
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
|
||||
float3 uvw = vec3((0.5f + id.x) / w, (0.5f + id.y) / h, (0.5f + id.z) / d);
|
||||
|
||||
float3 rayleigh, mie;
|
||||
ComputeSingleScatteringTexture(
|
||||
atm, TransmittanceLUT, uint2(TransmittanceSize), uvw, uint3(ScatteringSize), rayleigh, mie
|
||||
);
|
||||
|
||||
SingleScatteringMieLUTResult[id.xyz] = mie;
|
||||
SingleScatteringRayleighLUTResult[id.xyz] = rayleigh;
|
||||
}
|
||||
|
||||
/*
|
||||
==========================================
|
||||
|| Multiple Scattering Density ||
|
||||
==========================================
|
||||
*/
|
||||
RWTexture3D<float3> MultipleScatteringDensityResult;
|
||||
|
||||
RadianceDensitySpectrum ComputeScatteringDensityTexture(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 transmittance_size,
|
||||
IN(ReducedScatteringTexture) single_rayleigh_scattering_texture,
|
||||
IN(ReducedScatteringTexture) single_mie_scattering_texture,
|
||||
IN(ScatteringTexture) multiple_scattering_texture,
|
||||
uint3 scattering_size,
|
||||
IN(IrradianceTexture) irradiance_texture,
|
||||
uint2 irradiance_size,
|
||||
IN(vec3) frag_coord, int scattering_order);
|
||||
|
||||
[numthreads(8,8,8)]
|
||||
void CalculateMultipleScatteringDensityLUT(uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID) {
|
||||
|
||||
id += _ThreadOffset * uint3(8, 8, 8);
|
||||
|
||||
uint w, h, d;
|
||||
MultipleScatteringDensityResult.GetDimensions(w, h, d);
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
|
||||
float3 uvw = vec3((0.5f + id.x) / w, (0.5f + id.y) / h, (0.5f + id.z) / d);
|
||||
|
||||
float3 density = ComputeScatteringDensityTexture(
|
||||
atm, TransmittanceLUT, TransmittanceSize,
|
||||
SingleRayleighScatteringLUT, SingleMieScatteringLUT, MultipleScatteringLUT, ScatteringSize,
|
||||
IrradianceLUT, IrradianceSize,
|
||||
uvw, ScatteringOrder
|
||||
);
|
||||
|
||||
MultipleScatteringDensityResult[id.xyz] = density;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================================
|
||||
|| Multiple Scattering ||
|
||||
==========================================
|
||||
*/
|
||||
|
||||
RWTexture3D<float3> MultipleScatteringResult;
|
||||
|
||||
RadianceSpectrum ComputeMultipleScatteringTexture(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 transmittance_size,
|
||||
IN(ScatteringDensityTexture) scattering_density_texture,
|
||||
uint3 scattering_size,
|
||||
IN(vec3) frag_coord);
|
||||
|
||||
[numthreads(8, 8, 8)]
|
||||
void CalculateMultipleScatteringLUT(uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID) {
|
||||
id += _ThreadOffset * uint3(8, 8, 8);
|
||||
|
||||
uint w, h, d;
|
||||
MultipleScatteringResult.GetDimensions(w, h, d);
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
|
||||
float3 uvw = vec3((0.5f + id.x) / w, (0.5f + id.y) / h, (0.5f + id.z) / d);
|
||||
|
||||
float3 scattering = ComputeMultipleScatteringTexture(atm, TransmittanceLUT, TransmittanceSize, MultipleScatteringDensityLUT, ScatteringSize, uvw);
|
||||
|
||||
MultipleScatteringResult[id.xyz] = scattering;
|
||||
}
|
||||
|
||||
/*
|
||||
==========================================
|
||||
|| Ground Direct Irradiance ||
|
||||
==========================================
|
||||
*/
|
||||
|
||||
RWTexture2D<float3> GroundDirectIrradianceResult;
|
||||
|
||||
IrradianceSpectrum ComputeDirectIrradianceTexture(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 transmittance_size,
|
||||
IN(vec2) frag_coord,
|
||||
uint2 irrdiance_size);
|
||||
|
||||
[numthreads(32, 32, 1)]
|
||||
void CalculateGroundDirectIrradianceLUT(uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID) {
|
||||
id += _ThreadOffset * uint3(32, 32, 1);
|
||||
|
||||
uint w, h;
|
||||
GroundDirectIrradianceResult.GetDimensions(w, h);
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
|
||||
float2 uvw = vec2((0.5f + id.x) / w, (0.5f + id.y) / h);
|
||||
|
||||
float3 irradiance = ComputeDirectIrradianceTexture(atm, TransmittanceLUT, TransmittanceSize, uvw, IrradianceSize);
|
||||
|
||||
GroundDirectIrradianceResult[id.xy] = irradiance;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================================
|
||||
|| Ground Indirect Irradiance ||
|
||||
==========================================
|
||||
*/
|
||||
|
||||
RWTexture2D<float3> GroundIndirectIrradianceResult;
|
||||
|
||||
IrradianceSpectrum ComputeIndirectIrradianceTexture(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(ReducedScatteringTexture) single_rayleigh_scattering_texture,
|
||||
IN(ReducedScatteringTexture) single_mie_scattering_texture,
|
||||
IN(ScatteringTexture) multiple_scattering_texture,
|
||||
uint3 scattering_size,
|
||||
IN(vec2) frag_coord, int scattering_order, uint2 irrdiance_size);
|
||||
|
||||
[numthreads(32, 32, 1)]
|
||||
void CalculateGroundIndirectIrradianceLUT(uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID) {
|
||||
id += _ThreadOffset * uint3(32, 32, 1);
|
||||
|
||||
uint w, h;
|
||||
GroundIndirectIrradianceResult.GetDimensions(w, h);
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
|
||||
float2 uvw = vec2((0.5f + id.x) / w, (0.5f + id.y) / h);
|
||||
|
||||
float3 irradiance = ComputeIndirectIrradianceTexture(atm,
|
||||
SingleRayleighScatteringLUT, SingleMieScatteringLUT, MultipleScatteringLUT, ScatteringSize,
|
||||
uvw, ScatteringOrder, uint2(w,h));
|
||||
|
||||
GroundIndirectIrradianceResult[id.xy] = irradiance;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==========================================
|
||||
|| Ground Irradiance Combine ||
|
||||
==========================================
|
||||
*/
|
||||
|
||||
RWTexture2D<float3> GroundIrradianceSumTarget;
|
||||
RWTexture2D<float3> GroundIrradianceSumAdder;
|
||||
|
||||
[numthreads(32, 32, 1)]
|
||||
void CombineGroundIrradianceLUT(uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID) {
|
||||
id += _ThreadOffset * uint3(32, 32, 1);
|
||||
|
||||
GroundIrradianceSumTarget[id.xy] += GroundIrradianceSumAdder[id.xy];
|
||||
}
|
||||
|
||||
[numthreads(32, 32, 1)]
|
||||
void ClearCombineGroundIrradianceLUT(uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID) {
|
||||
id += _ThreadOffset * uint3(32, 32, 1);
|
||||
GroundIrradianceSumTarget[id.xy] = 0.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
==========================================
|
||||
|| Scattering Combine ||
|
||||
==========================================
|
||||
*/
|
||||
|
||||
RWTexture3D<float4> ScatteringSumTarget;
|
||||
RWTexture3D<float4> ScatteringSumAdd;
|
||||
|
||||
[numthreads(8, 8, 8)]
|
||||
void CombineMultipleScatteringLUT(uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID) {
|
||||
id += _ThreadOffset * uint3(8, 8, 8);
|
||||
|
||||
ScatteringSumTarget[id.xyz] += ScatteringSumAdd[id.xyz];
|
||||
}
|
||||
[numthreads(8, 8, 8)]
|
||||
void ClearCombineMultipleScatteringLUT(uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID) {
|
||||
id += _ThreadOffset * uint3(8, 8, 8);
|
||||
|
||||
ScatteringSumTarget[id.xyz] = 0.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
==========================================
|
||||
|| Camera Volume Tex ||
|
||||
==========================================
|
||||
*/
|
||||
#include "HLSLSupport.cginc"
|
||||
#include "AerialPerspectiveHelper.cginc"
|
||||
RWTexture3D<float3> CameraVolumeTransmittance;
|
||||
RWTexture3D<float3> CameraVolumeScattering;
|
||||
float4x4 Inverse_VP;
|
||||
float3 _CameraPos;
|
||||
float3 _SunDir;
|
||||
|
||||
float2 _NearFarPlane;
|
||||
float3 _CamBotLeft;
|
||||
float3 _CamBotRight;
|
||||
float3 _CamTopLeft;
|
||||
float3 _CamTopRight;
|
||||
|
||||
[numthreads(8, 8, 8)]
|
||||
void CalculateCameraScatteringVolume(uint3 id : SV_DispatchThreadID, uint3 groupid : SV_GroupThreadID) {
|
||||
id += _ThreadOffset * uint3(8, 8, 8);
|
||||
|
||||
uint3 whd;
|
||||
CameraVolumeScattering.GetDimensions(whd.x, whd.y, whd.z);
|
||||
float3 texelSize = 1.0f / whd;
|
||||
|
||||
//Get uvw from id.
|
||||
float3 uvw = (id + 0.5f) * texelSize;
|
||||
|
||||
float3 viewDir;
|
||||
|
||||
//Get camera ray.
|
||||
{
|
||||
float3 t1 = lerp(_CamBotLeft, _CamBotRight, uvw.x);
|
||||
float3 t2 = lerp(_CamTopLeft, _CamTopRight, uvw.x);
|
||||
float3 ray_end = lerp(t1, t2, uvw.y);
|
||||
viewDir = ray_end - _CameraPos;
|
||||
}
|
||||
|
||||
float distance = lerp(_NearFarPlane.x, _NearFarPlane.y, uvw.z);
|
||||
viewDir = normalize(viewDir);
|
||||
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
float3 earthToCamera = _CameraPos + float3(0.0f, atm.bottom_radius, 0.0f);
|
||||
|
||||
float r, mu, mu_s, nu;
|
||||
float r_d, mu_d, mu_s_d;
|
||||
|
||||
CalculateRMuMusFromPosViewdir(atm, _CameraPos, viewDir, _SunDir, r, mu, mu_s, nu);
|
||||
float d1, d2;
|
||||
bool ray_r_mu_intersects_ground = RayIntersectsGround(atm, r, mu, d1, d2);
|
||||
CalculateRMuMusForDistancePoint(atm, r, mu, mu_s, nu, distance, r_d, mu_d, mu_s_d);
|
||||
|
||||
float3 transmittanceToTarget = GetTransmittanceLerped(
|
||||
r, mu, distance, ray_r_mu_intersects_ground);
|
||||
float3 scatteringBetween =
|
||||
GetTotalScatteringLerped(r, mu, mu_s, nu, ray_r_mu_intersects_ground)
|
||||
- GetTotalScatteringLerped(r_d, mu_d, mu_s_d, nu, ray_r_mu_intersects_ground) * transmittanceToTarget;
|
||||
|
||||
CameraVolumeTransmittance[id] = transmittanceToTarget;
|
||||
CameraVolumeScattering[id] = scatteringBetween;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2d4396a54b390d742b84d4bb4a122e54
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 4
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
276
Assets/Plugins/AtmosphereScattering/Shaders/Common.cginc
Normal file
276
Assets/Plugins/AtmosphereScattering/Shaders/Common.cginc
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
#ifndef __COMMON_HELPER__
|
||||
#define __COMMON_HELPER__
|
||||
|
||||
#define Length float
|
||||
#define Wavelength float
|
||||
#define Angle float
|
||||
#define SolidAngle float
|
||||
#define Power float
|
||||
#define LuminousPower float
|
||||
|
||||
#define Number float
|
||||
#define InverseLength float
|
||||
#define Area float
|
||||
#define Volume float
|
||||
#define NumberDensity float
|
||||
#define Irradiance float
|
||||
#define Radiance float
|
||||
#define SpectralPower float
|
||||
#define SpectralIrradiance float
|
||||
#define SpectralRadiance float
|
||||
#define SpectralRadianceDensity float
|
||||
#define ScatteringCoefficient float
|
||||
#define InverseSolidAngle float
|
||||
#define LuminousIntensity float
|
||||
#define Luminance float
|
||||
#define Illuminance float
|
||||
|
||||
// A generic function from Wavelength to some other type.
|
||||
#define AbstractSpectrum vec3
|
||||
// A function from Wavelength to Number.
|
||||
#define DimensionlessSpectrum vec3
|
||||
// A function from Wavelength to SpectralPower.
|
||||
#define PowerSpectrum vec3
|
||||
// A function from Wavelength to SpectralIrradiance.
|
||||
#define IrradianceSpectrum vec3
|
||||
// A function from Wavelength to SpectralRadiance.
|
||||
#define RadianceSpectrum vec3
|
||||
// A function from Wavelength to SpectralRadianceDensity.
|
||||
#define RadianceDensitySpectrum vec3
|
||||
// A function from Wavelength to ScaterringCoefficient.
|
||||
#define ScatteringSpectrum vec3
|
||||
|
||||
// A position in 3D (3 length values).
|
||||
#define Position vec3
|
||||
// A unit direction vector in 3D (3 unitless values).
|
||||
#define Direction vec3
|
||||
// A vector of 3 luminance values.
|
||||
#define Luminance3 half3
|
||||
// A vector of 3 illuminance values.
|
||||
#define Illuminance3 half3
|
||||
|
||||
#define TransmittanceTexture sampler2D
|
||||
#define IrradianceTexture sampler2D
|
||||
#define ScatteringTexture sampler3D
|
||||
#define ScatteringDensityTexture sampler3D
|
||||
#define ReducedScatteringTexture sampler3D
|
||||
#define vec2 float2
|
||||
#define vec3 float3
|
||||
#define vec4 float4
|
||||
#define IN(x) x
|
||||
#define OUT(x) out x
|
||||
#define assert(x) ;
|
||||
|
||||
static const Length m = 1.0f;
|
||||
static const Wavelength nm = 1.0f;
|
||||
static const Angle rad = 1.0f;
|
||||
static const SolidAngle sr = 1.0;
|
||||
static const Power watt = 1.0;
|
||||
static const LuminousPower lm = 1.0;
|
||||
|
||||
static const float PI = 3.14159265358979323846;
|
||||
|
||||
static const Length km = 1000.0 * m;
|
||||
static const Area m2 = m * m;
|
||||
static const Volume m3 = m * m * m;
|
||||
static const Angle pi = PI * rad;
|
||||
static const Angle deg = pi / 180.0;
|
||||
static const Irradiance watt_per_square_meter = watt / m2;
|
||||
static const Radiance watt_per_square_meter_per_sr = watt / (m2 * sr);
|
||||
static const SpectralIrradiance watt_per_square_meter_per_nm = watt / (m2 * nm);
|
||||
static const SpectralRadiance watt_per_square_meter_per_sr_per_nm =
|
||||
watt / (m2 * sr * nm);
|
||||
static const SpectralRadianceDensity watt_per_cubic_meter_per_sr_per_nm =
|
||||
watt / (m3 * sr * nm);
|
||||
static const LuminousIntensity cd = lm / sr;
|
||||
static const LuminousIntensity kcd = 1000.0 * cd;
|
||||
static const Luminance cd_per_square_meter = cd / m2;
|
||||
static const Luminance kcd_per_square_meter = kcd / m2;
|
||||
|
||||
struct AtmosphereParameters {
|
||||
Length top_radius;
|
||||
Length bottom_radius;
|
||||
Number sun_angular_radius;
|
||||
DimensionlessSpectrum rayleigh_scattering;
|
||||
IrradianceSpectrum ground_albedo;
|
||||
Number rayleigh_scale_height;
|
||||
Number mie_scattering;
|
||||
Number mie_extinction;
|
||||
Number mie_scale_height;
|
||||
DimensionlessSpectrum absorption_extinction;
|
||||
Number absorption_extinction_scale_height;
|
||||
Number solar_irradiance;
|
||||
Number mu_s_min;
|
||||
Number mie_phase_function_g;
|
||||
};
|
||||
|
||||
AtmosphereParameters GetAtmosphereStruct(
|
||||
float atmosphere_top_radius,
|
||||
float atmosphere_bot_radius,
|
||||
float atmosphere_sun_angular_radius,
|
||||
DimensionlessSpectrum rayleigh_scattering,
|
||||
Number rayleigh_scale_height,
|
||||
Number mie_scattering,
|
||||
Number mie_extinction,
|
||||
Number mie_scale_height,
|
||||
Number mie_phase_function_g,
|
||||
DimensionlessSpectrum absorption_extinction,
|
||||
Number absorption_extinction_scale_height
|
||||
) {
|
||||
AtmosphereParameters result;
|
||||
result.top_radius = atmosphere_top_radius;
|
||||
result.bottom_radius = atmosphere_bot_radius;
|
||||
result.sun_angular_radius = atmosphere_sun_angular_radius;
|
||||
|
||||
|
||||
result.rayleigh_scattering = rayleigh_scattering;
|
||||
result.rayleigh_scale_height = rayleigh_scale_height;
|
||||
result.mie_scattering = mie_scattering;
|
||||
result.mie_extinction = mie_extinction;
|
||||
result.mie_scale_height = mie_scale_height;
|
||||
result.mie_phase_function_g = mie_phase_function_g;
|
||||
result.absorption_extinction = absorption_extinction;
|
||||
result.absorption_extinction_scale_height = absorption_extinction_scale_height;
|
||||
|
||||
result.solar_irradiance = 1.0f;
|
||||
result.mu_s_min = -0.2f;
|
||||
result.ground_albedo = float3(0.1, 0.1, 0.1);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Number ClampCosine(Number mu) {
|
||||
return clamp(mu, Number(-1.0), Number(1.0));
|
||||
}
|
||||
|
||||
Length ClampDistance(Length d) {
|
||||
return max(d, 0.0);
|
||||
}
|
||||
|
||||
Length ClampRadius(IN(AtmosphereParameters) atmosphere, Length r) {
|
||||
return clamp(r, atmosphere.bottom_radius, atmosphere.top_radius);
|
||||
}
|
||||
|
||||
Length SafeSqrt(Area a) {
|
||||
return sqrt(max(a, 0.0));
|
||||
}
|
||||
|
||||
Length DistanceToTopAtmosphereBoundary(IN(AtmosphereParameters) atmosphere,
|
||||
Length r, Number mu) {
|
||||
assert(r <= atmosphere.top_radius);
|
||||
assert(mu >= -1.0 && mu <= 1.0);
|
||||
Area discriminant = r * r * (mu * mu - 1.0) +
|
||||
atmosphere.top_radius * atmosphere.top_radius;
|
||||
return ClampDistance(-r * mu + SafeSqrt(discriminant));
|
||||
}
|
||||
|
||||
Length DistanceToBottomAtmosphereBoundary(IN(AtmosphereParameters) atmosphere,
|
||||
Length r, Number mu) {
|
||||
assert(r >= atmosphere.bottom_radius);
|
||||
assert(mu >= -1.0 && mu <= 1.0);
|
||||
Area discriminant = r * r * (mu * mu - 1.0) +
|
||||
atmosphere.bottom_radius * atmosphere.bottom_radius;
|
||||
return ClampDistance(-r * mu - SafeSqrt(discriminant));
|
||||
}
|
||||
|
||||
bool RayIntersectsGround(IN(AtmosphereParameters) atmosphere,
|
||||
Length r, Number mu, OUT(Length) d_1, OUT(Length) d_2) {
|
||||
assert(r >= atmosphere.bottom_radius);
|
||||
assert(mu >= -1.0 && mu <= 1.0);
|
||||
d_1 = 0.0;
|
||||
d_2 = 0.0;
|
||||
float discriminant = 4 * r * r * (mu * mu - 1.0) +
|
||||
4 * atmosphere.bottom_radius * atmosphere.bottom_radius;
|
||||
if (discriminant >= 0.0f) {
|
||||
float sqDis = sqrt(discriminant);
|
||||
d_1 = (-2.0f * r * mu - sqDis) / 2.0f;
|
||||
d_2 = (-2.0f * r * mu + sqDis) / 2.0f;
|
||||
}
|
||||
return mu < 0.0 && discriminant >= 0.0;
|
||||
}
|
||||
|
||||
bool RayIntersectsGround(IN(AtmosphereParameters) atmosphere,
|
||||
Length r, Number mu) {
|
||||
assert(r >= atmosphere.bottom_radius);
|
||||
assert(mu >= -1.0 && mu <= 1.0);
|
||||
return mu < 0.0 && r * r * (mu * mu - 1.0) +
|
||||
atmosphere.bottom_radius * atmosphere.bottom_radius >= 0.0;
|
||||
}
|
||||
|
||||
Number GetTextureCoordFromUnitRange(Number x, int texture_size) {
|
||||
return 0.5 / Number(texture_size) + x * (1.0 - 1.0 / Number(texture_size));
|
||||
}
|
||||
|
||||
Number GetUnitRangeFromTextureCoord(Number u, int texture_size) {
|
||||
return (u - 0.5 / Number(texture_size)) / (1.0 - 1.0 / Number(texture_size));
|
||||
}
|
||||
|
||||
Number GetScaleHeight(Length altitude, Length scale_height) {
|
||||
return exp(-altitude / scale_height);
|
||||
}
|
||||
|
||||
vec2 GetScaleHeight(Length altitude, vec2 scale_height_rayleigh_mie) {
|
||||
return exp(-vec2(altitude, altitude) / scale_height_rayleigh_mie);
|
||||
}
|
||||
|
||||
Length DistanceToNearestAtmosphereBoundary(IN(AtmosphereParameters) atmosphere,
|
||||
Length r, Number mu, bool ray_r_mu_intersects_ground) {
|
||||
if (ray_r_mu_intersects_ground) {
|
||||
return DistanceToBottomAtmosphereBoundary(atmosphere, r, mu);
|
||||
}
|
||||
else {
|
||||
return DistanceToTopAtmosphereBoundary(atmosphere, r, mu);
|
||||
}
|
||||
}
|
||||
|
||||
Number GetNuFromMuMus(float mu, float mu_s) {
|
||||
return /*cos(a-b), where cos(a) == mu, cos(b) == mu_s*/ mu * mu_s + (1 - mu * mu) * (1 - mu_s * mu_s);
|
||||
}
|
||||
|
||||
/*
|
||||
Pass in variables.
|
||||
*/
|
||||
float atmosphere_top_radius;
|
||||
float atmosphere_bot_radius;
|
||||
float atmosphere_sun_angular_radius;
|
||||
float3 rayleigh_scattering;
|
||||
float rayleigh_scale_height;
|
||||
float mie_scattering;
|
||||
float mie_extinction;
|
||||
float mie_scale_height;
|
||||
float mie_phase_function_g;
|
||||
float3 absorption_extinction;
|
||||
float absorption_extinction_scale_height;
|
||||
|
||||
AtmosphereParameters GetAtmParameters() {
|
||||
return GetAtmosphereStruct(
|
||||
atmosphere_top_radius,
|
||||
atmosphere_bot_radius,
|
||||
atmosphere_sun_angular_radius,
|
||||
rayleigh_scattering,
|
||||
rayleigh_scale_height,
|
||||
mie_scattering,
|
||||
mie_extinction,
|
||||
mie_scale_height,
|
||||
mie_phase_function_g,
|
||||
absorption_extinction,
|
||||
absorption_extinction_scale_height
|
||||
);
|
||||
}
|
||||
|
||||
InverseSolidAngle RayleighPhaseFunction(Number nu) {
|
||||
InverseSolidAngle k = 3.0 / (16.0 * PI * sr);
|
||||
return k * (1.0 + nu * nu);
|
||||
//return 0.8f * (1.4f + 0.5f * nu) / (4.0 * PI);
|
||||
}
|
||||
|
||||
InverseSolidAngle AdhocRayleighPhaseFunction(Number nu) {
|
||||
return 0.8f * (1.4f + 0.5f * nu) / (4.0 * PI * sr);
|
||||
}
|
||||
|
||||
InverseSolidAngle MiePhaseFunction(Number g, Number nu) {
|
||||
InverseSolidAngle k = 3.0 / (8.0 * PI * sr) * (1.0 - g * g) / (2.0 + g * g);
|
||||
return k * (1.0 + nu * nu) / pow(abs(1.0 + g * g - 2.0 * g * nu), 1.5);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 498005b870bb3d74e8dafc015b3de52d
|
||||
timeCreated: 1531897786
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
125
Assets/Plugins/AtmosphereScattering/Shaders/GroundHelper.cginc
Normal file
125
Assets/Plugins/AtmosphereScattering/Shaders/GroundHelper.cginc
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
#ifndef __GROUND_HELPER__
|
||||
#define __GROUND_HELPER__
|
||||
|
||||
#include "Common.cginc"
|
||||
#include "TransmittanceHelper.cginc"
|
||||
#include "MultipleScatteringHelper.cginc"
|
||||
|
||||
IrradianceSpectrum ComputeDirectIrradiance(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 transmittance_size,
|
||||
Length r, Number mu_s) {
|
||||
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
|
||||
assert(mu_s >= -1.0 && mu_s <= 1.0);
|
||||
|
||||
Number alpha_s = atmosphere.sun_angular_radius / rad;
|
||||
// Approximate average of the cosine factor mu_s over the visible fraction of
|
||||
// the Sun disc.
|
||||
Number average_cosine_factor =
|
||||
mu_s < -alpha_s ? 0.0 : (mu_s > alpha_s ? mu_s :
|
||||
(mu_s + alpha_s) * (mu_s + alpha_s) / (4.0 * alpha_s));
|
||||
|
||||
return atmosphere.solar_irradiance *
|
||||
GetTransmittanceToTopAtmosphereBoundary(
|
||||
atmosphere, transmittance_texture, transmittance_size, r, mu_s) * average_cosine_factor;
|
||||
}
|
||||
|
||||
IrradianceSpectrum ComputeIndirectIrradiance(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(ReducedScatteringTexture) single_rayleigh_scattering_texture,
|
||||
IN(ReducedScatteringTexture) single_mie_scattering_texture,
|
||||
IN(ScatteringTexture) multiple_scattering_texture,
|
||||
uint3 scattering_size,
|
||||
Length r, Number mu_s, int scattering_order) {
|
||||
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
|
||||
assert(mu_s >= -1.0 && mu_s <= 1.0);
|
||||
assert(scattering_order >= 1);
|
||||
|
||||
const int SAMPLE_COUNT = 32;
|
||||
const Angle dphi = pi / Number(SAMPLE_COUNT);
|
||||
const Angle dtheta = pi / Number(SAMPLE_COUNT);
|
||||
|
||||
IrradianceSpectrum result =
|
||||
IrradianceSpectrum(0.0, 0.0, 0.0);
|
||||
vec3 omega_s = vec3(sqrt(1.0 - mu_s * mu_s), 0.0, mu_s);
|
||||
for (int j = 0; j < SAMPLE_COUNT / 2; ++j) {
|
||||
Angle theta = (Number(j) + 0.5) * dtheta;
|
||||
for (int i = 0; i < 2 * SAMPLE_COUNT; ++i) {
|
||||
Angle phi = (Number(i) + 0.5) * dphi;
|
||||
vec3 omega =
|
||||
vec3(cos(phi) * sin(theta), sin(phi) * sin(theta), cos(theta));
|
||||
SolidAngle domega = (dtheta / rad) * (dphi / rad) * sin(theta) ;
|
||||
|
||||
Number nu = dot(omega, omega_s);
|
||||
result += GetScattering(atmosphere, single_rayleigh_scattering_texture,
|
||||
single_mie_scattering_texture, multiple_scattering_texture, scattering_size,
|
||||
r, omega.z, mu_s, nu, false /* ray_r_theta_intersects_ground */,
|
||||
scattering_order) *
|
||||
omega.z * domega;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
vec2 GetIrradianceTextureUvFromRMuS(IN(AtmosphereParameters) atmosphere,
|
||||
Length r, Number mu_s, uint2 irradiance_size) {
|
||||
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
|
||||
assert(mu_s >= -1.0 && mu_s <= 1.0);
|
||||
Number x_r = (r - atmosphere.bottom_radius) /
|
||||
(atmosphere.top_radius - atmosphere.bottom_radius);
|
||||
Number x_mu_s = mu_s * 0.5 + 0.5;
|
||||
return vec2(GetTextureCoordFromUnitRange(x_mu_s, irradiance_size.x),
|
||||
GetTextureCoordFromUnitRange(x_r, irradiance_size.y));
|
||||
}
|
||||
|
||||
void GetRMuSFromIrradianceTextureUv(IN(AtmosphereParameters) atmosphere,
|
||||
IN(vec2) uv, OUT(Length) r, OUT(Number) mu_s, uint2 irradiance_size) {
|
||||
assert(uv.x >= 0.0 && uv.x <= 1.0);
|
||||
assert(uv.y >= 0.0 && uv.y <= 1.0);
|
||||
Number x_mu_s = GetUnitRangeFromTextureCoord(uv.x, irradiance_size.x);
|
||||
Number x_r = GetUnitRangeFromTextureCoord(uv.y, irradiance_size.y);
|
||||
r = atmosphere.bottom_radius +
|
||||
x_r * (atmosphere.top_radius - atmosphere.bottom_radius);
|
||||
mu_s = ClampCosine(2.0 * x_mu_s - 1.0);
|
||||
}
|
||||
|
||||
IrradianceSpectrum GetIrradiance(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(IrradianceTexture) irradiance_texture,
|
||||
uint2 irradiance_size,
|
||||
Length r, Number mu_s) {
|
||||
vec2 uv = GetIrradianceTextureUvFromRMuS(atmosphere, r, mu_s, irradiance_size);
|
||||
return IrradianceSpectrum(tex2Dlod(irradiance_texture, float4(uv,0.0, 0.0)).rgb);
|
||||
}
|
||||
|
||||
|
||||
IrradianceSpectrum ComputeDirectIrradianceTexture(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 transmittance_size,
|
||||
IN(vec2) uv,
|
||||
uint2 irrdiance_size) {
|
||||
Length r;
|
||||
Number mu_s;
|
||||
GetRMuSFromIrradianceTextureUv(
|
||||
atmosphere, uv, r, mu_s, irrdiance_size);
|
||||
return ComputeDirectIrradiance(atmosphere, transmittance_texture, transmittance_size, r, mu_s);
|
||||
}
|
||||
|
||||
IrradianceSpectrum ComputeIndirectIrradianceTexture(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(ReducedScatteringTexture) single_rayleigh_scattering_texture,
|
||||
IN(ReducedScatteringTexture) single_mie_scattering_texture,
|
||||
IN(ScatteringTexture) multiple_scattering_texture,
|
||||
uint3 scattering_size,
|
||||
IN(vec2) uv, int scattering_order, uint2 irrdiance_size) {
|
||||
Length r;
|
||||
Number mu_s;
|
||||
GetRMuSFromIrradianceTextureUv(
|
||||
atmosphere, uv, r, mu_s, irrdiance_size);
|
||||
return ComputeIndirectIrradiance(atmosphere,
|
||||
single_rayleigh_scattering_texture, single_mie_scattering_texture,
|
||||
multiple_scattering_texture, scattering_size, r, mu_s, scattering_order);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: edb2696599cfe204d9a12cfa587afc0f
|
||||
timeCreated: 1531897786
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,209 @@
|
|||
#ifndef __MULTIPLE_SCATTERING_HELPER__
|
||||
#define __MULTIPLE_SCATTERING_HELPER__
|
||||
|
||||
#include "Common.cginc"
|
||||
#include "TransmittanceHelper.cginc"
|
||||
#include "SingleScatteringHelper.cginc"
|
||||
|
||||
IrradianceSpectrum GetIrradiance(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(IrradianceTexture) irradiance_texture, uint2 irradiance_size,
|
||||
Length r, Number mu_s);
|
||||
|
||||
RadianceDensitySpectrum ComputeScatteringDensity(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 transmittance_size,
|
||||
IN(ReducedScatteringTexture) single_rayleigh_scattering_texture,
|
||||
IN(ReducedScatteringTexture) single_mie_scattering_texture,
|
||||
IN(ScatteringTexture) multiple_scattering_texture,
|
||||
uint3 scattering_size,
|
||||
IN(IrradianceTexture) irradiance_texture,
|
||||
uint2 irradiance_size,
|
||||
Length r, Number mu, Number mu_s, Number nu, int scattering_order) {
|
||||
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
|
||||
assert(mu >= -1.0 && mu <= 1.0);
|
||||
assert(mu_s >= -1.0 && mu_s <= 1.0);
|
||||
assert(scattering_order >= 2);
|
||||
|
||||
|
||||
// Compute unit direction vectors for the zenith, the view direction omega and
|
||||
// and the sun direction omega_s, such that the cosine of the view-zenith
|
||||
// angle is mu, the cosine of the sun-zenith angle is mu_s, and the cosine of
|
||||
// the view-sun angle is nu. The goal is to simplify computations below.
|
||||
vec3 zenith_direction = vec3(0.0, 0.0, 1.0);
|
||||
vec3 omega = vec3(sqrt(1.0 - mu * mu), 0.0, mu);
|
||||
Number sun_dir_x = omega.x == 0.0 ? 0.0 : (nu - mu * mu_s) / omega.x;
|
||||
Number sun_dir_y = sqrt(max(1.0 - sun_dir_x * sun_dir_x - mu_s * mu_s, 0.0));
|
||||
vec3 omega_s = vec3(sun_dir_x, sun_dir_y, mu_s);
|
||||
|
||||
const int SAMPLE_COUNT = 16;
|
||||
const Angle dphi = pi / Number(SAMPLE_COUNT);
|
||||
const Angle dtheta = pi / Number(SAMPLE_COUNT);
|
||||
RadianceDensitySpectrum rayleigh_mie =
|
||||
RadianceDensitySpectrum(0.0, 0.0, 0.0);
|
||||
|
||||
// Nested loops for the integral over all the incident directions omega_i.
|
||||
for (int l = 0; l < SAMPLE_COUNT; ++l) {
|
||||
Angle theta = (Number(l) + 0.5) * dtheta;
|
||||
Number cos_theta = cos(theta);
|
||||
Number sin_theta = sin(theta);
|
||||
bool ray_r_theta_intersects_ground =
|
||||
RayIntersectsGround(atmosphere, r, cos_theta);
|
||||
|
||||
// The distance and transmittance to the ground only depend on theta, so we
|
||||
// can compute them in the outer loop for efficiency.
|
||||
Length distance_to_ground = 0.0 * m;
|
||||
DimensionlessSpectrum transmittance_to_ground = DimensionlessSpectrum(0.0, 0.0, 0.0);
|
||||
DimensionlessSpectrum ground_albedo = DimensionlessSpectrum(0.0, 0.0, 0.0);
|
||||
if (ray_r_theta_intersects_ground) {
|
||||
distance_to_ground =
|
||||
DistanceToBottomAtmosphereBoundary(atmosphere, r, cos_theta);
|
||||
transmittance_to_ground =
|
||||
GetTransmittance(atmosphere, transmittance_texture, transmittance_size, r, cos_theta,
|
||||
distance_to_ground, true /* ray_intersects_ground */);
|
||||
ground_albedo = atmosphere.ground_albedo;
|
||||
}
|
||||
|
||||
for (int m = 0; m < 2 * SAMPLE_COUNT; ++m) {
|
||||
Angle phi = (Number(m) + 0.5) * dphi;
|
||||
vec3 omega_i =
|
||||
vec3(cos(phi) * sin_theta, sin(phi) * sin_theta, cos_theta);
|
||||
SolidAngle domega_i = (dtheta / rad) * (dphi / rad) * sin(theta) * sr;
|
||||
|
||||
// The radiance L_i arriving from direction omega_i after n-1 bounces is
|
||||
// the sum of a term given by the precomputed scattering texture for the
|
||||
// (n-1)-th order:
|
||||
Number nu1 = dot(omega_s, omega_i);
|
||||
RadianceSpectrum incident_radiance = GetScattering(atmosphere,
|
||||
single_rayleigh_scattering_texture, single_mie_scattering_texture,
|
||||
multiple_scattering_texture, scattering_size, r, omega_i.z, mu_s, nu1,
|
||||
ray_r_theta_intersects_ground, scattering_order - 1);
|
||||
|
||||
// and of the contribution from the light paths with n-1 bounces and whose
|
||||
// last bounce is on the ground. This contribution is the product of the
|
||||
// transmittance to the ground, the ground albedo, the ground BRDF, and
|
||||
// the irradiance received on the ground after n-2 bounces.
|
||||
vec3 ground_normal =
|
||||
normalize(zenith_direction * r + omega_i * distance_to_ground);
|
||||
IrradianceSpectrum ground_irradiance = GetIrradiance(
|
||||
atmosphere, irradiance_texture, irradiance_size, atmosphere.bottom_radius,
|
||||
dot(ground_normal, omega_s));
|
||||
incident_radiance += transmittance_to_ground *
|
||||
ground_albedo * (1.0 / (PI * sr)) * ground_irradiance;
|
||||
|
||||
// The radiance finally scattered from direction omega_i towards direction
|
||||
// -omega is the product of the incident radiance, the scattering
|
||||
// coefficient, and the phase function for directions omega and omega_i
|
||||
// (all this summed over all particle types, i.e. Rayleigh and Mie).
|
||||
Number nu2 = dot(omega, omega_i);
|
||||
Number rayleigh_density = GetScaleHeight(
|
||||
r - atmosphere.bottom_radius, atmosphere.rayleigh_scale_height);
|
||||
Number mie_density = GetScaleHeight(
|
||||
r - atmosphere.bottom_radius, atmosphere.mie_scale_height);
|
||||
|
||||
rayleigh_mie += incident_radiance * (
|
||||
atmosphere.rayleigh_scattering * rayleigh_density *
|
||||
RayleighPhaseFunction(nu2) +
|
||||
atmosphere.mie_scattering * mie_density *
|
||||
MiePhaseFunction(atmosphere.mie_phase_function_g, nu2)) *
|
||||
domega_i;
|
||||
}
|
||||
}
|
||||
return rayleigh_mie;
|
||||
}
|
||||
|
||||
RadianceSpectrum ComputeMultipleScattering(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 transmittance_size,
|
||||
IN(ScatteringDensityTexture) scattering_density_texture,
|
||||
uint3 scattering_size,
|
||||
Length r, Number mu, Number mu_s, Number nu,
|
||||
bool ray_r_mu_intersects_ground) {
|
||||
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
|
||||
assert(mu >= -1.0 && mu <= 1.0);
|
||||
assert(mu_s >= -1.0 && mu_s <= 1.0);
|
||||
|
||||
// Number of intervals for the numerical integration.
|
||||
const int SAMPLE_COUNT = 50;
|
||||
// The integration step, i.e. the length of each integration interval.
|
||||
Length dx =
|
||||
DistanceToNearestAtmosphereBoundary(
|
||||
atmosphere, r, mu, ray_r_mu_intersects_ground) /
|
||||
Number(SAMPLE_COUNT);
|
||||
// Integration loop.
|
||||
RadianceSpectrum rayleigh_mie_sum =
|
||||
RadianceSpectrum(0.0, 0.0, 0.0);
|
||||
for (int i = 0; i <= SAMPLE_COUNT; ++i) {
|
||||
Length d_i = Number(i) * dx;
|
||||
|
||||
// The r, mu and mu_s parameters at the current integration point (see the
|
||||
// single scattering section for a detailed explanation).
|
||||
Length r_i =
|
||||
ClampRadius(atmosphere, sqrt(d_i * d_i + 2.0 * r * mu * d_i + r * r));
|
||||
Number mu_i = ClampCosine((r * mu + d_i) / r_i);
|
||||
Number mu_s_i = ClampCosine((r * mu_s + d_i * nu) / r_i);
|
||||
|
||||
// The Rayleigh and Mie multiple scattering at the current sample point.
|
||||
RadianceSpectrum rayleigh_mie_i =
|
||||
SampleScattering(
|
||||
atmosphere, scattering_density_texture, scattering_size, r_i, mu_i, mu_s_i,
|
||||
ray_r_mu_intersects_ground) *
|
||||
GetTransmittance(
|
||||
atmosphere, transmittance_texture, transmittance_size, r, mu, d_i,
|
||||
ray_r_mu_intersects_ground) *
|
||||
dx;
|
||||
// Sample weight (from the trapezoidal rule).
|
||||
Number weight_i = (i == 0 || i == SAMPLE_COUNT) ? 0.5 : 1.0;
|
||||
rayleigh_mie_sum += rayleigh_mie_i * weight_i;
|
||||
}
|
||||
return rayleigh_mie_sum;
|
||||
}
|
||||
|
||||
RadianceDensitySpectrum ComputeScatteringDensityTexture(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 transmittance_size,
|
||||
IN(ReducedScatteringTexture) single_rayleigh_scattering_texture,
|
||||
IN(ReducedScatteringTexture) single_mie_scattering_texture,
|
||||
IN(ScatteringTexture) multiple_scattering_texture,
|
||||
uint3 scattering_size,
|
||||
IN(IrradianceTexture) irradiance_texture,
|
||||
uint2 irradiance_size,
|
||||
IN(vec3) frag_coord, int scattering_order) {
|
||||
Length r;
|
||||
Number mu;
|
||||
Number mu_s;
|
||||
Number nu;
|
||||
|
||||
bool ray_r_mu_intersects_ground;
|
||||
GetRMuMuSNuFromScatteringTextureUvwz(atmosphere, frag_coord,
|
||||
r, mu, mu_s, ray_r_mu_intersects_ground, scattering_size);
|
||||
nu = GetNuFromMuMus(mu, mu_s);
|
||||
return ComputeScatteringDensity(atmosphere, transmittance_texture, transmittance_size,
|
||||
single_rayleigh_scattering_texture, single_mie_scattering_texture,
|
||||
multiple_scattering_texture, scattering_size, irradiance_texture, irradiance_size, r, mu, mu_s, nu,
|
||||
scattering_order);
|
||||
}
|
||||
|
||||
RadianceSpectrum ComputeMultipleScatteringTexture(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 transmittance_size,
|
||||
IN(ScatteringDensityTexture) scattering_density_texture,
|
||||
uint3 scattering_size,
|
||||
IN(vec3) frag_coord) {
|
||||
Length r;
|
||||
Number mu;
|
||||
Number mu_s;
|
||||
Number nu;
|
||||
bool ray_r_mu_intersects_ground;
|
||||
GetRMuMuSNuFromScatteringTextureUvwz(atmosphere, frag_coord,
|
||||
r, mu, mu_s, ray_r_mu_intersects_ground, scattering_size);
|
||||
nu = GetNuFromMuMus(mu, mu_s);
|
||||
return ComputeMultipleScattering(atmosphere, transmittance_texture, transmittance_size,
|
||||
scattering_density_texture, scattering_size, r, mu, mu_s, nu,
|
||||
ray_r_mu_intersects_ground);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d94410a36635724f887c5648062ed59
|
||||
timeCreated: 1531897786
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,245 @@
|
|||
#ifndef __SINGLE_SCATTERING_HELPER__
|
||||
#define __SINGLE_SCATTERING_HELPER__
|
||||
|
||||
#include "Common.cginc"
|
||||
#include "TransmittanceHelper.cginc"
|
||||
|
||||
void ComputeSingleScatteringIntegrand(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 texture_size,
|
||||
Length r, Number mu, Number mu_s, Number nu, Length d,
|
||||
bool ray_r_mu_intersects_ground,
|
||||
OUT(DimensionlessSpectrum) rayleigh, OUT(DimensionlessSpectrum) mie) {
|
||||
|
||||
Length r_d = ClampRadius(atmosphere, sqrt(d * d + 2.0 * r * mu * d + r * r));
|
||||
Number mu_s_d = ClampCosine((r * mu_s + d * nu) / r_d);
|
||||
DimensionlessSpectrum transmittance =
|
||||
GetTransmittance(
|
||||
atmosphere, transmittance_texture, texture_size, r, mu, d,
|
||||
ray_r_mu_intersects_ground) *
|
||||
GetTransmittanceToSun(
|
||||
atmosphere, transmittance_texture, texture_size, r_d, mu_s_d);
|
||||
rayleigh = transmittance * GetScaleHeight(r_d - atmosphere.bottom_radius, atmosphere.rayleigh_scale_height);
|
||||
mie = transmittance * GetScaleHeight(r_d - atmosphere.bottom_radius, atmosphere.rayleigh_scale_height);
|
||||
}
|
||||
|
||||
void ComputeSingleScattering(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 texture_size,
|
||||
Length r, Number mu, Number mu_s, Number nu,
|
||||
bool ray_r_mu_intersects_ground,
|
||||
OUT(IrradianceSpectrum) rayleigh, OUT(IrradianceSpectrum) mie) {
|
||||
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
|
||||
assert(mu >= -1.0 && mu <= 1.0);
|
||||
assert(mu_s >= -1.0 && mu_s <= 1.0);
|
||||
|
||||
|
||||
// Number of intervals for the numerical integration.
|
||||
const int SAMPLE_COUNT = 50;
|
||||
// The integration step, i.e. the length of each integration interval.
|
||||
Length dx =
|
||||
DistanceToNearestAtmosphereBoundary(atmosphere, r, mu,
|
||||
ray_r_mu_intersects_ground) / Number(SAMPLE_COUNT);
|
||||
// Integration loop.
|
||||
DimensionlessSpectrum rayleigh_sum = DimensionlessSpectrum(0.0, 0.0, 0.0);
|
||||
DimensionlessSpectrum mie_sum = DimensionlessSpectrum(0.0, 0.0, 0.0);
|
||||
for (int i = 0; i <= SAMPLE_COUNT; ++i) {
|
||||
Length d_i = Number(i) * dx;
|
||||
// The Rayleigh and Mie single scattering at the current sample point.
|
||||
DimensionlessSpectrum rayleigh_i;
|
||||
DimensionlessSpectrum mie_i;
|
||||
ComputeSingleScatteringIntegrand(atmosphere, transmittance_texture, texture_size,
|
||||
r, mu, mu_s, nu, d_i, ray_r_mu_intersects_ground, rayleigh_i, mie_i);
|
||||
// Sample weight (from the trapezoidal rule).
|
||||
Number weight_i = (i == 0 || i == SAMPLE_COUNT) ? 0.5 : 1.0;
|
||||
rayleigh_sum += rayleigh_i * weight_i;
|
||||
mie_sum += mie_i * weight_i;
|
||||
}
|
||||
//Phase function terms are not added yet. See GetScattering.(And also, we need to store rayleigh and mie seprately, since they use different phase functions.)
|
||||
rayleigh = rayleigh_sum * dx * atmosphere.solar_irradiance * atmosphere.rayleigh_scattering;
|
||||
mie = mie_sum * dx * atmosphere.solar_irradiance * atmosphere.mie_scattering;
|
||||
}
|
||||
|
||||
vec3 GetScatteringTextureUvwzFromRMuMuSNu(IN(AtmosphereParameters) atmosphere,
|
||||
Length r, Number mu, Number mu_s, uint3 texture_size,
|
||||
bool ray_r_mu_intersects_ground) {
|
||||
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
|
||||
assert(mu >= -1.0 && mu <= 1.0);
|
||||
assert(mu_s >= -1.0 && mu_s <= 1.0);
|
||||
|
||||
// Distance to top atmosphere boundary for a horizontal ray at ground level.
|
||||
Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
|
||||
atmosphere.bottom_radius * atmosphere.bottom_radius);
|
||||
// Distance to the horizon.
|
||||
Length rho =
|
||||
SafeSqrt(r * r - atmosphere.bottom_radius * atmosphere.bottom_radius);
|
||||
Number u_r = GetTextureCoordFromUnitRange(rho / H, texture_size.z);
|
||||
|
||||
// Discriminant of the quadratic equation for the intersections of the ray
|
||||
// (r,mu) with the ground (see RayIntersectsGround).
|
||||
Length r_mu = r * mu;
|
||||
Area discriminant =
|
||||
r_mu * r_mu - r * r + atmosphere.bottom_radius * atmosphere.bottom_radius;
|
||||
Number u_mu;
|
||||
if (ray_r_mu_intersects_ground) {
|
||||
// Distance to the ground for the ray (r,mu), and its minimum and maximum
|
||||
// values over all mu - obtained for (r,-1) and (r,mu_horizon).
|
||||
Length d = -r_mu - SafeSqrt(discriminant);
|
||||
Length d_min = r - atmosphere.bottom_radius;
|
||||
Length d_max = rho;
|
||||
u_mu = 0.5 - 0.5 * GetTextureCoordFromUnitRange(d_max == d_min ? 0.0 :
|
||||
(d - d_min) / (d_max - d_min), texture_size.y / 2);
|
||||
}
|
||||
else {
|
||||
// Distance to the top atmosphere boundary for the ray (r,mu), and its
|
||||
// minimum and maximum values over all mu - obtained for (r,1) and
|
||||
// (r,mu_horizon).
|
||||
Length d = -r_mu + SafeSqrt(discriminant + H * H);
|
||||
Length d_min = atmosphere.top_radius - r;
|
||||
Length d_max = rho + H;
|
||||
u_mu = 0.5 + 0.5 * GetTextureCoordFromUnitRange(
|
||||
(d - d_min) / (d_max - d_min), texture_size.y / 2);
|
||||
}
|
||||
|
||||
Length d = DistanceToTopAtmosphereBoundary(
|
||||
atmosphere, atmosphere.bottom_radius, mu_s);
|
||||
Length d_min = atmosphere.top_radius - atmosphere.bottom_radius;
|
||||
Length d_max = H;
|
||||
Number a = (d - d_min) / (d_max - d_min);
|
||||
Number A =
|
||||
-2.0 * atmosphere.mu_s_min * atmosphere.bottom_radius / (d_max - d_min);
|
||||
Number u_mu_s = GetTextureCoordFromUnitRange(
|
||||
max(1.0 - a / A, 0.0) / (1.0 + a), texture_size.x);
|
||||
|
||||
return vec3(u_mu_s, u_mu, u_r);
|
||||
}
|
||||
|
||||
void GetRMuMuSNuFromScatteringTextureUvwz(IN(AtmosphereParameters) atmosphere,
|
||||
IN(vec3) uvwz, OUT(Length) r, OUT(Number) mu, OUT(Number) mu_s, OUT(bool) ray_r_mu_intersects_ground,
|
||||
uint3 scattering_size
|
||||
) {
|
||||
assert(uvwz.x >= 0.0 && uvwz.x <= 1.0);
|
||||
assert(uvwz.y >= 0.0 && uvwz.y <= 1.0);
|
||||
assert(uvwz.z >= 0.0 && uvwz.z <= 1.0);
|
||||
|
||||
// Distance to top atmosphere boundary for a horizontal ray at ground level.
|
||||
Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
|
||||
atmosphere.bottom_radius * atmosphere.bottom_radius);
|
||||
// Distance to the horizon.
|
||||
Length rho =
|
||||
H * GetUnitRangeFromTextureCoord(uvwz.z, scattering_size.z);
|
||||
r = sqrt(rho * rho + atmosphere.bottom_radius * atmosphere.bottom_radius);
|
||||
|
||||
if (uvwz.y < 0.5) {
|
||||
// Distance to the ground for the ray (r,mu), and its minimum and maximum
|
||||
// values over all mu - obtained for (r,-1) and (r,mu_horizon) - from which
|
||||
// we can recover mu:
|
||||
Length d_min = r - atmosphere.bottom_radius;
|
||||
Length d_max = rho;
|
||||
Length d = d_min + (d_max - d_min) * GetUnitRangeFromTextureCoord(
|
||||
1.0 - 2.0 * uvwz.y, scattering_size.y / 2);
|
||||
mu = d == 0.0 * m ? Number(-1.0) :
|
||||
ClampCosine(-(rho * rho + d * d) / (2.0 * r * d));
|
||||
ray_r_mu_intersects_ground = true;
|
||||
}
|
||||
else {
|
||||
// Distance to the top atmosphere boundary for the ray (r,mu), and its
|
||||
// minimum and maximum values over all mu - obtained for (r,1) and
|
||||
// (r,mu_horizon) - from which we can recover mu:
|
||||
Length d_min = atmosphere.top_radius - r;
|
||||
Length d_max = rho + H;
|
||||
Length d = d_min + (d_max - d_min) * GetUnitRangeFromTextureCoord(
|
||||
2.0 * uvwz.y - 1.0, scattering_size.y / 2);
|
||||
mu = d == 0.0 * m ? Number(1.0) :
|
||||
ClampCosine((H * H - rho * rho - d * d) / (2.0 * r * d));
|
||||
ray_r_mu_intersects_ground = false;
|
||||
}
|
||||
|
||||
Number x_mu_s =
|
||||
GetUnitRangeFromTextureCoord(uvwz.x, scattering_size.x);
|
||||
Length d_min = atmosphere.top_radius - atmosphere.bottom_radius;
|
||||
Length d_max = H;
|
||||
Number A =
|
||||
-2.0 * atmosphere.mu_s_min * atmosphere.bottom_radius / (d_max - d_min);
|
||||
Number a = (A - x_mu_s * A) / (1.0 + x_mu_s * A);
|
||||
Length d = d_min + min(a, A) * (d_max - d_min);
|
||||
mu_s = d == 0.0 * m ? Number(1.0) :
|
||||
ClampCosine((H * H - d * d) / (2.0 * atmosphere.bottom_radius * d));
|
||||
}
|
||||
|
||||
void ComputeSingleScatteringTexture(IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 transmittance_size,
|
||||
IN(vec3) gl_frag_coord,
|
||||
uint3 scattering_size,
|
||||
OUT(IrradianceSpectrum) rayleigh,
|
||||
OUT(IrradianceSpectrum) mie) {
|
||||
|
||||
Length r;
|
||||
Number mu;
|
||||
Number mu_s;
|
||||
bool ray_r_mu_intersects_ground;
|
||||
GetRMuMuSNuFromScatteringTextureUvwz(atmosphere, gl_frag_coord,
|
||||
r, mu, mu_s, ray_r_mu_intersects_ground, scattering_size);
|
||||
Number nu = GetNuFromMuMus(mu, mu_s);
|
||||
ComputeSingleScattering(atmosphere, transmittance_texture, transmittance_size,
|
||||
r, mu, mu_s, nu, ray_r_mu_intersects_ground, rayleigh, mie);
|
||||
}
|
||||
|
||||
RadianceSpectrum SampleScattering(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(ScatteringTexture) scattering_texture,
|
||||
uint3 texture_size,
|
||||
Length r, Number mu, Number mu_s, bool ray_r_mu_intersects_ground
|
||||
|
||||
) {
|
||||
vec3 uvwz = GetScatteringTextureUvwzFromRMuMuSNu(
|
||||
atmosphere, r, mu, mu_s, texture_size, ray_r_mu_intersects_ground);
|
||||
return tex3Dlod(scattering_texture, float4(uvwz, 0.0)).rgb;
|
||||
}
|
||||
|
||||
RadianceSpectrum SampleScatteringLerped(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(ScatteringTexture) scattering_texture,
|
||||
IN(ScatteringTexture) scattering_texture_2,
|
||||
float lerpValue,
|
||||
uint3 texture_size,
|
||||
Length r, Number mu, Number mu_s, bool ray_r_mu_intersects_ground
|
||||
|
||||
) {
|
||||
vec3 uvwz = GetScatteringTextureUvwzFromRMuMuSNu(
|
||||
atmosphere, r, mu, mu_s, texture_size, ray_r_mu_intersects_ground);
|
||||
return lerp(tex3Dlod(scattering_texture, float4(uvwz, 0.0)).rgb, tex3Dlod(scattering_texture_2, float4(uvwz, 0.0)).rgb, lerpValue);
|
||||
}
|
||||
|
||||
RadianceSpectrum GetScattering(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(ReducedScatteringTexture) single_rayleigh_scattering_texture,
|
||||
IN(ReducedScatteringTexture) single_mie_scattering_texture,
|
||||
IN(ScatteringTexture) multiple_scattering_texture,
|
||||
uint3 texture_size,
|
||||
Length r, Number mu, Number mu_s, Number nu,
|
||||
bool ray_r_mu_intersects_ground,
|
||||
int scattering_order
|
||||
) {
|
||||
|
||||
if (scattering_order == 1) {
|
||||
IrradianceSpectrum rayleigh = SampleScattering(
|
||||
atmosphere, single_rayleigh_scattering_texture, texture_size, r, mu, mu_s,
|
||||
ray_r_mu_intersects_ground);
|
||||
IrradianceSpectrum mie = SampleScattering(
|
||||
atmosphere, single_mie_scattering_texture, texture_size, r, mu, mu_s,
|
||||
ray_r_mu_intersects_ground);
|
||||
return rayleigh * RayleighPhaseFunction(nu) +
|
||||
mie * MiePhaseFunction(atmosphere.mie_phase_function_g, nu);
|
||||
}
|
||||
else {
|
||||
return SampleScattering(
|
||||
atmosphere, multiple_scattering_texture, texture_size, r, mu, mu_s,
|
||||
ray_r_mu_intersects_ground);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2ef315dd659e48f49ab150ef0aed889b
|
||||
timeCreated: 1531897786
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
|
||||
|
||||
Shader "Skybox/AtmosphereScatteringPrecomputed"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// No culling or depth
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Tags{
|
||||
"PreviewType" = "Skybox"
|
||||
}
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "MultipleScatteringHelper.cginc"
|
||||
#include "AerialPerspectiveHelper.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
float4 worldPos : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
float _LightScale;
|
||||
|
||||
RadianceSpectrum GetScattering(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(ScatteringTexture) scattering_texture,
|
||||
uint3 texture_size,
|
||||
Length r, Number mu, Number mu_s, bool ray_r_mu_intersects_ground
|
||||
);
|
||||
|
||||
void ComputeSingleScattering(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 texture_size,
|
||||
Length r, Number mu, Number mu_s, Number nu,
|
||||
bool ray_r_mu_intersects_ground,
|
||||
OUT(IrradianceSpectrum) rayleigh, OUT(IrradianceSpectrum) mie);
|
||||
|
||||
half4 frag (v2f i) : SV_Target
|
||||
{
|
||||
i.worldPos /= i.worldPos.w;
|
||||
float3 view_ray = normalize(i.worldPos.xyz - _WorldSpaceCameraPos);
|
||||
float3 sun_direction = normalize(_WorldSpaceLightPos0.xyz);
|
||||
AtmosphereParameters atm = GetAtmParameters();
|
||||
float3 camera = _WorldSpaceCameraPos + float3(0, atm.bottom_radius, 0);
|
||||
float r = length(camera);
|
||||
r = max(r, atm.bottom_radius + 1.0f); //r below bottom_radius causes glitch.
|
||||
Length rmu = dot(camera, view_ray);
|
||||
|
||||
Length distance_to_top_atmosphere_boundary = -rmu -
|
||||
sqrt(rmu * rmu - r * r + atm.top_radius * atm.top_radius);
|
||||
|
||||
if (distance_to_top_atmosphere_boundary > 0.0 ) {
|
||||
camera = camera + view_ray * distance_to_top_atmosphere_boundary;
|
||||
r = atm.top_radius;
|
||||
rmu += distance_to_top_atmosphere_boundary;
|
||||
}
|
||||
else if (r > atm.top_radius) {
|
||||
// If the view ray does not intersect the atmosphere, simply return 0.
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
// Compute the r, mu, mu_s and nu parameters needed for the texture lookups.
|
||||
Number mu = rmu / r;
|
||||
Number mu_s = dot(camera, sun_direction) / r;
|
||||
Number nu = dot(view_ray, sun_direction);
|
||||
bool ray_r_mu_intersects_ground = RayIntersectsGround(atm, r, mu);
|
||||
|
||||
float3 transmittance = GetTransmittanceToTopAtmosphereBoundaryLerped(r, mu) * (ray_r_mu_intersects_ground ? 0.0f : 1.0f);
|
||||
|
||||
float3 direct_sun_strength = 0.0f;
|
||||
if (!ray_r_mu_intersects_ground)
|
||||
{
|
||||
direct_sun_strength = EvaluateSunDiskRadianceOfUnitRadiance(atm, r, mu, nu) * transmittance;
|
||||
}
|
||||
return half4((direct_sun_strength + GetTotalScatteringLerped(r, mu, mu_s, nu, ray_r_mu_intersects_ground)), 0.0f);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e2088dd19a71d1244976cd0de1ff68a7
|
||||
timeCreated: 1531897513
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
#ifndef __TRANSMITTANCE_HELPER__
|
||||
#define __TRANSMITTANCE_HELPER__
|
||||
|
||||
#include "Common.cginc"
|
||||
|
||||
vec2 GetTransmittanceTextureUvFromRMu(IN(AtmosphereParameters) atmosphere,
|
||||
Length r, Number mu, uint2 texture_size) {
|
||||
// Distance to top atmosphere boundary for a horizontal ray at ground level.
|
||||
Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
|
||||
atmosphere.bottom_radius * atmosphere.bottom_radius);
|
||||
// Distance to the horizon.
|
||||
Length rho =
|
||||
SafeSqrt(r * r - atmosphere.bottom_radius * atmosphere.bottom_radius);
|
||||
// Distance to the top atmosphere boundary for the ray (r,mu), and its minimum
|
||||
// and maximum values over all mu - obtained for (r,1) and (r,mu_horizon).
|
||||
Length d = DistanceToTopAtmosphereBoundary(atmosphere, r, mu);
|
||||
Length d_min = atmosphere.top_radius - r;
|
||||
Length d_max = rho + H;
|
||||
Number x_mu = (d - d_min) / (d_max - d_min);
|
||||
Number x_r = rho / H;
|
||||
return vec2(GetTextureCoordFromUnitRange(x_mu, texture_size.x),
|
||||
GetTextureCoordFromUnitRange(x_r, texture_size.y));
|
||||
}
|
||||
|
||||
void GetRMuFromTransmittanceTextureUv(IN(AtmosphereParameters) atmosphere,
|
||||
IN(vec2) uv, OUT(Length) r, OUT(Number) mu, int TRANSMITTANCE_TEXTURE_WIDTH, int TRANSMITTANCE_TEXTURE_HEIGHT) {
|
||||
assert(uv.x >= 0.0 && uv.x <= 1.0);
|
||||
assert(uv.y >= 0.0 && uv.y <= 1.0);
|
||||
Number x_mu = GetUnitRangeFromTextureCoord(uv.x, TRANSMITTANCE_TEXTURE_WIDTH);
|
||||
Number x_r = GetUnitRangeFromTextureCoord(uv.y, TRANSMITTANCE_TEXTURE_HEIGHT);
|
||||
// Distance to top atmosphere boundary for a horizontal ray at ground level.
|
||||
Length H = sqrt(atmosphere.top_radius * atmosphere.top_radius -
|
||||
atmosphere.bottom_radius * atmosphere.bottom_radius);
|
||||
// Distance to the horizon, from which we can compute r:
|
||||
Length rho = H * x_r;
|
||||
r = sqrt(rho * rho + atmosphere.bottom_radius * atmosphere.bottom_radius);
|
||||
// Distance to the top atmosphere boundary for the ray (r,mu), and its minimum
|
||||
// and maximum values over all mu - obtained for (r,1) and (r,mu_horizon) -
|
||||
// from which we can recover mu:
|
||||
Length d_min = atmosphere.top_radius - r;
|
||||
Length d_max = rho + H;
|
||||
Length d = d_min + x_mu * (d_max - d_min);
|
||||
mu = d == 0.0 ? Number(1.0) : (H * H - rho * rho - d * d) / (2.0 * r * d);
|
||||
mu = ClampCosine(mu);
|
||||
}
|
||||
|
||||
DimensionlessSpectrum GetTransmittanceToTopAtmosphereBoundary(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 texture_size,
|
||||
Length r, Number mu) {
|
||||
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
|
||||
|
||||
vec2 uv = GetTransmittanceTextureUvFromRMu(atmosphere, r, mu, texture_size);
|
||||
return DimensionlessSpectrum(tex2Dlod(transmittance_texture, float4(uv, 0, 0)).rgb);
|
||||
}
|
||||
|
||||
DimensionlessSpectrum GetTransmittanceToSun(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 texture_size,
|
||||
Length r, Number mu_s) {
|
||||
Number sin_theta_h = atmosphere.bottom_radius / r;
|
||||
Number cos_theta_h = -sqrt(max(1.0 - sin_theta_h * sin_theta_h, 0.0));
|
||||
return GetTransmittanceToTopAtmosphereBoundary(
|
||||
atmosphere, transmittance_texture, texture_size, r, mu_s) *
|
||||
smoothstep(-sin_theta_h * atmosphere.sun_angular_radius / rad,
|
||||
sin_theta_h * atmosphere.sun_angular_radius / rad,
|
||||
mu_s - cos_theta_h);
|
||||
}
|
||||
|
||||
Length ComputeOpticalLengthToTopAtmosphereBoundary(
|
||||
IN(AtmosphereParameters) atmosphere, Length r, Number mu, Length scale_height) {
|
||||
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
|
||||
assert(mu >= -1.0 && mu <= 1.0);
|
||||
// Number of intervals for the numerical integration.
|
||||
const int SAMPLE_COUNT = 500;
|
||||
// The integration step, i.e. the length of each integration interval.
|
||||
Length dx =
|
||||
DistanceToTopAtmosphereBoundary(atmosphere, r, mu) / Number(SAMPLE_COUNT);
|
||||
// Integration loop.
|
||||
Length result = 0.0;
|
||||
for (int i = 0; i <= SAMPLE_COUNT; ++i) {
|
||||
Length d_i = Number(i) * dx;
|
||||
// Distance between the current sample point and the planet center.
|
||||
Length r_i = sqrt(d_i * d_i + 2.0 * r * mu * d_i + r * r);
|
||||
// Number density at the current sample point (divided by the number density
|
||||
// at the bottom of the atmosphere, yielding a dimensionless number).
|
||||
Number y_i = GetScaleHeight(r_i - atmosphere.bottom_radius, scale_height);
|
||||
// Sample weight (from the trapezoidal rule).
|
||||
Number weight_i = i == 0 || i == SAMPLE_COUNT ? 0.5 : 1.0;
|
||||
result += y_i * weight_i * dx;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
DimensionlessSpectrum ComputeTransmittanceToTopAtmosphereBoundary(
|
||||
IN(AtmosphereParameters) atmosphere, Length r, Number mu) {
|
||||
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
|
||||
assert(mu >= -1.0 && mu <= 1.0);
|
||||
return exp(-(
|
||||
atmosphere.rayleigh_scattering *
|
||||
ComputeOpticalLengthToTopAtmosphereBoundary(
|
||||
atmosphere, r, mu, atmosphere.rayleigh_scale_height) +
|
||||
atmosphere.mie_extinction *
|
||||
ComputeOpticalLengthToTopAtmosphereBoundary(
|
||||
atmosphere, r, mu, atmosphere.mie_scale_height) +
|
||||
atmosphere.absorption_extinction *
|
||||
ComputeOpticalLengthToTopAtmosphereBoundary(
|
||||
atmosphere, r, mu, atmosphere.absorption_extinction_scale_height)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
DimensionlessSpectrum GetTransmittance(
|
||||
IN(AtmosphereParameters) atmosphere,
|
||||
IN(TransmittanceTexture) transmittance_texture,
|
||||
uint2 texture_size,
|
||||
Length r, Number mu, Length d, bool ray_r_mu_intersects_ground) {
|
||||
assert(r >= atmosphere.bottom_radius && r <= atmosphere.top_radius);
|
||||
assert(mu >= -1.0 && mu <= 1.0);
|
||||
assert(d >= 0.0 * m);
|
||||
|
||||
Length r_d = ClampRadius(atmosphere, sqrt(d * d + 2.0 * r * mu * d + r * r));
|
||||
Number mu_d = ClampCosine((r * mu + d) / r_d);
|
||||
|
||||
if (ray_r_mu_intersects_ground) {
|
||||
return min(
|
||||
GetTransmittanceToTopAtmosphereBoundary(
|
||||
atmosphere, transmittance_texture, texture_size, r_d, -mu_d) /
|
||||
GetTransmittanceToTopAtmosphereBoundary(
|
||||
atmosphere, transmittance_texture, texture_size, r, -mu),
|
||||
DimensionlessSpectrum(1.0, 1.0, 1.0));
|
||||
}
|
||||
else {
|
||||
return min(
|
||||
GetTransmittanceToTopAtmosphereBoundary(
|
||||
atmosphere, transmittance_texture, texture_size, r, mu) /
|
||||
GetTransmittanceToTopAtmosphereBoundary(
|
||||
atmosphere, transmittance_texture, texture_size, r_d, mu_d),
|
||||
DimensionlessSpectrum(1.0, 1.0, 1.0));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c7015e6cfed6e2e46992e2af76282301
|
||||
timeCreated: 1531897786
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
Shader "Unlit/VolumeTexturePreview"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 3D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
// make fog work
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float4 vertex : SV_POSITION;
|
||||
float4 worldPos : TEXCOORD1;
|
||||
};
|
||||
|
||||
sampler3D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
// sample the texture
|
||||
fixed4 col = tex3D(_MainTex, i.worldPos / i.worldPos.w);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7ca93c1a56ee0154b8c714591d6d211a
|
||||
timeCreated: 1437991034
|
||||
licenseType: Pro
|
||||
guid: e6e68121d3504774dbf546d1f331c83a
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
8
Assets/Plugins/AtmosphereScattering/Transparent.meta
Normal file
8
Assets/Plugins/AtmosphereScattering/Transparent.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 37b0cb2f245dc7b4cb3dda322844678e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,526 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 8
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.17984006, g: 0.22517684, b: 0.3066335, a: 1}
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 11
|
||||
m_GIWorkflowMode: 0
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_TemporalCoherenceThreshold: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 9
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_TextureWidth: 1024
|
||||
m_TextureHeight: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ShowResolutionOverlay: 1
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_UseShadowmask: 1
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &7102893
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 7102896}
|
||||
- component: {fileID: 7102895}
|
||||
- component: {fileID: 7102894}
|
||||
- component: {fileID: 7102898}
|
||||
- component: {fileID: 7102897}
|
||||
- component: {fileID: 7102899}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &7102894
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &7102895
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 10000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 0
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &7102896
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -172.5}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &7102897
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ff26db721962cdf4a8edcdfa9a767d2a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
profile: {fileID: 11400000, guid: 16ee1eaff8bdab6429f048d7a5b1d15f, type: 2}
|
||||
--- !u!114 &7102898
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 45d85419f2e23c540999c1a1fee6ed90, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
distance: 10
|
||||
center: {x: 0, y: 0, z: 0}
|
||||
scale: 1
|
||||
distanceSpeed: 0.1
|
||||
rotationSpeed: 0.1
|
||||
--- !u!114 &7102899
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 7102893}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b535dacf702e20c4b9ef528e42081835, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
volumeTexSize: {x: 128, y: 128, z: 32}
|
||||
--- !u!1 &74323546
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 74323548}
|
||||
- component: {fileID: 74323547}
|
||||
- component: {fileID: 74323549}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &74323547
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 74323546}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 8
|
||||
m_Type: 1
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_Lightmapping: 4
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &74323548
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 74323546}
|
||||
m_LocalRotation: {x: 0.43573615, y: -0, z: -0, w: 0.9000745}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 51.664, y: 0, z: 0}
|
||||
--- !u!114 &74323549
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 74323546}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 325c269146dc2ac49b190f730a961573, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
basePosition: {x: 0, y: 50, z: 0}
|
||||
--- !u!1 &297555710
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 297555712}
|
||||
- component: {fileID: 297555711}
|
||||
m_Layer: 0
|
||||
m_Name: LutManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &297555711
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 297555710}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e16dd2ddbdfa7ea4f87a3cfb032ffd0f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
computeShader: {fileID: 7200000, guid: 2d4396a54b390d742b84d4bb4a122e54, type: 3}
|
||||
outputDebug: 0
|
||||
lutConfig:
|
||||
transmittanceSize: {x: 256, y: 128}
|
||||
scatteringSize: {x: 32, y: 128, z: 32}
|
||||
irradianceSize: {x: 64, y: 32}
|
||||
cameraVolumeSize: {x: 128, y: 128, z: 32}
|
||||
atmosphereConfig: {fileID: 11400000, guid: 8e73e89daf00b8447b2410427953df25, type: 2}
|
||||
skyboxMaterial: {fileID: 0}
|
||||
--- !u!4 &297555712
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 297555710}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 2.736024, y: 2.8123064, z: -0.70711327}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &563571916
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 563571920}
|
||||
- component: {fileID: 563571919}
|
||||
- component: {fileID: 563571918}
|
||||
- component: {fileID: 563571917}
|
||||
m_Layer: 0
|
||||
m_Name: Opaque
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!23 &563571917
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 563571916}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 222fb78855dcd5c42b991cd095da28fa, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_PreserveUVs: 1
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 0
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!65 &563571918
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 563571916}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &563571919
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 563571916}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &563571920
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 563571916}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 2484, y: 1, z: -4.01}
|
||||
m_LocalScale: {x: 1655.8981, y: 82.79491, z: 1655.8981}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1764631964
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 1764631968}
|
||||
- component: {fileID: 1764631967}
|
||||
- component: {fileID: 1764631966}
|
||||
- component: {fileID: 1764631965}
|
||||
m_Layer: 0
|
||||
m_Name: Transparent
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!23 &1764631965
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1764631964}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: b928a4c54f20eaa458c853f105a16f9a, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_PreserveUVs: 1
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 0
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!65 &1764631966
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1764631964}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &1764631967
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1764631964}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &1764631968
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1764631964}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -4.01}
|
||||
m_LocalScale: {x: 1655.8981, y: 82.79491, z: 1655.8981}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 03e7708501515d84aab396db1cb4849f
|
||||
guid: 694a3c0c25cb46646891cc9878b1ee07
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
76
Assets/Plugins/AtmosphereScattering/Transparent/Opaque.mat
Normal file
76
Assets/Plugins/AtmosphereScattering/Transparent/Opaque.mat
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Opaque
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
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
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 222fb78855dcd5c42b991cd095da28fa
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: Transparent-Ap
|
||||
m_Shader: {fileID: 4800000, guid: 7060206adfb8023499f89d502c3431fa, 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
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b928a4c54f20eaa458c853f105a16f9a
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
Shader "Ap/TransparentExample" {
|
||||
Properties {
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_Glossiness ("Smoothness", Range(0,1)) = 0.5
|
||||
_Metallic ("Metallic", Range(0,1)) = 0.0
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType"="Transparent"
|
||||
"Queue" = "Transparent"
|
||||
}
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
//We enable alpha to use transparent
|
||||
//Use finalcolor modifier to add ap to final result.
|
||||
//And we need custom vs to calculate ap info on every vertex.
|
||||
#pragma surface surf Standard fullforwardshadows alpha finalcolor:aerialPerspective vertex:vert
|
||||
|
||||
// Use shader model 3.0 target, to get nicer looking lighting
|
||||
#pragma target 3.0
|
||||
|
||||
|
||||
//Declare these values to use later.
|
||||
float3 _SunIrradianceOnAtm;
|
||||
sampler3D _CameraVolumeTransmittance;
|
||||
sampler3D _CameraVolumeScattering;
|
||||
|
||||
float3 GetTransmittanceWithCameraVolume(float3 uvw) {
|
||||
return tex3Dlod(_CameraVolumeTransmittance, float4(uvw, 0.0f)).rgb;
|
||||
}
|
||||
|
||||
float3 GetScatteringWithCameraVolume(float3 uvw) {
|
||||
return tex3Dlod(_CameraVolumeScattering, float4(uvw, 0.0f)).rgb;
|
||||
}
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
|
||||
//Add these two to interpolate. Sample them from 3d volume in vertex shader.
|
||||
float3 ap_transmittance;
|
||||
float3 ap_scattering;
|
||||
};
|
||||
|
||||
void vert(inout appdata_full v, out Input o) {
|
||||
UNITY_INITIALIZE_OUTPUT(Input, o);
|
||||
|
||||
//Get uv using clip pos.
|
||||
float4 hpos = UnityObjectToClipPos(v.vertex);
|
||||
float3 ap_volume_uvw = float3(hpos.xy / hpos.w, 0.0f);
|
||||
ap_volume_uvw.xy = (ap_volume_uvw + 1.0f) / 2.0f;
|
||||
|
||||
//Get w using view pos.
|
||||
float3 view_pos = UnityObjectToViewPos(v.vertex);
|
||||
view_pos.z *= -1;
|
||||
ap_volume_uvw.z = (view_pos.z - _ProjectionParams.y) / (_ProjectionParams.z - _ProjectionParams.y);
|
||||
|
||||
//Set them to output.
|
||||
o.ap_transmittance = GetTransmittanceWithCameraVolume(ap_volume_uvw);
|
||||
o.ap_scattering = GetScatteringWithCameraVolume(ap_volume_uvw);
|
||||
}
|
||||
|
||||
void aerialPerspective(Input IN, SurfaceOutputStandard o, inout fixed4 color)
|
||||
{
|
||||
//Edit final color using following formular.
|
||||
color.xyz = color.xyz * IN.ap_transmittance + color.a * IN.ap_scattering * _SunIrradianceOnAtm;
|
||||
|
||||
//I'm not pretty familiar with how Unity deal with Transparent and alpha, but it seems to be correct to mult scattering with color.a
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
//Following are default standard shader setup. Nothing changed.
|
||||
//========================================================================
|
||||
|
||||
sampler2D _MainTex;
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
fixed4 _Color;
|
||||
|
||||
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||||
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||||
// #pragma instancing_options assumeuniformscaling
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
// put more per-instance properties here
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o) {
|
||||
// Albedo comes from a texture tinted by color
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb;
|
||||
// Metallic and smoothness come from slider variables
|
||||
o.Metallic = _Metallic;
|
||||
o.Smoothness = _Glossiness;
|
||||
o.Alpha = c.a;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e84bd3245769b9746ae57a016126a416
|
||||
timeCreated: 1486464894
|
||||
licenseType: Pro
|
||||
guid: 7060206adfb8023499f89d502c3431fa
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 84601beb499ecf74f8daebb154302aab
|
||||
folderAsset: yes
|
||||
timeCreated: 1457526840
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7b926f3795cf3f3468014ed343f77d48
|
||||
timeCreated: 1457528618
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,63 +0,0 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Example2Settings
|
||||
serializedVersion: 3
|
||||
m_GIWorkflowMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 0
|
||||
m_BakeBackend: 0
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 40
|
||||
m_Padding: 2
|
||||
m_TextureCompression: 1
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 0
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 1
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 2
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 1024
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: ExampleSettings
|
||||
serializedVersion: 3
|
||||
m_GIWorkflowMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 0
|
||||
m_BakeBackend: 0
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 40
|
||||
m_Padding: 2
|
||||
m_TextureCompression: 1
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 0
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 1
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 2
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 1024
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVREnvironmentSampleCount: 512
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d7fcd113946fe884682affa68d7a9a8a
|
||||
folderAsset: yes
|
||||
timeCreated: 1437990609
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4e5bbb5f788c9d84d8173556caa0b920
|
||||
timeCreated: 1438002115
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e8364b88f137b7844ab5b8ca8776f54f
|
||||
timeCreated: 1437997052
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,328 +0,0 @@
|
|||
// Copyright (c) <2015> <Playdead>
|
||||
// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE.TXT)
|
||||
// AUTHOR: Lasse Jon Fuglsang Pedersen <lasse@playdead.com>
|
||||
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
#define SUPPORT_STEREO
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera))]
|
||||
[AddComponentMenu("Playdead/FrustumJitter")]
|
||||
public class FrustumJitter : MonoBehaviour
|
||||
{
|
||||
#region Static point data
|
||||
private static float[] points_Still = new float[] {
|
||||
0.5f, 0.5f,
|
||||
};
|
||||
private static float[] points_Uniform2 = new float[] {
|
||||
-0.25f, -0.25f,//ll
|
||||
0.25f, 0.25f,//ur
|
||||
};
|
||||
private static float[] points_Uniform4 = new float[] {
|
||||
-0.25f, -0.25f,//ll
|
||||
0.25f, -0.25f,//lr
|
||||
0.25f, 0.25f,//ur
|
||||
-0.25f, 0.25f,//ul
|
||||
};
|
||||
private static float[] points_Uniform4_Helix = new float[] {
|
||||
-0.25f, -0.25f,//ll 3 1
|
||||
0.25f, 0.25f,//ur \/|
|
||||
0.25f, -0.25f,//lr /\|
|
||||
-0.25f, 0.25f,//ul 0 2
|
||||
};
|
||||
private static float[] points_Uniform4_DoubleHelix = new float[] {
|
||||
-0.25f, -0.25f,//ll 3 1
|
||||
0.25f, 0.25f,//ur \/|
|
||||
0.25f, -0.25f,//lr /\|
|
||||
-0.25f, 0.25f,//ul 0 2
|
||||
-0.25f, -0.25f,//ll 6--7
|
||||
0.25f, -0.25f,//lr \
|
||||
-0.25f, 0.25f,//ul \
|
||||
0.25f, 0.25f,//ur 4--5
|
||||
};
|
||||
private static float[] points_SkewButterfly = new float[] {
|
||||
-0.250f, -0.250f,
|
||||
0.250f, 0.250f,
|
||||
0.125f, -0.125f,
|
||||
-0.125f, 0.125f,
|
||||
};
|
||||
private static float[] points_Rotated4 = new float[] {
|
||||
-0.125f, -0.375f,//ll
|
||||
0.375f, -0.125f,//lr
|
||||
0.125f, 0.375f,//ur
|
||||
-0.375f, 0.125f,//ul
|
||||
};
|
||||
private static float[] points_Rotated4_Helix = new float[] {
|
||||
-0.125f, -0.375f,//ll 3 1
|
||||
0.125f, 0.375f,//ur \/|
|
||||
0.375f, -0.125f,//lr /\|
|
||||
-0.375f, 0.125f,//ul 0 2
|
||||
};
|
||||
private static float[] points_Rotated4_Helix2 = new float[] {
|
||||
-0.125f, -0.375f,//ll 2--1
|
||||
0.125f, 0.375f,//ur \/
|
||||
-0.375f, 0.125f,//ul /\
|
||||
0.375f, -0.125f,//lr 0 3
|
||||
};
|
||||
private static float[] points_Poisson10 = new float[] {
|
||||
-0.16795960f*0.25f, 0.65544910f*0.25f,
|
||||
-0.69096030f*0.25f, 0.59015970f*0.25f,
|
||||
0.49843820f*0.25f, 0.83099720f*0.25f,
|
||||
0.17230150f*0.25f, -0.03882703f*0.25f,
|
||||
-0.60772670f*0.25f, -0.06013587f*0.25f,
|
||||
0.65606390f*0.25f, 0.24007600f*0.25f,
|
||||
0.80348370f*0.25f, -0.48096900f*0.25f,
|
||||
0.33436540f*0.25f, -0.73007030f*0.25f,
|
||||
-0.47839520f*0.25f, -0.56005300f*0.25f,
|
||||
-0.12388120f*0.25f, -0.96633990f*0.25f,
|
||||
};
|
||||
private static float[] points_Pentagram = new float[] {
|
||||
0.000000f*0.5f, 0.525731f*0.5f,// head
|
||||
-0.309017f*0.5f, -0.425325f*0.5f,// lleg
|
||||
0.500000f*0.5f, 0.162460f*0.5f,// rarm
|
||||
-0.500000f*0.5f, 0.162460f*0.5f,// larm
|
||||
0.309017f*0.5f, -0.425325f*0.5f,// rleg
|
||||
};
|
||||
private static float[] points_Halton_2_3_x8 = new float[8 * 2];
|
||||
private static float[] points_Halton_2_3_x16 = new float[16 * 2];
|
||||
private static float[] points_Halton_2_3_x32 = new float[32 * 2];
|
||||
private static float[] points_Halton_2_3_x256 = new float[256 * 2];
|
||||
private static float[] points_MotionPerp2 = new float[] {
|
||||
0.00f, -0.25f,
|
||||
0.00f, 0.25f,
|
||||
};
|
||||
#endregion
|
||||
|
||||
#region Static point data, static initialization
|
||||
private static void TransformPattern(float[] seq, float theta, float scale)
|
||||
{
|
||||
float cs = Mathf.Cos(theta);
|
||||
float sn = Mathf.Sin(theta);
|
||||
for (int i = 0, j = 1, n = seq.Length; i != n; i += 2, j += 2)
|
||||
{
|
||||
float x = scale * seq[i];
|
||||
float y = scale * seq[j];
|
||||
seq[i] = x * cs - y * sn;
|
||||
seq[j] = x * sn + y * cs;
|
||||
}
|
||||
}
|
||||
|
||||
// http://en.wikipedia.org/wiki/Halton_sequence
|
||||
public static float HaltonSeq(int prime, int index = 1/* NOT! zero-based */)
|
||||
{
|
||||
float r = 0.0f;
|
||||
float f = 1.0f;
|
||||
int i = index;
|
||||
while (i > 0)
|
||||
{
|
||||
f /= prime;
|
||||
r += f * (i % prime);
|
||||
i = (int)Mathf.Floor(i / (float)prime);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
private static void InitializeHalton_2_3(float[] seq)
|
||||
{
|
||||
for (int i = 0, n = seq.Length / 2; i != n; i++)
|
||||
{
|
||||
float u = HaltonSeq(2, i + 1) - 0.5f;
|
||||
float v = HaltonSeq(3, i + 1) - 0.5f;
|
||||
seq[2 * i + 0] = u;
|
||||
seq[2 * i + 1] = v;
|
||||
}
|
||||
}
|
||||
|
||||
static FrustumJitter()
|
||||
{
|
||||
// points_Pentagram
|
||||
Vector2 vh = new Vector2(points_Pentagram[0] - points_Pentagram[2], points_Pentagram[1] - points_Pentagram[3]);
|
||||
Vector2 vu = new Vector2(0.0f, 1.0f);
|
||||
TransformPattern(points_Pentagram, Mathf.Deg2Rad * (0.5f * Vector2.Angle(vu, vh)), 1.0f);
|
||||
|
||||
// points_Halton_2_3_xN
|
||||
InitializeHalton_2_3(points_Halton_2_3_x8);
|
||||
InitializeHalton_2_3(points_Halton_2_3_x16);
|
||||
InitializeHalton_2_3(points_Halton_2_3_x32);
|
||||
InitializeHalton_2_3(points_Halton_2_3_x256);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Static point data accessors
|
||||
public enum Pattern
|
||||
{
|
||||
Still,
|
||||
Uniform2,
|
||||
Uniform4,
|
||||
Uniform4_Helix,
|
||||
Uniform4_DoubleHelix,
|
||||
SkewButterfly,
|
||||
Rotated4,
|
||||
Rotated4_Helix,
|
||||
Rotated4_Helix2,
|
||||
Poisson10,
|
||||
Pentagram,
|
||||
Halton_2_3_X8,
|
||||
Halton_2_3_X16,
|
||||
Halton_2_3_X32,
|
||||
Halton_2_3_X256,
|
||||
MotionPerp2,
|
||||
};
|
||||
|
||||
private static float[] AccessPointData(Pattern pattern)
|
||||
{
|
||||
switch (pattern)
|
||||
{
|
||||
case Pattern.Still:
|
||||
return points_Still;
|
||||
case Pattern.Uniform2:
|
||||
return points_Uniform2;
|
||||
case Pattern.Uniform4:
|
||||
return points_Uniform4;
|
||||
case Pattern.Uniform4_Helix:
|
||||
return points_Uniform4_Helix;
|
||||
case Pattern.Uniform4_DoubleHelix:
|
||||
return points_Uniform4_DoubleHelix;
|
||||
case Pattern.SkewButterfly:
|
||||
return points_SkewButterfly;
|
||||
case Pattern.Rotated4:
|
||||
return points_Rotated4;
|
||||
case Pattern.Rotated4_Helix:
|
||||
return points_Rotated4_Helix;
|
||||
case Pattern.Rotated4_Helix2:
|
||||
return points_Rotated4_Helix2;
|
||||
case Pattern.Poisson10:
|
||||
return points_Poisson10;
|
||||
case Pattern.Pentagram:
|
||||
return points_Pentagram;
|
||||
case Pattern.Halton_2_3_X8:
|
||||
return points_Halton_2_3_x8;
|
||||
case Pattern.Halton_2_3_X16:
|
||||
return points_Halton_2_3_x16;
|
||||
case Pattern.Halton_2_3_X32:
|
||||
return points_Halton_2_3_x32;
|
||||
case Pattern.Halton_2_3_X256:
|
||||
return points_Halton_2_3_x256;
|
||||
case Pattern.MotionPerp2:
|
||||
return points_MotionPerp2;
|
||||
default:
|
||||
Debug.LogError("missing point distribution");
|
||||
return points_Halton_2_3_x16;
|
||||
}
|
||||
}
|
||||
|
||||
public static int AccessLength(Pattern pattern)
|
||||
{
|
||||
return AccessPointData(pattern).Length / 2;
|
||||
}
|
||||
|
||||
public Vector2 Sample(Pattern pattern, int index)
|
||||
{
|
||||
float[] points = AccessPointData(pattern);
|
||||
int n = points.Length / 2;
|
||||
int i = index % n;
|
||||
|
||||
float x = patternScale * points[2 * i + 0];
|
||||
float y = patternScale * points[2 * i + 1];
|
||||
|
||||
if (pattern != Pattern.MotionPerp2)
|
||||
return new Vector2(x, y);
|
||||
else
|
||||
return new Vector2(x, y).Rotate(Vector2.right.SignedAngle(focalMotionDir));
|
||||
}
|
||||
#endregion
|
||||
|
||||
private Camera _camera;
|
||||
|
||||
private Vector3 focalMotionPos = Vector3.zero;
|
||||
private Vector3 focalMotionDir = Vector3.right;
|
||||
|
||||
public Pattern pattern = Pattern.Halton_2_3_X16;
|
||||
public float patternScale = 1.0f;
|
||||
|
||||
public Vector4 activeSample = Vector4.zero;// xy = current sample, zw = previous sample
|
||||
public int activeIndex = -2;
|
||||
|
||||
void Reset()
|
||||
{
|
||||
_camera = GetComponent<Camera>();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
_camera.ResetProjectionMatrix();
|
||||
|
||||
activeSample = Vector4.zero;
|
||||
activeIndex = -2;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Reset();
|
||||
Clear();
|
||||
}
|
||||
|
||||
void OnPreCull()
|
||||
{
|
||||
// update motion dir
|
||||
{
|
||||
Vector3 oldWorld = focalMotionPos;
|
||||
Vector3 newWorld = _camera.transform.TransformVector(_camera.nearClipPlane * Vector3.forward);
|
||||
|
||||
Vector3 oldPoint = (_camera.worldToCameraMatrix * oldWorld);
|
||||
Vector3 newPoint = (_camera.worldToCameraMatrix * newWorld);
|
||||
Vector3 newDelta = (newPoint - oldPoint).WithZ(0.0f);
|
||||
|
||||
var mag = newDelta.magnitude;
|
||||
if (mag != 0.0f)
|
||||
{
|
||||
var dir = newDelta / mag;// yes, apparently this is necessary instead of newDelta.normalized... because facepalm
|
||||
if (dir.sqrMagnitude != 0.0f)
|
||||
{
|
||||
focalMotionPos = newWorld;
|
||||
focalMotionDir = Vector3.Slerp(focalMotionDir, dir, 0.2f);
|
||||
//Debug.Log("CHANGE focalMotionDir " + focalMotionDir.ToString("G4") + " delta was " + newDelta.ToString("G4") + " delta.mag " + newDelta.magnitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update jitter
|
||||
#if SUPPORT_STEREO
|
||||
if (_camera.stereoEnabled)
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (activeIndex == -2)
|
||||
{
|
||||
activeSample = Vector4.zero;
|
||||
activeIndex += 1;
|
||||
|
||||
_camera.projectionMatrix = _camera.GetProjectionMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeIndex += 1;
|
||||
activeIndex %= AccessLength(pattern);
|
||||
|
||||
Vector2 sample = Sample(pattern, activeIndex);
|
||||
activeSample.z = activeSample.x;
|
||||
activeSample.w = activeSample.y;
|
||||
activeSample.x = sample.x;
|
||||
activeSample.y = sample.y;
|
||||
|
||||
_camera.projectionMatrix = _camera.GetProjectionMatrix(sample.x, sample.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 899f97884c6d96b4ca20648ec109a37f
|
||||
timeCreated: 1437991076
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,266 +0,0 @@
|
|||
// Copyright (c) <2015> <Playdead>
|
||||
// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE.TXT)
|
||||
// AUTHOR: Lasse Jon Fuglsang Pedersen <lasse@playdead.com>
|
||||
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
#define SUPPORT_STEREO
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera), typeof(FrustumJitter), typeof(VelocityBuffer))]
|
||||
[AddComponentMenu("Playdead/TemporalReprojection")]
|
||||
public class TemporalReprojection : EffectBase
|
||||
{
|
||||
private static RenderBuffer[] mrt = new RenderBuffer[2];
|
||||
|
||||
private Camera _camera;
|
||||
private FrustumJitter _frustumJitter;
|
||||
private VelocityBuffer _velocityBuffer;
|
||||
|
||||
#region dithering
|
||||
public Texture ditherTex = null;
|
||||
|
||||
private const int NUM_DITHEROFS = 1024;
|
||||
const float DITHERSIZ = 256;
|
||||
private static int frameofs = 0;
|
||||
private static Vector4[] ditheroffsets = null;
|
||||
public static Vector4 GetFrame_DitherOffset()
|
||||
{
|
||||
if ( ditheroffsets == null )
|
||||
init_ditheroffsets();
|
||||
|
||||
frameofs = (frameofs+1) % NUM_DITHEROFS;
|
||||
return ditheroffsets[frameofs];
|
||||
}
|
||||
private static void init_ditheroffsets()
|
||||
{
|
||||
if ( ditheroffsets != null )
|
||||
return;
|
||||
|
||||
ditheroffsets = new Vector4[NUM_DITHEROFS];
|
||||
|
||||
for ( int i=0, n=ditheroffsets.Length; i<n; ++i )
|
||||
{
|
||||
Vector4 p = new Vector4( DITHERSIZ * FrustumJitter.HaltonSeq(2, i+1),
|
||||
DITHERSIZ * FrustumJitter.HaltonSeq(3, i+1),
|
||||
DITHERSIZ * FrustumJitter.HaltonSeq(5, i+1),
|
||||
DITHERSIZ * FrustumJitter.HaltonSeq(7, i+1) );
|
||||
|
||||
ditheroffsets[i] = new Vector4( Mathf.Floor(p.x),
|
||||
Mathf.Floor(p.y),
|
||||
Mathf.Floor(p.z),
|
||||
Mathf.Floor(p.w) );
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public Shader reprojectionShader;
|
||||
private Material reprojectionMaterial;
|
||||
private RenderTexture[,] reprojectionBuffer;
|
||||
private int[] reprojectionIndex = new int[2] { -1, -1 };
|
||||
|
||||
public enum Dilation
|
||||
{
|
||||
None, Dilate5X, Dilate3X3
|
||||
};
|
||||
public enum HistoryRectification
|
||||
{
|
||||
Clamping, CenterClipping, Clipping
|
||||
};
|
||||
public enum ColorSpace
|
||||
{
|
||||
RGB, Chroma /*YCoCg, YCrCg?*/
|
||||
};
|
||||
|
||||
//public bool unjitterColorSamples = true;
|
||||
//public bool unjitterNeighborhood = false;
|
||||
//public bool unjitterReprojection = false;
|
||||
|
||||
[Tooltip("TAA colorspace. RGB is faster, Chroma is more better")]
|
||||
public ColorSpace colorspace = ColorSpace.RGB;
|
||||
|
||||
[Tooltip("use soft-cubic for sampling maincolor")]
|
||||
public bool useHigherOrderFilteringMainColor = false;
|
||||
|
||||
[Tooltip("use catmull-rom for sampling historybuffer")]
|
||||
public bool useHigherOrderFilteringHistory = true;
|
||||
|
||||
[Tooltip("History color restricted by clamping (faster), centerClipping or clipping (better)")]
|
||||
public HistoryRectification historyRectification = HistoryRectification.Clamping;
|
||||
|
||||
[Tooltip("Shrink color-aabb using variance of neighborhood")]
|
||||
public bool useVarianceClipping = true;
|
||||
|
||||
[Tooltip("Smooth color-aabb using rounding")]
|
||||
public bool useAABBRounding = true;
|
||||
|
||||
public Dilation dilation = Dilation.Dilate3X3;
|
||||
public bool useMotionBlur = true;
|
||||
|
||||
[Range(0.0f, 1.0f)] public float feedbackMin = 0.88f;
|
||||
[Range(0.0f, 1.0f)] public float feedbackMax = 0.97f;
|
||||
|
||||
public float motionBlurStrength = 1.0f;
|
||||
public bool motionBlurIgnoreFF = false;
|
||||
|
||||
#region shaderparms
|
||||
int jitter_id = -1; int JitterUVID() { if (jitter_id < 0) jitter_id = Shader.PropertyToID("_JitterUV"); return jitter_id; }
|
||||
int vb_id =-1; int VelocityBufferID() { if (vb_id<0) vb_id=Shader.PropertyToID( "_VelocityBuffer" ); return vb_id; }
|
||||
int vnm_id=-1; int VelocityNeighborMaxID() { if (vnm_id<0) vnm_id=Shader.PropertyToID( "_VelocityNeighborMax" ); return vnm_id; }
|
||||
int maintex_id=-1; int MainTexID() { if (maintex_id<0) maintex_id=Shader.PropertyToID( "_MainTex" ); return maintex_id; }
|
||||
int prevtex_id=-1; int PrevTexID() { if (prevtex_id<0) prevtex_id=Shader.PropertyToID( "_PrevTex" ); return prevtex_id; }
|
||||
int fbmin_id=-1; int FeedbackMinID() { if (fbmin_id<0) fbmin_id=Shader.PropertyToID( "_FeedbackMin" ); return fbmin_id; }
|
||||
int fbmax_id=-1; int FeedbackMinMaxID() { if (fbmax_id<0) fbmax_id=Shader.PropertyToID( "_FeedbackMinMax" ); return fbmax_id; }
|
||||
int ms_id=-1; int MotionScaleID() { if (ms_id<0) ms_id=Shader.PropertyToID( "_MotionScale" ); return ms_id; }
|
||||
int dithertex_id=-1; int DitherTexID() { if (dithertex_id<0) dithertex_id=Shader.PropertyToID( "_DitherTex" ); return dithertex_id; }
|
||||
int ditherofslocal_id=-1; int DitherOffsetLocalID() { if (ditherofslocal_id<0) ditherofslocal_id=Shader.PropertyToID( "_DitherOffset_local" ); return ditherofslocal_id; }
|
||||
#endregion
|
||||
|
||||
void Reset()
|
||||
{
|
||||
_camera = GetComponent<Camera>();
|
||||
_frustumJitter = GetComponent<FrustumJitter>();
|
||||
_velocityBuffer = GetComponent<VelocityBuffer>();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
EnsureArray(ref reprojectionIndex, 2);
|
||||
reprojectionIndex[0] = -1;
|
||||
reprojectionIndex[1] = -1;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Reset();
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Resolve(RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
EnsureArray(ref reprojectionBuffer, 2, 2);
|
||||
EnsureArray(ref reprojectionIndex, 2, initialValue: -1);
|
||||
|
||||
EnsureMaterial(ref reprojectionMaterial, reprojectionShader);
|
||||
if (reprojectionMaterial == null)
|
||||
{
|
||||
Graphics.Blit(source, destination);
|
||||
return;
|
||||
}
|
||||
|
||||
#if SUPPORT_STEREO
|
||||
int eyeIndex = (_camera.stereoActiveEye == Camera.MonoOrStereoscopicEye.Right) ? 1 : 0;
|
||||
#else
|
||||
int eyeIndex = 0;
|
||||
#endif
|
||||
int bufferW = source.width;
|
||||
int bufferH = source.height;
|
||||
|
||||
if (EnsureRenderTarget(ref reprojectionBuffer[eyeIndex, 0], bufferW, bufferH, RenderTextureFormat.ARGB32, FilterMode.Bilinear, antiAliasing: source.antiAliasing))
|
||||
Clear();
|
||||
if (EnsureRenderTarget(ref reprojectionBuffer[eyeIndex, 1], bufferW, bufferH, RenderTextureFormat.ARGB32, FilterMode.Bilinear, antiAliasing: source.antiAliasing))
|
||||
Clear();
|
||||
|
||||
#if SUPPORT_STEREO
|
||||
bool stereoEnabled = _camera.stereoEnabled;
|
||||
#else
|
||||
bool stereoEnabled = false;
|
||||
#endif
|
||||
#if UNITY_EDITOR
|
||||
bool allowMotionBlur = !stereoEnabled && Application.isPlaying;
|
||||
#else
|
||||
bool allowMotionBlur = !stereoEnabled;
|
||||
#endif
|
||||
|
||||
EnsureKeyword(reprojectionMaterial, "CAMERA_PERSPECTIVE", !_camera.orthographic);
|
||||
EnsureKeyword(reprojectionMaterial, "CAMERA_ORTHOGRAPHIC", _camera.orthographic);
|
||||
//EnsureKeyword(reprojectionMaterial, "UNJITTER_COLORSAMPLES", unjitterColorSamples);
|
||||
//EnsureKeyword(reprojectionMaterial, "UNJITTER_NEIGHBORHOOD", unjitterNeighborhood);
|
||||
//EnsureKeyword(reprojectionMaterial, "UNJITTER_REPROJECTION", unjitterReprojection);
|
||||
EnsureKeyword(reprojectionMaterial, "USE_CHROMA_COLORSPACE", colorspace == ColorSpace.Chroma);
|
||||
EnsureKeyword(reprojectionMaterial, "USE_CLIPPING", historyRectification == HistoryRectification.CenterClipping || historyRectification == HistoryRectification.Clipping );
|
||||
EnsureKeyword(reprojectionMaterial, "USE_CENTER_CLIPPING", historyRectification == HistoryRectification.CenterClipping );
|
||||
EnsureKeyword(reprojectionMaterial, "USE_VARIANCE_CLIPPING", useVarianceClipping );
|
||||
EnsureKeyword(reprojectionMaterial, "USE_AABB_ROUNDING", useAABBRounding );
|
||||
EnsureKeyword(reprojectionMaterial, "USE_DILATION_5X", dilation == Dilation.Dilate5X);
|
||||
EnsureKeyword(reprojectionMaterial, "USE_DILATION_3X3", dilation == Dilation.Dilate3X3);
|
||||
EnsureKeyword(reprojectionMaterial, "USE_MOTION_BLUR", useMotionBlur && allowMotionBlur);
|
||||
EnsureKeyword(reprojectionMaterial, "USE_MOTION_BLUR_NEIGHBORMAX", _velocityBuffer.activeVelocityNeighborMax != null);
|
||||
EnsureKeyword(reprojectionMaterial, "USE_HIGHER_ORDER_TEXTURE_FILTERING_COLOR", useHigherOrderFilteringMainColor);
|
||||
EnsureKeyword(reprojectionMaterial, "USE_HIGHER_ORDER_TEXTURE_FILTERING_HISTORY", useHigherOrderFilteringHistory);
|
||||
|
||||
if (reprojectionIndex[eyeIndex] == -1)// bootstrap
|
||||
{
|
||||
reprojectionIndex[eyeIndex] = 0;
|
||||
reprojectionBuffer[eyeIndex, reprojectionIndex[eyeIndex]].DiscardContents();
|
||||
Graphics.Blit(source, reprojectionBuffer[eyeIndex, reprojectionIndex[eyeIndex]]);
|
||||
}
|
||||
|
||||
int indexRead = reprojectionIndex[eyeIndex];
|
||||
int indexWrite = (reprojectionIndex[eyeIndex] + 1) % 2;
|
||||
|
||||
Vector4 jitterUV = _frustumJitter.activeSample;
|
||||
jitterUV.x /= source.width;
|
||||
jitterUV.y /= source.height;
|
||||
jitterUV.z /= source.width;
|
||||
jitterUV.w /= source.height;
|
||||
|
||||
reprojectionMaterial.SetVector(JitterUVID(), jitterUV);
|
||||
reprojectionMaterial.SetTexture(VelocityBufferID(), _velocityBuffer.activeVelocityBuffer);
|
||||
reprojectionMaterial.SetTexture(VelocityNeighborMaxID(), _velocityBuffer.activeVelocityNeighborMax);
|
||||
reprojectionMaterial.SetTexture(MainTexID(), source);
|
||||
reprojectionMaterial.SetTexture(PrevTexID(), reprojectionBuffer[eyeIndex, indexRead]);
|
||||
reprojectionMaterial.SetFloat(FeedbackMinID(), feedbackMin);
|
||||
reprojectionMaterial.SetFloat(FeedbackMinMaxID(), feedbackMax - feedbackMin);
|
||||
reprojectionMaterial.SetFloat(MotionScaleID(), motionBlurStrength * (motionBlurIgnoreFF ? Mathf.Min(1.0f, 1.0f / _velocityBuffer.timeScale) : 1.0f));
|
||||
|
||||
reprojectionMaterial.SetTexture(DitherTexID(), ditherTex);
|
||||
Vector4 ofs = GetFrame_DitherOffset();
|
||||
reprojectionMaterial.SetVector( DitherOffsetLocalID(), GetFrame_DitherOffset() );
|
||||
|
||||
// reproject frame n-1 into output + history buffer
|
||||
{
|
||||
mrt[0] = reprojectionBuffer[eyeIndex, indexWrite].colorBuffer;
|
||||
mrt[1] = destination.colorBuffer;
|
||||
|
||||
Graphics.SetRenderTarget(mrt, source.depthBuffer);
|
||||
reprojectionMaterial.SetPass(0);
|
||||
reprojectionBuffer[eyeIndex, indexWrite].DiscardContents();
|
||||
|
||||
//DrawFullscreenQuad();
|
||||
DrawFullscreenTri();
|
||||
|
||||
reprojectionIndex[eyeIndex] = indexWrite;
|
||||
}
|
||||
}
|
||||
|
||||
void OnRenderImage(RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
if (destination != null && source.antiAliasing == destination.antiAliasing)// resolve without additional blit when not end of chain
|
||||
{
|
||||
Resolve(source, destination);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderTexture internalDestination = RenderTexture.GetTemporary(source.width, source.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default, source.antiAliasing);
|
||||
{
|
||||
Resolve(source, internalDestination);
|
||||
Graphics.Blit(internalDestination, destination);
|
||||
}
|
||||
RenderTexture.ReleaseTemporary(internalDestination);
|
||||
}
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
if (reprojectionBuffer != null)
|
||||
{
|
||||
ReleaseRenderTarget(ref reprojectionBuffer[0, 0]);
|
||||
ReleaseRenderTarget(ref reprojectionBuffer[0, 1]);
|
||||
ReleaseRenderTarget(ref reprojectionBuffer[1, 0]);
|
||||
ReleaseRenderTarget(ref reprojectionBuffer[1, 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 65f5677aa325c184f801528d78a73827
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- ditherTex: {fileID: 2800000, guid: 859f329ee8606864ea19dbf373a5ec56, type: 3}
|
||||
- reprojectionShader: {fileID: 4800000, guid: 7ca93c1a56ee0154b8c714591d6d211a,
|
||||
type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,282 +0,0 @@
|
|||
// Copyright (c) <2015> <Playdead>
|
||||
// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE.TXT)
|
||||
// AUTHOR: Lasse Jon Fuglsang Pedersen <lasse@playdead.com>
|
||||
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
#define SUPPORT_STEREO
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera), typeof(FrustumJitter))]
|
||||
[AddComponentMenu("Playdead/VelocityBuffer")]
|
||||
public class VelocityBuffer : EffectBase
|
||||
{
|
||||
#if UNITY_PS4
|
||||
private const RenderTextureFormat velocityFormat = RenderTextureFormat.RGHalf;
|
||||
#else
|
||||
private const RenderTextureFormat velocityFormat = RenderTextureFormat.RGFloat;
|
||||
#endif
|
||||
|
||||
private Camera _camera;
|
||||
private FrustumJitter _frustumJitter;
|
||||
|
||||
public Shader velocityShader;
|
||||
private Material velocityMaterial;
|
||||
private RenderTexture[] velocityBuffer;
|
||||
private RenderTexture[] velocityNeighborMax;
|
||||
|
||||
private bool[] paramInitialized;
|
||||
private Vector4[] paramProjectionExtents;
|
||||
private Matrix4x4[] paramCurrV;
|
||||
private Matrix4x4[] paramCurrVP;
|
||||
private Matrix4x4[] paramPrevVP;
|
||||
private Matrix4x4[] paramPrevVP_NoFlip;
|
||||
|
||||
private int activeEyeIndex = -1;
|
||||
public RenderTexture activeVelocityBuffer { get { return (activeEyeIndex != -1) ? velocityBuffer[activeEyeIndex] : null; } }
|
||||
public RenderTexture activeVelocityNeighborMax { get { return (activeEyeIndex != -1) ? velocityNeighborMax[activeEyeIndex] : null; } }
|
||||
|
||||
public enum NeighborMaxSupport
|
||||
{
|
||||
TileSize10,
|
||||
TileSize20,
|
||||
TileSize40,
|
||||
};
|
||||
|
||||
public bool neighborMaxGen = false;
|
||||
public NeighborMaxSupport neighborMaxSupport = NeighborMaxSupport.TileSize20;
|
||||
|
||||
private float timeScaleNextFrame;
|
||||
public float timeScale { get; private set; }
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[Header("Stats")]
|
||||
public int numResident = 0;
|
||||
public int numRendered = 0;
|
||||
public int numDrawCalls = 0;
|
||||
#endif
|
||||
|
||||
void Reset()
|
||||
{
|
||||
_camera = GetComponent<Camera>();
|
||||
_frustumJitter = GetComponent<FrustumJitter>();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
EnsureArray(ref paramInitialized, 2);
|
||||
paramInitialized[0] = false;
|
||||
paramInitialized[1] = false;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Reset();
|
||||
Clear();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
timeScaleNextFrame = Time.timeScale;
|
||||
}
|
||||
|
||||
void OnPreRender()
|
||||
{
|
||||
EnsureDepthTexture(_camera);
|
||||
}
|
||||
|
||||
void OnPostRender()
|
||||
{
|
||||
EnsureArray(ref velocityBuffer, 2);
|
||||
EnsureArray(ref velocityNeighborMax, 2);
|
||||
|
||||
EnsureArray(ref paramInitialized, 2, initialValue: false);
|
||||
EnsureArray(ref paramProjectionExtents, 2);
|
||||
EnsureArray(ref paramCurrV, 2);
|
||||
EnsureArray(ref paramCurrVP, 2);
|
||||
EnsureArray(ref paramPrevVP, 2);
|
||||
EnsureArray(ref paramPrevVP_NoFlip, 2);
|
||||
|
||||
EnsureMaterial(ref velocityMaterial, velocityShader);
|
||||
if (velocityMaterial == null)
|
||||
return;
|
||||
|
||||
timeScale = timeScaleNextFrame;
|
||||
timeScaleNextFrame = (Time.timeScale == 0.0f) ? timeScaleNextFrame : Time.timeScale;
|
||||
|
||||
#if SUPPORT_STEREO
|
||||
int eyeIndex = (_camera.stereoActiveEye == Camera.MonoOrStereoscopicEye.Right) ? 1 : 0;
|
||||
#else
|
||||
int eyeIndex = 0;
|
||||
#endif
|
||||
int bufferW = _camera.pixelWidth;
|
||||
int bufferH = _camera.pixelHeight;
|
||||
|
||||
if (EnsureRenderTarget(ref velocityBuffer[eyeIndex], bufferW, bufferH, velocityFormat, FilterMode.Point, depthBits: 16))
|
||||
Clear();
|
||||
|
||||
EnsureKeyword(velocityMaterial, "CAMERA_PERSPECTIVE", !_camera.orthographic);
|
||||
EnsureKeyword(velocityMaterial, "CAMERA_ORTHOGRAPHIC", _camera.orthographic);
|
||||
|
||||
EnsureKeyword(velocityMaterial, "TILESIZE_10", neighborMaxSupport == NeighborMaxSupport.TileSize10);
|
||||
EnsureKeyword(velocityMaterial, "TILESIZE_20", neighborMaxSupport == NeighborMaxSupport.TileSize20);
|
||||
EnsureKeyword(velocityMaterial, "TILESIZE_40", neighborMaxSupport == NeighborMaxSupport.TileSize40);
|
||||
|
||||
#if SUPPORT_STEREO
|
||||
if (_camera.stereoEnabled)
|
||||
{
|
||||
for (int i = 0; i != 2; i++)
|
||||
{
|
||||
Camera.StereoscopicEye eye = (Camera.StereoscopicEye)i;
|
||||
|
||||
Matrix4x4 currV = _camera.GetStereoViewMatrix(eye);
|
||||
Matrix4x4 currP = GL.GetGPUProjectionMatrix(_camera.GetStereoProjectionMatrix(eye), true);
|
||||
Matrix4x4 currP_NoFlip = GL.GetGPUProjectionMatrix(_camera.GetStereoProjectionMatrix(eye), false);
|
||||
Matrix4x4 prevV = paramInitialized[i] ? paramCurrV[i] : currV;
|
||||
|
||||
paramInitialized[i] = true;
|
||||
paramProjectionExtents[i] = _camera.GetProjectionExtents(eye);
|
||||
paramCurrV[i] = currV;
|
||||
paramCurrVP[i] = currP * currV;
|
||||
paramPrevVP[i] = currP * prevV;
|
||||
paramPrevVP_NoFlip[i] = currP_NoFlip * prevV;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
Matrix4x4 currV = _camera.worldToCameraMatrix;
|
||||
Matrix4x4 currP = GL.GetGPUProjectionMatrix(_camera.projectionMatrix, true);
|
||||
Matrix4x4 currP_NoFlip = GL.GetGPUProjectionMatrix(_camera.projectionMatrix, false);
|
||||
Matrix4x4 prevV = paramInitialized[0] ? paramCurrV[0] : currV;
|
||||
|
||||
paramInitialized[0] = true;
|
||||
paramProjectionExtents[0] = _frustumJitter.enabled ? _camera.GetProjectionExtents(_frustumJitter.activeSample.x, _frustumJitter.activeSample.y) : _camera.GetProjectionExtents();
|
||||
paramCurrV[0] = currV;
|
||||
paramCurrVP[0] = currP * currV;
|
||||
paramPrevVP[0] = currP * prevV;
|
||||
paramPrevVP_NoFlip[0] = currP_NoFlip * prevV;
|
||||
}
|
||||
|
||||
RenderTexture activeRT = RenderTexture.active;
|
||||
RenderTexture.active = velocityBuffer[eyeIndex];
|
||||
{
|
||||
GL.Clear(true, true, Color.black);
|
||||
|
||||
const int kPrepass = 0;
|
||||
const int kVertices = 1;
|
||||
const int kVerticesSkinned = 2;
|
||||
const int kTileMax = 3;
|
||||
const int kNeighborMax = 4;
|
||||
|
||||
// 0: prepass
|
||||
#if SUPPORT_STEREO
|
||||
velocityMaterial.SetVectorArray("_ProjectionExtents", paramProjectionExtents);
|
||||
velocityMaterial.SetMatrixArray("_CurrV", paramCurrV);
|
||||
velocityMaterial.SetMatrixArray("_CurrVP", paramCurrVP);
|
||||
velocityMaterial.SetMatrixArray("_PrevVP", paramPrevVP);
|
||||
velocityMaterial.SetMatrixArray("_PrevVP_NoFlip", paramPrevVP_NoFlip);
|
||||
#else
|
||||
velocityMaterial.SetVector("_ProjectionExtents", paramProjectionExtents[0]);
|
||||
velocityMaterial.SetMatrix("_CurrV", paramCurrV[0]);
|
||||
velocityMaterial.SetMatrix("_CurrVP", paramCurrVP[0]);
|
||||
velocityMaterial.SetMatrix("_PrevVP", paramPrevVP[0]);
|
||||
velocityMaterial.SetMatrix("_PrevVP_NoFlip", paramPrevVP_NoFlip[0]);
|
||||
#endif
|
||||
velocityMaterial.SetPass(kPrepass);
|
||||
DrawFullscreenQuad();
|
||||
|
||||
// 1 + 2: vertices + vertices skinned
|
||||
var obs = VelocityBufferTag.activeObjects;
|
||||
#if UNITY_EDITOR
|
||||
numResident = obs.Count;
|
||||
numRendered = 0;
|
||||
numDrawCalls = 0;
|
||||
#endif
|
||||
for (int i = 0, n = obs.Count; i != n; i++)
|
||||
{
|
||||
var ob = obs[i];
|
||||
if (ob != null && ob.rendering && ob.mesh != null)
|
||||
{
|
||||
velocityMaterial.SetMatrix("_CurrM", ob.localToWorldCurr);
|
||||
velocityMaterial.SetMatrix("_PrevM", ob.localToWorldPrev);
|
||||
velocityMaterial.SetPass(ob.meshSmrActive ? kVerticesSkinned : kVertices);
|
||||
|
||||
for (int j = 0; j != ob.mesh.subMeshCount; j++)
|
||||
{
|
||||
Graphics.DrawMeshNow(ob.mesh, Matrix4x4.identity, j);
|
||||
#if UNITY_EDITOR
|
||||
numDrawCalls++;
|
||||
#endif
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
numRendered++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// 3 + 4: tilemax + neighbormax
|
||||
if (neighborMaxGen)
|
||||
{
|
||||
int tileSize = 1;
|
||||
|
||||
switch (neighborMaxSupport)
|
||||
{
|
||||
case NeighborMaxSupport.TileSize10: tileSize = 10; break;
|
||||
case NeighborMaxSupport.TileSize20: tileSize = 20; break;
|
||||
case NeighborMaxSupport.TileSize40: tileSize = 40; break;
|
||||
}
|
||||
|
||||
int neighborMaxW = bufferW / tileSize;
|
||||
int neighborMaxH = bufferH / tileSize;
|
||||
|
||||
EnsureRenderTarget(ref velocityNeighborMax[eyeIndex], neighborMaxW, neighborMaxH, velocityFormat, FilterMode.Bilinear);
|
||||
|
||||
// tilemax
|
||||
RenderTexture tileMax = RenderTexture.GetTemporary(neighborMaxW, neighborMaxH, 0, velocityFormat);
|
||||
RenderTexture.active = tileMax;
|
||||
{
|
||||
velocityMaterial.SetTexture("_VelocityTex", velocityBuffer[eyeIndex]);
|
||||
velocityMaterial.SetVector("_VelocityTex_TexelSize", new Vector4(1.0f / bufferW, 1.0f / bufferH, 0.0f, 0.0f));
|
||||
velocityMaterial.SetPass(kTileMax);
|
||||
DrawFullscreenQuad();
|
||||
}
|
||||
|
||||
// neighbormax
|
||||
RenderTexture.active = velocityNeighborMax[eyeIndex];
|
||||
{
|
||||
velocityMaterial.SetTexture("_VelocityTex", tileMax);
|
||||
velocityMaterial.SetVector("_VelocityTex_TexelSize", new Vector4(1.0f / neighborMaxW, 1.0f / neighborMaxH, 0.0f, 0.0f));
|
||||
velocityMaterial.SetPass(kNeighborMax);
|
||||
DrawFullscreenQuad();
|
||||
}
|
||||
|
||||
RenderTexture.ReleaseTemporary(tileMax);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReleaseRenderTarget(ref velocityNeighborMax[0]);
|
||||
ReleaseRenderTarget(ref velocityNeighborMax[1]);
|
||||
}
|
||||
}
|
||||
RenderTexture.active = activeRT;
|
||||
|
||||
activeEyeIndex = eyeIndex;
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
if (velocityBuffer != null)
|
||||
{
|
||||
ReleaseRenderTarget(ref velocityBuffer[0]);
|
||||
ReleaseRenderTarget(ref velocityBuffer[1]);
|
||||
}
|
||||
if (velocityNeighborMax != null)
|
||||
{
|
||||
ReleaseRenderTarget(ref velocityNeighborMax[0]);
|
||||
ReleaseRenderTarget(ref velocityNeighborMax[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b642ff60407fe724bafa6602199213c0
|
||||
timeCreated: 1438011374
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- velocityShader: {fileID: 4800000, guid: 0d7f09e63dd99504ca6e04212a21ec72, type: 3}
|
||||
- velocityBuffer: {instanceID: 0}
|
||||
- velocityNeighborMax: {instanceID: 0}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
// Copyright (c) <2015> <Playdead>
|
||||
// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE.TXT)
|
||||
// AUTHOR: Lasse Jon Fuglsang Pedersen <lasse@playdead.com>
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("Playdead/VelocityBufferTag")]
|
||||
public class VelocityBufferTag : MonoBehaviour
|
||||
{
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
private static List<Vector3> temporaryVertexStorage = new List<Vector3>(512);
|
||||
#endif
|
||||
public static List<VelocityBufferTag> activeObjects = new List<VelocityBufferTag>(128);
|
||||
|
||||
private Transform _transform;
|
||||
|
||||
[NonSerialized, HideInInspector] public SkinnedMeshRenderer meshSmr;
|
||||
[NonSerialized, HideInInspector] public bool meshSmrActive;
|
||||
[NonSerialized, HideInInspector] public Mesh mesh;
|
||||
[NonSerialized, HideInInspector] public Matrix4x4 localToWorldPrev;
|
||||
[NonSerialized, HideInInspector] public Matrix4x4 localToWorldCurr;
|
||||
|
||||
private const int framesNotRenderedSleepThreshold = 60;
|
||||
private int framesNotRendered = framesNotRenderedSleepThreshold;
|
||||
public bool rendering { get { return (framesNotRendered < framesNotRenderedSleepThreshold); } }
|
||||
|
||||
void Reset()
|
||||
{
|
||||
_transform = this.transform;
|
||||
|
||||
var smr = GetComponent<SkinnedMeshRenderer>();
|
||||
if (smr != null)
|
||||
{
|
||||
if (mesh == null || meshSmrActive == false)
|
||||
{
|
||||
mesh = new Mesh();
|
||||
mesh.hideFlags = HideFlags.HideAndDontSave;
|
||||
}
|
||||
|
||||
meshSmrActive = true;
|
||||
meshSmr = smr;
|
||||
}
|
||||
else
|
||||
{
|
||||
var mf = GetComponent<MeshFilter>();
|
||||
if (mf != null)
|
||||
mesh = mf.sharedMesh;
|
||||
else
|
||||
mesh = null;
|
||||
|
||||
meshSmrActive = false;
|
||||
meshSmr = null;
|
||||
}
|
||||
|
||||
// force restart
|
||||
framesNotRendered = framesNotRenderedSleepThreshold;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void TagUpdate(bool restart)
|
||||
{
|
||||
if (meshSmrActive && meshSmr == null)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
if (meshSmrActive)
|
||||
{
|
||||
if (restart)
|
||||
{
|
||||
meshSmr.BakeMesh(mesh);
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
mesh.GetVertices(temporaryVertexStorage);
|
||||
mesh.SetNormals(temporaryVertexStorage);
|
||||
#else
|
||||
mesh.normals = mesh.vertices;// garbage ahoy
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
mesh.GetVertices(temporaryVertexStorage);
|
||||
meshSmr.BakeMesh(mesh);
|
||||
mesh.SetNormals(temporaryVertexStorage);
|
||||
#else
|
||||
Vector3[] vs = mesh.vertices;// garbage ahoy
|
||||
meshSmr.BakeMesh(mesh);
|
||||
mesh.normals = vs;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (restart)
|
||||
{
|
||||
localToWorldCurr = _transform.localToWorldMatrix;
|
||||
localToWorldPrev = localToWorldCurr;
|
||||
}
|
||||
else
|
||||
{
|
||||
localToWorldPrev = localToWorldCurr;
|
||||
localToWorldCurr = _transform.localToWorldMatrix;
|
||||
}
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if (framesNotRendered < framesNotRenderedSleepThreshold)
|
||||
{
|
||||
framesNotRendered++;
|
||||
TagUpdate(restart: false);
|
||||
}
|
||||
}
|
||||
|
||||
void OnWillRenderObject()
|
||||
{
|
||||
if (Camera.current != Camera.main)
|
||||
return;// ignore anything but main cam
|
||||
|
||||
if (framesNotRendered >= framesNotRenderedSleepThreshold)
|
||||
TagUpdate(restart: true);
|
||||
|
||||
framesNotRendered = 0;
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
activeObjects.Add(this);
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
activeObjects.Remove(this);
|
||||
|
||||
// force restart
|
||||
framesNotRendered = framesNotRenderedSleepThreshold;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1cc21c48ee370cb42a042622dd21640d
|
||||
timeCreated: 1437991033
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f0aa195420e263d4ba033b84c407fba5
|
||||
folderAsset: yes
|
||||
timeCreated: 1437991376
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
#ifndef __PD_COLOR_CGINC__
|
||||
#define __PD_COLOR_CGINC__
|
||||
|
||||
//note: Symmetric triangular distribution on [-1,1] with maximal density at 0
|
||||
//note: from https://github.com/Unity-Technologies/ScriptableRenderPipeline/blob/master/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FinalPass.shader#L124
|
||||
float remap_noise_tri( float v )
|
||||
{
|
||||
v = v*2.0-1.0;
|
||||
return sign(v) * (1.0 - sqrt(1.0 - abs(v)));
|
||||
}
|
||||
float4 remap_noise_tri( float4 v )
|
||||
{
|
||||
v = v*2.0-1.0;
|
||||
return sign(v) * (1.0 - sqrt(1.0 - abs(v)));
|
||||
}
|
||||
|
||||
//from https://github.com/h3r2tic/rtoy-samples/blob/master/assets/shaders/inc/color.inc
|
||||
// Rec. 709
|
||||
float3 RGB_YCbCr(float3 col)
|
||||
{
|
||||
return float3( dot( col, float3(0.2126, 0.7152, 0.0722)),
|
||||
dot( col, float3(-0.1146, -0.3854, 0.5)),
|
||||
dot( col, float3(0.5, -0.4542, -0.0458)) );
|
||||
}
|
||||
float3 YCbCr_RGB(float3 col)
|
||||
{
|
||||
return float3( col.r + 1.5748 * col.b,
|
||||
col.r - 0.1873 * col.g -0.4681 * col.b,
|
||||
col.r + 1.8556 * col.g );
|
||||
}
|
||||
|
||||
// https://software.intel.com/en-us/node/503873
|
||||
float3 RGB_YCoCg(float3 c)
|
||||
{
|
||||
// Y = R/4 + G/2 + B/4
|
||||
// Co = R/2 - B/2
|
||||
// Cg = -R/4 + G/2 - B/4
|
||||
return float3( c.x/4.0 + c.y/2.0 + c.z/4.0,
|
||||
c.x/2.0 - c.z/2.0,
|
||||
-c.x/4.0 + c.y/2.0 - c.z/4.0 );
|
||||
}
|
||||
|
||||
// https://software.intel.com/en-us/node/503873
|
||||
float3 YCoCg_RGB(float3 c)
|
||||
{
|
||||
// R = Y + Co - Cg
|
||||
// G = Y + Cg
|
||||
// B = Y - Co - Cg
|
||||
return saturate(float3( c.x + c.y - c.z,
|
||||
c.x + c.z,
|
||||
c.x - c.y - c.z ));
|
||||
}
|
||||
|
||||
// Samples a texture with Catmull-Rom filtering, using 9 texture fetches instead of 16.
|
||||
// Source: https://gist.github.com/TheRealMJP/c83b8c0f46b63f3a88a5986f4fa982b1
|
||||
// See http://vec3.ca/bicubic-filtering-in-fewer-taps/ for more details
|
||||
float4 sample_catmull_rom(in sampler2D linearSampler, in float2 uv, in float2 texSize)
|
||||
{
|
||||
// We're going to sample a a 4x4 grid of texels surrounding the target UV coordinate. We'll do this by rounding
|
||||
// down the sample location to get the exact center of our "starting" texel. The starting texel will be at
|
||||
// location [1, 1] in the grid, where [0, 0] is the top left corner.
|
||||
float2 samplePos = uv * texSize;
|
||||
float2 texPos1 = floor(samplePos - 0.5f) + 0.5f;
|
||||
|
||||
// Compute the fractional offset from our starting texel to our original sample location, which we'll
|
||||
// feed into the Catmull-Rom spline function to get our filter weights.
|
||||
float2 f = samplePos - texPos1;
|
||||
|
||||
// Compute the Catmull-Rom weights using the fractional offset that we calculated earlier.
|
||||
// These equations are pre-expanded based on our knowledge of where the texels will be located,
|
||||
// which lets us avoid having to evaluate a piece-wise function.
|
||||
float2 w0 = f * (-0.5f + f * (1.0f - 0.5f * f));
|
||||
float2 w1 = 1.0f + f * f * (-2.5f + 1.5f * f);
|
||||
float2 w2 = f * (0.5f + f * (2.0f - 1.5f * f));
|
||||
float2 w3 = f * f * (-0.5f + 0.5f * f);
|
||||
|
||||
// Work out weighting factors and sampling offsets that will let us use bilinear filtering to
|
||||
// simultaneously evaluate the middle 2 samples from the 4x4 grid.
|
||||
float2 w12 = w1 + w2;
|
||||
float2 offset12 = w2 / w12;
|
||||
|
||||
// Compute the final UV coordinates we'll use for sampling the texture
|
||||
float2 texPos0 = texPos1 - 1;
|
||||
float2 texPos3 = texPos1 + 2;
|
||||
float2 texPos12 = texPos1 + offset12;
|
||||
|
||||
texPos0 /= texSize;
|
||||
texPos3 /= texSize;
|
||||
texPos12 /= texSize;
|
||||
|
||||
float4 result = 0.0f;
|
||||
result += tex2D(linearSampler, float2(texPos0.x, texPos0.y)) * w0.x * w0.y;
|
||||
result += tex2D(linearSampler, float2(texPos12.x, texPos0.y)) * w12.x * w0.y;
|
||||
result += tex2D(linearSampler, float2(texPos3.x, texPos0.y)) * w3.x * w0.y;
|
||||
|
||||
result += tex2D(linearSampler, float2(texPos0.x, texPos12.y)) * w0.x * w12.y;
|
||||
result += tex2D(linearSampler, float2(texPos12.x, texPos12.y)) * w12.x * w12.y;
|
||||
result += tex2D(linearSampler, float2(texPos3.x, texPos12.y)) * w3.x * w12.y;
|
||||
|
||||
result += tex2D(linearSampler, float2(texPos0.x, texPos3.y)) * w0.x * w3.y;
|
||||
result += tex2D(linearSampler, float2(texPos12.x, texPos3.y)) * w12.x * w3.y;
|
||||
result += tex2D(linearSampler, float2(texPos3.x, texPos3.y)) * w3.x * w3.y;
|
||||
|
||||
return max( 0.0, result );
|
||||
}
|
||||
|
||||
//note: see http://vec3.ca/bicubic-filtering-in-fewer-taps/ for more details
|
||||
//note: also http://mate.tue.nl/mate/pdfs/10318.pdf
|
||||
float4 sample_cubic( in sampler2D linearSampler, float2 uv, float2 texSiz )
|
||||
{
|
||||
//return
|
||||
float2 iTc = uv * texSiz;
|
||||
float2 tc = floor(iTc - 0.5) + 0.5;
|
||||
|
||||
float2 f = iTc - tc;
|
||||
|
||||
const float2 f2 = float2( f * f );
|
||||
float2 w0 = f * ( f * ( 0.5 - 1.0/6.0 * f ) - 0.5 ) + (1.0/6.0);
|
||||
float2 w1 = (0.5 * f - 1.0) * f2 + (2.0/3.0);
|
||||
float2 w2 = f * ( f * (0.5 - 0.5 * f) + 0.5) + (1.0/6.0);
|
||||
float2 w3 = (1.0/6.0) * f*f2;
|
||||
|
||||
float2 s0 = w0 + w1;
|
||||
float2 s1 = w2 + w3;
|
||||
|
||||
float2 f0 = w1 / s0;
|
||||
float2 f1 = w3 / s1;
|
||||
|
||||
float2 t0 = tc - 1.0 + f0;
|
||||
float2 t1 = tc + 1.0 + f1;
|
||||
|
||||
const float2 rcpTexSiz = 1.0 / texSiz;
|
||||
|
||||
return
|
||||
(tex2D( linearSampler, float2( t0.x, t0.y )*rcpTexSiz) * s0.x
|
||||
+ tex2D( linearSampler, float2( t1.x, t0.y )*rcpTexSiz) * s1.x) * s0.y
|
||||
+ (tex2D( linearSampler, float2( t0.x, t1.y )*rcpTexSiz) * s0.x
|
||||
+ tex2D( linearSampler, float2( t1.x, t1.y )*rcpTexSiz) * s1.x ) * s1.y;
|
||||
}
|
||||
|
||||
|
||||
#endif // __PD_COLOR_CGINC__
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
// Copyright (c) <2015> <Playdead>
|
||||
// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE.TXT)
|
||||
// AUTHOR: Lasse Jon Fuglsang Pedersen <lasse@playdead.com>
|
||||
|
||||
#ifndef __DEPTH_CGINC__
|
||||
#define __DEPTH_CGINC__
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
uniform sampler2D_float _CameraDepthTexture;
|
||||
uniform float4 _CameraDepthTexture_TexelSize;
|
||||
|
||||
#if UNITY_REVERSED_Z
|
||||
#define ZCMP_GT(a, b) (a < b)
|
||||
#else
|
||||
#define ZCMP_GT(a, b) (a > b)
|
||||
#endif
|
||||
|
||||
float depth_resolve_linear(float z)
|
||||
{
|
||||
#if CAMERA_ORTHOGRAPHIC
|
||||
#if UNITY_REVERSED_Z
|
||||
return (1.0 - z) * (_ProjectionParams.z - _ProjectionParams.y) + _ProjectionParams.y;
|
||||
#else
|
||||
return z * (_ProjectionParams.z - _ProjectionParams.y) + _ProjectionParams.y;
|
||||
#endif
|
||||
#else
|
||||
return LinearEyeDepth(z);
|
||||
#endif
|
||||
}
|
||||
|
||||
float depth_sample_linear(float2 uv)
|
||||
{
|
||||
return depth_resolve_linear(tex2D(_CameraDepthTexture, uv).x);
|
||||
}
|
||||
|
||||
float3 find_closest_fragment_3x3(float2 uv)
|
||||
{
|
||||
float2 dd = abs(_CameraDepthTexture_TexelSize.xy);
|
||||
float2 du = float2(dd.x, 0.0);
|
||||
float2 dv = float2(0.0, dd.y);
|
||||
|
||||
float3 dtl = float3(-1, -1, tex2D(_CameraDepthTexture, uv - dv - du).x);
|
||||
float3 dtc = float3( 0, -1, tex2D(_CameraDepthTexture, uv - dv).x);
|
||||
float3 dtr = float3( 1, -1, tex2D(_CameraDepthTexture, uv - dv + du).x);
|
||||
|
||||
float3 dml = float3(-1, 0, tex2D(_CameraDepthTexture, uv - du).x);
|
||||
float3 dmc = float3( 0, 0, tex2D(_CameraDepthTexture, uv).x);
|
||||
float3 dmr = float3( 1, 0, tex2D(_CameraDepthTexture, uv + du).x);
|
||||
|
||||
float3 dbl = float3(-1, 1, tex2D(_CameraDepthTexture, uv + dv - du).x);
|
||||
float3 dbc = float3( 0, 1, tex2D(_CameraDepthTexture, uv + dv).x);
|
||||
float3 dbr = float3( 1, 1, tex2D(_CameraDepthTexture, uv + dv + du).x);
|
||||
|
||||
float3 dmin = dtl;
|
||||
if (ZCMP_GT(dmin.z, dtc.z)) dmin = dtc;
|
||||
if (ZCMP_GT(dmin.z, dtr.z)) dmin = dtr;
|
||||
|
||||
if (ZCMP_GT(dmin.z, dml.z)) dmin = dml;
|
||||
if (ZCMP_GT(dmin.z, dmc.z)) dmin = dmc;
|
||||
if (ZCMP_GT(dmin.z, dmr.z)) dmin = dmr;
|
||||
|
||||
if (ZCMP_GT(dmin.z, dbl.z)) dmin = dbl;
|
||||
if (ZCMP_GT(dmin.z, dbc.z)) dmin = dbc;
|
||||
if (ZCMP_GT(dmin.z, dbr.z)) dmin = dbr;
|
||||
|
||||
return float3(uv + dd.xy * dmin.xy, dmin.z);
|
||||
}
|
||||
|
||||
/* UNUSED: tested slower than branching
|
||||
float2 find_closest_fragment_3x3_packed(in float2 uv)
|
||||
{
|
||||
float2 dd = abs(_CameraDepthTexture_TexelSize.xy);
|
||||
float2 du = float2(dd.x, 0.0);
|
||||
float2 dv = float2(0.0, dd.y);
|
||||
|
||||
const float s = 100000.0;
|
||||
float dtl = trunc(s * tex2D(_CameraDepthTexture, uv - dv - du).x) + 0.1010;// -+-+
|
||||
float dtc = trunc(s * tex2D(_CameraDepthTexture, uv - dv).x) + 0.0010;
|
||||
float dtr = trunc(s * tex2D(_CameraDepthTexture, uv - dv + du).x) + 0.0110;
|
||||
float dml = trunc(s * tex2D(_CameraDepthTexture, uv - du).x) + 0.1000;
|
||||
float dmc = trunc(s * tex2D(_CameraDepthTexture, uv).x) + 0.0000;
|
||||
float dmr = trunc(s * tex2D(_CameraDepthTexture, uv + du).x) + 0.0100;
|
||||
float dbl = trunc(s * tex2D(_CameraDepthTexture, uv + dv - du).x) + 0.1001;
|
||||
float dbc = trunc(s * tex2D(_CameraDepthTexture, uv + dv).x) + 0.0001;
|
||||
float dbr = trunc(s * tex2D(_CameraDepthTexture, uv + dv + du).x) + 0.0101;
|
||||
float enc = frac(min(dtl, min(dtc, min(dtr, min(dml, min(dmc, min(dmr, min(dbl, min(dbc, dbr)))))))));
|
||||
|
||||
float ru = 0.0;
|
||||
float rv = 0.0;
|
||||
|
||||
enc *= 10.0;
|
||||
ru -= trunc(enc);
|
||||
enc = frac(enc);
|
||||
|
||||
enc *= 10.0;
|
||||
ru += trunc(enc);
|
||||
enc = frac(enc);
|
||||
|
||||
enc *= 10.0;
|
||||
rv -= trunc(enc);
|
||||
enc = frac(enc);
|
||||
|
||||
enc *= 10.0;
|
||||
rv += trunc(enc);
|
||||
enc = frac(enc);
|
||||
|
||||
return uv + dd * float2(ru, rv);
|
||||
}*/
|
||||
|
||||
float3 find_closest_fragment_5tap(float2 uv)
|
||||
{
|
||||
float2 dd = abs(_CameraDepthTexture_TexelSize.xy);
|
||||
float2 du = float2(dd.x, 0.0);
|
||||
float2 dv = float2(0.0, dd.y);
|
||||
|
||||
float2 tl = -dv - du;
|
||||
float2 tr = -dv + du;
|
||||
float2 bl = dv - du;
|
||||
float2 br = dv + du;
|
||||
|
||||
float dtl = tex2D(_CameraDepthTexture, uv + tl).x;
|
||||
float dtr = tex2D(_CameraDepthTexture, uv + tr).x;
|
||||
float dmc = tex2D(_CameraDepthTexture, uv).x;
|
||||
float dbl = tex2D(_CameraDepthTexture, uv + bl).x;
|
||||
float dbr = tex2D(_CameraDepthTexture, uv + br).x;
|
||||
|
||||
float dmin = dmc;
|
||||
float2 dif = 0.0;
|
||||
|
||||
if (ZCMP_GT(dmin, dtl)) { dmin = dtl; dif = tl; }
|
||||
if (ZCMP_GT(dmin, dtr)) { dmin = dtr; dif = tr; }
|
||||
if (ZCMP_GT(dmin, dbl)) { dmin = dbl; dif = bl; }
|
||||
if (ZCMP_GT(dmin, dbr)) { dmin = dbr; dif = br; }
|
||||
|
||||
return float3(uv + dif, dmin);
|
||||
}
|
||||
|
||||
#endif//__DEPTH_CGINC__
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright (c) <2015> <Playdead>
|
||||
// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE.TXT)
|
||||
// AUTHOR: Lasse Jon Fuglsang Pedersen <lasse@playdead.com>
|
||||
|
||||
#ifndef __NOISE_CGINC__
|
||||
#define __NOISE_CGINC__
|
||||
|
||||
//====
|
||||
//note: normalized random, float=[0;1[
|
||||
float PDnrand( float2 n ) {
|
||||
return frac( sin(dot(n.xy, float2(12.9898f, 78.233f)))* 43758.5453f );
|
||||
}
|
||||
float2 PDnrand2( float2 n ) {
|
||||
return frac( sin(dot(n.xy, float2(12.9898f, 78.233f)))* float2(43758.5453f, 28001.8384f) );
|
||||
}
|
||||
float3 PDnrand3( float2 n ) {
|
||||
return frac( sin(dot(n.xy, float2(12.9898f, 78.233f)))* float3(43758.5453f, 28001.8384f, 50849.4141f ) );
|
||||
}
|
||||
float4 PDnrand4( float2 n ) {
|
||||
return frac( sin(dot(n.xy, float2(12.9898f, 78.233f)))* float4(43758.5453f, 28001.8384f, 50849.4141f, 12996.89f) );
|
||||
}
|
||||
|
||||
//====
|
||||
//note: signed random, float=[-1;1[
|
||||
float PDsrand( float2 n ) {
|
||||
return PDnrand( n ) * 2 - 1;
|
||||
}
|
||||
float2 PDsrand2( float2 n ) {
|
||||
return PDnrand2( n ) * 2 - 1;
|
||||
}
|
||||
float3 PDsrand3( float2 n ) {
|
||||
return PDnrand3( n ) * 2 - 1;
|
||||
}
|
||||
float4 PDsrand4( float2 n ) {
|
||||
return PDnrand4( n ) * 2 - 1;
|
||||
}
|
||||
|
||||
#endif//__NOISE_CGINC__
|
||||
|
|
@ -1,431 +0,0 @@
|
|||
// Copyright (c) <2015> <Playdead>
|
||||
// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE.TXT)
|
||||
// AUTHOR: Lasse Jon Fuglsang Pedersen <lasse@playdead.com>
|
||||
|
||||
Shader "Playdead/Post/TemporalReprojection"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
//--- program begin
|
||||
|
||||
#pragma only_renderers ps4 xboxone d3d11 d3d9 xbox360 opengl glcore gles3 metal vulkan
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma multi_compile CAMERA_PERSPECTIVE CAMERA_ORTHOGRAPHIC
|
||||
//#pragma multi_compile __ UNJITTER_COLORSAMPLES
|
||||
//#pragma multi_compile __ UNJITTER_NEIGHBORHOOD
|
||||
//#pragma multi_compile __ UNJITTER_REPROJECTION
|
||||
#pragma multi_compile __ USE_AABB_ROUNDING
|
||||
#pragma multi_compile __ USE_CHROMA_COLORSPACE
|
||||
#pragma multi_compile __ USE_CLIPPING
|
||||
#pragma multi_compile __ USE_VARIANCE_CLIPPING
|
||||
#pragma multi_compile __ USE_CENTER_CLIPPING
|
||||
#pragma multi_compile __ USE_DILATION_5X
|
||||
#pragma multi_compile __ USE_DILATION_3X3
|
||||
#pragma multi_compile __ USE_HIGHER_ORDER_TEXTURE_FILTERING_COLOR
|
||||
#pragma multi_compile __ USE_HIGHER_ORDER_TEXTURE_FILTERING_HISTORY
|
||||
#pragma multi_compile __ USE_MOTION_BLUR
|
||||
#pragma multi_compile __ USE_MOTION_BLUR_NEIGHBORMAX
|
||||
|
||||
#define UNJITTER_COLORSAMPLES 1
|
||||
#define UNJITTER_NEIGHBORHOOD 0
|
||||
#define UNJITTER_REPROJECTION 0
|
||||
|
||||
//TODO: presets
|
||||
/*
|
||||
#if USE_HIGH_PERFORMANCE
|
||||
// best perf: 5 tap nearest, RGB, minmaxrounded, clamping, green_is_luminance, low-motionblur-samples
|
||||
#define USE_DILATION_5X 1
|
||||
#define USE_CENTER_CLIPPING 1
|
||||
#define APPROXIMATE_LUMINANCE_AS_GREEN 1
|
||||
#endif
|
||||
|
||||
#if USE_HIGH_QUALITY
|
||||
// best qual: 9 tap nearest, YCbCg, minmax, full clip, full lum, high-motionblur-samples
|
||||
#define USE_DILATION_3X3 1
|
||||
#define USE_CLIPPING 1
|
||||
#define USE_CHROMA_COLORSPACE 1
|
||||
#define USE_HIGHER_ORDER_TEXTURE_FILTERING_COLOR 1
|
||||
#define USE_HIGHER_ORDER_TEXTURE_FILTERING_HISTORY 1
|
||||
#endif
|
||||
*/
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "IncDepth.cginc"
|
||||
#include "IncNoise.cginc"
|
||||
#include "IncColor.cginc"
|
||||
|
||||
#if SHADER_API_MOBILE
|
||||
static const float FLT_EPS = 0.0001f;
|
||||
#else
|
||||
static const float FLT_EPS = 0.00000001f;
|
||||
#endif
|
||||
|
||||
uniform float4 _JitterUV;// frustum jitter uv deltas, where xy = current frame, zw = previous
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform float4 _MainTex_TexelSize;
|
||||
|
||||
uniform sampler2D_half _VelocityBuffer;
|
||||
uniform sampler2D _VelocityNeighborMax;
|
||||
uniform float4 _VelocityNeighborMax_TexelSize;
|
||||
|
||||
uniform sampler2D _PrevTex;
|
||||
uniform float4 _PrevTex_TexelSize;
|
||||
|
||||
uniform sampler2D _DitherTex;
|
||||
uniform float4 _DitherTex_TexelSize;
|
||||
uniform float4 _DitherOffset_local;
|
||||
|
||||
uniform float _FeedbackMin;
|
||||
uniform float _FeedbackMinMax;
|
||||
uniform float _MotionScale;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 cs_pos : SV_POSITION;
|
||||
float2 ss_txc : TEXCOORD0;
|
||||
nointerpolation float4 mad : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f vert(appdata_img IN)
|
||||
{
|
||||
v2f OUT;
|
||||
|
||||
#if UNITY_VERSION < 540
|
||||
OUT.cs_pos = UnityObjectToClipPos(IN.vertex);
|
||||
#else
|
||||
OUT.cs_pos = UnityObjectToClipPos(IN.vertex);
|
||||
#endif
|
||||
#if UNITY_SINGLE_PASS_STEREO
|
||||
OUT.ss_txc = UnityStereoTransformScreenSpaceTex(IN.texcoord.xy);
|
||||
#else
|
||||
OUT.ss_txc = IN.texcoord.xy;
|
||||
#endif
|
||||
|
||||
OUT.mad.xy = _PrevTex_TexelSize.zw * _DitherTex_TexelSize.xy;
|
||||
OUT.mad.zw = _DitherOffset_local.xy * _DitherTex_TexelSize.xy;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
float4 to_working_colorspace( float4 c )
|
||||
{
|
||||
#if USE_CHROMA_COLORSPACE
|
||||
return float4( RGB_YCbCr(c.rgb), c.a );
|
||||
//return float4( RGB_YCoCg(c.rgb), c.a );
|
||||
#else
|
||||
return c;
|
||||
#endif
|
||||
}
|
||||
float4 from_working_colorspace( float4 c )
|
||||
{
|
||||
#if USE_CHROMA_COLORSPACE
|
||||
return float4( YCbCr_RGB(c.rgb), c.a );
|
||||
//return float4( YCoCg_RGB(c.rgb), c.a );
|
||||
#else
|
||||
return c;
|
||||
#endif
|
||||
}
|
||||
|
||||
float4 clip_aabb(float3 aabb_min, float3 aabb_max, float4 p, float4 q)
|
||||
{
|
||||
#if USE_CENTER_CLIPPING
|
||||
// note: only clips towards aabb center (but fast!)
|
||||
float3 p_clip = 0.5 * (aabb_max + aabb_min);
|
||||
float3 e_clip = 0.5 * (aabb_max - aabb_min) + FLT_EPS;
|
||||
|
||||
float4 v_clip = q - float4(p_clip, p.w);
|
||||
float3 v_unit = v_clip.xyz / e_clip;
|
||||
float3 a_unit = abs(v_unit);
|
||||
float ma_unit = max(a_unit.x, max(a_unit.y, a_unit.z));
|
||||
|
||||
if (ma_unit > 1.0)
|
||||
return float4(p_clip, p.w) + v_clip / ma_unit;
|
||||
else
|
||||
return q;// point inside aabb
|
||||
#else
|
||||
float4 r = q - p;
|
||||
float3 rmax = aabb_max - p.xyz;
|
||||
float3 rmin = aabb_min - p.xyz;
|
||||
|
||||
const float eps = FLT_EPS;
|
||||
if (r.x > rmax.x + eps) r *= (rmax.x / r.x);
|
||||
if (r.y > rmax.y + eps) r *= (rmax.y / r.y);
|
||||
if (r.z > rmax.z + eps) r *= (rmax.z / r.z);
|
||||
|
||||
if (r.x < rmin.x - eps) r *= (rmin.x / r.x);
|
||||
if (r.y < rmin.y - eps) r *= (rmin.y / r.y);
|
||||
if (r.z < rmin.z - eps) r *= (rmin.z / r.z);
|
||||
|
||||
return p + r;
|
||||
#endif
|
||||
}
|
||||
|
||||
//TODO: option to toggle symmetric sampling
|
||||
static const int NUM_TAPS = 3;// on either side!
|
||||
static const float RCP_NUM_TAPS_F = 1.0f / float(NUM_TAPS);
|
||||
static const float RCP_NUM_TOTAL_TAPS_F = 1.0f / float(2*NUM_TAPS+1);
|
||||
half4 sample_color_motion( float2 uv, float2 ss_vel, float srand )
|
||||
{
|
||||
const float2 v = 0.5 * ss_vel;
|
||||
float2 vtap = v * RCP_NUM_TAPS_F;
|
||||
float2 pos0 = uv + vtap * srand;
|
||||
half4 accu = 0.0h;
|
||||
|
||||
[unroll]
|
||||
for (int i = -NUM_TAPS; i <= NUM_TAPS; i++)
|
||||
{
|
||||
accu += to_working_colorspace( tex2D(_MainTex, pos0 + i * vtap) );
|
||||
}
|
||||
|
||||
return accu * RCP_NUM_TOTAL_TAPS_F;
|
||||
}
|
||||
|
||||
float lengthsq( float2 v )
|
||||
{
|
||||
return dot(v,v);
|
||||
}
|
||||
|
||||
float4 temporal_reprojection(float2 ss_txc, float2 ss_vel, float vs_dist)
|
||||
{
|
||||
// read texels
|
||||
#if UNJITTER_COLORSAMPLES
|
||||
float2 cuv = ss_txc - _JitterUV.xy;
|
||||
#else
|
||||
float2 cuv = ss_txc;
|
||||
#endif
|
||||
|
||||
// read texels
|
||||
#if USE_HIGHER_ORDER_TEXTURE_FILTERING_COLOR
|
||||
half4 texel0 = sample_cubic(_MainTex, cuv, _MainTex_TexelSize.zw); //softer
|
||||
#else
|
||||
half4 texel0 = tex2D(_MainTex, cuv); //note: sharper, faster
|
||||
#endif
|
||||
texel0 = to_working_colorspace( texel0 );
|
||||
|
||||
#if USE_HIGHER_ORDER_TEXTURE_FILTERING_HISTORY
|
||||
half4 texel1 = sample_catmull_rom(_PrevTex, ss_txc - ss_vel, _PrevTex_TexelSize.zw);
|
||||
#else
|
||||
half4 texel1 = tex2D(_PrevTex, ss_txc - ss_vel);
|
||||
#endif
|
||||
texel1 = to_working_colorspace( texel1 );
|
||||
|
||||
// calc min-max of current neighbourhood
|
||||
#if UNJITTER_NEIGHBORHOOD
|
||||
float2 uv = ss_txc - _JitterUV.xy;
|
||||
#else
|
||||
float2 uv = ss_txc;
|
||||
#endif
|
||||
|
||||
float2 du = float2(_MainTex_TexelSize.x, 0.0);
|
||||
float2 dv = float2(0.0, _MainTex_TexelSize.y);
|
||||
float4 ctl = to_working_colorspace( tex2D(_MainTex, uv - dv - du) );
|
||||
float4 ctc = to_working_colorspace( tex2D(_MainTex, uv - dv) );
|
||||
float4 ctr = to_working_colorspace( tex2D(_MainTex, uv - dv + du) );
|
||||
float4 cml = to_working_colorspace( tex2D(_MainTex, uv - du) );
|
||||
float4 cmc = to_working_colorspace( tex2D(_MainTex, uv) );
|
||||
float4 cmr = to_working_colorspace( tex2D(_MainTex, uv + du) );
|
||||
float4 cbl = to_working_colorspace( tex2D(_MainTex, uv + dv - du) );
|
||||
float4 cbc = to_working_colorspace( tex2D(_MainTex, uv + dv) );
|
||||
float4 cbr = to_working_colorspace( tex2D(_MainTex, uv + dv + du) );
|
||||
|
||||
float4 cmin5 = min(ctc, min(cml, min(cmc, min(cmr, cbc))));
|
||||
float4 cmax5 = max(ctc, max(cml, max(cmc, max(cmr, cbc))));
|
||||
float4 csum5 = ctc + cml + cmc + cmr + cbc;
|
||||
|
||||
float4 cmin = min(cmin5, min(ctl, min(ctr, min(cbl, cbr))));
|
||||
float4 cmax = max(cmax5, max(ctl, max(ctr, max(cbl, cbr))));
|
||||
|
||||
#if USE_CHROMA_COLORSPACE || USE_CLIPPING
|
||||
float4 cavg = (csum5 + ctl + ctr + cbl + cbr) / 9.0;
|
||||
#endif
|
||||
|
||||
#if USE_AABB_ROUNDING
|
||||
cmin = 0.5 * (cmin + cmin5);
|
||||
cmax = 0.5 * (cmax + cmax5);
|
||||
#if USE_CLIPPING
|
||||
cavg = 0.5 * (cavg + 0.2 * csum5);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_VARIANCE_CLIPPING
|
||||
//note: salvi variance-clipping
|
||||
{
|
||||
const float3 w = float3(1.0/16.0, 2.0/16.0, 4.0/16.0);
|
||||
|
||||
float4 colorAvg = w.z*cmc;
|
||||
float4 colorVar = w.z*cmc*cmc;
|
||||
colorAvg += w.x * ctl; colorVar += w.x * ctl * ctl;
|
||||
colorAvg += w.y * ctc; colorVar += w.y * ctc * ctc;
|
||||
colorAvg += w.x * ctr; colorVar += w.x * ctr * ctr;
|
||||
colorAvg += w.y * cml; colorVar += w.y * cml * cml;
|
||||
//colorAvg += w.z * cmc; colorVar += w.z * cmc * cmc;
|
||||
colorAvg += w.y * cmr; colorVar += w.y * cmr * cmr;
|
||||
colorAvg += w.x * cbl; colorVar += w.x * cbl * cbl;
|
||||
colorAvg += w.y * cbc; colorVar += w.y * cbc * cbc;
|
||||
colorAvg += w.x * cbr; colorVar += w.x * cbr * cbr;
|
||||
|
||||
float4 dev = sqrt(max(FLT_EPS, colorVar - colorAvg*colorAvg));
|
||||
const float gColorBoxSigma = 1.0; //TODO: expose [0.75;1.25]
|
||||
cmin = max(cmin, colorAvg - gColorBoxSigma * dev );
|
||||
cmax = min(cmax, colorAvg + gColorBoxSigma * dev );
|
||||
#if USE_CLIPPING
|
||||
cavg = colorAvg;
|
||||
#endif
|
||||
}
|
||||
#endif //USE_VARIANCE_CLIPPING
|
||||
|
||||
//note: shrink chroma min-max
|
||||
#if USE_CHROMA_COLORSPACE
|
||||
float2 chroma_extent = 0.25 * 0.5 * (cmax.xx - cmin.xx);
|
||||
float2 chroma_center = texel0.yz;
|
||||
float2 ccmin = chroma_center - chroma_extent;
|
||||
float2 ccmax = chroma_center + chroma_extent;
|
||||
if ( lengthsq(ccmax-ccmin) > lengthsq(cmax.yz-cmin.yz) )
|
||||
{
|
||||
cmin.yz = ccmin;
|
||||
cmax.yz = ccmax;
|
||||
#if USE_CLIPPING
|
||||
cavg.yz = chroma_center;
|
||||
#endif
|
||||
}
|
||||
#endif //USE_CHROMA_COLORSPACE
|
||||
|
||||
// clamp to neighbourhood of current sample
|
||||
#if USE_CLIPPING
|
||||
texel1 = clip_aabb(cmin.xyz, cmax.xyz, clamp(cavg, cmin, cmax), texel1);
|
||||
#else
|
||||
texel1 = clamp(texel1, cmin, cmax);
|
||||
#endif
|
||||
|
||||
|
||||
// feedback weight from unbiased luminance diff (t.lottes)
|
||||
#if USE_CHROMA_COLORSPACE
|
||||
float lum0 = texel0.r;
|
||||
float lum1 = texel1.r;
|
||||
#else
|
||||
#if APPROXIMATE_LUMINANCE_AS_GREEN
|
||||
float lum0 = texel0.g;
|
||||
float lum1 = texel1.g;
|
||||
#else
|
||||
float lum0 = Luminance(texel0.rgb);
|
||||
float lum1 = Luminance(texel1.rgb);
|
||||
#endif
|
||||
#endif
|
||||
float unbiased_diff = abs(lum0 - lum1) / max(lum0, max(lum1, 0.2));
|
||||
float unbiased_weight = 1.0 - unbiased_diff;
|
||||
float unbiased_weight_sqr = unbiased_weight * unbiased_weight;
|
||||
float k_feedback = _FeedbackMin + unbiased_weight_sqr * _FeedbackMinMax;
|
||||
|
||||
// output
|
||||
return lerp(texel0, texel1, k_feedback);
|
||||
}
|
||||
|
||||
struct f2rt
|
||||
{
|
||||
fixed4 buffer : SV_Target0;
|
||||
fixed4 screen : SV_Target1;
|
||||
};
|
||||
|
||||
f2rt frag(v2f IN)
|
||||
{
|
||||
f2rt OUT;
|
||||
|
||||
#if UNJITTER_REPROJECTION
|
||||
float2 uv = IN.ss_txc - _JitterUV.xy;
|
||||
#else
|
||||
float2 uv = IN.ss_txc;
|
||||
#endif
|
||||
|
||||
//note: RPDF blue-noise
|
||||
half4 rnd = tex2Dlod( _DitherTex, float4( IN.ss_txc * IN.mad.xy + IN.mad.zw, 0, 0) );
|
||||
|
||||
#if USE_DILATION_5X
|
||||
//--- 5 tap nearest (decent)
|
||||
float3 c_frag = find_closest_fragment_5tap(uv);
|
||||
float2 ss_vel = tex2D(_VelocityBuffer, c_frag.xy).xy;
|
||||
float vs_dist = depth_resolve_linear(c_frag.z);
|
||||
#elif USE_DILATION_3X3
|
||||
//--- 3x3 nearest (good)
|
||||
float3 c_frag = find_closest_fragment_3x3(uv);
|
||||
float2 ss_vel = tex2D(_VelocityBuffer, c_frag.xy).xy;
|
||||
float vs_dist = depth_resolve_linear(c_frag.z);
|
||||
#else
|
||||
float2 ss_vel = tex2D(_VelocityBuffer, uv).xy;
|
||||
float vs_dist = depth_sample_linear(uv);
|
||||
#endif
|
||||
|
||||
// temporal resolve
|
||||
float4 color_temporal = temporal_reprojection(IN.ss_txc, ss_vel, vs_dist);
|
||||
|
||||
// prepare outputs
|
||||
float4 to_buffer = color_temporal;
|
||||
|
||||
#if USE_MOTION_BLUR
|
||||
#if USE_MOTION_BLUR_NEIGHBORMAX
|
||||
//ss_vel = _MotionScale * tex2D(_VelocityNeighborMax, IN.ss_txc).xy;
|
||||
ss_vel = _MotionScale * sample_cubic(_VelocityNeighborMax, IN.ss_txc, _VelocityNeighborMax_TexelSize.zw).xy;
|
||||
#else
|
||||
ss_vel = _MotionScale * ss_vel;
|
||||
#endif
|
||||
|
||||
float vel_mag = length(ss_vel * _MainTex_TexelSize.zw);
|
||||
const float vel_trust_full = 2.0;
|
||||
const float vel_trust_none = 15.0;
|
||||
const float vel_trust_span = vel_trust_none - vel_trust_full;
|
||||
float trust = 1.0 - clamp(vel_mag - vel_trust_full, 0.0, vel_trust_span) / vel_trust_span;
|
||||
|
||||
#if UNJITTER_COLORSAMPLES
|
||||
half4 color_motion = sample_color_motion( IN.ss_txc - _JitterUV.xy, ss_vel, rnd.xy-0.5h);
|
||||
#else
|
||||
half4 color_motion = sample_color_motion( IN.ss_txc, ss_vel, rnd.xy-0.5h);
|
||||
#endif
|
||||
|
||||
float4 to_screen = lerp(color_motion, color_temporal, trust);
|
||||
#else
|
||||
float4 to_screen = color_temporal;
|
||||
#endif
|
||||
|
||||
to_buffer = from_working_colorspace( to_buffer );
|
||||
to_screen = from_working_colorspace( to_screen );
|
||||
|
||||
//note: velocity debug
|
||||
//to_screen.g += 100.0 * length(ss_vel);
|
||||
//to_screen = float4(100.0 * abs(ss_vel), 0.0, 0.0);
|
||||
|
||||
// dither color-output
|
||||
float4 noise4_tri = remap_noise_tri( rnd ) / 255.0;
|
||||
OUT.buffer = saturate(to_buffer + noise4_tri);
|
||||
OUT.screen = saturate(to_screen + noise4_tri);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
//--- program end
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
ZTest Always
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
Fallback off
|
||||
}
|
||||
|
|
@ -1,309 +0,0 @@
|
|||
// Copyright (c) <2015> <Playdead>
|
||||
// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE.TXT)
|
||||
// AUTHOR: Lasse Jon Fuglsang Pedersen <lasse@playdead.com>
|
||||
|
||||
Shader "Playdead/Post/VelocityBuffer"
|
||||
{
|
||||
CGINCLUDE
|
||||
//--- program begin
|
||||
|
||||
#pragma only_renderers ps4 xboxone d3d11 d3d9 xbox360 opengl glcore gles3 metal vulkan
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma multi_compile CAMERA_PERSPECTIVE CAMERA_ORTHOGRAPHIC
|
||||
#pragma multi_compile __ TILESIZE_10 TILESIZE_20 TILESIZE_40
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "IncDepth.cginc"
|
||||
|
||||
#if UNITY_VERSION < 540
|
||||
uniform float4x4 _CameraToWorld;// UNITY_SHADER_NO_UPGRADE
|
||||
#endif
|
||||
|
||||
#if UNITY_VERSION < 550
|
||||
#define STEREO_ARRAY
|
||||
#define STEREO_INDEX(x) x
|
||||
#else
|
||||
#define STEREO_ARRAY [2]
|
||||
#define STEREO_INDEX(x) x[unity_StereoEyeIndex]
|
||||
#endif
|
||||
|
||||
uniform sampler2D_half _VelocityTex;
|
||||
uniform float4 _VelocityTex_TexelSize;
|
||||
|
||||
uniform float4 _ProjectionExtents STEREO_ARRAY;// xy = frustum extents at distance 1, zw = jitter at distance 1
|
||||
|
||||
uniform float4x4 _CurrV STEREO_ARRAY;
|
||||
uniform float4x4 _CurrVP STEREO_ARRAY;
|
||||
uniform float4x4 _CurrM;
|
||||
|
||||
uniform float4x4 _PrevVP STEREO_ARRAY;
|
||||
uniform float4x4 _PrevVP_NoFlip STEREO_ARRAY;
|
||||
uniform float4x4 _PrevM;
|
||||
|
||||
struct blit_v2f
|
||||
{
|
||||
float4 cs_pos : SV_POSITION;
|
||||
float2 ss_txc : TEXCOORD0;
|
||||
float2 vs_ray : TEXCOORD1;
|
||||
};
|
||||
|
||||
blit_v2f blit_vert(appdata_img IN)
|
||||
{
|
||||
blit_v2f OUT;
|
||||
|
||||
#if UNITY_VERSION < 540
|
||||
OUT.cs_pos = mul(UNITY_MATRIX_MVP, IN.vertex);
|
||||
#else
|
||||
OUT.cs_pos = UnityObjectToClipPos(IN.vertex);
|
||||
#endif
|
||||
|
||||
#if UNITY_SINGLE_PASS_STEREO
|
||||
OUT.ss_txc = UnityStereoTransformScreenSpaceTex(IN.texcoord.xy);
|
||||
#else
|
||||
OUT.ss_txc = IN.texcoord.xy;
|
||||
#endif
|
||||
OUT.vs_ray = (2.0 * IN.texcoord.xy - 1.0) * STEREO_INDEX(_ProjectionExtents).xy + STEREO_INDEX(_ProjectionExtents).zw;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
float4 blit_frag_prepass(blit_v2f IN) : SV_Target
|
||||
{
|
||||
// reconstruct world position
|
||||
float vs_dist = depth_sample_linear(IN.ss_txc);
|
||||
#if CAMERA_PERSPECTIVE
|
||||
float3 vs_pos = float3(IN.vs_ray, 1.0) * vs_dist;
|
||||
#elif CAMERA_ORTHOGRAPHIC
|
||||
float3 vs_pos = float3(IN.vs_ray, vs_dist);
|
||||
#else
|
||||
#error "missing keyword CAMERA_..."
|
||||
#endif
|
||||
|
||||
#if UNITY_VERSION < 540
|
||||
float4 ws_pos = mul(_CameraToWorld, float4(vs_pos, 1.0));// UNITY_SHADER_NO_UPGRADE
|
||||
#else
|
||||
float4 ws_pos = mul(unity_CameraToWorld, float4(vs_pos, 1.0));
|
||||
#endif
|
||||
|
||||
//// NOTE: world space debug at 3D crane
|
||||
//return 0.1 * float4(ws_pos.xy - float2(595.0, -215.0), 0.0, 0.0);
|
||||
|
||||
// reproject into previous frame
|
||||
float4 rp_cs_pos = mul(STEREO_INDEX(_PrevVP_NoFlip), ws_pos);
|
||||
float2 rp_ss_ndc = rp_cs_pos.xy / rp_cs_pos.w;
|
||||
float2 rp_ss_txc = 0.5 * rp_ss_ndc + 0.5;
|
||||
|
||||
// estimate velocity
|
||||
#if UNITY_SINGLE_PASS_STEREO
|
||||
float2 ss_vel = IN.ss_txc - UnityStereoTransformScreenSpaceTex(rp_ss_txc);
|
||||
#else
|
||||
float2 ss_vel = IN.ss_txc - rp_ss_txc;
|
||||
#endif
|
||||
|
||||
// output
|
||||
return float4(ss_vel, 0.0, 0.0);
|
||||
}
|
||||
|
||||
float4 blit_frag_tilemax(blit_v2f IN) : SV_Target
|
||||
{
|
||||
#if TILESIZE_10
|
||||
const int support = 10;
|
||||
#elif TILESIZE_20
|
||||
const int support = 20;
|
||||
#elif TILESIZE_40
|
||||
const int support = 40;
|
||||
#else
|
||||
const int support = 1;
|
||||
#endif
|
||||
|
||||
const float2 step = _VelocityTex_TexelSize.xy;
|
||||
const float2 base = IN.ss_txc + (0.5 - 0.5 * support) * step;
|
||||
const float2 du = float2(_VelocityTex_TexelSize.x, 0.0);
|
||||
const float2 dv = float2(0.0, _VelocityTex_TexelSize.y);
|
||||
|
||||
float2 mv = 0.0;
|
||||
float rmv = 0.0;
|
||||
|
||||
[unroll(10)]
|
||||
for (int i = 0; i != support; i++)
|
||||
{
|
||||
[unroll(10)]
|
||||
for (int j = 0; j != support; j++)
|
||||
{
|
||||
float2 v = tex2D(_VelocityTex, base + i * dv + j * du).xy;
|
||||
float rv = dot(v, v);
|
||||
if (rv > rmv)
|
||||
{
|
||||
mv = v;
|
||||
rmv = rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return float4(mv, 0.0, 0.0);
|
||||
}
|
||||
|
||||
float4 blit_frag_neighbormax(blit_v2f IN) : SV_Target
|
||||
{
|
||||
const float2 du = float2(_VelocityTex_TexelSize.x, 0.0);
|
||||
const float2 dv = float2(0.0, _VelocityTex_TexelSize.y);
|
||||
|
||||
float2 mv = 0.0;
|
||||
float dmv = 0.0;
|
||||
|
||||
[unroll]
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
[unroll]
|
||||
for (int j = -1; j <= 1; j++)
|
||||
{
|
||||
float2 v = tex2D(_VelocityTex, IN.ss_txc + i * dv + j * du).xy;
|
||||
float dv = dot(v, v);
|
||||
if (dv > dmv)
|
||||
{
|
||||
mv = v;
|
||||
dmv = dv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return float4(mv, 0.0, 0.0);
|
||||
}
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 cs_pos : SV_POSITION;
|
||||
float4 ss_pos : TEXCOORD0;
|
||||
float3 cs_xy_curr : TEXCOORD1;
|
||||
float3 cs_xy_prev : TEXCOORD2;
|
||||
};
|
||||
|
||||
v2f process_vertex(float4 ws_pos_curr, float4 ws_pos_prev)
|
||||
{
|
||||
v2f OUT;
|
||||
|
||||
const float occlusion_bias = 0.03;
|
||||
|
||||
OUT.cs_pos = mul(mul(STEREO_INDEX(_CurrVP), _CurrM), ws_pos_curr);
|
||||
OUT.ss_pos = ComputeScreenPos(OUT.cs_pos);
|
||||
OUT.ss_pos.z = -mul(mul(STEREO_INDEX(_CurrV), _CurrM), ws_pos_curr).z - occlusion_bias;// COMPUTE_EYEDEPTH
|
||||
OUT.cs_xy_curr = OUT.cs_pos.xyw;
|
||||
OUT.cs_xy_prev = mul(mul(STEREO_INDEX(_PrevVP), _PrevM), ws_pos_prev).xyw;
|
||||
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
OUT.cs_xy_curr.y = -OUT.cs_xy_curr.y;
|
||||
OUT.cs_xy_prev.y = -OUT.cs_xy_prev.y;
|
||||
#endif
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
v2f vert(appdata_base IN)
|
||||
{
|
||||
return process_vertex(IN.vertex, IN.vertex);
|
||||
}
|
||||
|
||||
v2f vert_skinned(appdata_base IN)
|
||||
{
|
||||
return process_vertex(IN.vertex, float4(IN.normal, 1.0));// previous frame positions stored in normal data
|
||||
}
|
||||
|
||||
float4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
float2 ss_txc = IN.ss_pos.xy / IN.ss_pos.w;
|
||||
float scene_d = depth_sample_linear(ss_txc);
|
||||
|
||||
// discard if occluded
|
||||
clip(scene_d - IN.ss_pos.z);
|
||||
|
||||
// compute velocity in ndc
|
||||
float2 ndc_curr = IN.cs_xy_curr.xy / IN.cs_xy_curr.z;
|
||||
float2 ndc_prev = IN.cs_xy_prev.xy / IN.cs_xy_prev.z;
|
||||
|
||||
// compute screen space velocity [0,1;0,1]
|
||||
#if UNITY_SINGLE_PASS_STEREO
|
||||
return float4(0.5 * (ndc_curr - ndc_prev) * unity_StereoScaleOffset[unity_StereoEyeIndex].xy, 0.0, 0.0);
|
||||
#else
|
||||
return float4(0.5 * (ndc_curr - ndc_prev), 0.0, 0.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
//--- program end
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
// 0: prepass
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode Off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex blit_vert
|
||||
#pragma fragment blit_frag_prepass
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// 1: vertices
|
||||
Pass
|
||||
{
|
||||
ZTest LEqual Cull Back ZWrite On
|
||||
Fog { Mode Off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// 2: vertices skinned
|
||||
Pass
|
||||
{
|
||||
ZTest LEqual Cull Back ZWrite On
|
||||
Fog { Mode Off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_skinned
|
||||
#pragma fragment frag
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// 3: tilemax
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode Off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex blit_vert
|
||||
#pragma fragment blit_frag_tilemax
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
// 4: neighbormax
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode Off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex blit_vert
|
||||
#pragma fragment blit_frag_neighbormax
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
Fallback Off
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0d7f09e63dd99504ca6e04212a21ec72
|
||||
timeCreated: 1437991034
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/PDTAA/Textures/bluenoise_frd_256x256_uni.bmp
(Stored with Git LFS)
BIN
Assets/Plugins/PDTAA/Textures/bluenoise_frd_256x256_uni.bmp
(Stored with Git LFS)
Binary file not shown.
8
Assets/Plugins/VolumeCloud.meta
Normal file
8
Assets/Plugins/VolumeCloud.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f7a5905754299444c8c54e4e59668749
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6ba0f1d2bd55e0f449f84e7e8ec3d73a
|
||||
guid: a5355ed4c7ace6e4194bb0c52fd10fc3
|
||||
folderAsset: yes
|
||||
timeCreated: 1521966588
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
BIN
Assets/Plugins/VolumeCloud/Editor/Config.asset
(Stored with Git LFS)
Normal file
BIN
Assets/Plugins/VolumeCloud/Editor/Config.asset
(Stored with Git LFS)
Normal file
Binary file not shown.
|
|
@ -1,5 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ca1886ece3dfc5e49902e78defccd355
|
||||
guid: ff23f3c539d9073408464e0039314ed5
|
||||
timeCreated: 1521972532
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
141
Assets/Plugins/VolumeCloud/Editor/VolumeCloudWindowEditor.cs
Normal file
141
Assets/Plugins/VolumeCloud/Editor/VolumeCloudWindowEditor.cs
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
|
||||
namespace Yangrc.VolumeCloud {
|
||||
public class VolumeCloudWindowEditor : EditorWindow {
|
||||
private VolumeCloudWindowConfigurations config {
|
||||
get {
|
||||
if (_config == null) {
|
||||
_config = AssetDatabase.LoadAssetAtPath<VolumeCloudWindowConfigurations>("Assets/VolumeCloud/Editor/Config.asset");
|
||||
if (_config == null) {
|
||||
var newConfig = ScriptableObject.CreateInstance<VolumeCloudWindowConfigurations>();
|
||||
AssetDatabase.CreateAsset(newConfig, "Assets/VolumeCloud/Editor/Config.asset");
|
||||
// AssetDatabase.IsValidFolder(
|
||||
this._config = newConfig;
|
||||
}
|
||||
}
|
||||
return _config;
|
||||
}
|
||||
}
|
||||
private VolumeCloudWindowConfigurations _config;
|
||||
private SerializedObject configSO {
|
||||
get {
|
||||
return _configSO ?? (_configSO = new SerializedObject(config));
|
||||
}
|
||||
}
|
||||
private SerializedObject _configSO;
|
||||
|
||||
|
||||
private Texture2D testTexPreview;
|
||||
private Texture2D firstTexPreview;
|
||||
private Texture2D secondTexPreview;
|
||||
|
||||
private Vector2 scrollPos;
|
||||
|
||||
// Add menu named "My Window" to the Window menu
|
||||
[MenuItem("Window/VolumeCloud")]
|
||||
static void Init() {
|
||||
// Get existing open window or if none, make a new one:
|
||||
VolumeCloudWindowEditor window = (VolumeCloudWindowEditor)EditorWindow.GetWindow(typeof(VolumeCloudWindowEditor));
|
||||
window.Show();
|
||||
}
|
||||
|
||||
private void OnGUI() {
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height));
|
||||
//Test only.
|
||||
EditorGUILayout.BeginHorizontal();//Second 3d tex.
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
{ //Config area.
|
||||
EditorGUILayout.PropertyField(configSO.FindProperty("testGenerator"), true);
|
||||
if (GUILayout.Button("Save tex")) {
|
||||
var texture = Utils.GetTex(config.testGenerator, 128, TextureFormat.RGB24);
|
||||
AssetDatabase.CreateAsset(texture, "Assets/VolumeCloud/" + "TestTex" + ".asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
if (configSO.FindProperty("testGenerator").isExpanded) {
|
||||
EditorGUILayout.BeginVertical(GUILayout.Width(256.0f)); //Preview Area
|
||||
{
|
||||
if (GUILayout.Button("Preview")) {
|
||||
testTexPreview = Utils.GetPreviewTex(config.testGenerator, 128, TextureFormat.RGFloat);
|
||||
}
|
||||
if (GUILayout.Button("Save preview")) {
|
||||
AssetDatabase.CreateAsset(testTexPreview, "Assets/VolumeCloud/" + "curlNoise" + ".asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
if (testTexPreview != null) {
|
||||
GUI.DrawTexture(EditorGUILayout.GetControlRect(false, GUILayout.Width(256.0f), GUILayout.Height(256.0f)), testTexPreview);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();// First 3d texture.
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
{ //Config area.
|
||||
EditorGUILayout.PropertyField(configSO.FindProperty("first3DTexGenerator"), true);
|
||||
if (configSO.FindProperty("first3DTexGenerator").isExpanded) {
|
||||
EditorGUILayout.PropertyField(configSO.FindProperty("first3DTexSaveName"));
|
||||
if (GUILayout.Button("Save tex")) {
|
||||
var texture = Utils.GetTex(config.first3DTexGenerator, config.first3DTexGenerator.texResolution);
|
||||
AssetDatabase.CreateAsset(texture, "Assets/VolumeCloud/" + config.first3DTexSaveName + ".asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.BeginVertical(GUILayout.Width(256.0f)); ;
|
||||
{
|
||||
if (GUILayout.Button("Preview"))
|
||||
firstTexPreview = Utils.GetPreviewTex(config.first3DTexGenerator, config.first3DTexGenerator.texResolution);
|
||||
if (firstTexPreview != null)
|
||||
GUI.DrawTexture(EditorGUILayout.GetControlRect(false, GUILayout.Width(256.0f), GUILayout.Height(256.0f)), firstTexPreview);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();//Second 3d tex.
|
||||
{
|
||||
EditorGUILayout.BeginVertical();
|
||||
{ //Config area.
|
||||
EditorGUILayout.PropertyField(configSO.FindProperty("second3DTexGenerator"), true);
|
||||
if (configSO.FindProperty("second3DTexGenerator").isExpanded) {
|
||||
EditorGUILayout.PropertyField(configSO.FindProperty("second3DTexSaveName"));
|
||||
if (GUILayout.Button("Save tex")) {
|
||||
var texture = Utils.GetTex(config.second3DTexGenerator, config.second3DTexGenerator.texResolution, TextureFormat.RGB24);
|
||||
AssetDatabase.CreateAsset(texture, "Assets/VolumeCloud/" + config.second3DTexSaveName + ".asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.BeginVertical(GUILayout.Width(256.0f)); //Preview Area
|
||||
{
|
||||
if (GUILayout.Button("Preview")) {
|
||||
secondTexPreview = Utils.GetPreviewTex(config.second3DTexGenerator, config.second3DTexGenerator.texResolution);
|
||||
}
|
||||
if (secondTexPreview != null) {
|
||||
GUI.DrawTexture(EditorGUILayout.GetControlRect(false, GUILayout.Width(256.0f), GUILayout.Height(256.0f)), secondTexPreview);
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
EditorGUILayout.EndScrollView();
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
configSO.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7adc29af50ded2b4a90b86b7df94be23
|
||||
timeCreated: 1521969753
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Plugins/VolumeCloud/Example.meta
Normal file
10
Assets/Plugins/VolumeCloud/Example.meta
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2cc7484e5816b124a98120309af6a4e7
|
||||
folderAsset: yes
|
||||
timeCreated: 1530938310
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/VolumeCloud/Example/Screenshot1.meta
Normal file
8
Assets/Plugins/VolumeCloud/Example/Screenshot1.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4aad6993da61d5549913dd868a11e328
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
594
Assets/Plugins/VolumeCloud/Example/Screenshot1/Screenshot1.unity
Normal file
594
Assets/Plugins/VolumeCloud/Example/Screenshot1/Screenshot1.unity
Normal file
|
|
@ -0,0 +1,594 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 1432092516}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 49040651}
|
||||
m_IndirectSpecularColor: {r: 0.019927999, g: 0.037775546, b: 0.06939693, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 11
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 0
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 2
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_UseShadowmask: 1
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &49040650
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 49040652}
|
||||
- component: {fileID: 49040651}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &49040651
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 49040650}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 10
|
||||
m_Type: 1
|
||||
m_Shape: 0
|
||||
m_Color: {r: 0.95686275, g: 0.6813293, b: 0.3865726, a: 1}
|
||||
m_Intensity: 2.02
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &49040652
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 49040650}
|
||||
m_LocalRotation: {x: -0.9797308, y: -0.13232979, z: 0.05140217, w: -0.1413304}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 523.11, y: -716.206, z: -14.820984}
|
||||
--- !u!1 &636899334
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 636899336}
|
||||
- component: {fileID: 636899335}
|
||||
- component: {fileID: 636899337}
|
||||
m_Layer: 8
|
||||
m_Name: AtmManager
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &636899335
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 636899334}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e16dd2ddbdfa7ea4f87a3cfb032ffd0f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
progressiveUpdate: 0
|
||||
computeShader: {fileID: 7200000, guid: 2d4396a54b390d742b84d4bb4a122e54, type: 3}
|
||||
outputDebug: 0
|
||||
lutConfig:
|
||||
transmittanceSize: {x: 512, y: 512}
|
||||
scatteringSize: {x: 32, y: 32, z: 128}
|
||||
irradianceSize: {x: 32, y: 32}
|
||||
cameraVolumeSize: {x: 128, y: 128, z: 32}
|
||||
atmosphereConfig: {fileID: 11400000, guid: 8e73e89daf00b8447b2410427953df25, type: 2}
|
||||
--- !u!4 &636899336
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 636899334}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &636899337
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 636899334}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8b9a305e18de0c04dbd257a21cd47087, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
sharedProfile: {fileID: 11400000, guid: fb5c6f5333d1578418cdc5074b1c900e, type: 2}
|
||||
isGlobal: 1
|
||||
blendDistance: 0
|
||||
weight: 1
|
||||
priority: 0
|
||||
--- !u!21 &1432092516
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Skybox/AtmosphereScatteringPrecomputed
|
||||
m_Shader: {fileID: 4800000, guid: e2088dd19a71d1244976cd0de1ff68a7, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs: []
|
||||
m_Floats: []
|
||||
m_Colors: []
|
||||
--- !u!1 &1662884154
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1662884158}
|
||||
- component: {fileID: 1662884157}
|
||||
- component: {fileID: 1662884156}
|
||||
- component: {fileID: 1662884155}
|
||||
m_Layer: 0
|
||||
m_Name: Sphere
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!135 &1662884155
|
||||
SphereCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1662884154}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.5
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &1662884156
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1662884154}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!33 &1662884157
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1662884154}
|
||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &1662884158
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1662884154}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -11124, y: -397, z: 5874}
|
||||
m_LocalScale: {x: 7556.414, y: 7556.414, z: 7556.414}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1748146228
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1748146232}
|
||||
- component: {fileID: 1748146231}
|
||||
- component: {fileID: 1748146229}
|
||||
- component: {fileID: 1748146234}
|
||||
- component: {fileID: 1748146230}
|
||||
- component: {fileID: 1748146236}
|
||||
- component: {fileID: 1748146235}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &1748146229
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_Enabled: 1
|
||||
--- !u!114 &1748146230
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 948f4100a11a5c24981795d21301da5c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
volumeTrigger: {fileID: 1748146232}
|
||||
volumeLayer:
|
||||
serializedVersion: 2
|
||||
m_Bits: 256
|
||||
stopNaNPropagation: 1
|
||||
finalBlitToCameraTarget: 0
|
||||
antialiasingMode: 3
|
||||
temporalAntialiasing:
|
||||
jitterSpread: 0.75
|
||||
sharpness: 0.25
|
||||
stationaryBlending: 0.95
|
||||
motionBlending: 0.85
|
||||
subpixelMorphologicalAntialiasing:
|
||||
quality: 2
|
||||
fastApproximateAntialiasing:
|
||||
fastMode: 0
|
||||
keepAlpha: 0
|
||||
fog:
|
||||
enabled: 1
|
||||
excludeSkybox: 1
|
||||
debugLayer:
|
||||
lightMeter:
|
||||
width: 512
|
||||
height: 256
|
||||
showCurves: 1
|
||||
histogram:
|
||||
width: 512
|
||||
height: 256
|
||||
channel: 3
|
||||
waveform:
|
||||
exposure: 0.12
|
||||
height: 256
|
||||
vectorscope:
|
||||
size: 256
|
||||
exposure: 0.12
|
||||
overlaySettings:
|
||||
linearDepth: 0
|
||||
motionColorIntensity: 4
|
||||
motionGridSize: 64
|
||||
colorBlindnessType: 0
|
||||
colorBlindnessStrength: 1
|
||||
m_Resources: {fileID: 11400000, guid: d82512f9c8e5d4a4d938b575d47f88d4, type: 2}
|
||||
m_ShowToolkit: 0
|
||||
m_ShowCustomSorter: 0
|
||||
breakBeforeColorGrading: 0
|
||||
m_BeforeTransparentBundles: []
|
||||
m_BeforeStackBundles: []
|
||||
m_AfterStackBundles: []
|
||||
--- !u!20 &1748146231
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 100
|
||||
far clip plane: 10000
|
||||
field of view: 75
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 0
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &1748146232
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_LocalRotation: {x: 0.14780942, y: 0, z: 0, w: 0.9890159}
|
||||
m_LocalPosition: {x: -10082, y: 4927.1, z: -2027}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 17, y: 0, z: 0}
|
||||
--- !u!114 &1748146234
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9f1db61281524fb40bc9a1f6acce6baf, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
configuration: {fileID: 11400000, guid: a15886e93ac3e7847861da392782f13d, type: 2}
|
||||
downSample: 0
|
||||
quality: 2
|
||||
allowCloudFrontObject: 1
|
||||
useApSystem: 0
|
||||
useHierarchicalHeightMap: 1
|
||||
cloudShader: {fileID: 4800000, guid: 84e97169589c5e94e8521fe4deb2e3f8, type: 3}
|
||||
heightPreprocessShader: {fileID: 7200000, guid: 40276bd53f35a694e8d4e025ca310775,
|
||||
type: 3}
|
||||
cloudHeightProcessShader: {fileID: 4800000, guid: b80bf04ca56d3d642a6b925cff3f5ddf,
|
||||
type: 3}
|
||||
--- !u!114 &1748146235
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0a9c4d2e823dfc247b2f6850f76ca2b6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &1748146236
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b535dacf702e20c4b9ef528e42081835, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
volumeTexSize: {x: 128, y: 128, z: 32}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f3d704c6fc646ad48a89a5db504dbd37
|
||||
guid: e4a8c6ec9e196d241854a4ff221a28fd
|
||||
timeCreated: 1521964013
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fc2731fc466427a429629ea6bd19ebd5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/VolumeCloud/Example/Screenshot1/Screenshot1_Profiles/AtmManager Profile.asset
(Stored with Git LFS)
Normal file
BIN
Assets/Plugins/VolumeCloud/Example/Screenshot1/Screenshot1_Profiles/AtmManager Profile.asset
(Stored with Git LFS)
Normal file
Binary file not shown.
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b342bf0806dd2d140b9555fad4385c0f
|
||||
guid: fb5c6f5333d1578418cdc5074b1c900e
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
8
Assets/Plugins/VolumeCloud/Example/Screenshot2.meta
Normal file
8
Assets/Plugins/VolumeCloud/Example/Screenshot2.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d8eb8b025c1be6d409d9e1745b9214dc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Plugins/VolumeCloud/Example/Screenshot2/Config.asset
(Stored with Git LFS)
Normal file
BIN
Assets/Plugins/VolumeCloud/Example/Screenshot2/Config.asset
(Stored with Git LFS)
Normal file
Binary file not shown.
|
|
@ -1,5 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d3145d0fdeb93df40b15edabf13afdaf
|
||||
guid: e9b06b77cd78e5e4b95a6ca30e5f61e7
|
||||
timeCreated: 1524043690
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
329
Assets/Plugins/VolumeCloud/Example/Screenshot2/Screenshot2.unity
Normal file
329
Assets/Plugins/VolumeCloud/Example/Screenshot2/Screenshot2.unity
Normal file
|
|
@ -0,0 +1,329 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 8
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 49040651}
|
||||
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 11
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_TemporalCoherenceThreshold: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 9
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_TextureWidth: 1024
|
||||
m_TextureHeight: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 0
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ShowResolutionOverlay: 1
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_UseShadowmask: 1
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &49040650
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 49040652}
|
||||
- component: {fileID: 49040651}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &49040651
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 49040650}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 8
|
||||
m_Type: 1
|
||||
m_Color: {r: 1, g: 0.96572006, b: 0.9044118, a: 1}
|
||||
m_Intensity: 1.2
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_Lightmapping: 4
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &49040652
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 49040650}
|
||||
m_LocalRotation: {x: -0.52715605, y: 0.67356503, z: -0.4896874, w: -0.16918293}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 56.934002, y: 148.093, z: -93.717}
|
||||
--- !u!1 &466916245
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 466916246}
|
||||
m_Layer: 0
|
||||
m_Name: GameObject
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &466916246
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 466916245}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -317.8709, y: 20000, z: -159.77051}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1748146228
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 1748146232}
|
||||
- component: {fileID: 1748146231}
|
||||
- component: {fileID: 1748146229}
|
||||
- component: {fileID: 1748146234}
|
||||
- component: {fileID: 1748146233}
|
||||
- component: {fileID: 1748146235}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &1748146229
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &1748146231
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 2000
|
||||
field of view: 75
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 0
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &1748146232
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_LocalRotation: {x: -0.46222746, y: -0, z: -0, w: 0.8867614}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: -55.062004, y: 0, z: 0}
|
||||
--- !u!114 &1748146233
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ff26db721962cdf4a8edcdfa9a767d2a, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
profile: {fileID: 11400000, guid: cdea7d3b49937774abb1b5ac066885fd, type: 2}
|
||||
--- !u!114 &1748146234
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 9f1db61281524fb40bc9a1f6acce6baf, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
configuration: {fileID: 11400000, guid: e9b06b77cd78e5e4b95a6ca30e5f61e7, type: 2}
|
||||
downSample: 1
|
||||
quality: 0
|
||||
allowCloudFrontObject: 0
|
||||
useApSystem: 0
|
||||
useHierarchicalHeightMap: 1
|
||||
cloudShader: {fileID: 4800000, guid: 84e97169589c5e94e8521fe4deb2e3f8, type: 3}
|
||||
heightPreprocessShader: {fileID: 7200000, guid: 40276bd53f35a694e8d4e025ca310775,
|
||||
type: 3}
|
||||
cloudHeightProcessShader: {fileID: 4800000, guid: b80bf04ca56d3d642a6b925cff3f5ddf,
|
||||
type: 3}
|
||||
--- !u!114 &1748146235
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748146228}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0a9c4d2e823dfc247b2f6850f76ca2b6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue