diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2dba61f --- /dev/null +++ b/.gitignore @@ -0,0 +1,80 @@ +# This .gitignore file should be placed at the root of your Unity project directory +# +# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore +# +/[Ll]ibrary/ +/[Tt]emp/ +/[Oo]bj/ +/[Bb]uild/ +/[Bb]uilds/ +/[Ll]ogs/ +/[Uu]ser[Ss]ettings/ + +# MemoryCaptures can get excessive in size. +# They also could contain extremely sensitive data +/[Mm]emoryCaptures/ + +# Asset meta data should only be ignored when the corresponding asset is also ignored +!/[Aa]ssets/**/*.meta + +# Uncomment this line if you wish to ignore the asset store tools plugin +# /[Aa]ssets/AssetStoreTools* + +# Autogenerated Jetbrains Rider plugin +/[Aa]ssets/Plugins/Editor/JetBrains* + +# Visual Studio cache directory +.vs/ + +# Gradle cache directory +.gradle/ + +# Autogenerated VS/MD/Consulo solution and project files +ExportedObj/ +.consulo/ +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd +*.pdb +*.mdb +*.opendb +*.VC.db + +# Unity3D generated meta files +*.pidb.meta +*.pdb.meta +*.mdb.meta + +# Unity3D generated file on crash reports +sysinfo.txt + +# Builds +*.apk +*.unitypackage + +# Crashlytics generated file +crashlytics-build.properties + +# Packed Addressables +/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* + +# Temporary auto-generated Android Assets +/[Aa]ssets/[Ss]treamingAssets/aa.meta +/[Aa]ssets/[Ss]treamingAssets/aa/* + +# VSCode +.vscode + +# Others +.DS_Store +/[Ww]iki/ + +# Raw file is not allowed to be redistributed. +*.raw diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..bd0c9a4 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/../../../../../../:\Users\Planck\Unity_Projects\UnityVolumeRendering-master\.idea/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/UnityVolumeRendering-master.iml b/.idea/UnityVolumeRendering-master.iml new file mode 100644 index 0000000..749b094 --- /dev/null +++ b/.idea/UnityVolumeRendering-master.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..3d06546 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,33 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d30b5d6 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..08bab50 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000..9502488 --- /dev/null +++ b/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,105 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "ExecuteTime": { + "end_time": "2021-03-16T07:13:56.559086Z", + "start_time": "2021-03-16T07:13:39.464085Z" + } + }, + "outputs": [], + "source": [ + "from glob import glob\n", + "import pydicom\n", + "import os.path as osp\n", + "import numpy as np\n", + "\n", + "out_name = \"3D.raw\"\n", + "out_base_path = \"./Assets/\"\n", + "dicom_dir = \"D:3Dsyokudo/\"\n", + "dicom_file_list = glob(osp.join(dicom_dir, \"*\"))\n", + "dicom_file_list = sorted(dicom_file_list, key=lambda x: float(pydicom.read_file(x).SliceLocation), reverse=False)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "ExecuteTime": { + "end_time": "2021-03-16T07:09:08.808051Z", + "start_time": "2021-03-16T07:09:07.881746Z" + } + }, + "outputs": [], + "source": [ + "height, width = pydicom.read_file(dicom_file_list[0]).pixel_array.shape\n", + "depth = len(dicom_file_list)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "ExecuteTime": { + "end_time": "2021-03-14T13:56:53.161775Z", + "start_time": "2021-03-14T13:56:46.536770Z" + } + }, + "outputs": [], + "source": [ + "stack_img = np.stack([pydicom.read_file(x).pixel_array + pydicom.read_file(x).RescaleIntercept for x in dicom_file_list], axis=2)\n", + "row_format = stack_img.transpose(1, 0, 2).reshape(-1, order=\"F\")\n", + "\n", + "# ウィンドウ使うバージョン2\n", + "window_max = 330\n", + "window_min = -270\n", + "\n", + "scaled_row = row_format.copy().astype(np.float)\n", + "scaled_row[scaled_row < window_min] = window_min\n", + "scaled_row[window_max < scaled_row] = window_max\n", + "\n", + "scaled_row -= np.mean(scaled_row)\n", + "scaled_row = scaled_row / (np.max(np.abs(scaled_row)) + 1e-5) * (2 ** 16)\n", + "scaled_row -= np.mean(scaled_row)\n", + "scaled_row = np.clip(scaled_row, 0, 2 ** 16).astype(np.uint16)\n", + "scaled_row.tofile(osp.join(out_base_path, out_name))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.10" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/Assets/1. 3DTexture.meta b/Assets/1. 3DTexture.meta new file mode 100644 index 0000000..2375b79 --- /dev/null +++ b/Assets/1. 3DTexture.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 20a4aac65717a45228e212ba22f927c9 +folderAsset: yes +timeCreated: 1514952943 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/1. 3DTexture/Materials.meta b/Assets/1. 3DTexture/Materials.meta new file mode 100644 index 0000000..4ccf41a --- /dev/null +++ b/Assets/1. 3DTexture/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1d47d6e8090af416c9161bd210ae54c7 +folderAsset: yes +timeCreated: 1514989483 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/1. 3DTexture/Materials/3DTexture.mat b/Assets/1. 3DTexture/Materials/3DTexture.mat new file mode 100644 index 0000000..e93e2ad --- /dev/null +++ b/Assets/1. 3DTexture/Materials/3DTexture.mat @@ -0,0 +1,28 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: 3DTexture + m_Shader: {fileID: 4800000, guid: d055c95284dcf477e829fa7f610b5f99, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _Volume: + m_Texture: {fileID: 4849145913767034428, guid: fde1733cb0568314489ecd9a39dde6af, + type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: [] + m_Colors: [] diff --git a/Assets/1. 3DTexture/Materials/3DTexture.mat.meta b/Assets/1. 3DTexture/Materials/3DTexture.mat.meta new file mode 100644 index 0000000..4185a8b --- /dev/null +++ b/Assets/1. 3DTexture/Materials/3DTexture.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 2768e68e5c55d4751b8d5efe725e31ef +timeCreated: 1514949082 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/1. 3DTexture/Scenes.meta b/Assets/1. 3DTexture/Scenes.meta new file mode 100644 index 0000000..0a972cc --- /dev/null +++ b/Assets/1. 3DTexture/Scenes.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 913a01ceef39e4dd9a7dd45609c01157 +folderAsset: yes +timeCreated: 1514989498 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/1. 3DTexture/Scenes/3DTexture.unity b/Assets/1. 3DTexture/Scenes/3DTexture.unity new file mode 100644 index 0000000..6b38e8c --- /dev/null +++ b/Assets/1. 3DTexture/Scenes/3DTexture.unity @@ -0,0 +1,358 @@ +%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: 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, g: 0, b: 0, 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: 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 &773650577 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 773650579} + - component: {fileID: 773650578} + 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 &773650578 +Light: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 773650577} + m_Enabled: 1 + serializedVersion: 8 + m_Type: 1 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, 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 &773650579 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 773650577} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &872593035 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 872593040} + - component: {fileID: 872593039} + - component: {fileID: 872593038} + - component: {fileID: 872593037} + - component: {fileID: 872593036} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &872593036 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 872593035} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 72cd546864ba7442e9d15855ce643d7a, type: 3} + m_Name: + m_EditorClassIdentifier: + size: 12 +--- !u!23 &872593037 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 872593035} + 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: 2768e68e5c55d4751b8d5efe725e31ef, 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 &872593038 +BoxCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 872593035} + 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 &872593039 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 872593035} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &872593040 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 872593035} + 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!1 &1835919490 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1835919494} + - component: {fileID: 1835919493} + - component: {fileID: 1835919492} + - component: {fileID: 1835919491} + 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 &1835919491 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1835919490} + m_Enabled: 1 +--- !u!124 &1835919492 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1835919490} + m_Enabled: 1 +--- !u!20 &1835919493 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1835919490} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + 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: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1835919494 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1835919490} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + 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} diff --git a/Assets/1. 3DTexture/Scenes/3DTexture.unity.meta b/Assets/1. 3DTexture/Scenes/3DTexture.unity.meta new file mode 100644 index 0000000..a664641 --- /dev/null +++ b/Assets/1. 3DTexture/Scenes/3DTexture.unity.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 60983f548484a498a9bd2d226b327240 +timeCreated: 1514952937 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/1. 3DTexture/Scripts.meta b/Assets/1. 3DTexture/Scripts.meta new file mode 100644 index 0000000..daa3785 --- /dev/null +++ b/Assets/1. 3DTexture/Scripts.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 8d90e0b40087144e887ee247fb1f18e7 +folderAsset: yes +timeCreated: 1514989491 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/1. 3DTexture/Scripts/Create3DTex.cs b/Assets/1. 3DTexture/Scripts/Create3DTex.cs new file mode 100644 index 0000000..bf0fa5b --- /dev/null +++ b/Assets/1. 3DTexture/Scripts/Create3DTex.cs @@ -0,0 +1,37 @@ +using UnityEngine; + +public class Create3DTex : MonoBehaviour +{ + [SerializeField] + int size = 16; + + void Start() + { + var tex = new Texture3D(size, size, size, TextureFormat.ARGB32, true); + var colors = new Color[size * size * size]; + + float a = 1f / (size - 1); + int i = 0; + Color c = Color.white; + + for (int z = 0; z < size; ++z) + { + for (int y = 0; y < size; ++y) + { + for (int x = 0; x < size; ++x, ++i) + { + c.r = ((x & 1) != 0) ? x * a : 1 - x * a; + c.g = ((y & 1) != 0) ? y * a : 1 - y * a; + c.b = ((z & 1) != 0) ? z * a : 1 - z * a; + colors[i] = c; + } + } + } + + tex.SetPixels(colors); + tex.Apply(); + + var renderer = GetComponent(); + renderer.material.SetTexture("_Volume", tex); + } +} \ No newline at end of file diff --git a/Assets/1. 3DTexture/Scripts/Create3DTex.cs.meta b/Assets/1. 3DTexture/Scripts/Create3DTex.cs.meta new file mode 100644 index 0000000..2ac4e31 --- /dev/null +++ b/Assets/1. 3DTexture/Scripts/Create3DTex.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 72cd546864ba7442e9d15855ce643d7a +timeCreated: 1514950787 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/1. 3DTexture/Shaders.meta b/Assets/1. 3DTexture/Shaders.meta new file mode 100644 index 0000000..11248e2 --- /dev/null +++ b/Assets/1. 3DTexture/Shaders.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 575cd949fa98442c3b6e4e72be2f89ea +folderAsset: yes +timeCreated: 1514989478 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/1. 3DTexture/Shaders/3DTexture.shader b/Assets/1. 3DTexture/Shaders/3DTexture.shader new file mode 100644 index 0000000..e5b0b2f --- /dev/null +++ b/Assets/1. 3DTexture/Shaders/3DTexture.shader @@ -0,0 +1,60 @@ +Shader "VolumeRendering/WorldSpaceClipping" +{ + +Properties +{ + _Volume("Volume", 3D) = "" {} +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float3 uv : TEXCOORD0; +}; + +sampler3D _Volume; + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + float4 wpos = mul(unity_ObjectToWorld, v.vertex); + o.uv = wpos.xyz * 0.5 + 0.5; + return o; +} + +fixed4 frag(v2f i) : SV_Target +{ + return tex3D(_Volume, i.uv); +} + +ENDCG + +SubShader +{ + +Tags +{ + "RenderType"="Opaque" +} + +Pass +{ + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/1. 3DTexture/Shaders/3DTexture.shader.meta b/Assets/1. 3DTexture/Shaders/3DTexture.shader.meta new file mode 100644 index 0000000..b25b4c9 --- /dev/null +++ b/Assets/1. 3DTexture/Shaders/3DTexture.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d055c95284dcf477e829fa7f610b5f99 +timeCreated: 1514948053 +licenseType: Free +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/2. ImportPvm.meta b/Assets/2. ImportPvm.meta new file mode 100644 index 0000000..0fbb2ab --- /dev/null +++ b/Assets/2. ImportPvm.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: e53ca87a2ff1f41b193cffe94fd0989b +folderAsset: yes +timeCreated: 1514981625 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/2. ImportPvm/3dsyokudo.raw.meta b/Assets/2. ImportPvm/3dsyokudo.raw.meta new file mode 100644 index 0000000..ff44646 --- /dev/null +++ b/Assets/2. ImportPvm/3dsyokudo.raw.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: 69296e7051b1ebd42a278de0d58858fc +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 4076eb95b581041b5bb78255c2b05ea4, type: 3} + width: 512 + height: 512 + depth: 121 + bit: 2 + smooth: 2 diff --git a/Assets/2. ImportPvm/Carp.raw.meta b/Assets/2. ImportPvm/Carp.raw.meta new file mode 100644 index 0000000..dab3d8b --- /dev/null +++ b/Assets/2. ImportPvm/Carp.raw.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: 5aac9531e434cc04996aeb8eb81e94f6 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 4076eb95b581041b5bb78255c2b05ea4, type: 3} + width: 256 + height: 256 + depth: 512 + bit: 2 + smooth: 3 diff --git a/Assets/2. ImportPvm/Editor.meta b/Assets/2. ImportPvm/Editor.meta new file mode 100644 index 0000000..662f5fc --- /dev/null +++ b/Assets/2. ImportPvm/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d54f03bab263a461f9a4701e30e4a7f7 +folderAsset: yes +timeCreated: 1514981615 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/2. ImportPvm/Editor/PvmRawImporter.cs b/Assets/2. ImportPvm/Editor/PvmRawImporter.cs new file mode 100644 index 0000000..c461276 --- /dev/null +++ b/Assets/2. ImportPvm/Editor/PvmRawImporter.cs @@ -0,0 +1,91 @@ +using UnityEngine; +using UnityEditor; +using UnityEditor.Experimental.AssetImporters; +using System; +using System.IO; + +// Now using PvmRawImporter2 in "6. Gradient" section. +// [ScriptedImporter(1, "raw")] +public class PvmRawImporter : ScriptedImporter +{ + public enum Bits + { + Eight = 1, + Sixteen = 2, + } + + public int width = 256; + public int height = 256; + public int depth = 256; + public Bits bit = Bits.Eight; + + int totalSize + { + get { return width * height * depth * (int)bit; } + } + + int maxValueSize + { + get + { + switch (bit) + { + case Bits.Eight: return (int)Byte.MaxValue; + case Bits.Sixteen: return (int)UInt16.MaxValue; + default: + throw new Exception("bit is wrong."); + } + } + } + + Texture3D GetTexture3D(string path) + { + using (var stream = new FileStream(path, FileMode.Open)) + { + if (stream.Length != totalSize) + { + throw new Exception("Data size is wrong."); + } + + int n = totalSize; + var colors = new Color[n]; + float a = 1f / maxValueSize; + var buf = new byte[(int)bit]; + + for (int i = 0; i < n; ++i) + { + float value = 0f; + switch (bit) + { + case Bits.Eight: + var b = stream.ReadByte(); + value = a * b; + break; + case Bits.Sixteen: + stream.Read(buf, 0, 2); + value = a * BitConverter.ToUInt16(buf, 0); + break; + } + colors[i] = new Color(value, value, value, value); + } + + var tex3d = new Texture3D(width, height, depth, TextureFormat.RGBA32, false); + tex3d.SetPixels(colors, 0); + + return tex3d; + } + } + + public override void OnImportAsset(AssetImportContext ctx) + { + try + { + var tex3d = GetTexture3D(ctx.assetPath); + ctx.AddObjectToAsset("Volume", tex3d); + } + catch (Exception e) + { + Debug.LogException(e); + } + } +} diff --git a/Assets/2. ImportPvm/Editor/PvmRawImporter.cs.meta b/Assets/2. ImportPvm/Editor/PvmRawImporter.cs.meta new file mode 100644 index 0000000..2da25ff --- /dev/null +++ b/Assets/2. ImportPvm/Editor/PvmRawImporter.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 7fd08ae18e815473f866850973503b92 +timeCreated: 1514969617 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/2. ImportPvm/Materials.meta b/Assets/2. ImportPvm/Materials.meta new file mode 100644 index 0000000..ad5833e --- /dev/null +++ b/Assets/2. ImportPvm/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: cda46d880656e4766926c631d80029a5 +folderAsset: yes +timeCreated: 1514982295 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/2. ImportPvm/Materials/Carp.mat b/Assets/2. ImportPvm/Materials/Carp.mat new file mode 100644 index 0000000..56f7d66 --- /dev/null +++ b/Assets/2. ImportPvm/Materials/Carp.mat @@ -0,0 +1,82 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Carp + m_Shader: {fileID: 4800000, guid: d055c95284dcf477e829fa7f610b5f99, 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} + - _Volume: + m_Texture: {fileID: 4849145913767034428, guid: fde1733cb0568314489ecd9a39dde6af, + type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/2. ImportPvm/Materials/Carp.mat.meta b/Assets/2. ImportPvm/Materials/Carp.mat.meta new file mode 100644 index 0000000..f1161f1 --- /dev/null +++ b/Assets/2. ImportPvm/Materials/Carp.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c5ab262550a0641178e7e3019cd4f815 +timeCreated: 1514982308 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/2. ImportPvm/Scenes.meta b/Assets/2. ImportPvm/Scenes.meta new file mode 100644 index 0000000..f67991e --- /dev/null +++ b/Assets/2. ImportPvm/Scenes.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 0ac606db7e7fb4e409ac49f23491c002 +folderAsset: yes +timeCreated: 1514982279 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/2. ImportPvm/Scenes/ImportPvm.unity b/Assets/2. ImportPvm/Scenes/ImportPvm.unity new file mode 100644 index 0000000..32a14c1 --- /dev/null +++ b/Assets/2. ImportPvm/Scenes/ImportPvm.unity @@ -0,0 +1,400 @@ +%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: 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, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !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_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 &73477751 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 73477753} + - component: {fileID: 73477752} + 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 &73477752 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 73477751} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + 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 &73477753 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 73477751} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1873212973 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1873212977} + - component: {fileID: 1873212976} + - component: {fileID: 1873212975} + - component: {fileID: 1873212974} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &1873212974 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + 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: 2100000, guid: c5ab262550a0641178e7e3019cd4f815, type: 2} + 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: 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 &1873212975 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + 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 &1873212976 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1873212977 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1.7311451, y: 1.1492356, z: 1.7377192} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2108303124 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2108303128} + - component: {fileID: 2108303127} + - component: {fileID: 2108303126} + - component: {fileID: 2108303125} + 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 &2108303125 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 +--- !u!124 &2108303126 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 +--- !u!20 &2108303127 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, 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: 0.3 + far clip plane: 1000 + 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: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &2108303128 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + 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} diff --git a/Assets/2. ImportPvm/Scenes/ImportPvm.unity.meta b/Assets/2. ImportPvm/Scenes/ImportPvm.unity.meta new file mode 100644 index 0000000..d347ad8 --- /dev/null +++ b/Assets/2. ImportPvm/Scenes/ImportPvm.unity.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 325abfbc3c6514e4a9ed854f4572f001 +timeCreated: 1514982279 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/3. VolumeRendering.meta b/Assets/3. VolumeRendering.meta new file mode 100644 index 0000000..a40d954 --- /dev/null +++ b/Assets/3. VolumeRendering.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d5500c949fc184c3fbe7706306cc98f4 +folderAsset: yes +timeCreated: 1514989473 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/3. VolumeRendering/Materials.meta b/Assets/3. VolumeRendering/Materials.meta new file mode 100644 index 0000000..379d1f8 --- /dev/null +++ b/Assets/3. VolumeRendering/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d8f6a3ce5a5d240a683719b4e78d4ab4 +folderAsset: yes +timeCreated: 1515036073 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/3. VolumeRendering/Materials/VolumeRendering.mat b/Assets/3. VolumeRendering/Materials/VolumeRendering.mat new file mode 100644 index 0000000..a2d32ef --- /dev/null +++ b/Assets/3. VolumeRendering/Materials/VolumeRendering.mat @@ -0,0 +1,39 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: VolumeRendering + m_Shader: {fileID: 4800000, guid: 0ce3258b7fc1e4636999831a22bbd19f, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _Volume: + m_Texture: {fileID: 4849145913767034428, guid: fde1733cb0568314489ecd9a39dde6af, + type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _Intensity: 0.003 + - _Iteration: 1000 + - _MaxX: 1 + - _MaxY: 1 + - _MaxZ: 1 + - _MinX: 0 + - _MinY: 0 + - _MinZ: 0 + m_Colors: + - _Aspect: {r: 1, g: 1, b: 1, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _RangeX: {r: 0, g: 1, b: 0, a: 0} diff --git a/Assets/3. VolumeRendering/Materials/VolumeRendering.mat.meta b/Assets/3. VolumeRendering/Materials/VolumeRendering.mat.meta new file mode 100644 index 0000000..b8ab813 --- /dev/null +++ b/Assets/3. VolumeRendering/Materials/VolumeRendering.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: fa71a4a648fb44293a54d2c616f5d753 +timeCreated: 1515036067 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/3. VolumeRendering/Scenes.meta b/Assets/3. VolumeRendering/Scenes.meta new file mode 100644 index 0000000..3acd67f --- /dev/null +++ b/Assets/3. VolumeRendering/Scenes.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 335de3971ba3444b9999bbe36f925f29 +folderAsset: yes +timeCreated: 1514989517 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/3. VolumeRendering/Scenes/VolumeRendering.unity b/Assets/3. VolumeRendering/Scenes/VolumeRendering.unity new file mode 100644 index 0000000..ed0e72f --- /dev/null +++ b/Assets/3. VolumeRendering/Scenes/VolumeRendering.unity @@ -0,0 +1,418 @@ +%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: 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, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !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_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 &73477751 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 73477753} + - component: {fileID: 73477752} + 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 &73477752 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 73477751} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + 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 &73477753 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 73477751} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1873212973 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1873212977} + - component: {fileID: 1873212976} + - component: {fileID: 1873212975} + - component: {fileID: 1873212974} + m_Layer: 0 + m_Name: Carp + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &1873212974 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + 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: 2100000, guid: fa71a4a648fb44293a54d2c616f5d753, type: 2} + 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: 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 &1873212975 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + 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 &1873212976 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1873212977 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_LocalRotation: {x: 0, y: 0, z: 1, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 3.0171578, y: 1.996471, z: 6.8278666} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180} +--- !u!1 &2108303124 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2108303128} + - component: {fileID: 2108303127} + - component: {fileID: 2108303126} + - component: {fileID: 2108303125} + - component: {fileID: 2108303129} + 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 &2108303125 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 +--- !u!124 &2108303126 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 +--- !u!20 &2108303127 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, 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: 0.01 + far clip plane: 1000 + 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: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &2108303128 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_LocalRotation: {x: 0.43343452, y: -0.5586913, z: 0.43201023, w: 0.5597908} + m_LocalPosition: {x: 0.98, y: 3.98, z: -2.4} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 75.463005, y: -90.00101, z: -0.14600001} +--- !u!114 &2108303129 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dd40a3cd58d1f6344856e87338a631ca, type: 3} + m_Name: + m_EditorClassIdentifier: + x_sensi: 1 + y_sensi: 1 + trans_scale: 0.01 + target_camera: {fileID: 2108303124} + point_light: {fileID: 73477751} diff --git a/Assets/3. VolumeRendering/Scenes/VolumeRendering.unity.meta b/Assets/3. VolumeRendering/Scenes/VolumeRendering.unity.meta new file mode 100644 index 0000000..b025d30 --- /dev/null +++ b/Assets/3. VolumeRendering/Scenes/VolumeRendering.unity.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 2a74acd7105b04c3483a6c721ac61177 +timeCreated: 1514982279 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/3. VolumeRendering/Shaders.meta b/Assets/3. VolumeRendering/Shaders.meta new file mode 100644 index 0000000..03e23e7 --- /dev/null +++ b/Assets/3. VolumeRendering/Shaders.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 96ab233031d1c48d2a04db56b312855d +folderAsset: yes +timeCreated: 1514989528 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/3. VolumeRendering/Shaders/VolumeRendering.shader b/Assets/3. VolumeRendering/Shaders/VolumeRendering.shader new file mode 100644 index 0000000..01caede --- /dev/null +++ b/Assets/3. VolumeRendering/Shaders/VolumeRendering.shader @@ -0,0 +1,107 @@ +Shader "VolumeRendering/VolumeRendering" +{ + +Properties +{ + [Header(Rendering)] + _Volume("Volume", 3D) = "" {} + _Color("Color", Color) = (1, 1, 1, 1) + _Iteration("Iteration", Int) = 100 + _Intensity("Intensity", Range(0.0, 1.0)) = 0.1 + + [Header(Ranges)] + _MinX("MinX", Range(0, 1)) = 0.0 + _MaxX("MaxX", Range(0, 1)) = 1.0 + _MinY("MinY", Range(0, 1)) = 0.0 + _MaxY("MaxY", Range(0, 1)) = 1.0 + _MinZ("MinZ", Range(0, 1)) = 0.0 + _MaxZ("MaxZ", Range(0, 1)) = 1.0 +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float4 localPos : TEXCOORD0; + float4 worldPos : TEXCOORD1; +}; + +sampler3D _Volume; +fixed4 _Color; +int _Iteration; +fixed _Intensity; +fixed _MinX, _MaxX, _MinY, _MaxY, _MinZ, _MaxZ; + +fixed sample(float3 pos) +{ + fixed x = step(pos.x, _MaxX) * step(_MinX, pos.x); + fixed y = step(pos.y, _MaxY) * step(_MinY, pos.y); + fixed z = step(pos.z, _MaxZ) * step(_MinZ, pos.z); + return tex3D(_Volume, pos).a * x * y * z; +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.localPos = v.vertex; + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + return o; +} + +fixed4 frag(v2f i) : SV_Target +{ + float3 wdir = i.worldPos - _WorldSpaceCameraPos; + float3 ldir = normalize(mul(unity_WorldToObject, wdir)); + float3 lstep = ldir / _Iteration; + float3 lpos = i.localPos; + fixed output = 0.0; + + [loop] + for (int i = 0; i < _Iteration; ++i) + { + fixed a = sample(lpos + 0.5); + output += (1 - output) * a * _Intensity; + lpos += lstep; + if (!all(max(0.5 - abs(lpos), 0.0)) || output > 0.99) break; + } + + return _Color * output; +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Transparent" + "RenderType" = "Transparent" +} + +Pass +{ + Cull Back + ZWrite Off + ZTest LEqual + Blend SrcAlpha OneMinusSrcAlpha + Lighting Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/3. VolumeRendering/Shaders/VolumeRendering.shader.meta b/Assets/3. VolumeRendering/Shaders/VolumeRendering.shader.meta new file mode 100644 index 0000000..0c99726 --- /dev/null +++ b/Assets/3. VolumeRendering/Shaders/VolumeRendering.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 0ce3258b7fc1e4636999831a22bbd19f +timeCreated: 1514948053 +licenseType: Free +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/3D.raw.meta b/Assets/3D.raw.meta new file mode 100644 index 0000000..a43de1d --- /dev/null +++ b/Assets/3D.raw.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: b4adef9266565bb40b579ae31ef9072e +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 4076eb95b581041b5bb78255c2b05ea4, type: 3} + width: 512 + height: 512 + depth: 121 + bit: 2 + smooth: 2 diff --git a/Assets/4. AABB Intersection.meta b/Assets/4. AABB Intersection.meta new file mode 100644 index 0000000..0bb30e0 --- /dev/null +++ b/Assets/4. AABB Intersection.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 6e1e7757cb81d44749523970d8913432 +folderAsset: yes +timeCreated: 1515158799 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/4. AABB Intersection/Materials.meta b/Assets/4. AABB Intersection/Materials.meta new file mode 100644 index 0000000..f917b7a --- /dev/null +++ b/Assets/4. AABB Intersection/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b652ae86772a34e86b98e14ac65a934f +folderAsset: yes +timeCreated: 1515158844 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/4. AABB Intersection/Materials/VolumeRendering2.mat b/Assets/4. AABB Intersection/Materials/VolumeRendering2.mat new file mode 100644 index 0000000..a725a01 --- /dev/null +++ b/Assets/4. AABB Intersection/Materials/VolumeRendering2.mat @@ -0,0 +1,38 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: VolumeRendering2 + m_Shader: {fileID: 4800000, guid: 6647736c6e7b2450c938f7993be59528, type: 3} + m_ShaderKeywords: _RAY_FIXED_LENGTH + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _Volume: + m_Texture: {fileID: 4849145913767034428, guid: 5aac9531e434cc04996aeb8eb81e94f6, + type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _Intensity: 0.053 + - _Iteration: 100 + - _MaxX: 1 + - _MaxY: 1 + - _MaxZ: 1 + - _MinX: 0 + - _MinY: 0 + - _MinZ: 0 + - _RAY: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/4. AABB Intersection/Materials/VolumeRendering2.mat.meta b/Assets/4. AABB Intersection/Materials/VolumeRendering2.mat.meta new file mode 100644 index 0000000..f69f53a --- /dev/null +++ b/Assets/4. AABB Intersection/Materials/VolumeRendering2.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 53321a60ad46c4cd989f0f9e05ab6a6d +timeCreated: 1515158838 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/4. AABB Intersection/Scenes.meta b/Assets/4. AABB Intersection/Scenes.meta new file mode 100644 index 0000000..1414a06 --- /dev/null +++ b/Assets/4. AABB Intersection/Scenes.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 2a84abaf70d6e4be2800bb930a03f7ea +folderAsset: yes +timeCreated: 1514989517 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/4. AABB Intersection/Scenes/Optimize Ray.unity b/Assets/4. AABB Intersection/Scenes/Optimize Ray.unity new file mode 100644 index 0000000..a2c9d0c --- /dev/null +++ b/Assets/4. AABB Intersection/Scenes/Optimize Ray.unity @@ -0,0 +1,400 @@ +%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: 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, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !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_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 &73477751 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 73477753} + - component: {fileID: 73477752} + 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 &73477752 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 73477751} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + 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 &73477753 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 73477751} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1873212973 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1873212977} + - component: {fileID: 1873212976} + - component: {fileID: 1873212975} + - component: {fileID: 1873212974} + m_Layer: 0 + m_Name: Carp + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &1873212974 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + 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: 2100000, guid: 53321a60ad46c4cd989f0f9e05ab6a6d, type: 2} + 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: 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 &1873212975 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + 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 &1873212976 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1873212977 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_LocalRotation: {x: 0, y: 0, z: 1, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 3.0171578, y: 1.996471, z: 6.8278666} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180} +--- !u!1 &2108303124 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2108303128} + - component: {fileID: 2108303127} + - component: {fileID: 2108303126} + - component: {fileID: 2108303125} + 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 &2108303125 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 +--- !u!124 &2108303126 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 +--- !u!20 &2108303127 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, 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: 0.3 + far clip plane: 1000 + 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: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &2108303128 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_LocalRotation: {x: 0.43343452, y: -0.5586913, z: 0.43201023, w: 0.5597908} + m_LocalPosition: {x: 0.41, y: 1.15, z: -0.25} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 75.463005, y: -90.00101, z: -0.14600001} diff --git a/Assets/4. AABB Intersection/Scenes/Optimize Ray.unity.meta b/Assets/4. AABB Intersection/Scenes/Optimize Ray.unity.meta new file mode 100644 index 0000000..814aaf3 --- /dev/null +++ b/Assets/4. AABB Intersection/Scenes/Optimize Ray.unity.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: cc9a478041de64166b80535796ce3970 +timeCreated: 1514982279 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/4. AABB Intersection/Shaders.meta b/Assets/4. AABB Intersection/Shaders.meta new file mode 100644 index 0000000..6f59261 --- /dev/null +++ b/Assets/4. AABB Intersection/Shaders.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 14916bc8ece5a486680a45edfa787d88 +folderAsset: yes +timeCreated: 1514989528 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/4. AABB Intersection/Shaders/VolumeRendering2.shader b/Assets/4. AABB Intersection/Shaders/VolumeRendering2.shader new file mode 100644 index 0000000..605d0ef --- /dev/null +++ b/Assets/4. AABB Intersection/Shaders/VolumeRendering2.shader @@ -0,0 +1,144 @@ +Shader "VolumeRendering/VolumeRendering2" +{ + +Properties +{ + [Header(Rendering)] + _Volume("Volume", 3D) = "" {} + _Color("Color", Color) = (1, 1, 1, 1) + _Iteration("Iteration", Int) = 10 + _Intensity("Intensity", Range(0.0, 1.0)) = 0.1 + + [Header(Ranges)] + _MinX("MinX", Range(0, 1)) = 0.0 + _MaxX("MaxX", Range(0, 1)) = 1.0 + _MinY("MinY", Range(0, 1)) = 0.0 + _MaxY("MaxY", Range(0, 1)) = 1.0 + _MinZ("MinZ", Range(0, 1)) = 0.0 + _MaxZ("MaxZ", Range(0, 1)) = 1.0 + + [Header(Variable)] + [KeywordEnum(VARIABLE_LENGTH, FIXED_LENGTH)] + _RAY("Ray Method", Float) = 0 +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float4 localPos : TEXCOORD0; + float4 worldPos : TEXCOORD1; +}; + +sampler3D _Volume; +fixed4 _Color; +int _Iteration; +fixed _Intensity; +fixed _MinX, _MaxX, _MinY, _MaxY, _MinZ, _MaxZ; + +struct Ray +{ + float3 from; + float3 dir; + float tmax; +}; + +void intersection(inout Ray ray) +{ + float3 invDir = 1.0 / ray.dir; + float3 t1 = (-0.5 - ray.from) * invDir; + float3 t2 = (+0.5 - ray.from) * invDir; + + float3 tmax3 = max(t1, t2); + float2 tmax2 = min(tmax3.xx, tmax3.yz); + ray.tmax = min(tmax2.x, tmax2.y); +} + +fixed sample(float3 pos) +{ + fixed x = step(pos.x, _MaxX) * step(_MinX, pos.x); + fixed y = step(pos.y, _MaxY) * step(_MinY, pos.y); + fixed z = step(pos.z, _MaxZ) * step(_MinZ, pos.z); + return tex3D(_Volume, pos).a * (x * y * z); +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.localPos = v.vertex; + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + return o; +} + +fixed4 frag(v2f i) : SV_Target +{ + float3 worldDir = i.worldPos - _WorldSpaceCameraPos; + float3 localDir = normalize(mul(unity_WorldToObject, worldDir)); + + Ray ray; + ray.from = i.localPos; + ray.dir = localDir; + intersection(ray); + +#ifdef _RAY_FIXED_LENGTH + float dt = 1.0 / _Iteration; + float time = 0.0; + float3 localStep = localDir * dt; +#else + float3 localStep = localDir * ray.tmax / _Iteration; +#endif + float3 localPos = i.localPos; + fixed4 output = 0.0; + + [loop] + for (int i = 0; i < _Iteration; ++i) + { + output += (1.0 - output.a) * sample(localPos + 0.5) * _Intensity; + localPos += localStep; +#ifdef _RAY_FIXED_LENGTH + time += dt; + if (time > ray.tmax) break; +#endif + } + + return _Color * output; +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Transparent" + "RenderType" = "Transparent" +} + +Pass +{ + Cull Back + ZWrite Off + ZTest LEqual + Blend SrcAlpha OneMinusSrcAlpha + Lighting Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma multi_compile _RAY_VARIABLE_LENGTH _RAY_FIXED_LENGTH + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/4. AABB Intersection/Shaders/VolumeRendering2.shader.meta b/Assets/4. AABB Intersection/Shaders/VolumeRendering2.shader.meta new file mode 100644 index 0000000..f675b50 --- /dev/null +++ b/Assets/4. AABB Intersection/Shaders/VolumeRendering2.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 6647736c6e7b2450c938f7993be59528 +timeCreated: 1514948053 +licenseType: Free +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/5. Transfer Function.meta b/Assets/5. Transfer Function.meta new file mode 100644 index 0000000..63133f8 --- /dev/null +++ b/Assets/5. Transfer Function.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 81484b67a28454eafb5712de7f104a40 +folderAsset: yes +timeCreated: 1515426001 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/5. Transfer Function/Materials.meta b/Assets/5. Transfer Function/Materials.meta new file mode 100644 index 0000000..b36e630 --- /dev/null +++ b/Assets/5. Transfer Function/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 0c4121725cadf44a6b7f4134930a0982 +folderAsset: yes +timeCreated: 1515158844 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/5. Transfer Function/Materials/VolumeRendering3.mat b/Assets/5. Transfer Function/Materials/VolumeRendering3.mat new file mode 100644 index 0000000..35c50f9 --- /dev/null +++ b/Assets/5. Transfer Function/Materials/VolumeRendering3.mat @@ -0,0 +1,44 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: VolumeRendering3 + m_Shader: {fileID: 4800000, guid: 88397cc43f45b0b4d82ae165e46d9f9a, type: 3} + m_ShaderKeywords: _RAY_FIXED_LENGTH + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _Transfer: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Volume: + m_Texture: {fileID: 4849145913767034428, guid: fde1733cb0568314489ecd9a39dde6af, + type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BlendDst: 10 + - _BlendSrc: 5 + - _Intensity: 1 + - _Iteration: 1000 + - _MaxX: 1 + - _MaxY: 0.801 + - _MaxZ: 1 + - _MinX: 0 + - _MinY: 0 + - _MinZ: 0 + - _RAY: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/5. Transfer Function/Materials/VolumeRendering3.mat.meta b/Assets/5. Transfer Function/Materials/VolumeRendering3.mat.meta new file mode 100644 index 0000000..e8a96cb --- /dev/null +++ b/Assets/5. Transfer Function/Materials/VolumeRendering3.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: fac9380be039d42d6b22514ac17d4857 +timeCreated: 1515158838 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/5. Transfer Function/Scenes.meta b/Assets/5. Transfer Function/Scenes.meta new file mode 100644 index 0000000..24e54ed --- /dev/null +++ b/Assets/5. Transfer Function/Scenes.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b145e3d7bcb214b87a60a4e9ae6d0004 +folderAsset: yes +timeCreated: 1514989517 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/5. Transfer Function/Scenes/Transfer Function.unity b/Assets/5. Transfer Function/Scenes/Transfer Function.unity new file mode 100644 index 0000000..c7d684b --- /dev/null +++ b/Assets/5. Transfer Function/Scenes/Transfer Function.unity @@ -0,0 +1,490 @@ +%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: 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, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !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_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 &73477751 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 73477753} + - component: {fileID: 73477752} + 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 &73477752 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 73477751} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.802082 + 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 &73477753 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 73477751} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1000675180 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1000675181} + m_Layer: 0 + m_Name: SystemManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1000675181 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1000675180} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.88222265, y: 0.61854315, z: -0.4620441} + 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!1 &1873212973 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1873212977} + - component: {fileID: 1873212976} + - component: {fileID: 1873212975} + - component: {fileID: 1873212974} + - component: {fileID: 1873212978} + m_Layer: 0 + m_Name: Patient + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &1873212974 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + 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: 2100000, guid: fac9380be039d42d6b22514ac17d4857, type: 2} + 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: 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 &1873212975 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + 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 &1873212976 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1873212977 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_LocalRotation: {x: 0, y: 0, z: 1, w: 0} + m_LocalPosition: {x: -0.51, y: 0, z: 0.53} + m_LocalScale: {x: 3.4, y: 3.4, z: 6.05} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180} +--- !u!114 &1873212978 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1f42bf1e372bc4f52bf8066e82aeceb0, type: 3} + m_Name: + m_EditorClassIdentifier: + gradient: + serializedVersion: 2 + key0: {r: 0, g: 0, b: 0, a: 1} + key1: {r: 1, g: 1, b: 1, a: 1} + key2: {r: 0.5566038, g: 0.1891897, b: 0.04463333, a: 0.19471103} + key3: {r: 0.86274517, g: 0.73333335, b: 1, a: 0.6901961} + key4: {r: 0.86274517, g: 0.73333335, b: 1, a: 0} + key5: {r: 0.86274517, g: 0.73333335, b: 1, a: 1} + key6: {r: 0, g: 0, b: 0, a: 1} + key7: {r: 0, g: 0, b: 0, a: 1} + ctime0: 0 + ctime1: 65535 + ctime2: 44341 + ctime3: 50650 + ctime4: 65535 + ctime5: 65535 + ctime6: 0 + ctime7: 0 + atime0: 70 + atime1: 65535 + atime2: 65535 + atime3: 43260 + atime4: 52916 + atime5: 65535 + atime6: 65535 + atime7: 65535 + m_Mode: 0 + m_NumColorKeys: 2 + m_NumAlphaKeys: 2 + updateTextureInEveryFrame: 1 +--- !u!1 &2108303124 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2108303128} + - component: {fileID: 2108303127} + - component: {fileID: 2108303126} + - component: {fileID: 2108303125} + - component: {fileID: 2108303129} + 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 &2108303125 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 +--- !u!124 &2108303126 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 +--- !u!20 &2108303127 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, 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: 0.01 + far clip plane: 1000 + 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: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &2108303128 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_LocalRotation: {x: 0.43343452, y: -0.5586913, z: 0.43201023, w: 0.5597908} + m_LocalPosition: {x: 0.99, y: 3.4, z: -0.25} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 75.463005, y: -90.00101, z: -0.14600001} +--- !u!114 &2108303129 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dd40a3cd58d1f6344856e87338a631ca, type: 3} + m_Name: + m_EditorClassIdentifier: + x_sensi: 3 + y_sensi: 3 + trans_scale: 0.0125 + target_camera: {fileID: 2108303124} diff --git a/Assets/5. Transfer Function/Scenes/Transfer Function.unity.meta b/Assets/5. Transfer Function/Scenes/Transfer Function.unity.meta new file mode 100644 index 0000000..77539a5 --- /dev/null +++ b/Assets/5. Transfer Function/Scenes/Transfer Function.unity.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 42770b05b3ef340aea338b039ab26f16 +timeCreated: 1514982279 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/5. Transfer Function/Scripts.meta b/Assets/5. Transfer Function/Scripts.meta new file mode 100644 index 0000000..fdc2824 --- /dev/null +++ b/Assets/5. Transfer Function/Scripts.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 3b1062cc72d494ae2b3b29878def01c0 +folderAsset: yes +timeCreated: 1515427095 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/5. Transfer Function/Scripts/VolumeRenderingWithTransferFunction.cs b/Assets/5. Transfer Function/Scripts/VolumeRenderingWithTransferFunction.cs new file mode 100644 index 0000000..03173dd --- /dev/null +++ b/Assets/5. Transfer Function/Scripts/VolumeRenderingWithTransferFunction.cs @@ -0,0 +1,46 @@ +using UnityEngine; + +[ExecuteInEditMode] +public class VolumeRenderingWithTransferFunction : MonoBehaviour +{ + const int width = 100; + + [SerializeField] + Gradient gradient; + +#if UNITY_EDITOR + [SerializeField] + bool updateTextureInEveryFrame = false; +#endif + + Texture2D texture_; + + void Start() + { + UpdateTexture(); + } + + void Update() + { +#if UNITY_EDITOR + if (updateTextureInEveryFrame) + { + UpdateTexture(); + } +#endif + } + + [ContextMenu("UpdateTexture")] + void UpdateTexture() + { + texture_ = new Texture2D(width, 1, TextureFormat.ARGB32, false); + for (int i = 0; i < width; ++i) + { + var t = (float)i / width; + texture_.SetPixel(i, 0, gradient.Evaluate(t)); + } + texture_.Apply(false); + var renderer = GetComponent(); + renderer.sharedMaterial.SetTexture("_Transfer", texture_); + } +} diff --git a/Assets/5. Transfer Function/Scripts/VolumeRenderingWithTransferFunction.cs.meta b/Assets/5. Transfer Function/Scripts/VolumeRenderingWithTransferFunction.cs.meta new file mode 100644 index 0000000..dea53c3 --- /dev/null +++ b/Assets/5. Transfer Function/Scripts/VolumeRenderingWithTransferFunction.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1f42bf1e372bc4f52bf8066e82aeceb0 +timeCreated: 1515426554 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/5. Transfer Function/Shaders.meta b/Assets/5. Transfer Function/Shaders.meta new file mode 100644 index 0000000..9c62e14 --- /dev/null +++ b/Assets/5. Transfer Function/Shaders.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c6d8fd2af7bb643fb8538102a15cfc82 +folderAsset: yes +timeCreated: 1515426272 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/5. Transfer Function/Shaders/VolumeRendering3.shader b/Assets/5. Transfer Function/Shaders/VolumeRendering3.shader new file mode 100644 index 0000000..16f0281 --- /dev/null +++ b/Assets/5. Transfer Function/Shaders/VolumeRendering3.shader @@ -0,0 +1,165 @@ +Shader "VolumeRendering/VolumeRendering3" +{ + +Properties +{ + [Header(Rendering)] + _Volume("Volume", 3D) = "" {} + _Transfer("Transfer", 2D) = "" {} + _Iteration("Iteration", Int) = 10 + _Intensity("Intensity", Range(0.0, 1.0)) = 0.1 + [Enum(UnityEngine.Rendering.BlendMode)] _BlendSrc ("Blend Src", Float) = 5 + [Enum(UnityEngine.Rendering.BlendMode)] _BlendDst ("Blend Dst", Float) = 10 + + [Header(Ranges)] + _MinX("MinX", Range(0, 1)) = 0.0 + _MaxX("MaxX", Range(0, 1)) = 1.0 + _MinY("MinY", Range(0, 1)) = 0.0 + _MaxY("MaxY", Range(0, 1)) = 1.0 + _MinZ("MinZ", Range(0, 1)) = 0.0 + _MaxZ("MaxZ", Range(0, 1)) = 1.0 + + [Header(Variable)] + [KeywordEnum(VARIABLE_LENGTH, FIXED_LENGTH)] + _RAY("Ray Method", Float) = 0 +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float4 localPos : TEXCOORD0; + float4 worldPos : TEXCOORD1; +}; + +sampler3D _Volume; +sampler2D _Transfer; +int _Iteration; +fixed _Intensity; +fixed _MinX, _MaxX, _MinY, _MaxY, _MinZ, _MaxZ; + +struct Ray +{ + float3 from; + float3 dir; + float tmax; +}; + +void intersection(inout Ray ray) +{ + float3 invDir = 1.0 / ray.dir; + float3 t1 = (-0.5 - ray.from) * invDir; + float3 t2 = (+0.5 - ray.from) * invDir; + + float3 tmax3 = max(t1, t2); + float2 tmax2 = min(tmax3.xx, tmax3.yz); + ray.tmax = min(tmax2.x, tmax2.y); +} + +inline fixed sampleVolume(float3 pos) +{ + fixed x = step(pos.x, _MaxX) * step(_MinX, pos.x); + fixed y = step(pos.y, _MaxY) * step(_MinY, pos.y); + fixed z = step(pos.z, _MaxZ) * step(_MinZ, pos.z); + //return tex3D(_Volume, pos).a * (x * y * z); + return tex3D(_Volume, pos) * (x * y * z); +} + +inline fixed4 transferFunction(float t) +{ + return tex2D(_Transfer, float2(t, 0)); +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.localPos = v.vertex; + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + return o; +} + +fixed4 frag(v2f i) : SV_Target +{ + float3 worldDir = i.worldPos - _WorldSpaceCameraPos; + float3 localDir = normalize(mul(unity_WorldToObject, worldDir)); + float3 lightDir = normalize(mul(unity_WorldToObject, _WorldSpaceLightPos0)); + + Ray ray; + ray.from = i.localPos; + ray.dir = localDir; + intersection(ray); + +#ifdef _RAY_FIXED_LENGTH + float dt = 1.0 / _Iteration; + float time = 0.0; + float3 localStep = localDir * dt; +#else + float3 localStep = localDir * ray.tmax / _Iteration; +#endif + float3 localPos = i.localPos; + float4 output = 0; + + [loop] + for (int i = 0; i < _Iteration; ++i) + { + //fixed volume = sampleVolume(localPos + 0.5); + //fixed4 color = transferFunction(volume) * volume; + //output += (1.0 - output.a) * color * _Intensity; + fixed4 volume = sampleVolume(localPos + 0.5); + fixed a = volume.a; + fixed3 normal = 2.0 * volume.rgb - 1.0; + //fixed4 color = transferFunction(a) * a * _Intensity; + fixed shadow = dot(lightDir, -normal); + fixed4 color = transferFunction(a) * a * _Intensity; + color.rgb = color.a * normal; + output += (1.0 - output.a) * color; + localPos += localStep; +#ifdef _RAY_FIXED_LENGTH + time += dt; + if (time > ray.tmax) break; +#endif + } + + return output; +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Transparent" + "RenderType" = "Transparent" +} + +Pass +{ + Cull Back + ZWrite Off + ZTest LEqual + Blend [_BlendSrc] [_BlendDst] + Lighting Off + + Tags { "LightMode" = "ForwardBase" } + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma multi_compile _RAY_VARIABLE_LENGTH _RAY_FIXED_LENGTH + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/5. Transfer Function/Shaders/VolumeRendering3.shader.meta b/Assets/5. Transfer Function/Shaders/VolumeRendering3.shader.meta new file mode 100644 index 0000000..45a5f05 --- /dev/null +++ b/Assets/5. Transfer Function/Shaders/VolumeRendering3.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c52f24502551d4cd7bd7f47a21746d17 +timeCreated: 1514948053 +licenseType: Free +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/5. Transfer Function/Shaders/VolumeRendering_teratail.shader b/Assets/5. Transfer Function/Shaders/VolumeRendering_teratail.shader new file mode 100644 index 0000000..8dec03e --- /dev/null +++ b/Assets/5. Transfer Function/Shaders/VolumeRendering_teratail.shader @@ -0,0 +1,223 @@ +Shader "VolumeRendering/VolumeRendering_teratail" +{ + Properties + { + [Header(Rendering)] + _Volume("Volume", 3D) = "" {} + _Color("Color", Color) = (1, 1, 1, 1) + _Iteration("Iteration", Int) = 100 + _Intensity("Intensity", Range(0.0, 1.0)) = 0.1 + + [Header(Ranges)] + _MinX("MinX", Range(0, 1)) = 0.0 + _MaxX("MaxX", Range(0, 1)) = 1.0 + _MinY("MinY", Range(0, 1)) = 0.0 + _MaxY("MaxY", Range(0, 1)) = 1.0 + _MinZ("MinZ", Range(0, 1)) = 0.0 + _MaxZ("MaxZ", Range(0, 1)) = 1.0 + } + + CGINCLUDE +#include "UnityCG.cginc" + + struct appdata + { + float4 vertex : POSITION; + }; + + struct v2f + { + float4 vertex : SV_POSITION; + float3 localPos : TEXCOORD0; + float3 worldPos : TEXCOORD1; + float3 localViewDir : TEXCOORD2; + float3 worldViewDir : TEXCOORD3; + float4 screenPos : TEXCOORD4; + }; + + sampler3D _Volume; + fixed4 _Color; + int _Iteration; + fixed _Intensity; + fixed _MinX, _MaxX, _MinY, _MaxY, _MinZ, _MaxZ; + +#define INTEGRATION_THRESHOLD 0.01 +#define DIRECTIONAL_EPSILON 0.0009765625 +#define ALPHA_THRESHOLD 0.01 + + sampler2D _CameraDepthTexture; + + // キューブに関するtransform.InverseTransformPoint + float3 worldToObjectPos(float3 worldPos) { return mul(unity_WorldToObject, float4(worldPos, 1.0)).xyz; } + + // キューブに関するtransform.InverseTransformVector + float3 worldToObjectVec(float3 worldVec) { return mul((float3x3)unity_WorldToObject, worldVec); } + + // キューブに関するtransform.TransformVector + float3 objectToWorldVec(float3 localVec) { return mul((float3x3)unity_ObjectToWorld, localVec); } + + // カメラのtransform.position + float3 getWorldCameraPos() { return UNITY_MATRIX_I_V._14_24_34; } + + // カメラのtransform.forward + float3 getWorldCameraDir() { return -UNITY_MATRIX_V._31_32_33; } + + // カメラのnearClipPlane + float getWorldCameraNear() { return _ProjectionParams.y; } + + // カメラ投影法が透視投影かどうか + bool isPerspective() { return any(UNITY_MATRIX_P._41_42_43); } + + // カメラが透視投影ならカメラの位置、平行投影ならカメラ位置を通る平面上のworldPosを正面にとらえる位置 + float3 getWorldCameraOrigin(float3 worldPos) + { + return isPerspective() + ? getWorldCameraPos() + : worldPos + dot(getWorldCameraPos() - worldPos, getWorldCameraDir()) * getWorldCameraDir(); + } + + // キューブのtransform.position + float3 getWorldBoundsCenter() { return unity_ObjectToWorld._14_24_34; } + + // カメラの位置からキューブを見て、2枚の平面で前後にキューブを挟んだ時の長さを求める + float getWorldBoundsDepth(float3 worldCameraDir) + { + float3 worldCornerVec1 = objectToWorldVec(float3(0.5, 0.5, 0.5)); + float3 worldCornerVec2 = objectToWorldVec(float3(-0.5, 0.5, 0.5)); + float3 worldCornerVec3 = objectToWorldVec(float3(0.5, -0.5, 0.5)); + float3 worldCornerVec4 = objectToWorldVec(float3(-0.5, -0.5, 0.5)); + float2 lengths1 = abs(float2(dot(worldCornerVec1, worldCameraDir), dot(worldCornerVec2, worldCameraDir))); + float2 lengths2 = abs(float2(dot(worldCornerVec3, worldCameraDir), dot(worldCornerVec4, worldCameraDir))); + float2 lengths = max(lengths1, lengths2); + return max(lengths.x, lengths.y) * 2.0; + } + + // 上記のように挟んだ時の平面の位置を求める + float2 getWorldBoundsNearFar(float worldBoundsDepth) + { + float center = isPerspective() + ? distance(getWorldBoundsCenter(), getWorldCameraPos()) + : dot(getWorldBoundsCenter() - getWorldCameraPos(), getWorldCameraDir()); + return float2(-0.5, 0.5) * worldBoundsDepth + center; + } + + // キューブの面に関するPlane.Raycastを3方向まとめて行う + float3 getLocalBoundsFaces(float3 localPos, float3 localViewDir, float faceOffset) + { + float3 signs = sign(localViewDir); + return -(signs * localPos + faceOffset) / (abs(localViewDir) + (1.0 - abs(signs)) * DIRECTIONAL_EPSILON); + } + + // キューブ前面までの距離を求める + float getLocalBoundsFrontFace(float3 localPos, float3 localViewDir) + { + float3 lengths = getLocalBoundsFaces(localPos, localViewDir, 0.5); + return max(max(max(lengths.x, lengths.y), lengths.z), 0.0); + } + + // デプステクスチャをもとに他の不透明オブジェクトのZ位置を算出する + // キューブ内に他の不透明オブジェクトが貫入している場合に対応するため使用する + float sampleOpaqueZ(float4 screenPos) + { + float rawDepth = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(screenPos)); + return isPerspective() + ? LinearEyeDepth(rawDepth) + : -dot(unity_CameraInvProjection._33_34, float2(_ProjectionParams.x * (rawDepth * 2.0 - 1.0), 1.0)); + } + + fixed sample(float3 pos) + { + fixed x = step(pos.x, _MaxX) * step(_MinX, pos.x); + fixed y = step(pos.y, _MaxY) * step(_MinY, pos.y); + fixed z = step(pos.z, _MaxZ) * step(_MinZ, pos.z); + return tex3D(_Volume, pos).a * x * y * z; + } + + v2f vert(appdata v) + { + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + o.localPos = v.vertex.xyz; + o.worldViewDir = isPerspective() ? -UnityWorldSpaceViewDir(o.worldPos) : getWorldCameraDir(); + o.localViewDir = worldToObjectVec(o.worldViewDir); + o.screenPos = ComputeScreenPos(o.vertex); + return o; + } + + fixed4 frag(v2f i) : SV_Target + { + // カメラのニアプレーンから他の不透明オブジェクト表面までの範囲で、かつキューブ内である範囲を求める + float3 worldViewDir = normalize(i.worldViewDir); + float3 localViewDir = normalize(i.localViewDir); + float peripheralFactor = 1.0 / dot(getWorldCameraDir(), worldViewDir); + float3 worldCameraOrigin = getWorldCameraOrigin(i.worldPos); + float3 localCameraOrigin = worldToObjectPos(worldCameraOrigin); + float worldFrontFace = dot(objectToWorldVec(getLocalBoundsFrontFace(localCameraOrigin, localViewDir) * localViewDir), worldViewDir); + float worldBackFace = dot(i.worldPos - worldCameraOrigin, worldViewDir); + float worldCameraNear = getWorldCameraNear(); + float worldOpaque = sampleOpaqueZ(i.screenPos) * peripheralFactor; + float worldEnter = max(worldFrontFace, worldCameraNear); + float worldExit = min(worldBackFace, worldOpaque); + + // 不要な領域をクリッピングする + clip(worldExit - worldEnter); + + // 視線方向の色積分の開始・終了ステップ番号を求める + float worldBoundsDepth = getWorldBoundsDepth(getWorldCameraDir()); + float2 worldBoundsNear = getWorldBoundsNearFar(worldBoundsDepth).x; + float worldLineOrigin = worldBoundsNear * peripheralFactor; + float worldLineLength = worldBoundsDepth * peripheralFactor; + float worldStepLength = worldLineLength / _Iteration; + float worldLineOriginToEnter = worldEnter - worldLineOrigin; + float worldLineOriginToExit = worldExit - worldLineOrigin; + int startingIndex = (int)ceil(worldLineOriginToEnter / worldStepLength); + int terminalIndex = (int)(worldLineOriginToExit / worldStepLength); + + float3 localStep = worldToObjectVec(worldStepLength * worldViewDir); + float3 localLineOriginPos = worldToObjectPos(worldCameraOrigin + worldViewDir * worldLineOrigin); + fixed output = 0.0; + + [loop] + for (int j = startingIndex; j <= terminalIndex; j++) + { + float3 lpos = localLineOriginPos + j * localStep; + fixed a = sample(lpos + 0.5); + if (a < ALPHA_THRESHOLD) + { + continue; + } + output += (1.0 - output) * a * _Intensity; + if (output > 1.0 - INTEGRATION_THRESHOLD) + { + break; + } + } + + return _Color * output; + } + ENDCG + + SubShader + { + Tags + { + "Queue" = "Transparent" + "RenderType" = "Transparent" + } + + Pass + { + Cull Front + ZWrite Off + ZTest Always + Blend One OneMinusSrcAlpha + Lighting Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG + } + } +} \ No newline at end of file diff --git a/Assets/5. Transfer Function/Shaders/VolumeRendering_teratail.shader.meta b/Assets/5. Transfer Function/Shaders/VolumeRendering_teratail.shader.meta new file mode 100644 index 0000000..4ef5cc9 --- /dev/null +++ b/Assets/5. Transfer Function/Shaders/VolumeRendering_teratail.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1fd2ad284764d804c8e552323a6fce9c +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/6. Gradient.meta b/Assets/6. Gradient.meta new file mode 100644 index 0000000..b183e20 --- /dev/null +++ b/Assets/6. Gradient.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: fbaada11db9c74a579d9b735841d0b3e +folderAsset: yes +timeCreated: 1515597805 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/6. Gradient/Editor.meta b/Assets/6. Gradient/Editor.meta new file mode 100644 index 0000000..321e089 --- /dev/null +++ b/Assets/6. Gradient/Editor.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c28414e79aca447ac899219a8fde932b +folderAsset: yes +timeCreated: 1515597883 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/6. Gradient/Editor/PvmRawImporter2.cs b/Assets/6. Gradient/Editor/PvmRawImporter2.cs new file mode 100644 index 0000000..ccbee4b --- /dev/null +++ b/Assets/6. Gradient/Editor/PvmRawImporter2.cs @@ -0,0 +1,304 @@ +using UnityEngine; +using UnityEditor; +using UnityEditor.Experimental.AssetImporters; +using System; +using System.IO; + +[ScriptedImporter(1, "raw")] +public class PvmRawImporter2 : ScriptedImporter +{ + public enum Bits + { + Eight = 1, + Sixteen = 2, + } + + public int width = 256; + public int height = 256; + public int depth = 256; + public Bits bit = Bits.Eight; + public int smooth = 3; + + int valueCount + { + get { return width * height * depth; } + } + + int totalSize + { + get { return valueCount * (int)bit; } + } + + int maxValueSize + { + get + { + switch (bit) + { + case Bits.Eight: return (int)Byte.MaxValue; + case Bits.Sixteen: return (int)UInt16.MaxValue; + default: + throw new Exception("bit is wrong."); + } + } + } + + // 追加分 + void ReadVolumeData(string path, Color[] colors) + { + using (var stream = new FileStream(path, FileMode.Open)) + { + if (stream.Length != totalSize) + { + throw new Exception("Data size is wrong."); + } + + float a = 1f / maxValueSize; + var buf = new byte[(int)bit]; + + for (int i = 0; i < colors.Length; ++i) + { + float value = 0f; + switch (bit) + { + case Bits.Eight: + var b = stream.ReadByte(); + value = a * b; + break; + case Bits.Sixteen: + stream.Read(buf, 0, 2); + value = a * BitConverter.ToUInt16(buf, 0); + break; + } + colors[i].a = value; + } + } + } + + float SampleVolume(Color[] colors, int x, int y, int z) + { + if (x < 0) x = 0; + if (y < 0) y = 0; + if (z < 0) z = 0; + if (x >= width) x = width - 1; + if (y >= height) y = height - 1; + if (z >= depth) z = depth - 1; + var index = (z * width * height) + (y * width) + x; + return colors[index].a; + } + + Vector3 CalcSmoothedGradient(Vector3[] grads, int x0, int y0, int z0) + { + var sum = Vector3.zero; + int n = smooth; + + for (int z = z0 - n; z <= z0 + n; ++z) + { + if (z < 0 || z >= depth) continue; + for (int y = y0 - n; y <= y0 + n; ++y) + { + if (y < 0 || y >= height) continue; + for (int x = x0 - n; x <= x0 + n; ++x) + { + if (x < 0 || x >= width) continue; + var index = (z * width * height) + (y * width) + x; + sum += grads[index]; + } + } + } + + return sum.normalized; + } + + void CalcGradients(Color[] colors) + { + var grads = new Vector3[colors.Length]; + + for (int z = 0; z < depth; ++z) + { + for (int y = 0; y < height; ++y) + { + for (int x = 0; x < width; ++x) + { + var grad = new Vector3( + SampleVolume(colors, x - 1, y, z) - SampleVolume(colors, x, y, z), + SampleVolume(colors, x, y - 1, z) - SampleVolume(colors, x, y, z), + SampleVolume(colors, x, y, z - 1) - SampleVolume(colors, x, y, z)); + var index = (z * width * height) + (y * width) + x; + grads[index] = grad; + } + } + } + + for (int z = 0; z < depth; ++z) + { + for (int y = 0; y < height; ++y) + { + for (int x = 0; x < width; ++x) + { + var grad = CalcSmoothedGradient(grads, x, y, z); + var index = (z * width * height) + (y * width) + x; + colors[index].r = (1f + grad.x) * 0.5f; + colors[index].g = (1f + grad.y) * 0.5f; + colors[index].b = (1f + grad.z) * 0.5f; + } + } + } + } + + Texture3D GetTexture3D(string path) + { + var colors = new Color[valueCount]; + + ReadVolumeData(path, colors); + CalcGradients(colors); + + var tex3d = new Texture3D(width, height, depth, TextureFormat.RGBA32, false); + tex3d.SetPixels(colors, 0); + tex3d.Apply(); + + return tex3d; + } + + public override void OnImportAsset(AssetImportContext ctx) + { + try + { + var tex3d = GetTexture3D(ctx.assetPath); + ctx.AddObjectToAsset("Volume", tex3d); + } + catch (Exception e) + { + Debug.LogException(e); + } + } + + //public override void OnImportAsset(AssetImportContext ctx) + //{ + // try + // { + // var tex3d = GetTexture3D(ctx.assetPath); + // ctx.AddObjectToAsset("Volume", tex3d); + // } + // catch (Exception e) + // { + // Debug.LogException(e); + // } + //} + + //Texture3D GetTexture3D(string path) + //{ + // var colors = new Color[valueCount]; + + // ReadVolumeData(path, colors); + // CalcGradients(colors); + + // var tex3d = new Texture3D(width, height, depth, TextureFormat.RGBA32, false); + // tex3d.SetPixels(colors, 0); + // tex3d.Apply(); + + // return tex3d; + //} + + //void ReadVolumeData(string path, Color[] colors) + //{ + // using (var stream = new FileStream(path, FileMode.Open)) + // { + // if (stream.Length != totalSize) + // { + // throw new Exception("Data size is wrong."); + // } + + // float a = 1f / maxValueSize; + // var buf = new byte[(int)bit]; + + // for (int i = 0; i < colors.Length; ++i) + // { + // float value = 0f; + // switch (bit) + // { + // case Bits.Eight: + // var b = stream.ReadByte(); + // value = a * b; + // break; + // case Bits.Sixteen: + // stream.Read(buf, 0, 2); + // value = a * BitConverter.ToUInt16(buf, 0); + // break; + // } + // colors[i].a = value; + // } + // } + //} + + //void CalcGradients(Color[] colors) + //{ + // var grads = new Vector3[colors.Length]; + + // for (int z = 0; z < depth; ++z) + // { + // for (int y = 0; y < height; ++y) + // { + // for (int x = 0; x < width; ++x) + // { + // var grad = new Vector3( + // SampleVolume(colors, x + 1, y, z) - SampleVolume(colors, x, y, z), + // SampleVolume(colors, x, y + 1, z) - SampleVolume(colors, x, y, z), + // SampleVolume(colors, x, y, z + 1) - SampleVolume(colors, x, y, z)); + // var index = (z * width * height) + (y * width) + x; + // grads[index] = grad; + // } + // } + // } + + // for (int z = 0; z < depth; ++z) + // { + // for (int y = 0; y < height; ++y) + // { + // for (int x = 0; x < width; ++x) + // { + // var grad = CalcSmoothedGradient(grads, x, y, z); + // var index = (z * width * height) + (y * width) + x; + // colors[index].r = (1f + grad.x) * 0.5f; + // colors[index].g = (1f + grad.y) * 0.5f; + // colors[index].b = (1f + grad.z) * 0.5f; + // } + // } + // } + //} + + //float SampleVolume(Color[] colors, int x, int y, int z) + //{ + // if (x < 0) x = 0; + // if (y < 0) y = 0; + // if (z < 0) z = 0; + // if (x >= width) x = width - 1; + // if (y >= height) y = height - 1; + // if (z >= depth) z = depth - 1; + // var index = (z * width * height) + (y * width) + x; + // return colors[index].a; + //} + + //Vector3 CalcSmoothedGradient(Vector3[] grads, int x0, int y0, int z0) + //{ + // var sum = Vector3.zero; + // int n = smooth; + + // for (int z = z0 - n; z <= z0 + n; ++z) + // { + // if (z < 0 || z >= depth) continue; + // for (int y = y0 - n; y <= y0 + n; ++y) + // { + // if (y < 0 || y >= height) continue; + // for (int x = x0 - n; x <= x0 + n; ++x) + // { + // if (x < 0 || x >= width) continue; + // var index = (z * width * height) + (y * width) + x; + // sum += grads[index]; + // } + // } + // } + + // return sum.normalized; + //} +} diff --git a/Assets/6. Gradient/Editor/PvmRawImporter2.cs.meta b/Assets/6. Gradient/Editor/PvmRawImporter2.cs.meta new file mode 100644 index 0000000..48eec19 --- /dev/null +++ b/Assets/6. Gradient/Editor/PvmRawImporter2.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 4076eb95b581041b5bb78255c2b05ea4 +timeCreated: 1514969617 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/6. Gradient/FPSMover.cs b/Assets/6. Gradient/FPSMover.cs new file mode 100644 index 0000000..b9e9879 --- /dev/null +++ b/Assets/6. Gradient/FPSMover.cs @@ -0,0 +1,49 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class FPSMover : MonoBehaviour +{ + // public float mainSPEED; + public float x_sensi; + public float y_sensi; + public float trans_scale; + public GameObject target_camera; + + void Start() + { + } + + void Update() + { + // movecon(); + if (Input.GetMouseButton(0)) + { + cameracon(); + } + + + if (Input.GetKey(KeyCode.W)) target_camera.transform.Translate(0.0f, trans_scale, 0.0f); + + if (Input.GetKey(KeyCode.D)) target_camera.transform.Translate(trans_scale, 0.0f, 0.0f); + + if (Input.GetKey(KeyCode.X)) target_camera.transform.Translate(0.0f, -trans_scale, 0.0f); + + if (Input.GetKey(KeyCode.A)) target_camera.transform.Translate(-trans_scale, 0.0f, 0.0f); + + if (Input.GetKey(KeyCode.S)) target_camera.transform.Translate(0.0f, 0.0f, trans_scale); + + if (Input.GetKey(KeyCode.B)) target_camera.transform.Translate(0.0f, 0.0f, -trans_scale); + } + + void cameracon() + { + float x_Rotation = Input.GetAxis("Mouse X"); + float y_Rotation = Input.GetAxis("Mouse Y"); + x_Rotation = x_Rotation * x_sensi; + y_Rotation = y_Rotation * y_sensi; + target_camera.transform.Rotate(0, x_Rotation, 0); + target_camera.transform.Rotate(-y_Rotation, 0, 0); + } + +} diff --git a/Assets/6. Gradient/FPSMover.cs.meta b/Assets/6. Gradient/FPSMover.cs.meta new file mode 100644 index 0000000..921fe39 --- /dev/null +++ b/Assets/6. Gradient/FPSMover.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dd40a3cd58d1f6344856e87338a631ca +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/6. Gradient/Materials.meta b/Assets/6. Gradient/Materials.meta new file mode 100644 index 0000000..840491a --- /dev/null +++ b/Assets/6. Gradient/Materials.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 445b24ee8c6ea47b1b1936018a729ada +folderAsset: yes +timeCreated: 1515158844 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/6. Gradient/Materials/VolumeRendering4.mat b/Assets/6. Gradient/Materials/VolumeRendering4.mat new file mode 100644 index 0000000..c109184 --- /dev/null +++ b/Assets/6. Gradient/Materials/VolumeRendering4.mat @@ -0,0 +1,50 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: VolumeRendering4 + m_Shader: {fileID: 4800000, guid: 68171fb2942b24453899afe1ab89ecf4, type: 3} + m_ShaderKeywords: _RAY_FIXED_LENGTH + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _Transfer: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _Volume: + m_Texture: {fileID: 4849145913767034428, guid: f2573a9deb19ec947aa0c8521b2ff5bf, + type: 3} + m_Scale: {x: 0, y: 0} + m_Offset: {x: 1, y: 1} + m_Floats: + - _AlphaIntensity: 0.05 + - _Ambient: 0 + - _BlendDst: 10 + - _BlendSrc: 9 + - _ColorEnhance: 2.83 + - _ColorIntensity: 3 + - _Diffuse: 3.63 + - _Intensity: 0.01 + - _Iteration: 1000 + - _MaxX: 1 + - _MaxY: 0.768 + - _MaxZ: 1 + - _MinX: 0 + - _MinY: 0 + - _MinZ: 0 + - _RAY: 1 + - _Shadow: 0.71 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/6. Gradient/Materials/VolumeRendering4.mat.meta b/Assets/6. Gradient/Materials/VolumeRendering4.mat.meta new file mode 100644 index 0000000..df47a33 --- /dev/null +++ b/Assets/6. Gradient/Materials/VolumeRendering4.mat.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 655431cddcb6c414fbfdf49d75bdbcfe +timeCreated: 1515673970 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/6. Gradient/Scenes.meta b/Assets/6. Gradient/Scenes.meta new file mode 100644 index 0000000..d637c38 --- /dev/null +++ b/Assets/6. Gradient/Scenes.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 249711c57a2c8452ea6fff00aca3b3a2 +folderAsset: yes +timeCreated: 1514989517 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/6. Gradient/Scenes/Gradient.unity b/Assets/6. Gradient/Scenes/Gradient.unity new file mode 100644 index 0000000..5bb89a5 --- /dev/null +++ b/Assets/6. Gradient/Scenes/Gradient.unity @@ -0,0 +1,553 @@ +%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: 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, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !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_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 &73477751 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 73477753} + - component: {fileID: 73477752} + 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 &73477752 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 73477751} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 3 + 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 &73477753 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 73477751} + m_LocalRotation: {x: -0.25480404, y: -0.6607016, z: 0.11230456, w: -0.6970912} + m_LocalPosition: {x: -4.17, y: 1.43, z: -0.02} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: -329.759, y: -1349.807, z: 4692.034} +--- !u!1 &1873212973 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1873212977} + - component: {fileID: 1873212976} + - component: {fileID: 1873212975} + - component: {fileID: 1873212974} + - component: {fileID: 1873212978} + m_Layer: 0 + m_Name: Carp + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &1873212974 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 0 + m_MotionVectors: 2 + m_LightProbeUsage: 0 + m_ReflectionProbeUsage: 0 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 655431cddcb6c414fbfdf49d75bdbcfe, type: 2} + 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: 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 &1873212975 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + 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 &1873212976 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1873212977 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_LocalRotation: {x: 0, y: -0, z: 1, w: -0.0000001872535} + m_LocalPosition: {x: 0, y: 0, z: -0.3} + m_LocalScale: {x: 3.0171578, y: 1.996471, z: 6.8278666} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180.00002} +--- !u!114 &1873212978 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1873212973} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1f42bf1e372bc4f52bf8066e82aeceb0, type: 3} + m_Name: + m_EditorClassIdentifier: + gradient: + serializedVersion: 2 + key0: {r: 0, g: 0, b: 0, a: 0} + key1: {r: 0.10123711, g: 0.18569952, b: 0.23584908, a: 1} + key2: {r: 0.5566038, g: 0.1891897, b: 0.04463333, a: 0} + key3: {r: 0.86274517, g: 0.73333335, b: 1, a: 0.6901961} + key4: {r: 0.86274517, g: 0.73333335, b: 1, a: 0} + key5: {r: 0, g: 0, b: 0, a: 1} + key6: {r: 0, g: 0, b: 0, a: 0} + key7: {r: 0, g: 0, b: 0, a: 1} + ctime0: 0 + ctime1: 36114 + ctime2: 44341 + ctime3: 50650 + ctime4: 65535 + ctime5: 0 + ctime6: 0 + ctime7: 0 + atime0: 33709 + atime1: 36149 + atime2: 40227 + atime3: 43260 + atime4: 52916 + atime5: 65535 + atime6: 60655 + atime7: 65535 + m_Mode: 0 + m_NumColorKeys: 5 + m_NumAlphaKeys: 6 + updateTextureInEveryFrame: 1 +--- !u!1 &1982713311 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1982713313} + - component: {fileID: 1982713312} + m_Layer: 0 + m_Name: Point Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1982713312 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1982713311} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 2 + m_Shape: 0 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 0 + 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 &1982713313 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1982713311} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.4950986, y: -0.71243143, z: -0.06032896} + 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!1 &2108303124 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2108303128} + - component: {fileID: 2108303127} + - component: {fileID: 2108303126} + - component: {fileID: 2108303125} + - component: {fileID: 2108303129} + 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 &2108303125 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 +--- !u!124 &2108303126 +Behaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 +--- !u!20 &2108303127 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0, g: 0, b: 0, 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: 0.3 + far clip plane: 1000 + 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: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &2108303128 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} + m_LocalPosition: {x: 0.365, y: 0.05, z: 4.16} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} +--- !u!114 &2108303129 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2108303124} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dd40a3cd58d1f6344856e87338a631ca, type: 3} + m_Name: + m_EditorClassIdentifier: + x_sensi: 1 + y_sensi: 1 + trans_scale: 0.01 + target_camera: {fileID: 2108303124} + point_light: {fileID: 1982713311} diff --git a/Assets/6. Gradient/Scenes/Gradient.unity.meta b/Assets/6. Gradient/Scenes/Gradient.unity.meta new file mode 100644 index 0000000..f7c8db8 --- /dev/null +++ b/Assets/6. Gradient/Scenes/Gradient.unity.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ebd45cea729014ee297fae384e0316fc +timeCreated: 1514982279 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/6. Gradient/Shaders.meta b/Assets/6. Gradient/Shaders.meta new file mode 100644 index 0000000..2a832d1 --- /dev/null +++ b/Assets/6. Gradient/Shaders.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 454351ad8f13c470fab7c70162bf7540 +folderAsset: yes +timeCreated: 1515426272 +licenseType: Free +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/6. Gradient/Shaders/VolumeRendering4.shader b/Assets/6. Gradient/Shaders/VolumeRendering4.shader new file mode 100644 index 0000000..f7d07fd --- /dev/null +++ b/Assets/6. Gradient/Shaders/VolumeRendering4.shader @@ -0,0 +1,162 @@ +Shader "VolumeRendering/VolumeRendering4" +{ + +Properties +{ + [Header(Rendering)] + _Volume("Volume", 3D) = "" {} + _Transfer("Transfer", 2D) = "" {} + _Iteration("Iteration", Int) = 10 + _Intensity("Intensity", Range(0.0, 1.0)) = 0.1 + _Ambient("Ambient", Range(0.0, 1.0)) = 0.1 + _Shadow("Shadow", Range(0.0, 5.0)) = 2.0 + [Enum(UnityEngine.Rendering.BlendMode)] _BlendSrc ("Blend Src", Float) = 5 + [Enum(UnityEngine.Rendering.BlendMode)] _BlendDst ("Blend Dst", Float) = 10 + + [Header(Ranges)] + _MinX("MinX", Range(0, 1)) = 0.0 + _MaxX("MaxX", Range(0, 1)) = 1.0 + _MinY("MinY", Range(0, 1)) = 0.0 + _MaxY("MaxY", Range(0, 1)) = 1.0 + _MinZ("MinZ", Range(0, 1)) = 0.0 + _MaxZ("MaxZ", Range(0, 1)) = 1.0 + + [Header(Variable)] + [KeywordEnum(VARIABLE_LENGTH, FIXED_LENGTH)] + _RAY("Ray Method", Float) = 0 +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float4 localPos : TEXCOORD0; + float4 worldPos : TEXCOORD1; +}; + +sampler3D _Volume; +sampler2D _Transfer; +int _Iteration; +float _Intensity; +fixed _MinX, _MaxX, _MinY, _MaxY, _MinZ, _MaxZ; +float _Ambient; +float _Shadow; + +struct Ray +{ + float3 from; + float3 dir; + float tmax; +}; + +void intersection(inout Ray ray) +{ + float3 invDir = 1.0 / ray.dir; + float3 t1 = (-0.5 - ray.from) * invDir; + float3 t2 = (+0.5 - ray.from) * invDir; + + float3 tmax3 = max(t1, t2); + float2 tmax2 = min(tmax3.xx, tmax3.yz); + ray.tmax = min(tmax2.x, tmax2.y); +} + +inline fixed4 sampleVolume(float3 pos) +{ + fixed x = step(pos.x, _MaxX) * step(_MinX, pos.x); + fixed y = step(pos.y, _MaxY) * step(_MinY, pos.y); + fixed z = step(pos.z, _MaxZ) * step(_MinZ, pos.z); + return tex3D(_Volume, pos) * (x * y * z); +} + +inline fixed4 transferFunction(float t) +{ + return tex2D(_Transfer, float2(t, 0)); +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.localPos = v.vertex; + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + return o; +} + +fixed4 frag(v2f i) : SV_Target +{ + float3 worldDir = i.worldPos - _WorldSpaceCameraPos; + float3 localDir = normalize(mul(unity_WorldToObject, worldDir)); + + Ray ray; + ray.from = i.localPos; + ray.dir = localDir; + intersection(ray); + +#ifdef _RAY_FIXED_LENGTH + float dt = 1.0 / _Iteration; + float time = 0.0; + float3 localStep = localDir * dt; +#else + float3 localStep = localDir * ray.tmax / _Iteration; +#endif + float3 localPos = i.localPos; + float4 output = 0; + float3 lightDir = normalize(mul(unity_WorldToObject, _WorldSpaceLightPos0)); + + [loop] + for (int i = 0; i < _Iteration; ++i) + { + fixed4 volume = sampleVolume(localPos + 0.5); + fixed a = volume.a; + fixed3 normal = 2.0 * volume.rgb - 1.0; + fixed shadow = dot(lightDir, -normal); + fixed4 color = transferFunction(a) * a * _Intensity; + color.rgb *= _Ambient + (1.0 - shadow * _Shadow); + output += (1.0 - output.a) * color; + localPos += localStep; +#ifdef _RAY_FIXED_LENGTH + time += dt; + if (time > ray.tmax || output.a > 0.95) break; +#endif + } + + return output; +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Transparent" + "RenderType" = "Transparent" +} + +Pass +{ + Tags { "LightMode" = "ForwardBase" } + + Cull Back + ZWrite Off + Blend [_BlendSrc] [_BlendDst] + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma multi_compile _RAY_VARIABLE_LENGTH _RAY_FIXED_LENGTH + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/6. Gradient/Shaders/VolumeRendering4.shader.meta b/Assets/6. Gradient/Shaders/VolumeRendering4.shader.meta new file mode 100644 index 0000000..a1cc33d --- /dev/null +++ b/Assets/6. Gradient/Shaders/VolumeRendering4.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 68171fb2942b24453899afe1ab89ecf4 +timeCreated: 1514948053 +licenseType: Free +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/6. Gradient/Shaders/VoumeRendering_kai.shader b/Assets/6. Gradient/Shaders/VoumeRendering_kai.shader new file mode 100644 index 0000000..4b60137 --- /dev/null +++ b/Assets/6. Gradient/Shaders/VoumeRendering_kai.shader @@ -0,0 +1,253 @@ +Shader "VolumeRendering/VolumeRendering_kai" +{ + Properties + { + [Header(Rendering)] + _Volume("Volume", 3D) = "" {} + _Transfer("Transfer", 2D) = "" {} + _Iteration("Iteration", Int) = 100 + _Intensity("Intensity", Range(0.0, 1.0)) = 0.1 + [Enum(UnityEngine.Rendering.BlendMode)] _BlendSrc("Blend Src", Float) = 5 + [Enum(UnityEngine.Rendering.BlendMode)] _BlendDst("Blend Dst", Float) = 10 + + [Header(Ranges)] + _MinX("MinX", Range(0, 1)) = 0.0 + _MaxX("MaxX", Range(0, 1)) = 1.0 + _MinY("MinY", Range(0, 1)) = 0.0 + _MaxY("MaxY", Range(0, 1)) = 1.0 + _MinZ("MinZ", Range(0, 1)) = 0.0 + _MaxZ("MaxZ", Range(0, 1)) = 1.0 + + [Header(Variable)] + [KeywordEnum(VARIABLE_LENGTH, FIXED_LENGTH)] + _RAY("Ray Method", Float) = 0 + } + +CGINCLUDE +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float3 localPos : TEXCOORD0; + float3 worldPos : TEXCOORD1; + float3 localViewDir : TEXCOORD2; + float3 worldViewDir : TEXCOORD3; + float4 screenPos : TEXCOORD4; +}; + +struct Ray +{ + float3 from; + float3 dir; + float tmax; +}; + +sampler3D _Volume; +sampler2D _Transfer; +int _Iteration; +fixed _Intensity; +fixed _MinX, _MaxX, _MinY, _MaxY, _MinZ, _MaxZ; + +#define INTEGRATION_THRESHOLD 0.01 +#define DIRECTIONAL_EPSILON 0.0009765625 +#define ALPHA_THRESHOLD 0.01 + +void intersection(inout Ray ray) +{ + float3 invDir = 1.0 / ray.dir; + float3 t1 = (-0.5 - ray.from) * invDir; + float3 t2 = (+0.5 - ray.from) * invDir; + + float3 tmax3 = max(t1, t2); + float2 tmax2 = min(tmax3.xx, tmax3.yz); + ray.tmax = min(tmax2.x, tmax2.y); +} + +inline fixed sampleVolume(float3 pos) +{ + fixed x = step(pos.x, _MaxX) * step(_MinX, pos.x); + fixed y = step(pos.y, _MaxY) * step(_MinY, pos.y); + fixed z = step(pos.z, _MaxZ) * step(_MinZ, pos.z); + return tex3D(_Volume, pos).a * (x * y * z); +} + +inline fixed4 transferFunction(float t) +{ + return tex2D(_Transfer, float2(t, 0)); +} + +sampler2D _CameraDepthTexture; + +// キューブに関するtransform.InverseTransformPoint +float3 worldToObjectPos(float3 worldPos) { return mul(unity_WorldToObject, float4(worldPos, 1.0)).xyz; } + +// キューブに関するtransform.InverseTransformVector +float3 worldToObjectVec(float3 worldVec) { return mul((float3x3)unity_WorldToObject, worldVec); } + +// キューブに関するtransform.TransformVector +float3 objectToWorldVec(float3 localVec) { return mul((float3x3)unity_ObjectToWorld, localVec); } + +// カメラのtransform.position +float3 getWorldCameraPos() { return UNITY_MATRIX_I_V._14_24_34; } + +// カメラのtransform.forward +float3 getWorldCameraDir() { return -UNITY_MATRIX_V._31_32_33; } + +// カメラのnearClipPlane +float getWorldCameraNear() { return _ProjectionParams.y; } + +// カメラ投影法が透視投影かどうか +bool isPerspective() { return any(UNITY_MATRIX_P._41_42_43); } + +// カメラが透視投影ならカメラの位置、平行投影ならカメラ位置を通る平面上のworldPosを正面にとらえる位置 +float3 getWorldCameraOrigin(float3 worldPos) +{ + return isPerspective() + ? getWorldCameraPos() + : worldPos + dot(getWorldCameraPos() - worldPos, getWorldCameraDir()) * getWorldCameraDir(); +} + +// キューブのtransform.position +float3 getWorldBoundsCenter() { return unity_ObjectToWorld._14_24_34; } + +// カメラの位置からキューブを見て、2枚の平面で前後にキューブを挟んだ時の長さを求める +float getWorldBoundsDepth(float3 worldCameraDir) +{ + float3 worldCornerVec1 = objectToWorldVec(float3(0.5, 0.5, 0.5)); + float3 worldCornerVec2 = objectToWorldVec(float3(-0.5, 0.5, 0.5)); + float3 worldCornerVec3 = objectToWorldVec(float3(0.5, -0.5, 0.5)); + float3 worldCornerVec4 = objectToWorldVec(float3(-0.5, -0.5, 0.5)); + float2 lengths1 = abs(float2(dot(worldCornerVec1, worldCameraDir), dot(worldCornerVec2, worldCameraDir))); + float2 lengths2 = abs(float2(dot(worldCornerVec3, worldCameraDir), dot(worldCornerVec4, worldCameraDir))); + float2 lengths = max(lengths1, lengths2); + return max(lengths.x, lengths.y) * 2.0; +} + +// 上記のように挟んだ時の平面の位置を求める +float2 getWorldBoundsNearFar(float worldBoundsDepth) +{ + float center = isPerspective() + ? distance(getWorldBoundsCenter(), getWorldCameraPos()) + : dot(getWorldBoundsCenter() - getWorldCameraPos(), getWorldCameraDir()); + return float2(-0.5, 0.5) * worldBoundsDepth + center; +} + +// キューブの面に関するPlane.Raycastを3方向まとめて行う +float3 getLocalBoundsFaces(float3 localPos, float3 localViewDir, float faceOffset) +{ + float3 signs = sign(localViewDir); + return -(signs * localPos + faceOffset) / (abs(localViewDir) + (1.0 - abs(signs)) * DIRECTIONAL_EPSILON); +} + +// キューブ前面までの距離を求める +float getLocalBoundsFrontFace(float3 localPos, float3 localViewDir) +{ + float3 lengths = getLocalBoundsFaces(localPos, localViewDir, 0.5); + return max(max(max(lengths.x, lengths.y), lengths.z), 0.0); +} + +// デプステクスチャをもとに他の不透明オブジェクトのZ位置を算出する +// キューブ内に他の不透明オブジェクトが貫入している場合に対応するため使用する +float sampleOpaqueZ(float4 screenPos) +{ + float rawDepth = SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(screenPos)); + return isPerspective() + ? LinearEyeDepth(rawDepth) + : -dot(unity_CameraInvProjection._33_34, float2(_ProjectionParams.x * (rawDepth * 2.0 - 1.0), 1.0)); +} + +fixed sample(float3 pos) +{ + fixed x = step(pos.x, _MaxX) * step(_MinX, pos.x); + fixed y = step(pos.y, _MaxY) * step(_MinY, pos.y); + fixed z = step(pos.z, _MaxZ) * step(_MinZ, pos.z); + return tex3D(_Volume, pos).a * x * y * z; +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + o.localPos = v.vertex.xyz; + o.worldViewDir = isPerspective() ? -UnityWorldSpaceViewDir(o.worldPos) : getWorldCameraDir(); + o.localViewDir = worldToObjectVec(o.worldViewDir); + o.screenPos = ComputeScreenPos(o.vertex); + return o; +} + +fixed4 frag(v2f i) : SV_Target +{ + // カメラのニアプレーンから他の不透明オブジェクト表面までの範囲で、かつキューブ内である範囲を求める + float3 worldViewDir = normalize(i.worldViewDir); + float3 localViewDir = normalize(i.localViewDir); + float peripheralFactor = 1.0 / dot(getWorldCameraDir(), worldViewDir); + float3 worldCameraOrigin = getWorldCameraOrigin(i.worldPos); + float3 localCameraOrigin = worldToObjectPos(worldCameraOrigin); + float worldFrontFace = dot(objectToWorldVec(getLocalBoundsFrontFace(localCameraOrigin, localViewDir) * localViewDir), worldViewDir); + float worldBackFace = dot(i.worldPos - worldCameraOrigin, worldViewDir); + float worldCameraNear = getWorldCameraNear(); + float worldOpaque = sampleOpaqueZ(i.screenPos) * peripheralFactor; + float worldEnter = max(worldFrontFace, worldCameraNear); + float worldExit = min(worldBackFace, worldOpaque); + + // 不要な領域をクリッピングする + clip(worldExit - worldEnter); + + // 視線方向の色積分の開始・終了ステップ番号を求める + float worldBoundsDepth = getWorldBoundsDepth(getWorldCameraDir()); + float2 worldBoundsNear = getWorldBoundsNearFar(worldBoundsDepth).x; + float worldLineOrigin = worldBoundsNear * peripheralFactor; + float worldLineLength = worldBoundsDepth * peripheralFactor; + float worldStepLength = worldLineLength / _Iteration; + float worldLineOriginToEnter = worldEnter - worldLineOrigin; + float worldLineOriginToExit = worldExit - worldLineOrigin; + int startingIndex = (int)ceil(worldLineOriginToEnter / worldStepLength); + int terminalIndex = (int)(worldLineOriginToExit / worldStepLength); + + float3 localStep = worldToObjectVec(worldStepLength * worldViewDir); + float3 localLineOriginPos = worldToObjectPos(worldCameraOrigin + worldViewDir * worldLineOrigin); + float4 output = 0.0; + + [loop] + for (int j = startingIndex; j <= terminalIndex; j++) + { + float3 lpos = localLineOriginPos + j * localStep; + fixed volume = sampleVolume(lpos + 0.5); + fixed4 color = transferFunction(volume) * volume * _Intensity; + output += (1.0 - output.a) * color; + } + + return output; +} + ENDCG + + SubShader +{ + Tags + { + "Queue" = "Transparent" + "RenderType" = "Transparent" + } + + Pass + { + Cull Front + ZWrite Off + ZTest LEqual + Blend[_BlendSrc][_BlendDst] + Lighting Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG + } +} +} \ No newline at end of file diff --git a/Assets/6. Gradient/Shaders/VoumeRendering_kai.shader.meta b/Assets/6. Gradient/Shaders/VoumeRendering_kai.shader.meta new file mode 100644 index 0000000..82896bb --- /dev/null +++ b/Assets/6. Gradient/Shaders/VoumeRendering_kai.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 88397cc43f45b0b4d82ae165e46d9f9a +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural.meta b/Assets/7. Procedural.meta new file mode 100644 index 0000000..157a40a --- /dev/null +++ b/Assets/7. Procedural.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3864ee0c33c074d9bab2eca247bc17b8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Materials.meta b/Assets/7. Procedural/Materials.meta new file mode 100644 index 0000000..16646df --- /dev/null +++ b/Assets/7. Procedural/Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6e50d53a32a114d618a58e988c7b2102 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Materials/CloudLit.mat b/Assets/7. Procedural/Materials/CloudLit.mat new file mode 100644 index 0000000..2f0ece1 --- /dev/null +++ b/Assets/7. Procedural/Materials/CloudLit.mat @@ -0,0 +1,34 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: CloudLit + m_Shader: {fileID: 4800000, guid: 20f15f4ee9c4b4253ad44ef47954b062, 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: + - _Absorption: 43.3 + - _AbsorptionLight: 14.8 + - _Intensity: 0.1 + - _LightStepScale: 0.5 + - _Loop: 32 + - _LoopLight: 6 + - _NoiseScale: 8.1 + - _Opacity: 100 + - _OpacityLight: 84 + - _Radius: 0.7 + m_Colors: + - _Color: {r: 0.754717, g: 0.754717, b: 0.754717, a: 1} diff --git a/Assets/7. Procedural/Materials/CloudLit.mat.meta b/Assets/7. Procedural/Materials/CloudLit.mat.meta new file mode 100644 index 0000000..8aba61c --- /dev/null +++ b/Assets/7. Procedural/Materials/CloudLit.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d16742ae9008f4a17b7891dda8f7730b +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Materials/CloudLitAnimation.mat b/Assets/7. Procedural/Materials/CloudLitAnimation.mat new file mode 100644 index 0000000..01e84b8 --- /dev/null +++ b/Assets/7. Procedural/Materials/CloudLitAnimation.mat @@ -0,0 +1,33 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: CloudLitAnimation + m_Shader: {fileID: 4800000, guid: b146580797451cf4c99c314a8238f141, 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: + - _Absorption: 44.3 + - _AbsorptionLight: 46.2 + - _LightStepScale: 0.497 + - _Loop: 32 + - _LoopLight: 6 + - _NoiseScale: 10 + - _Opacity: 100 + - _OpacityLight: 93.4 + - _Radius: 1 + m_Colors: + - _Color: {r: 0.7830189, g: 0.7684994, b: 0.73131007, a: 1} diff --git a/Assets/7. Procedural/Materials/CloudLitAnimation.mat.meta b/Assets/7. Procedural/Materials/CloudLitAnimation.mat.meta new file mode 100644 index 0000000..7f724a9 --- /dev/null +++ b/Assets/7. Procedural/Materials/CloudLitAnimation.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 57bd04fe4e598a44db03694574686e36 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Materials/CloudUnlit.mat b/Assets/7. Procedural/Materials/CloudUnlit.mat new file mode 100644 index 0000000..e61ffec --- /dev/null +++ b/Assets/7. Procedural/Materials/CloudUnlit.mat @@ -0,0 +1,28 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: CloudUnlit + m_Shader: {fileID: 4800000, guid: 988a3b647c2a34bbe993edce3e2fcd2d, 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: + - _Intensity: 0.75 + - _Loop: 32 + - _NoiseScale: 12 + - _Radius: 0.7 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/7. Procedural/Materials/CloudUnlit.mat.meta b/Assets/7. Procedural/Materials/CloudUnlit.mat.meta new file mode 100644 index 0000000..99344a7 --- /dev/null +++ b/Assets/7. Procedural/Materials/CloudUnlit.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f5e14b41199d645de8bdf0dac44ee6d1 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Materials/VolumeSphereLit.mat b/Assets/7. Procedural/Materials/VolumeSphereLit.mat new file mode 100644 index 0000000..d1554ca --- /dev/null +++ b/Assets/7. Procedural/Materials/VolumeSphereLit.mat @@ -0,0 +1,31 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: VolumeSphereLit + m_Shader: {fileID: 4800000, guid: 94c8551aedb81c147998d08458877092, 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: + - _Absorption: 43.6 + - _AbsorptionLight: 26.4 + - _Intensity: 0.1 + - _Loop: 32 + - _LoopLight: 6 + - _Opacity: 61.3 + - _OpacityLight: 79.3 + m_Colors: + - _Color: {r: 0.7075472, g: 0.70379394, b: 0.67417234, a: 1} diff --git a/Assets/7. Procedural/Materials/VolumeSphereLit.mat.meta b/Assets/7. Procedural/Materials/VolumeSphereLit.mat.meta new file mode 100644 index 0000000..7f20801 --- /dev/null +++ b/Assets/7. Procedural/Materials/VolumeSphereLit.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2dd28e2588695ab41a33881029befe2d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Materials/VolumeSphereUnlit.mat b/Assets/7. Procedural/Materials/VolumeSphereUnlit.mat new file mode 100644 index 0000000..e4baf28 --- /dev/null +++ b/Assets/7. Procedural/Materials/VolumeSphereUnlit.mat @@ -0,0 +1,32 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: VolumeSphereUnlit + m_Shader: {fileID: 4800000, guid: d0b0b3112bd104e16869785b53fee030, type: 3} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _Volume: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _Intensity: 0.5 + - _Loop: 32 + - _NoiseScale: 27.6 + - _Step: 0.03 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/7. Procedural/Materials/VolumeSphereUnlit.mat.meta b/Assets/7. Procedural/Materials/VolumeSphereUnlit.mat.meta new file mode 100644 index 0000000..8174466 --- /dev/null +++ b/Assets/7. Procedural/Materials/VolumeSphereUnlit.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 62e6b5690f1364b0aa36549dd18607e3 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Scene.meta b/Assets/7. Procedural/Scene.meta new file mode 100644 index 0000000..9fa8a5e --- /dev/null +++ b/Assets/7. Procedural/Scene.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce5c2854b22b4420bbc39f62d4ac362e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Scene/Procedural.unity b/Assets/7. Procedural/Scene/Procedural.unity new file mode 100644 index 0000000..6e66b72 --- /dev/null +++ b/Assets/7. Procedural/Scene/Procedural.unity @@ -0,0 +1,391 @@ +%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: 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: 705507994} + m_IndirectSpecularColor: {r: 0.18388507, g: 0.22887228, b: 0.30218342, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !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_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + 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: 1 + 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 &675524032 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 675524036} + - component: {fileID: 675524035} + - component: {fileID: 675524034} + - component: {fileID: 675524033} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!65 &675524033 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 675524032} + 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!23 &675524034 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 675524032} + 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: 2100000, guid: 57bd04fe4e598a44db03694574686e36, type: 2} + 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 &675524035 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 675524032} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &675524036 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 675524032} + 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!1 &705507993 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 705507995} + - component: {fileID: 705507994} + 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 &705507994 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 0.7662869, g: 0.8501636, b: 0.990566, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.802082 + 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: 1 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 7.06e-43, y: 1.61e-43, z: 0, w: 4.792411e-10} + m_UseBoundingSphereOverride: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &705507995 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 705507993} + m_LocalRotation: {x: 0.5333399, y: 0.75344807, z: -0.050229754, w: 0.38123676} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 28.839, y: 143.51201, z: 60.898003} +--- !u!1 &963194225 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 963194228} + - component: {fileID: 963194227} + - component: {fileID: 963194226} + 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 &963194226 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_Enabled: 1 +--- !u!20 &963194227 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + 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: 0.3 + far clip plane: 1000 + 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: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &963194228 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 963194225} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -2} + 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} diff --git a/Assets/7. Procedural/Scene/Procedural.unity.meta b/Assets/7. Procedural/Scene/Procedural.unity.meta new file mode 100644 index 0000000..952bd1e --- /dev/null +++ b/Assets/7. Procedural/Scene/Procedural.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9fc0d4010bbf28b4594072e72b8655ab +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Shaders.meta b/Assets/7. Procedural/Shaders.meta new file mode 100644 index 0000000..29869a7 --- /dev/null +++ b/Assets/7. Procedural/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2eed5373c6c6647b98323d048f90c532 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Shaders/CloudLit.shader b/Assets/7. Procedural/Shaders/CloudLit.shader new file mode 100644 index 0000000..7e345e5 --- /dev/null +++ b/Assets/7. Procedural/Shaders/CloudLit.shader @@ -0,0 +1,190 @@ +Shader "CloudLit" +{ + +Properties +{ + [Header(Base)] + [Space(10)] + _Color("Color", Color) = (1, 1, 1, 1) + _Absorption("Absorption", Range(0, 100)) = 50 + _Opacity("Opacity", Range(0, 100)) = 50 + [IntRange] _Loop("Loop", Range(0, 128)) = 32 + + [Header(Noise)] + [Space(10)] + _NoiseScale("NoiseScale", Range(0, 100)) = 5 + _Radius("Radius", Range(0, 2)) = 1.0 + + [Header(Light)] + [Space(10)] + _AbsorptionLight("AbsorptionLight", Range(0, 100)) = 50 + _OpacityLight("OpacityLight", Range(0, 100)) = 50 + _LightStepScale("LightStepScale", Range(0, 1)) = 0.5 + [IntRange] _LoopLight("LoopLight", Range(0, 128)) = 6 +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float3 worldPos : TEXCOORD1; +}; + +float4 _Color; +int _Loop; +float _NoiseScale; +float _Radius; +float _Absorption; +float _Opacity; +float _AbsorptionLight; +float _OpacityLight; +int _LoopLight; +float _LightStepScale; +float4 _LightColor0; + +// ref. https://www.shadertoy.com/view/lss3zr +inline float hash(float n) +{ + return frac(sin(n) * 43758.5453); +} + +inline float noise(float3 x) +{ + float3 p = floor(x); + float3 f = frac(x); + f = f * f * (3.0 - 2.0 * f); + float n = p.x + p.y * 57.0 + 113.0 * p.z; + float res = + lerp(lerp(lerp(hash(n + 0.0), hash(n + 1.0), f.x), + lerp(hash(n + 57.0), hash(n + 58.0), f.x), f.y), + lerp(lerp(hash(n + 113.0), hash(n + 114.0), f.x), + lerp(hash(n + 170.0), hash(n + 171.0), f.x), f.y), f.z); + return res; +} + +inline float fbm(float3 p) +{ + float3x3 m = float3x3( + +0.00, +0.80, +0.60, + -0.80, +0.36, -0.48, + -0.60, -0.48, +0.64); + float f = 0.0; + f += 0.5 * noise(p); p = mul(m, p) * 2.02; + f += 0.3 * noise(p); p = mul(m, p) * 2.03; + f += 0.2 * noise(p); + return f; +} + +inline float densityFunction(float3 p) +{ + return fbm(p * _NoiseScale) - length(p / _Radius); +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; + return o; +} + +float4 frag(v2f i) : SV_Target +{ + float step = 1.0 / _Loop; + + float3 worldPos = i.worldPos; + float3 worldDir = normalize(worldPos - _WorldSpaceCameraPos); + + float3 localPos = mul(unity_WorldToObject, float4(worldPos, 1.0)); + float3 localDir = UnityWorldToObjectDir(worldDir); + float3 localStep = localDir * step; + float jitter = hash(localPos.x + localPos.y * 10 + localPos.z * 100 + _Time.x); + localPos += jitter * localStep; + + float lightStep = 1.0 / _LoopLight; + float3 localLightDir = UnityWorldToObjectDir(_WorldSpaceLightPos0.xyz); + float3 localLightStep = localLightDir * lightStep * _LightStepScale; + + float4 color = float4(_Color.rgb, 0.0); + float transmittance = 1.0; + + for (int i = 0; i < _Loop; ++i) + { + float density = densityFunction(localPos); + + if (density > 0.0) + { + float d = density * step; + transmittance *= 1.0 - d * _Absorption; + if (transmittance < 0.01) break; + + float transmittanceLight = 1.0; + float3 lightPos = localPos; + + for (int j = 0; j < _LoopLight; ++j) + { + float densityLight = densityFunction(lightPos); + + if (densityLight > 0.0) + { + float dl = densityLight * lightStep; + transmittanceLight *= 1.0 - dl * _AbsorptionLight; + if (transmittanceLight < 0.01) + { + transmittanceLight = 0.0; + break; + } + } + + lightPos += localLightStep; + } + + color.a += _Color.a * (_Opacity * d * transmittance); + color.rgb += _LightColor0 * (_OpacityLight * d * transmittance * transmittanceLight); + } + + color = clamp(color, 0.0, 1.0); + + localPos += localStep; + + if (!all(max(0.5 - abs(localPos), 0.0))) break; + } + + return color; +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Transparent" + "RenderType" = "Transparent" +} + +Pass +{ + Cull Back + ZWrite Off + Blend SrcAlpha OneMinusSrcAlpha + Lighting Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/7. Procedural/Shaders/CloudLit.shader.meta b/Assets/7. Procedural/Shaders/CloudLit.shader.meta new file mode 100644 index 0000000..ebd6ecb --- /dev/null +++ b/Assets/7. Procedural/Shaders/CloudLit.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 20f15f4ee9c4b4253ad44ef47954b062 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Shaders/CloudLitAnimation.shader b/Assets/7. Procedural/Shaders/CloudLitAnimation.shader new file mode 100644 index 0000000..0c4d8fa --- /dev/null +++ b/Assets/7. Procedural/Shaders/CloudLitAnimation.shader @@ -0,0 +1,213 @@ +Shader "CloudLitAnimation" +{ + +Properties +{ + [Header(Base)] + [Space(10)] + _Color("Color", Color) = (1, 1, 1, 1) + _Absorption("Absorption", Range(0, 100)) = 50 + _Opacity("Opacity", Range(0, 100)) = 50 + [IntRange] _Loop("Loop", Range(0, 128)) = 32 + + [Header(Noise)] + [Space(10)] + _NoiseScale("NoiseScale", Range(0, 100)) = 5 + + [Header(Light)] + [Space(10)] + _AbsorptionLight("AbsorptionLight", Range(0, 100)) = 50 + _OpacityLight("OpacityLight", Range(0, 100)) = 50 + _LightStepScale("LightStepScale", Range(0, 1)) = 0.5 + [IntRange] _LoopLight("LoopLight", Range(0, 128)) = 6 +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float3 worldPos : TEXCOORD1; +}; + +float4 _Color; +int _Loop; +float _NoiseScale; +float _Radius; +float _Absorption; +float _Opacity; +float _AbsorptionLight; +float _OpacityLight; +int _LoopLight; +float _LightStepScale; +float4 _LightColor0; + +// ref. https://www.shadertoy.com/view/lss3zr +inline float hash(float n) +{ + return frac(sin(n) * 43758.5453); +} + +inline float noise(float3 x) +{ + float3 p = floor(x); + float3 f = frac(x); + f = f * f * (3.0 - 2.0 * f); + float n = p.x + p.y * 57.0 + 113.0 * p.z; + float res = + lerp(lerp(lerp(hash(n + 0.0), hash(n + 1.0), f.x), + lerp(hash(n + 57.0), hash(n + 58.0), f.x), f.y), + lerp(lerp(hash(n + 113.0), hash(n + 114.0), f.x), + lerp(hash(n + 170.0), hash(n + 171.0), f.x), f.y), f.z); + return res; +} + +inline float fbm(float3 p) +{ + float3x3 m = float3x3( + +0.00, +0.80, +0.60, + -0.80, +0.36, -0.48, + -0.60, -0.48, +0.64); + float f = 0.0; + f += 0.5 * noise(p); p = mul(m, p) * 2.02; + f += 0.3 * noise(p); p = mul(m, p) * 2.03; + f += 0.2 * noise(p); + return f; +} + +// ref. https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm +inline float sphere(float3 pos, float radius) +{ + return length(pos) - radius; +} + +inline float torus(float3 pos, float2 radius) +{ + float2 r = float2(length(pos.xz) - radius.x, pos.y); + return length(r) - radius.y; +} + +inline float densityFunction(float3 p) +{ + float f = fbm(p * _NoiseScale); + + // 半径 0.2 の急に 0.3 くらいのノイズを混ぜたもの + float d1 = -sphere(p, 0.2) + f * 0.3; + + // 内径 0.36、外径 0.46 のトーラスに 0.2 くらいのノイズを混ぜたもの + float d2 = -torus(p, float2(0.36, 0.1)) + f * 0.2; + + // 2 つのブレンド比率を 0 ~ 1 でなめらかに + float blend = 0.5 + 0.5 * sin(_Time.z); + + // 2 つの密度関数を合成 + return lerp(d1, d2, blend); +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; + return o; +} + +float4 frag(v2f i) : SV_Target +{ + float step = 1.0 / _Loop; + + float3 worldPos = i.worldPos; + float3 worldDir = normalize(worldPos - _WorldSpaceCameraPos); + + float3 localPos = mul(unity_WorldToObject, float4(worldPos, 1.0)); + float3 localDir = UnityWorldToObjectDir(worldDir); + float3 localStep = localDir * step; + float jitter = hash(localPos.x + localPos.y * 10 + localPos.z * 100 + _Time.x); + localPos += jitter * localStep; + + float lightStep = 1.0 / _LoopLight; + float3 localLightDir = UnityWorldToObjectDir(_WorldSpaceLightPos0.xyz); + float3 localLightStep = localLightDir * lightStep * _LightStepScale; + + float4 color = float4(_Color.rgb, 0.0); + float transmittance = 1.0; + + for (int i = 0; i < _Loop; ++i) + { + float density = densityFunction(localPos); + + if (density > 0.0) + { + float d = density * step; + transmittance *= 1.0 - d * _Absorption; + if (transmittance < 0.01) break; + + float transmittanceLight = 1.0; + float3 lightPos = localPos; + + for (int j = 0; j < _LoopLight; ++j) + { + float densityLight = densityFunction(lightPos); + + if (densityLight > 0.0) + { + float dl = densityLight * lightStep; + transmittanceLight *= 1.0 - dl * _AbsorptionLight; + if (transmittanceLight < 0.01) + { + transmittanceLight = 0.0; + break; + } + } + + lightPos += localLightStep; + } + + color.a += _Color.a * (_Opacity * d * transmittance); + color.rgb += _LightColor0 * (_OpacityLight * d * transmittance * transmittanceLight); + } + + color = clamp(color, 0.0, 1.0); + + localPos += localStep; + + if (!all(max(0.5 - abs(localPos), 0.0))) break; + } + + return color; +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Transparent" + "RenderType" = "Transparent" +} + +Pass +{ + Cull Back + ZWrite Off + Blend SrcAlpha OneMinusSrcAlpha + Lighting Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/7. Procedural/Shaders/CloudLitAnimation.shader.meta b/Assets/7. Procedural/Shaders/CloudLitAnimation.shader.meta new file mode 100644 index 0000000..7ba9790 --- /dev/null +++ b/Assets/7. Procedural/Shaders/CloudLitAnimation.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b146580797451cf4c99c314a8238f141 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Shaders/CloudUnlit.shader b/Assets/7. Procedural/Shaders/CloudUnlit.shader new file mode 100644 index 0000000..040f2be --- /dev/null +++ b/Assets/7. Procedural/Shaders/CloudUnlit.shader @@ -0,0 +1,140 @@ +Shader "CloudUnlit" +{ + +Properties +{ + _Color("Color", Color) = (1, 1, 1, 1) + _Intensity("Intensity", Range(0, 1)) = 0.1 + _Loop("Loop", Range(0, 128)) = 32 + _NoiseScale("NoiseScale", Range(0, 100)) = 5 + _Radius("Radius", Range(0, 2)) = 1.0 +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float3 worldPos : TEXCOORD1; +}; + +float4 _Color; +float _Intensity; +int _Loop; +float _NoiseScale; +float _Radius; + +// ref. https://www.shadertoy.com/view/lss3zr +inline float hash(float n) +{ + return frac(sin(n) * 43758.5453); +} + +inline float noise(float3 x) +{ + float3 p = floor(x); + float3 f = frac(x); + f = f * f * (3.0 - 2.0 * f); + float n = p.x + p.y * 57.0 + 113.0 * p.z; + float res = + lerp(lerp(lerp(hash(n + 0.0), hash(n + 1.0), f.x), + lerp(hash(n + 57.0), hash(n + 58.0), f.x), f.y), + lerp(lerp(hash(n + 113.0), hash(n + 114.0), f.x), + lerp(hash(n + 170.0), hash(n + 171.0), f.x), f.y), f.z); + return res; +} + +inline float fbm(float3 p) +{ + float3x3 m = float3x3( + +0.00, +0.80, +0.60, + -0.80, +0.36, -0.48, + -0.60, -0.48, +0.64); + float f = 0.0; + f += 0.5 * noise(p); p = mul(m, p) * 2.02; + f += 0.3 * noise(p); p = mul(m, p) * 2.03; + f += 0.2 * noise(p); + return f; +} + +inline float densityFunction(float3 p) +{ + return fbm(p * _NoiseScale) - length(p / _Radius); +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + return o; +} + +float4 frag(v2f i) : SV_Target +{ + float step = 1.0 / _Loop; + + float3 worldPos = i.worldPos; + float3 worldDir = normalize(worldPos - _WorldSpaceCameraPos); + + float3 localPos = mul(unity_WorldToObject, float4(worldPos, 1.0)); + float3 localDir = UnityWorldToObjectDir(worldDir); + float3 localStep = localDir * step; + float jitter = hash(localPos.x + localPos.y * 10 + localPos.z * 100 + _Time.x); + localPos += jitter * localStep; + + float alpha = 0.0; + + for (int i = 0; i < _Loop; ++i) + { + float density = densityFunction(localPos); + + if (density > 0.001) + { + alpha += (1.0 - alpha) * density * _Intensity; + } + + localPos += localStep; + + if (!all(max(0.5 - abs(localPos), 0.0))) break; + } + + float4 color = _Color; + color.a *= alpha; + return color; +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Transparent" + "RenderType" = "Transparent" +} + +Pass +{ + Cull Back + ZWrite Off + Blend SrcAlpha OneMinusSrcAlpha + Lighting Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/7. Procedural/Shaders/CloudUnlit.shader.meta b/Assets/7. Procedural/Shaders/CloudUnlit.shader.meta new file mode 100644 index 0000000..fb2f923 --- /dev/null +++ b/Assets/7. Procedural/Shaders/CloudUnlit.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 988a3b647c2a34bbe993edce3e2fcd2d +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Shaders/VolumeSphereLit.shader b/Assets/7. Procedural/Shaders/VolumeSphereLit.shader new file mode 100644 index 0000000..0fed914 --- /dev/null +++ b/Assets/7. Procedural/Shaders/VolumeSphereLit.shader @@ -0,0 +1,144 @@ +Shader "VolumeSphereLit"{ + +Properties +{ + [Header(Base)] + [Space(10)] + _Color("Color", Color) = (1, 1, 1, 1) + _Absorption("Absorption", Range(0, 100)) = 50 + _Opacity("Opacity", Range(0, 100)) = 50 + [IntRange] _Loop("Loop", Range(0, 128)) = 32 + + [Header(Light)] + [Space(10)] + _AbsorptionLight("AbsorptionLight", Range(0, 100)) = 50 + _OpacityLight("OpacityLight", Range(0, 100)) = 50 + [IntRange] _LoopLight("LoopLight", Range(0, 128)) = 6 +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float3 worldPos : TEXCOORD1; +}; + +float4 _Color; +float _Absorption; +float _Opacity; +int _Loop; +float _AbsorptionLight; +float _OpacityLight; +int _LoopLight; +float4 _LightColor0; + +inline float densityFunction(float3 p) +{ + return 0.5 - length(p); +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; + return o; +} + +float4 frag(v2f i) : SV_Target +{ + float step = 1.0 / _Loop; + float3 worldPos = i.worldPos; + float3 worldDir = normalize(worldPos - _WorldSpaceCameraPos); + + float3 localPos = mul(unity_WorldToObject, float4(worldPos, 1.0)).xyz; + float3 localDir = UnityWorldToObjectDir(worldDir); + float3 localStep = localDir * step; + + float lightStep = 1.0 / _LoopLight; + float3 localLightDir = UnityWorldToObjectDir(_WorldSpaceLightPos0.xyz); + float3 localLightStep = localLightDir * lightStep * 0.5; + + float4 color = float4(_Color.rgb, 0.0); + float transmittance = 1.0; + + for (int i = 0; i < _Loop; ++i) + { + float density = densityFunction(localPos); + + if (density > 0.0) + { + float d = density * step; + transmittance *= 1.0 - d * _Absorption; + if (transmittance < 0.01) break; + + float transmittanceLight = 1.0; + float3 lightPos = localPos; + + for (int j = 0; j < _LoopLight; ++j) + { + float densityLight = densityFunction(lightPos); + + if (densityLight > 0.0) + { + float dl = densityLight * lightStep; + transmittanceLight *= 1.0 - dl * _AbsorptionLight; + if (transmittanceLight < 0.01) + { + transmittanceLight = 0.0; + break; + } + } + + lightPos += localLightStep; + } + + color.a += _Color.a * (_Opacity * d * transmittance); + color.rgb += _LightColor0 * (_OpacityLight * d * transmittance * transmittanceLight); + } + + localPos += localStep; + + if (!all(max(0.5 - abs(localPos), 0.0))) break; + } + + color.a = min(color.a, 1.0); + + return color; +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Transparent" + "RenderType" = "Transparent" +} + +Pass +{ + Cull Back + ZWrite Off + Blend SrcAlpha OneMinusSrcAlpha + Lighting Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/7. Procedural/Shaders/VolumeSphereLit.shader.meta b/Assets/7. Procedural/Shaders/VolumeSphereLit.shader.meta new file mode 100644 index 0000000..562efaf --- /dev/null +++ b/Assets/7. Procedural/Shaders/VolumeSphereLit.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 94c8551aedb81c147998d08458877092 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/7. Procedural/Shaders/VolumeSphereUnlit.shader b/Assets/7. Procedural/Shaders/VolumeSphereUnlit.shader new file mode 100644 index 0000000..7bde56f --- /dev/null +++ b/Assets/7. Procedural/Shaders/VolumeSphereUnlit.shader @@ -0,0 +1,111 @@ +Shader "VolumeSphere" +{ + +Properties +{ + _Color("Color", Color) = (1, 1, 1, 1) + _Intensity("Intensity", Range(0, 1)) = 0.1 + _Loop("Loop", Range(0, 128)) = 32 +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float3 worldPos : TEXCOORD1; +}; + +float4 _Color; +float _Intensity; +int _Loop; + +inline float densityFunction(float3 p) +{ + return 0.5 - length(p); +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + // ポリゴン表面の座標がフラグメントシェーダで使えるようにする + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + return o; +} + +float4 frag(v2f i) : SV_Target +{ + // ワールド空間でのポリゴン表面座標とそこへのカメラからの向き + float3 worldPos = i.worldPos; + float3 worldDir = normalize(worldPos - _WorldSpaceCameraPos); + + // オブジェクト空間に変換 + float3 localPos = mul(unity_WorldToObject, float4(worldPos, 1.0)); + float3 localDir = UnityWorldToObjectDir(worldDir); + + // オブジェクト空間でのレイのステップ長 + float step = 1.0 / _Loop; + float3 localStep = localDir * step; + + // レイを通過させて得られる透過率 + float alpha = 0.0; + + for (int i = 0; i < _Loop; ++i) + { + // ポリゴン中心ほど大きな値が返ってくる + float density = densityFunction(localPos); + + // 球の外側ではマイナスの値が返ってくるのでそれを弾く + if (density > 0.001) + { + // 透過率の足し合わせ + alpha += (1.0 - alpha) * density * _Intensity; + } + + // ステップを進める + localPos += localStep; + + // ポリゴンの外に出たら終わり + if (!all(max(0.5 - abs(localPos), 0.0))) break; + } + + float4 color = _Color; + color.a *= alpha; + return color; +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Transparent" + "RenderType" = "Transparent" +} + +Pass +{ + Cull Back + ZWrite Off + Blend SrcAlpha OneMinusSrcAlpha + Lighting Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/7. Procedural/Shaders/VolumeSphereUnlit.shader.meta b/Assets/7. Procedural/Shaders/VolumeSphereUnlit.shader.meta new file mode 100644 index 0000000..6af4fa5 --- /dev/null +++ b/Assets/7. Procedural/Shaders/VolumeSphereUnlit.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d0b0b3112bd104e16869785b53fee030 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/8. AABB Intersection 2.meta b/Assets/8. AABB Intersection 2.meta new file mode 100644 index 0000000..7a9071a --- /dev/null +++ b/Assets/8. AABB Intersection 2.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e781f2fe6f4c031459cce3343ded661b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/8. AABB Intersection 2/Materials.meta b/Assets/8. AABB Intersection 2/Materials.meta new file mode 100644 index 0000000..fcce886 --- /dev/null +++ b/Assets/8. AABB Intersection 2/Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ff654f9e1924f0b48a9fa43e2fdce0c6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/8. AABB Intersection 2/Materials/CloudLitOptimized.mat b/Assets/8. AABB Intersection 2/Materials/CloudLitOptimized.mat new file mode 100644 index 0000000..3e7ce4f --- /dev/null +++ b/Assets/8. AABB Intersection 2/Materials/CloudLitOptimized.mat @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: CloudLitOptimized + m_Shader: {fileID: 4800000, guid: f078f65ad6188a14da93219e2edd3aba, type: 3} + m_ShaderKeywords: DEBUG_RENDER_LOOP + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: [] + m_Floats: + - _Absorption: 64.3 + - _AbsorptionLight: 18.6 + - _DEBUG_RENDER_LOOP: 0 + - _DebugRenderLoop: 1 + - _LightStepScale: 0.5 + - _LoopLight: 6 + - _NoiseScale: 10 + - _Opacity: 100 + - _OpacityLight: 84 + - _Radius: 0.7 + - _Step: 0.03 + m_Colors: + - _Color: {r: 0.75471693, g: 0.75471693, b: 0.75471693, a: 1} diff --git a/Assets/8. AABB Intersection 2/Materials/CloudLitOptimized.mat.meta b/Assets/8. AABB Intersection 2/Materials/CloudLitOptimized.mat.meta new file mode 100644 index 0000000..c1698c7 --- /dev/null +++ b/Assets/8. AABB Intersection 2/Materials/CloudLitOptimized.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d7172bd4f6200304eb2962fce6e70211 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/8. AABB Intersection 2/Materials/Intersection.mat b/Assets/8. AABB Intersection 2/Materials/Intersection.mat new file mode 100644 index 0000000..5d5ab0d --- /dev/null +++ b/Assets/8. AABB Intersection 2/Materials/Intersection.mat @@ -0,0 +1,25 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Intersection + m_Shader: {fileID: 4800000, guid: 10b7c592d54452f4fb8658acc68ff8ff, 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: + - _Intensity: 0.1 + - _Step: 0.03 + m_Colors: [] diff --git a/Assets/8. AABB Intersection 2/Materials/Intersection.mat.meta b/Assets/8. AABB Intersection 2/Materials/Intersection.mat.meta new file mode 100644 index 0000000..ea0fd53 --- /dev/null +++ b/Assets/8. AABB Intersection 2/Materials/Intersection.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4848b0184fc295145ab3fae000b07d09 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/8. AABB Intersection 2/Scene.meta b/Assets/8. AABB Intersection 2/Scene.meta new file mode 100644 index 0000000..c9401f9 --- /dev/null +++ b/Assets/8. AABB Intersection 2/Scene.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b8d81fdbd6523784385f1d8a527edc40 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/8. AABB Intersection 2/Scene/Intersection.unity b/Assets/8. AABB Intersection 2/Scene/Intersection.unity new file mode 100644 index 0000000..b578624 --- /dev/null +++ b/Assets/8. AABB Intersection 2/Scene/Intersection.unity @@ -0,0 +1,484 @@ +%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: 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, g: 0, b: 0, 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: 0 + 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: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + 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 &123940816 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 123940820} + - component: {fileID: 123940819} + - component: {fileID: 123940818} + - component: {fileID: 123940817} + m_Layer: 0 + m_Name: Cube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!65 &123940817 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 123940816} + 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!23 &123940818 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 123940816} + 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: 2100000, guid: 4848b0184fc295145ab3fae000b07d09, type: 2} + 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 &123940819 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 123940816} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &123940820 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 123940816} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: -1, z: 0} + 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!1 &476719027 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 476719031} + - component: {fileID: 476719030} + - component: {fileID: 476719029} + - component: {fileID: 476719028} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!65 &476719028 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 476719027} + 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!23 &476719029 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 476719027} + 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: 2100000, guid: d7172bd4f6200304eb2962fce6e70211, type: 2} + 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 &476719030 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 476719027} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &476719031 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 476719027} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0.5, 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!1 &659941111 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 659941114} + - component: {fileID: 659941113} + - component: {fileID: 659941112} + 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 &659941112 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 659941111} + m_Enabled: 1 +--- !u!20 &659941113 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 659941111} + 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: 0.3 + far clip plane: 1000 + 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: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &659941114 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 659941111} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + 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 &1164371242 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1164371244} + - component: {fileID: 1164371243} + 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 &1164371243 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164371242} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 0.8392157, g: 0.94564813, b: 1, a: 1} + m_Intensity: 1 + 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 &1164371244 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164371242} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0.02, y: 0.91, z: -0.03} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} diff --git a/Assets/8. AABB Intersection 2/Scene/Intersection.unity.meta b/Assets/8. AABB Intersection 2/Scene/Intersection.unity.meta new file mode 100644 index 0000000..a62aa88 --- /dev/null +++ b/Assets/8. AABB Intersection 2/Scene/Intersection.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0272da01d89fa2f4a82ce06131ffe9b9 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/8. AABB Intersection 2/Shaders.meta b/Assets/8. AABB Intersection 2/Shaders.meta new file mode 100644 index 0000000..9183217 --- /dev/null +++ b/Assets/8. AABB Intersection 2/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 241d6ee2e2118ff4983362d11969e3ba +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/8. AABB Intersection 2/Shaders/CloudLitOptimized.shader b/Assets/8. AABB Intersection 2/Shaders/CloudLitOptimized.shader new file mode 100644 index 0000000..99c259d --- /dev/null +++ b/Assets/8. AABB Intersection 2/Shaders/CloudLitOptimized.shader @@ -0,0 +1,210 @@ +Shader "CloudLitOptimized" +{ + +Properties +{ + [Header(Base)] + [Space(10)] + _Color("Color", Color) = (1, 1, 1, 1) + _Absorption("Absorption", Range(0, 100)) = 50 + _Opacity("Opacity", Range(0, 100)) = 50 + [PowerSlider(10.0)] _Step("Step", Range(0.001, 0.1)) = 0.03 + + [Header(Noise)] + [Space(10)] + _NoiseScale("NoiseScale", Range(0, 100)) = 5 + _Radius("Radius", Range(0, 2)) = 1.0 + + [Header(Light)] + [Space(10)] + _AbsorptionLight("AbsorptionLight", Range(0, 100)) = 50 + _OpacityLight("OpacityLight", Range(0, 100)) = 50 + _LightStepScale("LightStepScale", Range(0, 1)) = 0.5 + [IntRange] _LoopLight("LoopLight", Range(0, 128)) = 6 + + [Header(Optimize)] + [Toggle] _DEBUG_RENDER_LOOP("DebugRenderLoop", Float) = 0 +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float3 worldPos : TEXCOORD1; +}; + +float4 _Color; +float _Step; +float _NoiseScale; +float _Radius; +float _Absorption; +float _Opacity; +float _AbsorptionLight; +float _OpacityLight; +int _LoopLight; +float _LightStepScale; +float4 _LightColor0; + +// ref. https://www.shadertoy.com/view/lss3zr +inline float hash(float n) +{ + return frac(sin(n) * 43758.5453); +} + +inline float noise(float3 x) +{ + float3 p = floor(x); + float3 f = frac(x); + f = f * f * (3.0 - 2.0 * f); + float n = p.x + p.y * 57.0 + 113.0 * p.z; + float res = + lerp(lerp(lerp(hash(n + 0.0), hash(n + 1.0), f.x), + lerp(hash(n + 57.0), hash(n + 58.0), f.x), f.y), + lerp(lerp(hash(n + 113.0), hash(n + 114.0), f.x), + lerp(hash(n + 170.0), hash(n + 171.0), f.x), f.y), f.z); + return res; +} + +inline float fbm(float3 p) +{ + float3x3 m = float3x3( + +0.00, +0.80, +0.60, + -0.80, +0.36, -0.48, + -0.60, -0.48, +0.64); + float f = 0.0; + f += 0.5 * noise(p); p = mul(m, p) * 2.02; + f += 0.3 * noise(p); p = mul(m, p) * 2.03; + f += 0.2 * noise(p); + return f; +} + +inline float densityFunction(float3 p) +{ + return fbm(p * _NoiseScale) - length(p / _Radius); +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; + return o; +} + +float4 frag(v2f i) : SV_Target +{ + float3 worldPos = i.worldPos; + float3 worldDir = normalize(worldPos - _WorldSpaceCameraPos); + + float3 localPos = mul(unity_WorldToObject, float4(worldPos, 1.0)); + float3 localDir = UnityWorldToObjectDir(worldDir); + float3 localStep = localDir * _Step; + float jitter = hash(localPos.x + localPos.y * 10 + localPos.z * 100 + _Time.x); + localPos += jitter * localStep; + + float3 invLocalDir = 1.0 / localDir; + float3 t1 = (-0.5 - localPos) * invLocalDir; + float3 t2 = (+0.5 - localPos) * invLocalDir; + float3 tmax3 = max(t1, t2); + float2 tmax2 = min(tmax3.xx, tmax3.yz); + float traverseDist = min(tmax2.x, tmax2.y); + int loop = floor(traverseDist / _Step); + + float lightStep = 1.0 / _LoopLight; + float3 localLightDir = UnityWorldToObjectDir(_WorldSpaceLightPos0.xyz); + float3 localLightStep = localLightDir * lightStep * _LightStepScale; + + float4 color = float4(_Color.rgb, 0.0); + float transmittance = 1.0; + +#ifdef _DEBUG_RENDER_LOOP_ON + int n = 0; +#endif + + for (int i = 0; i < loop; ++i) + { + float density = densityFunction(localPos); + + if (density > 0.0) + { + float d = density * _Step; + transmittance *= 1.0 - d * _Absorption; + if (transmittance < 0.01) break; + + float transmittanceLight = 1.0; + float3 lightPos = localPos; + + for (int j = 0; j < _LoopLight; ++j) + { + float densityLight = densityFunction(lightPos); + + if (densityLight > 0.0) + { + float dl = densityLight * lightStep; + transmittanceLight *= 1.0 - dl * _AbsorptionLight; + if (transmittanceLight < 0.01) + { + transmittanceLight = 0.0; + break; + } + } + + lightPos += localLightStep; + } + + color.a += _Color.a * (_Opacity * d * transmittance); + color.rgb += _LightColor0 * (_OpacityLight * d * transmittance * transmittanceLight); + } + + color = clamp(color, 0.0, 1.0); + + localPos += localStep; + +#ifdef _DEBUG_RENDER_LOOP_ON + ++n; +#endif + } + +#ifdef _DEBUG_RENDER_LOOP_ON + return float4(n * _Step, 0.0, 0.0, 1.0); +#else + return color; +#endif +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Transparent" + "RenderType" = "Transparent" +} + +Pass +{ + Cull Back + ZWrite Off + Blend SrcAlpha OneMinusSrcAlpha + Lighting Off + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + #pragma shader_feature _DEBUG_RENDER_LOOP_ON + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/8. AABB Intersection 2/Shaders/CloudLitOptimized.shader.meta b/Assets/8. AABB Intersection 2/Shaders/CloudLitOptimized.shader.meta new file mode 100644 index 0000000..c6301eb --- /dev/null +++ b/Assets/8. AABB Intersection 2/Shaders/CloudLitOptimized.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f078f65ad6188a14da93219e2edd3aba +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/8. AABB Intersection 2/Shaders/Intersection.shader b/Assets/8. AABB Intersection 2/Shaders/Intersection.shader new file mode 100644 index 0000000..3a91168 --- /dev/null +++ b/Assets/8. AABB Intersection 2/Shaders/Intersection.shader @@ -0,0 +1,80 @@ +Shader "Intersection" +{ + +Properties +{ +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float3 worldPos : TEXCOORD1; +}; + +float4 _Color; +float _Step; + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex); + return o; +} + +float4 frag(v2f i) : SV_Target +{ + // ワールド空間でのポリゴン表面座標とそこへのカメラからの向き + float3 worldPos = i.worldPos; + float3 worldDir = normalize(worldPos - _WorldSpaceCameraPos); + + // オブジェクト空間に変換 + float3 localPos = mul(unity_WorldToObject, float4(worldPos, 1.0)); + float3 localDir = UnityWorldToObjectDir(worldDir); + + // レイが突き抜けるまでの長さ + float3 invLocalDir = 1.0 / localDir; + float3 t1 = (-0.5 - localPos) * invLocalDir; + float3 t2 = (+0.5 - localPos) * invLocalDir; + float3 tmax3 = max(t1, t2); + float2 tmax2 = min(tmax3.xx, tmax3.yz); + float traverseDist = min(tmax2.x, tmax2.y); + + // 0 ~ 1 で赤、1 ~ で黄色になるように調整 + float f = frac(traverseDist); + float r = min(traverseDist, 1.0); + float g = max(traverseDist - r, 0.0); + return float4(r, g, 0.0, 1.0); +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Geometry" + "RenderType" = "Opaque" +} + +Pass +{ + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/8. AABB Intersection 2/Shaders/Intersection.shader.meta b/Assets/8. AABB Intersection 2/Shaders/Intersection.shader.meta new file mode 100644 index 0000000..130e7ee --- /dev/null +++ b/Assets/8. AABB Intersection 2/Shaders/Intersection.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 10b7c592d54452f4fb8658acc68ff8ff +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/9. Occlusion.meta b/Assets/9. Occlusion.meta new file mode 100644 index 0000000..9e86045 --- /dev/null +++ b/Assets/9. Occlusion.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9cb91604b1d69a345a9ff8acc189fb1a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/9. Occlusion/Materials.meta b/Assets/9. Occlusion/Materials.meta new file mode 100644 index 0000000..ac50b69 --- /dev/null +++ b/Assets/9. Occlusion/Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 13a99ec38528c5f43a68f6712698245f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/9. Occlusion/Materials/CloudLitOccluded.mat b/Assets/9. Occlusion/Materials/CloudLitOccluded.mat new file mode 100644 index 0000000..779b305 --- /dev/null +++ b/Assets/9. Occlusion/Materials/CloudLitOccluded.mat @@ -0,0 +1,33 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: CloudLitOccluded + m_Shader: {fileID: 4800000, guid: 0b6f520dfec2c454b91dc9989850c398, type: 3} + m_ShaderKeywords: DEBUG_RENDER_LOOP + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: [] + m_Floats: + - _Absorption: 46.9 + - _AbsorptionLight: 18.6 + - _LightStepScale: 0.5 + - _LoopLight: 6 + - _NoiseScale: 10 + - _Opacity: 100 + - _OpacityLight: 84 + - _Radius: 0.7 + - _Step: 0.03 + m_Colors: + - _Color: {r: 0.75471693, g: 0.75471693, b: 0.75471693, a: 1} diff --git a/Assets/9. Occlusion/Materials/CloudLitOccluded.mat.meta b/Assets/9. Occlusion/Materials/CloudLitOccluded.mat.meta new file mode 100644 index 0000000..7e8226d --- /dev/null +++ b/Assets/9. Occlusion/Materials/CloudLitOccluded.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7ed119f7ee7ae394aa796b1b37b1a979 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/9. Occlusion/Scene.meta b/Assets/9. Occlusion/Scene.meta new file mode 100644 index 0000000..fb24014 --- /dev/null +++ b/Assets/9. Occlusion/Scene.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fc78b861adb1e234688226438b233a83 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/9. Occlusion/Scene/Occlusion.unity b/Assets/9. Occlusion/Scene/Occlusion.unity new file mode 100644 index 0000000..20a9717 --- /dev/null +++ b/Assets/9. Occlusion/Scene/Occlusion.unity @@ -0,0 +1,470 @@ +%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: 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, g: 0, b: 0, 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: 0 + 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: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + 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 &476719027 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 476719031} + - component: {fileID: 476719030} + - component: {fileID: 476719029} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &476719029 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 476719027} + 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: 2100000, guid: 7ed119f7ee7ae394aa796b1b37b1a979, type: 2} + 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 &476719030 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 476719027} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &476719031 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 476719027} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.099, 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!1 &659941111 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 659941114} + - component: {fileID: 659941113} + - component: {fileID: 659941112} + 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 &659941112 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 659941111} + m_Enabled: 1 +--- !u!20 &659941113 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 659941111} + 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: 0.3 + far clip plane: 1000 + 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: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &659941114 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 659941111} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -1} + 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 &1164371242 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1164371244} + - component: {fileID: 1164371243} + 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 &1164371243 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164371242} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 0.8392157, g: 0.94564813, b: 1, a: 1} + m_Intensity: 1 + 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 &1164371244 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1164371242} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 1, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1593848653 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1593848657} + - component: {fileID: 1593848656} + - component: {fileID: 1593848655} + - component: {fileID: 1593848654} + m_Layer: 0 + m_Name: Sphere + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!135 &1593848654 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1593848653} + 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 &1593848655 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1593848653} + 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 &1593848656 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1593848653} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1593848657 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1593848653} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.187, y: 0, z: 0} + 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} diff --git a/Assets/9. Occlusion/Scene/Occlusion.unity.meta b/Assets/9. Occlusion/Scene/Occlusion.unity.meta new file mode 100644 index 0000000..143b959 --- /dev/null +++ b/Assets/9. Occlusion/Scene/Occlusion.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f7e25b40f0fc6df45a52b8690581a375 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/9. Occlusion/Shaders.meta b/Assets/9. Occlusion/Shaders.meta new file mode 100644 index 0000000..4526c32 --- /dev/null +++ b/Assets/9. Occlusion/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 378919ce8f12d4d4ca96d23ef3340206 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/9. Occlusion/Shaders/CloudLitOccluded.shader b/Assets/9. Occlusion/Shaders/CloudLitOccluded.shader new file mode 100644 index 0000000..3523d55 --- /dev/null +++ b/Assets/9. Occlusion/Shaders/CloudLitOccluded.shader @@ -0,0 +1,221 @@ +Shader "CloudLitOccluded" +{ + +Properties +{ + [Header(Base)] + [Space(10)] + _Color("Color", Color) = (1, 1, 1, 1) + _Absorption("Absorption", Range(0, 100)) = 50 + _Opacity("Opacity", Range(0, 100)) = 50 + [PowerSlider(10.0)] _Step("Step", Range(0.001, 0.1)) = 0.03 + + [Header(Noise)] + [Space(10)] + _NoiseScale("NoiseScale", Range(0, 100)) = 5 + _Radius("Radius", Range(0, 2)) = 1.0 + + [Header(Light)] + [Space(10)] + _AbsorptionLight("AbsorptionLight", Range(0, 100)) = 50 + _OpacityLight("OpacityLight", Range(0, 100)) = 50 + _LightStepScale("LightStepScale", Range(0, 1)) = 0.5 + [IntRange] _LoopLight("LoopLight", Range(0, 128)) = 6 +} + +CGINCLUDE + +#include "UnityCG.cginc" + +struct appdata +{ + float4 vertex : POSITION; +}; + +struct v2f +{ + float4 vertex : SV_POSITION; + float3 worldPos : TEXCOORD1; + float4 projPos : TEXCOORD2; +}; + +float4 _Color; +float _Step; +float _NoiseScale; +float _Radius; +float _Absorption; +float _Opacity; +float _AbsorptionLight; +float _OpacityLight; +int _LoopLight; +float _LightStepScale; +float4 _LightColor0; +UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture); + +// ref. https://www.shadertoy.com/view/lss3zr +inline float hash(float n) +{ + return frac(sin(n) * 43758.5453); +} + +inline float noise(float3 x) +{ + float3 p = floor(x); + float3 f = frac(x); + f = f * f * (3.0 - 2.0 * f); + float n = p.x + p.y * 57.0 + 113.0 * p.z; + float res = + lerp(lerp(lerp(hash(n + 0.0), hash(n + 1.0), f.x), + lerp(hash(n + 57.0), hash(n + 58.0), f.x), f.y), + lerp(lerp(hash(n + 113.0), hash(n + 114.0), f.x), + lerp(hash(n + 170.0), hash(n + 171.0), f.x), f.y), f.z); + return res; +} + +inline float fbm(float3 p) +{ + float3x3 m = float3x3( + +0.00, +0.80, +0.60, + -0.80, +0.36, -0.48, + -0.60, -0.48, +0.64); + float f = 0.0; + f += 0.5 * noise(p); p = mul(m, p) * 2.02; + f += 0.3 * noise(p); p = mul(m, p) * 2.03; + f += 0.2 * noise(p); + return f; +} + +inline float densityFunction(float3 p) +{ + return fbm(p * _NoiseScale) - length(p / _Radius); +} + +v2f vert(appdata v) +{ + v2f o; + o.vertex = UnityObjectToClipPos(v.vertex); + o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; + o.projPos = ComputeScreenPos(o.vertex); + COMPUTE_EYEDEPTH(o.projPos.z); + return o; +} + +void sample( + float3 pos, + float step, + float lightStep, + inout float4 color, + inout float transmittance) +{ + float density = densityFunction(pos); + if (density < 0.0) return; + + float d = density * step; + transmittance *= 1.0 - d * _Absorption; + if (transmittance < 0.01) return; + + float transmittanceLight = 1.0; + float3 lightPos = pos; + for (int j = 0; j < _LoopLight; ++j) + { + float densityLight = densityFunction(lightPos); + if (densityLight > 0.0) + { + float dl = densityLight * lightStep; + transmittanceLight *= 1.0 - dl * _AbsorptionLight; + if (transmittanceLight < 0.01) + { + transmittanceLight = 0.0; + break; + } + } + lightPos += lightStep; + } + + color.a += _Color.a * (_Opacity * d * transmittance); + color.rgb += _LightColor0 * (_OpacityLight * d * transmittance * transmittanceLight); + color = clamp(color, 0.0, 1.0); +} + +float4 frag(v2f i) : SV_Target +{ + float3 worldPos = i.worldPos; + float3 camToWorldPos = worldPos - _WorldSpaceCameraPos; + float3 worldDir = normalize(camToWorldPos); + + float3 localPos = mul(unity_WorldToObject, float4(worldPos, 1.0)); + float3 localDir = UnityWorldToObjectDir(worldDir); + float3 localStep = localDir * _Step; + localPos += (_Step - fmod(length(UnityWorldToObjectDir(camToWorldPos)), _Step)) * localDir; + float jitter = hash(localPos.x + localPos.y * 1000 + localPos.z * 10000 + _Time.x); + localPos += jitter * localStep; + + float3 invLocalDir = 1.0 / localDir; + float3 t1 = (-0.5 - localPos) * invLocalDir; + float3 t2 = (+0.5 - localPos) * invLocalDir; + float3 tmax3 = max(t1, t2); + float2 tmax2 = min(tmax3.xx, tmax3.yz); + float traverseDist = min(tmax2.x, tmax2.y); + int loop = floor(traverseDist / _Step); + + float lightStep = 1.0 / _LoopLight; + float3 localLightDir = UnityWorldToObjectDir(_WorldSpaceLightPos0.xyz); + float3 localLightStep = localLightDir * lightStep * _LightStepScale; + + float depth = LinearEyeDepth( + SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos))); + float3 cameraForward = -UNITY_MATRIX_V[2].xyz; + float cameraToDepth = depth / dot(worldDir, cameraForward); + float cameraToStart = length(worldPos - _WorldSpaceCameraPos); + float maxLen = cameraToDepth - cameraToStart; + float len = 0.f; + + float4 color = float4(_Color.rgb, 0.0); + float transmittance = 1.0; + + for (int i = 0; i < loop; ++i) + { + sample(localPos, _Step, lightStep, color, transmittance); + + len += _Step; + if (len > maxLen) break; + + localPos += localStep; + } + + if (len > maxLen) + { + float step = maxLen - (len - _Step); + localPos += step * localDir; + sample(localPos, step, lightStep, color, transmittance); + } + + return color; +} + +ENDCG + +SubShader +{ + +Tags +{ + "Queue" = "Transparent" + "RenderType" = "Transparent" +} + +Pass +{ + Cull Back + ZWrite Off + Blend SrcAlpha OneMinusSrcAlpha + + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + ENDCG +} + +} + +} \ No newline at end of file diff --git a/Assets/9. Occlusion/Shaders/CloudLitOccluded.shader.meta b/Assets/9. Occlusion/Shaders/CloudLitOccluded.shader.meta new file mode 100644 index 0000000..0ed2a80 --- /dev/null +++ b/Assets/9. Occlusion/Shaders/CloudLitOccluded.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0b6f520dfec2c454b91dc9989850c398 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts.meta b/Assets/Scripts.meta new file mode 100644 index 0000000..8b57c7f --- /dev/null +++ b/Assets/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bd54dc83b03c74d49b2366727885ff4c +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/load_setting.cs b/Assets/Scripts/load_setting.cs new file mode 100644 index 0000000..df3ebe6 --- /dev/null +++ b/Assets/Scripts/load_setting.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; + +using UnityEngine; + +[System.Serializable] +public class Setting +{ + public float x_scale; + public float y_scale; + public float z_scale; +} + +public class load_setting : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/Scripts/load_setting.cs.meta b/Assets/Scripts/load_setting.cs.meta new file mode 100644 index 0000000..f1603da --- /dev/null +++ b/Assets/Scripts/load_setting.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ade87100a2e14fa4e818d9571b0aff1b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/scaled_3dsyokudo.raw.meta b/Assets/scaled_3dsyokudo.raw.meta new file mode 100644 index 0000000..19f6f28 --- /dev/null +++ b/Assets/scaled_3dsyokudo.raw.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: 80f16738f0b5e9746b561e00c932c152 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 4076eb95b581041b5bb78255c2b05ea4, type: 3} + width: 512 + height: 512 + depth: 121 + bit: 2 + smooth: 2 diff --git a/Assets/scaled_3dsyokudo2.raw.meta b/Assets/scaled_3dsyokudo2.raw.meta new file mode 100644 index 0000000..702ebdd --- /dev/null +++ b/Assets/scaled_3dsyokudo2.raw.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: f2573a9deb19ec947aa0c8521b2ff5bf +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 4076eb95b581041b5bb78255c2b05ea4, type: 3} + width: 512 + height: 512 + depth: 121 + bit: 2 + smooth: 2 diff --git a/Assets/scaled_3dsyokudo_sukunai.raw.meta b/Assets/scaled_3dsyokudo_sukunai.raw.meta new file mode 100644 index 0000000..7dbb0d2 --- /dev/null +++ b/Assets/scaled_3dsyokudo_sukunai.raw.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: fde1733cb0568314489ecd9a39dde6af +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 4076eb95b581041b5bb78255c2b05ea4, type: 3} + width: 512 + height: 512 + depth: 117 + bit: 2 + smooth: 2 diff --git a/Assets/setting.json b/Assets/setting.json new file mode 100644 index 0000000..df75825 --- /dev/null +++ b/Assets/setting.json @@ -0,0 +1,5 @@ +{ + "x_scale": 340.48, + "y_scale": 340.48, + "z_scale": 605.0 +} \ No newline at end of file diff --git a/Assets/setting.json.meta b/Assets/setting.json.meta new file mode 100644 index 0000000..343a879 --- /dev/null +++ b/Assets/setting.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4ebb4bbebfeb75b489fa4f7da17c6a8f +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/manifest.json b/Packages/manifest.json new file mode 100644 index 0000000..328f2e1 --- /dev/null +++ b/Packages/manifest.json @@ -0,0 +1,49 @@ +{ + "dependencies": { + "com.unity.2d.sprite": "1.0.0", + "com.unity.2d.tilemap": "1.0.0", + "com.unity.ads": "3.4.4", + "com.unity.analytics": "3.3.5", + "com.unity.collab-proxy": "1.2.16", + "com.unity.ide.rider": "1.1.4", + "com.unity.ide.vscode": "1.1.4", + "com.unity.multiplayer-hlapi": "1.0.4", + "com.unity.purchasing": "2.0.6", + "com.unity.test-framework": "1.1.13", + "com.unity.textmeshpro": "2.0.1", + "com.unity.timeline": "1.2.10", + "com.unity.ugui": "1.0.0", + "com.unity.xr.legacyinputhelpers": "1.3.11", + "com.unity.modules.ai": "1.0.0", + "com.unity.modules.androidjni": "1.0.0", + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.cloth": "1.0.0", + "com.unity.modules.director": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.physics2d": "1.0.0", + "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.terrain": "1.0.0", + "com.unity.modules.terrainphysics": "1.0.0", + "com.unity.modules.tilemap": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.uielements": "1.0.0", + "com.unity.modules.umbra": "1.0.0", + "com.unity.modules.unityanalytics": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.unitywebrequesttexture": "1.0.0", + "com.unity.modules.unitywebrequestwww": "1.0.0", + "com.unity.modules.vehicles": "1.0.0", + "com.unity.modules.video": "1.0.0", + "com.unity.modules.vr": "1.0.0", + "com.unity.modules.wind": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } +} diff --git a/ProjectSettings/AudioManager.asset b/ProjectSettings/AudioManager.asset new file mode 100644 index 0000000..da61125 --- /dev/null +++ b/ProjectSettings/AudioManager.asset @@ -0,0 +1,17 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!11 &1 +AudioManager: + m_ObjectHideFlags: 0 + m_Volume: 1 + Rolloff Scale: 1 + Doppler Factor: 1 + Default Speaker Mode: 2 + m_SampleRate: 0 + m_DSPBufferSize: 0 + m_VirtualVoiceCount: 512 + m_RealVoiceCount: 32 + m_SpatializerPlugin: + m_AmbisonicDecoderPlugin: + m_DisableAudio: 0 + m_VirtualizeEffects: 1 diff --git a/ProjectSettings/ClusterInputManager.asset b/ProjectSettings/ClusterInputManager.asset new file mode 100644 index 0000000..e7886b2 --- /dev/null +++ b/ProjectSettings/ClusterInputManager.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!236 &1 +ClusterInputManager: + m_ObjectHideFlags: 0 + m_Inputs: [] diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset new file mode 100644 index 0000000..78992f0 --- /dev/null +++ b/ProjectSettings/DynamicsManager.asset @@ -0,0 +1,29 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!55 &1 +PhysicsManager: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_Gravity: {x: 0, y: -9.81, z: 0} + m_DefaultMaterial: {fileID: 0} + m_BounceThreshold: 2 + m_SleepThreshold: 0.005 + m_DefaultContactOffset: 0.01 + m_DefaultSolverIterations: 6 + m_DefaultSolverVelocityIterations: 1 + m_QueriesHitBackfaces: 0 + m_QueriesHitTriggers: 1 + m_EnableAdaptiveForce: 0 + m_ClothInterCollisionDistance: 0 + m_ClothInterCollisionStiffness: 0 + m_ContactsGeneration: 1 + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + m_AutoSimulation: 1 + m_AutoSyncTransforms: 1 + m_ClothInterCollisionSettingsToggle: 0 + m_ContactPairsMode: 0 + m_BroadphaseType: 0 + m_WorldBounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 250, y: 250, z: 250} + m_WorldSubdivisions: 8 diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset new file mode 100644 index 0000000..6dc24f7 --- /dev/null +++ b/ProjectSettings/EditorBuildSettings.asset @@ -0,0 +1,7 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1045 &1 +EditorBuildSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Scenes: [] diff --git a/ProjectSettings/EditorSettings.asset b/ProjectSettings/EditorSettings.asset new file mode 100644 index 0000000..2b70aa7 --- /dev/null +++ b/ProjectSettings/EditorSettings.asset @@ -0,0 +1,35 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!159 &1 +EditorSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_ExternalVersionControlSupport: Hidden Meta Files + m_SerializationMode: 2 + m_LineEndingsForNewScripts: 1 + m_DefaultBehaviorMode: 0 + m_PrefabRegularEnvironment: {fileID: 0} + m_PrefabUIEnvironment: {fileID: 0} + m_SpritePackerMode: 0 + m_SpritePackerPaddingPower: 1 + m_EtcTextureCompressorBehavior: 1 + m_EtcTextureFastCompressor: 1 + m_EtcTextureNormalCompressor: 2 + m_EtcTextureBestCompressor: 4 + m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref + m_ProjectGenerationRootNamespace: + m_CollabEditorSettings: + inProgressEnabled: 1 + m_EnableTextureStreamingInEditMode: 1 + m_EnableTextureStreamingInPlayMode: 1 + m_AsyncShaderCompilation: 1 + m_EnterPlayModeOptionsEnabled: 0 + m_EnterPlayModeOptions: 3 + m_ShowLightmapResolutionOverlay: 1 + m_UseLegacyProbeSampleCount: 1 + m_AssetPipelineMode: 1 + m_CacheServerMode: 0 + m_CacheServerEndpoint: + m_CacheServerNamespacePrefix: default + m_CacheServerEnableDownload: 1 + m_CacheServerEnableUpload: 1 diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset new file mode 100644 index 0000000..74d7b53 --- /dev/null +++ b/ProjectSettings/GraphicsSettings.asset @@ -0,0 +1,61 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!30 &1 +GraphicsSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_Deferred: + m_Mode: 1 + m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} + m_DeferredReflections: + m_Mode: 1 + m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} + m_ScreenSpaceShadows: + m_Mode: 1 + m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} + m_LegacyDeferred: + m_Mode: 1 + m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} + m_DepthNormals: + m_Mode: 1 + m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} + m_MotionVectors: + m_Mode: 1 + m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} + m_LightHalo: + m_Mode: 1 + m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} + m_LensFlare: + m_Mode: 1 + m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} + m_AlwaysIncludedShaders: + - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} + m_PreloadedShaders: [] + m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, + type: 0} + m_CustomRenderPipeline: {fileID: 0} + m_TransparencySortMode: 0 + m_TransparencySortAxis: {x: 0, y: 0, z: 1} + m_DefaultRenderingPath: 1 + m_DefaultMobileRenderingPath: 1 + m_TierSettings: [] + m_LightmapStripping: 0 + m_FogStripping: 0 + m_InstancingStripping: 0 + m_LightmapKeepPlain: 1 + m_LightmapKeepDirCombined: 1 + m_LightmapKeepDynamicPlain: 1 + m_LightmapKeepDynamicDirCombined: 1 + m_LightmapKeepShadowMask: 1 + m_LightmapKeepSubtractive: 1 + m_FogKeepLinear: 1 + m_FogKeepExp: 1 + m_FogKeepExp2: 1 + m_AlbedoSwatchInfos: [] + m_LightsUseLinearIntensity: 0 + m_LightsUseColorTemperature: 0 diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset new file mode 100644 index 0000000..17c8f53 --- /dev/null +++ b/ProjectSettings/InputManager.asset @@ -0,0 +1,295 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left shift + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: return + altNegativeButton: + altPositiveButton: joystick button 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: enter + altNegativeButton: + altPositiveButton: space + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Cancel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: escape + altNegativeButton: + altPositiveButton: joystick button 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 diff --git a/ProjectSettings/NavMeshAreas.asset b/ProjectSettings/NavMeshAreas.asset new file mode 100644 index 0000000..3b0b7c3 --- /dev/null +++ b/ProjectSettings/NavMeshAreas.asset @@ -0,0 +1,91 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!126 &1 +NavMeshProjectSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + areas: + - name: Walkable + cost: 1 + - name: Not Walkable + cost: 1 + - name: Jump + cost: 2 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + m_LastAgentTypeID: -887442657 + m_Settings: + - serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.75 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_SettingNames: + - Humanoid diff --git a/ProjectSettings/NetworkManager.asset b/ProjectSettings/NetworkManager.asset new file mode 100644 index 0000000..5dc6a83 --- /dev/null +++ b/ProjectSettings/NetworkManager.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!149 &1 +NetworkManager: + m_ObjectHideFlags: 0 + m_DebugLevel: 0 + m_Sendrate: 15 + m_AssetToPrefab: {} diff --git a/ProjectSettings/Physics2DSettings.asset b/ProjectSettings/Physics2DSettings.asset new file mode 100644 index 0000000..132ee6b --- /dev/null +++ b/ProjectSettings/Physics2DSettings.asset @@ -0,0 +1,37 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!19 &1 +Physics2DSettings: + m_ObjectHideFlags: 0 + serializedVersion: 3 + m_Gravity: {x: 0, y: -9.81} + m_DefaultMaterial: {fileID: 0} + m_VelocityIterations: 8 + m_PositionIterations: 3 + m_VelocityThreshold: 1 + m_MaxLinearCorrection: 0.2 + m_MaxAngularCorrection: 8 + m_MaxTranslationSpeed: 100 + m_MaxRotationSpeed: 360 + m_BaumgarteScale: 0.2 + m_BaumgarteTimeOfImpactScale: 0.75 + m_TimeToSleep: 0.5 + m_LinearSleepTolerance: 0.01 + m_AngularSleepTolerance: 2 + m_DefaultContactOffset: 0.01 + m_AutoSimulation: 1 + m_QueriesHitTriggers: 1 + m_QueriesStartInColliders: 1 + m_ChangeStopsCallbacks: 0 + m_CallbacksOnDisable: 1 + m_AutoSyncTransforms: 1 + m_AlwaysShowColliders: 0 + m_ShowColliderSleep: 1 + m_ShowColliderContacts: 0 + m_ShowColliderAABB: 0 + m_ContactArrowScale: 0.2 + m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} + m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} + m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} + m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/ProjectSettings/PresetManager.asset b/ProjectSettings/PresetManager.asset new file mode 100644 index 0000000..67a94da --- /dev/null +++ b/ProjectSettings/PresetManager.asset @@ -0,0 +1,7 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1386491679 &1 +PresetManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_DefaultPresets: {} diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset new file mode 100644 index 0000000..73f46f3 --- /dev/null +++ b/ProjectSettings/ProjectSettings.asset @@ -0,0 +1,643 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!129 &1 +PlayerSettings: + m_ObjectHideFlags: 0 + serializedVersion: 20 + productGUID: d0a1141b2bde84f65af33c9665d1698b + AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 + AndroidEnableSustainedPerformanceMode: 0 + defaultScreenOrientation: 4 + targetDevice: 2 + useOnDemandResources: 0 + accelerometerFrequency: 60 + companyName: DefaultCompany + productName: VolumeRenderingTest + defaultCursor: {fileID: 0} + cursorHotspot: {x: 0, y: 0} + m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} + m_ShowUnitySplashScreen: 1 + m_ShowUnitySplashLogo: 1 + m_SplashScreenOverlayOpacity: 1 + m_SplashScreenAnimation: 1 + m_SplashScreenLogoStyle: 1 + m_SplashScreenDrawMode: 0 + m_SplashScreenBackgroundAnimationZoom: 1 + m_SplashScreenLogoAnimationZoom: 1 + m_SplashScreenBackgroundLandscapeAspect: 1 + m_SplashScreenBackgroundPortraitAspect: 1 + m_SplashScreenBackgroundLandscapeUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenBackgroundPortraitUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenLogos: [] + m_VirtualRealitySplashScreen: {fileID: 0} + m_HolographicTrackingLossScreen: {fileID: 0} + defaultScreenWidth: 1024 + defaultScreenHeight: 768 + defaultScreenWidthWeb: 960 + defaultScreenHeightWeb: 600 + m_StereoRenderingPath: 0 + m_ActiveColorSpace: 1 + m_MTRendering: 1 + m_StackTraceTypes: 010000000100000001000000010000000100000001000000 + iosShowActivityIndicatorOnLoading: -1 + androidShowActivityIndicatorOnLoading: -1 + iosUseCustomAppBackgroundBehavior: 0 + iosAllowHTTPDownload: 1 + allowedAutorotateToPortrait: 1 + allowedAutorotateToPortraitUpsideDown: 1 + allowedAutorotateToLandscapeRight: 1 + allowedAutorotateToLandscapeLeft: 1 + useOSAutorotation: 1 + use32BitDisplayBuffer: 1 + preserveFramebufferAlpha: 0 + disableDepthAndStencilBuffers: 0 + androidStartInFullscreen: 1 + androidRenderOutsideSafeArea: 1 + androidUseSwappy: 0 + androidBlitType: 0 + defaultIsNativeResolution: 1 + macRetinaSupport: 1 + runInBackground: 0 + captureSingleScreen: 0 + muteOtherAudioSources: 0 + Prepare IOS For Recording: 0 + Force IOS Speakers When Recording: 0 + deferSystemGesturesMode: 0 + hideHomeButton: 0 + submitAnalytics: 1 + usePlayerLog: 1 + bakeCollisionMeshes: 0 + forceSingleInstance: 0 + useFlipModelSwapchain: 1 + resizableWindow: 0 + useMacAppStoreValidation: 0 + macAppStoreCategory: public.app-category.games + gpuSkinning: 0 + xboxPIXTextureCapture: 0 + xboxEnableAvatar: 0 + xboxEnableKinect: 0 + xboxEnableKinectAutoTracking: 0 + xboxEnableFitness: 0 + visibleInBackground: 1 + allowFullscreenSwitch: 1 + fullscreenMode: 1 + xboxSpeechDB: 0 + xboxEnableHeadOrientation: 0 + xboxEnableGuest: 0 + xboxEnablePIXSampling: 0 + metalFramebufferOnly: 0 + xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 + xboxOneMonoLoggingLevel: 0 + xboxOneLoggingLevel: 1 + xboxOneDisableEsram: 0 + xboxOnePresentImmediateThreshold: 0 + switchQueueCommandMemory: 1048576 + switchQueueControlMemory: 16384 + switchQueueComputeMemory: 262144 + switchNVNShaderPoolsGranularity: 33554432 + switchNVNDefaultPoolsGranularity: 16777216 + switchNVNOtherPoolsGranularity: 16777216 + vulkanNumSwapchainBuffers: 3 + vulkanEnableSetSRGBWrite: 0 + m_SupportedAspectRatios: + 4:3: 1 + 5:4: 1 + 16:10: 1 + 16:9: 1 + Others: 1 + bundleVersion: 1.0 + preloadedAssets: [] + metroInputSource: 0 + wsaTransparentSwapchain: 0 + m_HolographicPauseOnTrackingLoss: 1 + xboxOneDisableKinectGpuReservation: 0 + xboxOneEnable7thCore: 0 + vrSettings: + cardboard: + depthFormat: 0 + enableTransitionView: 0 + daydream: + depthFormat: 0 + useSustainedPerformanceMode: 0 + enableVideoLayer: 0 + useProtectedVideoMemory: 0 + minimumSupportedHeadTracking: 0 + maximumSupportedHeadTracking: 1 + hololens: + depthFormat: 1 + depthBufferSharingEnabled: 0 + lumin: + depthFormat: 0 + frameTiming: 2 + enableGLCache: 0 + glCacheMaxBlobSize: 524288 + glCacheMaxFileSize: 8388608 + oculus: + sharedDepthBuffer: 0 + dashSupport: 0 + lowOverheadMode: 0 + protectedContext: 0 + v2Signing: 1 + enable360StereoCapture: 0 + isWsaHolographicRemotingEnabled: 0 + enableFrameTimingStats: 0 + useHDRDisplay: 0 + D3DHDRBitDepth: 0 + m_ColorGamuts: 00000000 + targetPixelDensity: 30 + resolutionScalingMode: 0 + androidSupportedAspectRatio: 1 + androidMaxAspectRatio: 2.1 + applicationIdentifier: {} + buildNumber: {} + AndroidBundleVersionCode: 1 + AndroidMinSdkVersion: 19 + AndroidTargetSdkVersion: 0 + AndroidPreferredInstallLocation: 1 + aotOptions: + stripEngineCode: 1 + iPhoneStrippingLevel: 0 + iPhoneScriptCallOptimization: 0 + ForceInternetPermission: 0 + ForceSDCardPermission: 0 + CreateWallpaper: 0 + APKExpansionFiles: 0 + keepLoadedShadersAlive: 0 + StripUnusedMeshComponents: 0 + VertexChannelCompressionMask: 214 + iPhoneSdkVersion: 988 + iOSTargetOSVersionString: 10.0 + tvOSSdkVersion: 0 + tvOSRequireExtendedGameController: 0 + tvOSTargetOSVersionString: 10.0 + uIPrerenderedIcon: 0 + uIRequiresPersistentWiFi: 0 + uIRequiresFullScreen: 1 + uIStatusBarHidden: 1 + uIExitOnSuspend: 0 + uIStatusBarStyle: 0 + iPhoneSplashScreen: {fileID: 0} + iPhoneHighResSplashScreen: {fileID: 0} + iPhoneTallHighResSplashScreen: {fileID: 0} + iPhone47inSplashScreen: {fileID: 0} + iPhone55inPortraitSplashScreen: {fileID: 0} + iPhone55inLandscapeSplashScreen: {fileID: 0} + iPhone58inPortraitSplashScreen: {fileID: 0} + iPhone58inLandscapeSplashScreen: {fileID: 0} + iPadPortraitSplashScreen: {fileID: 0} + iPadHighResPortraitSplashScreen: {fileID: 0} + iPadLandscapeSplashScreen: {fileID: 0} + iPadHighResLandscapeSplashScreen: {fileID: 0} + iPhone65inPortraitSplashScreen: {fileID: 0} + iPhone65inLandscapeSplashScreen: {fileID: 0} + iPhone61inPortraitSplashScreen: {fileID: 0} + iPhone61inLandscapeSplashScreen: {fileID: 0} + appleTVSplashScreen: {fileID: 0} + appleTVSplashScreen2x: {fileID: 0} + tvOSSmallIconLayers: [] + tvOSSmallIconLayers2x: [] + tvOSLargeIconLayers: [] + tvOSLargeIconLayers2x: [] + tvOSTopShelfImageLayers: [] + tvOSTopShelfImageLayers2x: [] + tvOSTopShelfImageWideLayers: [] + tvOSTopShelfImageWideLayers2x: [] + iOSLaunchScreenType: 0 + iOSLaunchScreenPortrait: {fileID: 0} + iOSLaunchScreenLandscape: {fileID: 0} + iOSLaunchScreenBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreenFillPct: 100 + iOSLaunchScreenSize: 100 + iOSLaunchScreenCustomXibPath: + iOSLaunchScreeniPadType: 0 + iOSLaunchScreeniPadImage: {fileID: 0} + iOSLaunchScreeniPadBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreeniPadFillPct: 100 + iOSLaunchScreeniPadSize: 100 + iOSLaunchScreeniPadCustomXibPath: + iOSUseLaunchScreenStoryboard: 0 + iOSLaunchScreenCustomStoryboardPath: + iOSDeviceRequirements: [] + iOSURLSchemes: [] + iOSBackgroundModes: 0 + iOSMetalForceHardShadows: 0 + metalEditorSupport: 1 + metalAPIValidation: 1 + iOSRenderExtraFrameOnPause: 0 + appleDeveloperTeamID: + iOSManualSigningProvisioningProfileID: + tvOSManualSigningProvisioningProfileID: + iOSManualSigningProvisioningProfileType: 0 + tvOSManualSigningProvisioningProfileType: 0 + appleEnableAutomaticSigning: 0 + iOSRequireARKit: 0 + iOSAutomaticallyDetectAndAddCapabilities: 1 + appleEnableProMotion: 0 + clonedFromGUID: 00000000000000000000000000000000 + templatePackageId: + templateDefaultScene: + AndroidTargetArchitectures: 1 + AndroidSplashScreenScale: 0 + androidSplashScreen: {fileID: 0} + AndroidKeystoreName: '{inproject}: ' + AndroidKeyaliasName: + AndroidBuildApkPerCpuArchitecture: 0 + AndroidTVCompatibility: 1 + AndroidIsGame: 1 + AndroidEnableTango: 0 + androidEnableBanner: 1 + androidUseLowAccuracyLocation: 0 + androidUseCustomKeystore: 0 + m_AndroidBanners: + - width: 320 + height: 180 + banner: {fileID: 0} + androidGamepadSupportLevel: 0 + AndroidValidateAppBundleSize: 1 + AndroidAppBundleSizeToValidate: 150 + m_BuildTargetIcons: [] + m_BuildTargetPlatformIcons: [] + m_BuildTargetBatching: [] + m_BuildTargetGraphicsJobs: + - m_BuildTarget: MacStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: Switch + m_GraphicsJobs: 0 + - m_BuildTarget: MetroSupport + m_GraphicsJobs: 0 + - m_BuildTarget: AppleTVSupport + m_GraphicsJobs: 0 + - m_BuildTarget: BJMSupport + m_GraphicsJobs: 0 + - m_BuildTarget: LinuxStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: PS4Player + m_GraphicsJobs: 0 + - m_BuildTarget: iOSSupport + m_GraphicsJobs: 0 + - m_BuildTarget: WindowsStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobs: 0 + - m_BuildTarget: LuminSupport + m_GraphicsJobs: 0 + - m_BuildTarget: AndroidPlayer + m_GraphicsJobs: 0 + - m_BuildTarget: WebGLSupport + m_GraphicsJobs: 0 + m_BuildTargetGraphicsJobMode: + - m_BuildTarget: PS4Player + m_GraphicsJobMode: 0 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobMode: 0 + m_BuildTargetGraphicsAPIs: + - m_BuildTarget: MacStandaloneSupport + m_APIs: 1000000011000000 + m_Automatic: 0 + m_BuildTargetVRSettings: [] + openGLRequireES31: 0 + openGLRequireES31AEP: 0 + openGLRequireES32: 0 + m_TemplateCustomTags: {} + mobileMTRendering: + Android: 1 + iPhone: 1 + tvOS: 1 + m_BuildTargetGroupLightmapEncodingQuality: [] + m_BuildTargetGroupLightmapSettings: [] + playModeTestRunnerEnabled: 0 + runPlayModeTestAsEditModeTest: 0 + actionOnDotNetUnhandledException: 1 + enableInternalProfiler: 0 + logObjCUncaughtExceptions: 1 + enableCrashReportAPI: 0 + cameraUsageDescription: + locationUsageDescription: + microphoneUsageDescription: + switchNetLibKey: + switchSocketMemoryPoolSize: 6144 + switchSocketAllocatorPoolSize: 128 + switchSocketConcurrencyLimit: 14 + switchScreenResolutionBehavior: 2 + switchUseCPUProfiler: 0 + switchApplicationID: 0x01004b9000490000 + switchNSODependencies: + switchTitleNames_0: + switchTitleNames_1: + switchTitleNames_2: + switchTitleNames_3: + switchTitleNames_4: + switchTitleNames_5: + switchTitleNames_6: + switchTitleNames_7: + switchTitleNames_8: + switchTitleNames_9: + switchTitleNames_10: + switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: + switchPublisherNames_0: + switchPublisherNames_1: + switchPublisherNames_2: + switchPublisherNames_3: + switchPublisherNames_4: + switchPublisherNames_5: + switchPublisherNames_6: + switchPublisherNames_7: + switchPublisherNames_8: + switchPublisherNames_9: + switchPublisherNames_10: + switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: + switchIcons_0: {fileID: 0} + switchIcons_1: {fileID: 0} + switchIcons_2: {fileID: 0} + switchIcons_3: {fileID: 0} + switchIcons_4: {fileID: 0} + switchIcons_5: {fileID: 0} + switchIcons_6: {fileID: 0} + switchIcons_7: {fileID: 0} + switchIcons_8: {fileID: 0} + switchIcons_9: {fileID: 0} + switchIcons_10: {fileID: 0} + switchIcons_11: {fileID: 0} + switchIcons_12: {fileID: 0} + switchIcons_13: {fileID: 0} + switchIcons_14: {fileID: 0} + switchSmallIcons_0: {fileID: 0} + switchSmallIcons_1: {fileID: 0} + switchSmallIcons_2: {fileID: 0} + switchSmallIcons_3: {fileID: 0} + switchSmallIcons_4: {fileID: 0} + switchSmallIcons_5: {fileID: 0} + switchSmallIcons_6: {fileID: 0} + switchSmallIcons_7: {fileID: 0} + switchSmallIcons_8: {fileID: 0} + switchSmallIcons_9: {fileID: 0} + switchSmallIcons_10: {fileID: 0} + switchSmallIcons_11: {fileID: 0} + switchSmallIcons_12: {fileID: 0} + switchSmallIcons_13: {fileID: 0} + switchSmallIcons_14: {fileID: 0} + switchManualHTML: + switchAccessibleURLs: + switchLegalInformation: + switchMainThreadStackSize: 1048576 + switchPresenceGroupId: + switchLogoHandling: 0 + switchReleaseVersion: 0 + switchDisplayVersion: 1.0.0 + switchStartupUserAccount: 0 + switchTouchScreenUsage: 0 + switchSupportedLanguagesMask: 0 + switchLogoType: 0 + switchApplicationErrorCodeCategory: + switchUserAccountSaveDataSize: 0 + switchUserAccountSaveDataJournalSize: 0 + switchApplicationAttribute: 0 + switchCardSpecSize: -1 + switchCardSpecClock: -1 + switchRatingsMask: 0 + switchRatingsInt_0: 0 + switchRatingsInt_1: 0 + switchRatingsInt_2: 0 + switchRatingsInt_3: 0 + switchRatingsInt_4: 0 + switchRatingsInt_5: 0 + switchRatingsInt_6: 0 + switchRatingsInt_7: 0 + switchRatingsInt_8: 0 + switchRatingsInt_9: 0 + switchRatingsInt_10: 0 + switchRatingsInt_11: 0 + switchRatingsInt_12: 0 + switchLocalCommunicationIds_0: + switchLocalCommunicationIds_1: + switchLocalCommunicationIds_2: + switchLocalCommunicationIds_3: + switchLocalCommunicationIds_4: + switchLocalCommunicationIds_5: + switchLocalCommunicationIds_6: + switchLocalCommunicationIds_7: + switchParentalControl: 0 + switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 + switchAllowsRuntimeAddOnContentInstall: 0 + switchDataLossConfirmation: 0 + switchUserAccountLockEnabled: 0 + switchSystemResourceMemory: 16777216 + switchSupportedNpadStyles: 3 + switchNativeFsCacheSize: 32 + switchIsHoldTypeHorizontal: 0 + switchSupportedNpadCount: 8 + switchSocketConfigEnabled: 0 + switchTcpInitialSendBufferSize: 32 + switchTcpInitialReceiveBufferSize: 64 + switchTcpAutoSendBufferSizeMax: 256 + switchTcpAutoReceiveBufferSizeMax: 256 + switchUdpSendBufferSize: 9 + switchUdpReceiveBufferSize: 42 + switchSocketBufferEfficiency: 4 + switchSocketInitializeEnabled: 1 + switchNetworkInterfaceManagerInitializeEnabled: 1 + switchPlayerConnectionEnabled: 1 + ps4NPAgeRating: 12 + ps4NPTitleSecret: + ps4NPTrophyPackPath: + ps4ParentalLevel: 11 + ps4ContentID: ED1633-NPXX51362_00-0000000000000000 + ps4Category: 0 + ps4MasterVersion: 01.00 + ps4AppVersion: 01.00 + ps4AppType: 0 + ps4ParamSfxPath: + ps4VideoOutPixelFormat: 0 + ps4VideoOutInitialWidth: 1920 + ps4VideoOutBaseModeInitialWidth: 1920 + ps4VideoOutReprojectionRate: 60 + ps4PronunciationXMLPath: + ps4PronunciationSIGPath: + ps4BackgroundImagePath: + ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: + ps4SaveDataImagePath: + ps4SdkOverride: + ps4BGMPath: + ps4ShareFilePath: + ps4ShareOverlayImagePath: + ps4PrivacyGuardImagePath: + ps4NPtitleDatPath: + ps4RemotePlayKeyAssignment: -1 + ps4RemotePlayKeyMappingDir: + ps4PlayTogetherPlayerCount: 0 + ps4EnterButtonAssignment: 1 + ps4ApplicationParam1: 0 + ps4ApplicationParam2: 0 + ps4ApplicationParam3: 0 + ps4ApplicationParam4: 0 + ps4DownloadDataSize: 0 + ps4GarlicHeapSize: 2048 + ps4ProGarlicHeapSize: 2560 + playerPrefsMaxSize: 32768 + ps4Passcode: 5PN2qmWqBlQ9wQj99nsQzldVI5ZuGXbE + ps4pnSessions: 1 + ps4pnPresence: 1 + ps4pnFriends: 1 + ps4pnGameCustomData: 1 + playerPrefsSupport: 0 + enableApplicationExit: 0 + resetTempFolder: 1 + restrictedAudioUsageRights: 0 + ps4UseResolutionFallback: 0 + ps4ReprojectionSupport: 0 + ps4UseAudio3dBackend: 0 + ps4SocialScreenEnabled: 0 + ps4ScriptOptimizationLevel: 0 + ps4Audio3dVirtualSpeakerCount: 14 + ps4attribCpuUsage: 0 + ps4PatchPkgPath: + ps4PatchLatestPkgPath: + ps4PatchChangeinfoPath: + ps4PatchDayOne: 0 + ps4attribUserManagement: 0 + ps4attribMoveSupport: 0 + ps4attrib3DSupport: 0 + ps4attribShareSupport: 0 + ps4attribExclusiveVR: 0 + ps4disableAutoHideSplash: 0 + ps4videoRecordingFeaturesUsed: 0 + ps4contentSearchFeaturesUsed: 0 + ps4attribEyeToEyeDistanceSettingVR: 0 + ps4IncludedModules: [] + ps4attribVROutputEnabled: 0 + monoEnv: + splashScreenBackgroundSourceLandscape: {fileID: 0} + splashScreenBackgroundSourcePortrait: {fileID: 0} + blurSplashScreenBackground: 1 + spritePackerPolicy: + webGLMemorySize: 256 + webGLExceptionSupport: 1 + webGLNameFilesAsHashes: 0 + webGLDataCaching: 0 + webGLDebugSymbols: 0 + webGLEmscriptenArgs: + webGLModulesDirectory: + webGLTemplate: APPLICATION:Default + webGLAnalyzeBuildSize: 0 + webGLUseEmbeddedResources: 0 + webGLCompressionFormat: 1 + webGLLinkerTarget: 1 + webGLThreadsSupport: 0 + webGLWasmStreaming: 0 + scriptingDefineSymbols: {} + platformArchitecture: {} + scriptingBackend: {} + il2cppCompilerConfiguration: {} + managedStrippingLevel: {} + incrementalIl2cppBuild: {} + allowUnsafeCode: 0 + additionalIl2CppArgs: + scriptingRuntimeVersion: 1 + gcIncremental: 0 + gcWBarrierValidation: 0 + apiCompatibilityLevelPerPlatform: {} + m_RenderingPath: 1 + m_MobileRenderingPath: 1 + metroPackageName: VolumeRenderingTest + metroPackageVersion: + metroCertificatePath: + metroCertificatePassword: + metroCertificateSubject: + metroCertificateIssuer: + metroCertificateNotAfter: 0000000000000000 + metroApplicationDescription: VolumeRenderingTest + wsaImages: {} + metroTileShortName: + metroTileShowName: 0 + metroMediumTileShowName: 0 + metroLargeTileShowName: 0 + metroWideTileShowName: 0 + metroSupportStreamingInstall: 0 + metroLastRequiredScene: 0 + metroDefaultTileSize: 1 + metroTileForegroundText: 2 + metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} + metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, + a: 1} + metroSplashScreenUseBackgroundColor: 0 + platformCapabilities: {} + metroTargetDeviceFamilies: {} + metroFTAName: + metroFTAFileTypes: [] + metroProtocolName: + XboxOneProductId: + XboxOneUpdateKey: + XboxOneSandboxId: + XboxOneContentId: + XboxOneTitleId: + XboxOneSCId: + XboxOneGameOsOverridePath: + XboxOnePackagingOverridePath: + XboxOneAppManifestOverridePath: + XboxOneVersion: 1.0.0.0 + XboxOnePackageEncryption: 0 + XboxOnePackageUpdateGranularity: 2 + XboxOneDescription: + XboxOneLanguage: + - enus + XboxOneCapability: [] + XboxOneGameRating: {} + XboxOneIsContentPackage: 0 + XboxOneEnableGPUVariability: 0 + XboxOneSockets: {} + XboxOneSplashScreen: {fileID: 0} + XboxOneAllowedProductIds: [] + XboxOnePersistentLocalStorageSize: 0 + XboxOneXTitleMemory: 8 + XboxOneOverrideIdentityName: + vrEditorSettings: + daydream: + daydreamIconForeground: {fileID: 0} + daydreamIconBackground: {fileID: 0} + cloudServicesEnabled: {} + luminIcon: + m_Name: + m_ModelFolderPath: + m_PortalFolderPath: + luminCert: + m_CertPath: + m_SignPackage: 1 + luminIsChannelApp: 0 + luminVersion: + m_VersionCode: 1 + m_VersionName: + apiCompatibilityLevel: 6 + cloudProjectId: 21deb73a-61a9-4873-b6fe-0d04a9f17ee5 + framebufferDepthMemorylessMode: 0 + projectName: VolumeRenderingTest + organizationId: hecomi + cloudEnabled: 0 + enableNativePlatformBackendsForNewInputSystem: 0 + disableOldInputManagerSupport: 0 + legacyClampBlendShapeWeights: 1 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt new file mode 100644 index 0000000..1c8f32f --- /dev/null +++ b/ProjectSettings/ProjectVersion.txt @@ -0,0 +1,2 @@ +m_EditorVersion: 2019.3.10f1 +m_EditorVersionWithRevision: 2019.3.10f1 (5968d7f82152) diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset new file mode 100644 index 0000000..05daac3 --- /dev/null +++ b/ProjectSettings/QualitySettings.asset @@ -0,0 +1,191 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!47 &1 +QualitySettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_CurrentQuality: 5 + m_QualitySettings: + - serializedVersion: 2 + name: Very Low + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 15 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 1 + textureQuality: 1 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.3 + maximumLODLevel: 0 + particleRaycastBudget: 4 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Low + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.4 + maximumLODLevel: 0 + particleRaycastBudget: 16 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Medium + pixelLightCount: 1 + shadows: 1 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 0 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 1 + lodBias: 0.7 + maximumLODLevel: 0 + particleRaycastBudget: 64 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: High + pixelLightCount: 2 + shadows: 2 + shadowResolution: 1 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 40 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1 + maximumLODLevel: 0 + particleRaycastBudget: 256 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Very High + pixelLightCount: 3 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 70 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1.5 + maximumLODLevel: 0 + particleRaycastBudget: 1024 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Ultra + pixelLightCount: 4 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 4 + shadowDistance: 150 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + shadowmaskMode: 1 + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 2 + maximumLODLevel: 0 + particleRaycastBudget: 4096 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + resolutionScalingFixedDPIFactor: 1 + excludedTargetPlatforms: [] + m_PerPlatformDefaultQuality: + Android: 2 + Nintendo 3DS: 5 + Nintendo Switch: 5 + PS4: 5 + PSM: 5 + PSP2: 2 + Standalone: 5 + Tizen: 2 + WebGL: 3 + WiiU: 5 + Windows Store Apps: 5 + XboxOne: 5 + iPhone: 2 + tvOS: 2 diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset new file mode 100644 index 0000000..1c92a78 --- /dev/null +++ b/ProjectSettings/TagManager.asset @@ -0,0 +1,43 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!78 &1 +TagManager: + serializedVersion: 2 + tags: [] + layers: + - Default + - TransparentFX + - Ignore Raycast + - + - Water + - UI + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + m_SortingLayers: + - name: Default + uniqueID: 0 + locked: 0 diff --git a/ProjectSettings/TimeManager.asset b/ProjectSettings/TimeManager.asset new file mode 100644 index 0000000..558a017 --- /dev/null +++ b/ProjectSettings/TimeManager.asset @@ -0,0 +1,9 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!5 &1 +TimeManager: + m_ObjectHideFlags: 0 + Fixed Timestep: 0.02 + Maximum Allowed Timestep: 0.33333334 + m_TimeScale: 1 + Maximum Particle Timestep: 0.03 diff --git a/ProjectSettings/UnityConnectSettings.asset b/ProjectSettings/UnityConnectSettings.asset new file mode 100644 index 0000000..f327fe1 --- /dev/null +++ b/ProjectSettings/UnityConnectSettings.asset @@ -0,0 +1,34 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!310 &1 +UnityConnectSettings: + m_ObjectHideFlags: 0 + m_Enabled: 0 + m_TestMode: 0 + m_TestEventUrl: + m_TestConfigUrl: + m_TestInitMode: 0 + CrashReportingSettings: + m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes + m_NativeEventUrl: https://perf-events.cloud.unity3d.com/symbolicate + m_Enabled: 0 + m_CaptureEditorExceptions: 1 + UnityPurchasingSettings: + m_Enabled: 0 + m_TestMode: 0 + UnityAnalyticsSettings: + m_Enabled: 1 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_TestEventUrl: + m_TestConfigUrl: + UnityAdsSettings: + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_IosGameId: + m_AndroidGameId: + m_GameIds: {} + m_GameId: + PerformanceReportingSettings: + m_Enabled: 0 diff --git a/ProjectSettings/VFXManager.asset b/ProjectSettings/VFXManager.asset new file mode 100644 index 0000000..3a95c98 --- /dev/null +++ b/ProjectSettings/VFXManager.asset @@ -0,0 +1,12 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!937362698 &1 +VFXManager: + m_ObjectHideFlags: 0 + m_IndirectShader: {fileID: 0} + m_CopyBufferShader: {fileID: 0} + m_SortShader: {fileID: 0} + m_StripUpdateShader: {fileID: 0} + m_RenderPipeSettingsPath: + m_FixedTimeStep: 0.016666668 + m_MaxDeltaTime: 0.05 diff --git a/ProjectSettings/XRSettings.asset b/ProjectSettings/XRSettings.asset new file mode 100644 index 0000000..482590c --- /dev/null +++ b/ProjectSettings/XRSettings.asset @@ -0,0 +1,10 @@ +{ + "m_SettingKeys": [ + "VR Device Disabled", + "VR Device User Alert" + ], + "m_SettingValues": [ + "False", + "False" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 656903c..2b03240 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,12 @@ -VolumeRendering_in_Unity -=============== +Unity Volume Rendering +====================== -VolumeZrenderingをUnity内で出来るようにした奴 \ No newline at end of file +頑張って基礎からつくりました + +Screen Shots +------------ + + + + + diff --git a/Untitled.ipynb b/Untitled.ipynb new file mode 100644 index 0000000..9502488 --- /dev/null +++ b/Untitled.ipynb @@ -0,0 +1,105 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "ExecuteTime": { + "end_time": "2021-03-16T07:13:56.559086Z", + "start_time": "2021-03-16T07:13:39.464085Z" + } + }, + "outputs": [], + "source": [ + "from glob import glob\n", + "import pydicom\n", + "import os.path as osp\n", + "import numpy as np\n", + "\n", + "out_name = \"3D.raw\"\n", + "out_base_path = \"./Assets/\"\n", + "dicom_dir = \"D:3Dsyokudo/\"\n", + "dicom_file_list = glob(osp.join(dicom_dir, \"*\"))\n", + "dicom_file_list = sorted(dicom_file_list, key=lambda x: float(pydicom.read_file(x).SliceLocation), reverse=False)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "ExecuteTime": { + "end_time": "2021-03-16T07:09:08.808051Z", + "start_time": "2021-03-16T07:09:07.881746Z" + } + }, + "outputs": [], + "source": [ + "height, width = pydicom.read_file(dicom_file_list[0]).pixel_array.shape\n", + "depth = len(dicom_file_list)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "ExecuteTime": { + "end_time": "2021-03-14T13:56:53.161775Z", + "start_time": "2021-03-14T13:56:46.536770Z" + } + }, + "outputs": [], + "source": [ + "stack_img = np.stack([pydicom.read_file(x).pixel_array + pydicom.read_file(x).RescaleIntercept for x in dicom_file_list], axis=2)\n", + "row_format = stack_img.transpose(1, 0, 2).reshape(-1, order=\"F\")\n", + "\n", + "# ウィンドウ使うバージョン2\n", + "window_max = 330\n", + "window_min = -270\n", + "\n", + "scaled_row = row_format.copy().astype(np.float)\n", + "scaled_row[scaled_row < window_min] = window_min\n", + "scaled_row[window_max < scaled_row] = window_max\n", + "\n", + "scaled_row -= np.mean(scaled_row)\n", + "scaled_row = scaled_row / (np.max(np.abs(scaled_row)) + 1e-5) * (2 ** 16)\n", + "scaled_row -= np.mean(scaled_row)\n", + "scaled_row = np.clip(scaled_row, 0, 2 ** 16).astype(np.uint16)\n", + "scaled_row.tofile(osp.join(out_base_path, out_name))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.10" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/init_Unity_settings.py b/init_Unity_settings.py new file mode 100644 index 0000000..475d1b0 --- /dev/null +++ b/init_Unity_settings.py @@ -0,0 +1,45 @@ +from glob import glob +import pydicom +import json +import os.path as osp +import numpy as np + +dicom_dir = "D:3Dsyokudo/" + +out_name = "3D.raw" +out_base_path = "./Assets/" +dicom_file_list = glob(osp.join(dicom_dir, "*")) +dicom_file_list = sorted(dicom_file_list, key=lambda x: float(pydicom.read_file(x).SliceLocation), reverse=False) +sample_dcm1, sample_dcm2 = pydicom.read_file(dicom_file_list[0]), pydicom.read_file(dicom_file_list[1]) + +height, width = pydicom.read_file(dicom_file_list[0]).pixel_array.shape +depth = len(dicom_file_list) + +x_scale_f, y_scale_f = sample_dcm1.PixelSpacing +z_scale_f = abs(sample_dcm1.ImagePositionPatient[2] - sample_dcm2.ImagePositionPatient[2]) + +stack_img = np.stack([pydicom.read_file(x).pixel_array + pydicom.read_file(x).RescaleIntercept for x in dicom_file_list], axis=2) +row_format = stack_img.transpose((1, 0, 2)).reshape(-1, order="F") + +# ウィンドウ使うバージョン +window_max = 330 +window_min = -270 + +scaled_row = row_format.copy().astype(np.float) +scaled_row[scaled_row < window_min] = window_min +scaled_row[window_max < scaled_row] = window_max + +scaled_row -= np.mean(scaled_row) +scaled_row = scaled_row / (np.max(np.abs(scaled_row)) + 1e-5) * (2 ** 16) +scaled_row -= np.mean(scaled_row) +scaled_row = np.clip(scaled_row, 0, 2 ** 16).astype(np.uint16) +scaled_row.tofile(osp.join(out_base_path, out_name)) + +to_json = { + "x_scale": width * x_scale_f, + "y_scale": height * y_scale_f, + "z_scale": depth * z_scale_f +} + +with open(osp.join(out_base_path, "setting.json"), "w") as f: + json.dump(to_json, f, indent=4)