└── Assets └── TP └── CGBull ├── Common ├── Shaders │ ├── Resources │ │ ├── Textures │ │ │ ├── BlueNoise.tga │ │ │ ├── IBR_PreintegratedLUT │ │ │ │ ├── PBR_GFD.exr │ │ │ │ ├── Cloth_PBR_GFD.exr │ │ │ │ ├── Cloth_Cloth_GFD.exr │ │ │ │ ├── PBR_GFD.exr.meta │ │ │ │ ├── Cloth_PBR_GFD.exr.meta │ │ │ │ └── Cloth_Cloth_GFD.exr.meta │ │ │ ├── IBR_PreintegratedLUT.meta │ │ │ └── BlueNoise.tga.meta │ │ ├── Common.hlsl.meta │ │ ├── Random.hlsl.meta │ │ ├── AreaLight.hlsl.meta │ │ ├── BSDF_Library.hlsl.meta │ │ ├── Filtter_Library.hlsl.meta │ │ ├── Include_HLSL.hlsl.meta │ │ ├── Montcalo_Library.hlsl.meta │ │ ├── Noise_Library.hlsl.meta │ │ ├── ShadingModel.hlsl.meta │ │ ├── ImageBasedLighting.hlsl.meta │ │ ├── Textures.meta │ │ ├── Include_HLSL.hlsl │ │ ├── Noise_Library.hlsl │ │ ├── ImageBasedLighting.hlsl │ │ ├── ShadingModel.hlsl │ │ ├── Montcalo_Library.hlsl │ │ ├── AreaLight.hlsl │ │ ├── Filtter_Library.hlsl │ │ └── Common.hlsl │ └── Resources.meta ├── Script.meta ├── Shaders.meta └── Script │ ├── ShaderIDs.cs.meta │ ├── GraphicsUtility.cs.meta │ ├── ShaderIDs.cs │ └── GraphicsUtility.cs ├── Common.meta ├── System_LUT.meta ├── InfinityShader.meta ├── ImageBasedReflection.meta ├── System_LUT ├── Material.meta ├── RenderLUT.meta ├── Shaders.meta ├── Shaders │ ├── Resources.meta │ └── Resources │ │ ├── SystemLUT_IBR_Shader.shader.meta │ │ └── SystemLUT_IBR_Shader.shader ├── Material │ ├── SystemLUT_IBR_Material.mat.meta │ └── SystemLUT_IBR_Material.mat └── RenderLUT │ ├── SystemLUT_IBR_RenderTexture.asset.meta │ └── SystemLUT_IBR_RenderTexture.asset ├── GroundTruthAmbientOcclusion.meta ├── SeparableSubsurfaceScatter.meta ├── ImageBasedReflection ├── Shaders.meta └── Shaders │ ├── Resources.meta │ └── Resources │ ├── CustomGBuffer.cginc.meta │ ├── Custom-DeferredReflections.shader.meta │ ├── CustomGBuffer.cginc │ └── Custom-DeferredReflections.shader ├── StochasticScreenSpaceReflection.meta ├── GroundTruthAmbientOcclusion ├── Script.meta ├── Shaders.meta ├── Shaders │ ├── Resources.meta │ └── Resources │ │ ├── ReflectionOcclusion.meta │ │ ├── ReflectionOcclusion │ │ ├── GTSO.mat.meta │ │ ├── GTSO_LUT.asset.meta │ │ ├── GTSO_LUT.shader.meta │ │ ├── SpecularOcclusionIntegrate.cginc.meta │ │ ├── GTSO_LUT.shader │ │ ├── GTSO_LUT.asset │ │ ├── GTSO.mat │ │ └── SpecularOcclusionIntegrate.cginc │ │ ├── GTAO.shader.meta │ │ ├── GTAO_Pass.cginc.meta │ │ ├── GTAO_Common.cginc.meta │ │ ├── GTAO.shader │ │ ├── GTAO_Pass.cginc │ │ └── GTAO_Common.cginc └── Script │ └── GroundTruthOcclusion.cs.meta ├── SeparableSubsurfaceScatter ├── Resources │ ├── Shader.meta │ └── Shader │ │ ├── Post.meta │ │ ├── Surface.meta │ │ ├── Surface │ │ ├── Standard_Skin.shader.meta │ │ ├── Standard_Skin_Tessellation.shader.meta │ │ └── Standard_Skin_Tessellation.shader │ │ └── Post │ │ ├── SeparableSubsurfaceScatter.shader.meta │ │ ├── SeparableSubsurfaceScatterCommon.cginc.meta │ │ ├── SeparableSubsurfaceScatter.shader │ │ └── SeparableSubsurfaceScatterCommon.cginc ├── Script.meta ├── Resources.meta └── Script │ ├── SeparableSubsurface.meta │ └── SeparableSubsurface │ ├── SeparableSSSLibrary.cs.meta │ ├── SeparableSubsurfaceScatter.cs.meta │ ├── SeparableSSSLibrary.cs │ └── SeparableSubsurfaceScatter.cs ├── StochasticScreenSpaceReflection ├── Shaders │ ├── Resources.meta │ └── Resources │ │ ├── SSRPass.cginc.meta │ │ ├── SSRLibrary.cginc.meta │ │ ├── StochasticScreenSpaceReflection.shader.meta │ │ ├── StochasticScreenSpaceReflection.shader │ │ └── SSRLibrary.cginc ├── Script.meta ├── Shaders.meta └── Script │ └── StochasticScreenSpaceReflection.cs.meta └── InfinityShader ├── Refraction.shader.meta ├── Hair.shader.meta ├── SuperStandard.shader.meta ├── Cloth.shader.meta ├── ClearCoat.shader.meta ├── Hair.shader ├── SuperStandard.shader ├── Cloth.shader └── ClearCoat.shader /Assets/TP/CGBull/Common/Shaders/Resources/Textures/BlueNoise.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaxwellGengYF/Unity-Screen-Space-Reflection/HEAD/Assets/TP/CGBull/Common/Shaders/Resources/Textures/BlueNoise.tga -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6fc7597f07a7df4a81ee63b55b095f6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/System_LUT.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e764ed957225684da9ac2c11242a4eb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Script.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dab3ba437ade9914988f461f65191157 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89f6456831dec174fa56e76459073cd0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/InfinityShader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d560592f3d331a4429074711d67479ad 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Textures/IBR_PreintegratedLUT/PBR_GFD.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaxwellGengYF/Unity-Screen-Space-Reflection/HEAD/Assets/TP/CGBull/Common/Shaders/Resources/Textures/IBR_PreintegratedLUT/PBR_GFD.exr -------------------------------------------------------------------------------- /Assets/TP/CGBull/ImageBasedReflection.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6fd6424915017b408b16f35a9a88097 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/System_LUT/Material.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d47185e779f2def449346bd9f46d78df 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/System_LUT/RenderLUT.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa8dda3a90e2fd247ad75436b96d6f39 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/System_LUT/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d0dddd95145f6747bc21d0c488692f9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2cea97962d750c945a151a3f3b93900b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e9373ba5aaf1334fa5985f62aa60d2e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6a90700329850b04d92c6cab5c0c4307 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Textures/IBR_PreintegratedLUT/Cloth_PBR_GFD.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaxwellGengYF/Unity-Screen-Space-Reflection/HEAD/Assets/TP/CGBull/Common/Shaders/Resources/Textures/IBR_PreintegratedLUT/Cloth_PBR_GFD.exr -------------------------------------------------------------------------------- /Assets/TP/CGBull/ImageBasedReflection/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60e73baf6c69c1443b822024d0e09b79 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/StochasticScreenSpaceReflection.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9882cd8c0e0e784a8245b58a541a689 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/System_LUT/Shaders/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1343737ce9c42344482abe8695d56e99 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Textures/IBR_PreintegratedLUT/Cloth_Cloth_GFD.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MaxwellGengYF/Unity-Screen-Space-Reflection/HEAD/Assets/TP/CGBull/Common/Shaders/Resources/Textures/IBR_PreintegratedLUT/Cloth_Cloth_GFD.exr -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Script.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e84f81e635d53dc44b488446f3b0b1b7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1ad6e65b2f2a264eb221b11ebac5abd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/ImageBasedReflection/Shaders/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab04886096c71214d84f939d99dcb760 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f8f2a1884693e64eb4b29df19703afd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Resources/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f35915b8e323a94590d16e56c246ef4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/StochasticScreenSpaceReflection/Shaders/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5246e5aeacc81e14995d281f1ef3ce0d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Textures/IBR_PreintegratedLUT.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ac2eae8984ea626489cc4634785b4b3f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/System_LUT/Material/SystemLUT_IBR_Material.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a5a7314cc1c44954ba16e75ca67a2f6a 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/ReflectionOcclusion.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fd59d7d1ab29e345871c064d7c18cbe 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Script.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2a891a3893977c94caf58a86a4c4039e 3 | folderAsset: yes 4 | timeCreated: 1509972427 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/System_LUT/RenderLUT/SystemLUT_IBR_RenderTexture.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ffd7f7b5cb283dc49a0362b74efb8321 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Common.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7234fdd1fca53c74b9540d0f6c5c4ecd 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Random.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ac17fe825447ea4dbc5ac125b6a7f59 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/InfinityShader/Refraction.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 197083037105cce4d9b31424419dec30 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Resources/Shader/Post.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0623be689353f546b115b4559dc6136 3 | folderAsset: yes 4 | timeCreated: 1511200584 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/AreaLight.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91b0090b90000a84bb1b4331721697db 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Resources/Shader/Surface.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fcb02fa5c98e4a940aee445e46b66090 3 | folderAsset: yes 4 | timeCreated: 1511200591 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/BSDF_Library.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a728d9c441a76348b47c7302740e97d 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Filtter_Library.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 017fc8d50e649a74c82971d069793f72 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Include_HLSL.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc87411af36a9d3418cadc50ec9df73c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Montcalo_Library.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 66910459dbc1d934da3fa5457461e053 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Noise_Library.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5fc868af7d3f8274082d3b61d2603066 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/ShadingModel.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1bd342f7a28dafa4680c0e3a050fb5ab 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/ReflectionOcclusion/GTSO.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c49da236832bca64c88c3501553c62cf 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 2100000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/ImageBasedLighting.hlsl.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e703bc8418a3eb48813f5911bfe417d 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Textures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1a53fff7dedfba4aab3c43f09eee5fd 3 | folderAsset: yes 4 | timeCreated: 1475269453 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/ReflectionOcclusion/GTSO_LUT.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3259ff3bea45efe4796e750ed7cb244a 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 8600000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64f7b51058309d540a1d7b8d37637f48 3 | folderAsset: yes 4 | timeCreated: 1528025577 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/StochasticScreenSpaceReflection/Script.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9e595e2c99a05e488dc4698ee7a154e 3 | folderAsset: yes 4 | timeCreated: 1528618027 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/StochasticScreenSpaceReflection/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7d67dd7f16212754ba27eac0aa85f0c3 3 | folderAsset: yes 4 | timeCreated: 1461434120 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/StochasticScreenSpaceReflection/Shaders/Resources/SSRPass.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a54adce9184ee3a42acdbd907059ef88 3 | timeCreated: 1466621325 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/System_LUT/Shaders/Resources/SystemLUT_IBR_Shader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e89dca435d9323a4c9caccc3f51a3fbf 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/GTAO.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2dbab40b5193e7640a8d53163872d2f7 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/GTAO_Pass.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d1b139a30c983e40aee1dc834dbeef0 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/ImageBasedReflection/Shaders/Resources/CustomGBuffer.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d78272daf988d784b939df9dc68f4492 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/GTAO_Common.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d8264880f6b9ea4cbdaececa3fcfd99 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Resources/Shader/Surface/Standard_Skin.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb744e82edaaa9042b4ce826eee1b1ed 3 | timeCreated: 1511704241 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Script/SeparableSubsurface.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c92ec05a0db5c984892e7ca6e7f1deac 3 | folderAsset: yes 4 | timeCreated: 1527164097 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Resources/Shader/Post/SeparableSubsurfaceScatter.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81489e72f0f0d1f438e0101f0cb9be8d 3 | timeCreated: 1509978750 4 | licenseType: Free 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/ReflectionOcclusion/GTSO_LUT.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 855d44dd94427de46a1d8370398e55a5 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Resources/Shader/Surface/Standard_Skin_Tessellation.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 466188f0062744a4f973164f1d7d37fa 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/StochasticScreenSpaceReflection/Shaders/Resources/SSRLibrary.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5e82bb51dbb6dd4e8c5f0be306e0f37 3 | timeCreated: 1466621325 4 | licenseType: Free 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/ReflectionOcclusion/SpecularOcclusionIntegrate.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aef7f2afa8c9a8f4aaf1198116d3db86 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: [] 6 | nonModifiableTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Resources/Shader/Post/SeparableSubsurfaceScatterCommon.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f9cdd8bffbbb014c900a4b2f1997e2d 3 | timeCreated: 1526811155 4 | licenseType: Free 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/StochasticScreenSpaceReflection/Shaders/Resources/StochasticScreenSpaceReflection.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 189b5a0299160974db35a8589c338bb8 3 | timeCreated: 1528549218 4 | licenseType: Free 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Script/SeparableSubsurface/SeparableSSSLibrary.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8adbcbb4816ac7541ba910c6eb2816f2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Script/ShaderIDs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88e554ffe9d0d934a9d66af4a2aa3f63 3 | timeCreated: 1528618039 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Script/GraphicsUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8600e59a33da2fd45ab8b962524e66bb 3 | timeCreated: 1528618039 4 | licenseType: Free 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/InfinityShader/Hair.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48df1c1260af31c4b9c5bbc49b11722c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: 6 | - _PreintegratedLUT: {fileID: 8600000, guid: fb1694502b019304f8ba19d4b9049186, type: 2} 7 | - _NomralTexture: {instanceID: 0} 8 | nonModifiableTextures: [] 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/ImageBasedReflection/Shaders/Resources/Custom-DeferredReflections.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f44b54346af304f4383aeb500b68932c 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: 6 | - _PreintegratedLUT: {fileID: 2800000, guid: a39cb4814e9b26b4b8282706720b7a27, type: 3} 7 | nonModifiableTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Include_HLSL.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _Include_HLSL_ 2 | #define _Include_HLSL_ 3 | 4 | #include "AreaLight.hlsl" 5 | #include "BSDF_Library.hlsl" 6 | #include "Common.hlsl" 7 | #include "Random.hlsl" 8 | #include "Filtter_Library.hlsl" 9 | #include "ImageBasedLighting.hlsl" 10 | #include "Montcalo_Library.hlsl" 11 | #include "Noise_Library.hlsl" 12 | #include "ShadingModel.hlsl" 13 | 14 | #endif -------------------------------------------------------------------------------- /Assets/TP/CGBull/InfinityShader/SuperStandard.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43d4379f6f2180e4d8f347761badc9ce 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: 6 | - _PreintegratedLUT: {fileID: 2800000, guid: a39cb4814e9b26b4b8282706720b7a27, type: 3} 7 | - _NomralTexture: {instanceID: 0} 8 | nonModifiableTextures: [] 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Script/GroundTruthOcclusion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e5720f3e4091d5649966a31a0c9adc84 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - GTSO_LUT: {fileID: 8600000, guid: 3259ff3bea45efe4796e750ed7cb244a, type: 2} 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/InfinityShader/Cloth.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e6554efb1d33624fb621e11e1f8ed58 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: 6 | - _PreintegratedLUT: {fileID: 2800000, guid: 0d712fa13cf8ae24ab72a70329769229, type: 3} 7 | - _AlbedoTexture: {instanceID: 0} 8 | - _NomralTexture: {instanceID: 0} 9 | nonModifiableTextures: [] 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/InfinityShader/ClearCoat.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bac9a7cccdebf8a43a887aacc7b4895f 3 | ShaderImporter: 4 | externalObjects: {} 5 | defaultTextures: 6 | - _PreintegratedLUT: {fileID: 2800000, guid: a39cb4814e9b26b4b8282706720b7a27, type: 3} 7 | - _NomralTexture: {instanceID: 0} 8 | - _ClearCoatNomralTexture: {instanceID: 0} 9 | nonModifiableTextures: [] 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Script/SeparableSubsurface/SeparableSubsurfaceScatter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 17cb4c49a230a5243b8b0bcc7c91f9a0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - BlueNoise: {fileID: 2800000, guid: be1a86331b04ef047b7dc25e87ae8982, type: 3} 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/StochasticScreenSpaceReflection/Script/StochasticScreenSpaceReflection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2529b19ec8088594985082181a497bc1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: 7 | - BlueNoise_LUT: {fileID: 2800000, guid: be1a86331b04ef047b7dc25e87ae8982, type: 3} 8 | - PreintegratedGF_LUT: {fileID: 2800000, guid: a39cb4814e9b26b4b8282706720b7a27, 9 | type: 3} 10 | executionOrder: 0 11 | icon: {instanceID: 0} 12 | userData: 13 | assetBundleName: 14 | assetBundleVariant: 15 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Script/ShaderIDs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public static class ShaderIDs { 4 | //Some Examples 5 | public static int _MainTex = Shader.PropertyToID("_MainTex"); 6 | //Use id value instead of string could have less cost. 7 | //Set your custom variables here 8 | public static int _TempTex = Shader.PropertyToID("_TempTex"); 9 | public static int _DepthTex = Shader.PropertyToID("_DepthTexture"); 10 | public static int _MirrorNormal = Shader.PropertyToID("_MirrorNormal"); 11 | public static int _MirrorPos = Shader.PropertyToID("_MirrorPos"); 12 | public static int _BlurOffset = Shader.PropertyToID("_BlurOffset"); 13 | } 14 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/System_LUT/Shaders/Resources/SystemLUT_IBR_Shader.shader: -------------------------------------------------------------------------------- 1 | Shader "CGBull/SystemLUT/SystemLUT_IBR_Shader" { 2 | Properties { 3 | 4 | } 5 | CGINCLUDE 6 | #include "UnityCG.cginc" 7 | #include "UnityCustomRenderTexture.cginc" 8 | #include "Assets/TP/CGBull/Common/Shaders/Resources/Include_HLSL.hlsl" 9 | 10 | //////////////PBR Integrated_GFD 11 | half3 frag_Integrated_GFD (v2f_customrendertexture i) : SV_Target { 12 | half2 uv = i.localTexcoord.xy; 13 | 14 | half DiffuseD = Standard_Burley(uv.x, uv.y); 15 | half2 ReflectionGF = Standard_Karis(uv.x, uv.y); 16 | 17 | return half3(ReflectionGF, DiffuseD); 18 | } 19 | ENDCG 20 | SubShader { 21 | Pass { 22 | Name "PBR_Integrated_GFD" 23 | CGPROGRAM 24 | #pragma vertex CustomRenderTextureVertexShader 25 | #pragma fragment frag_Integrated_GFD 26 | ENDCG 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/ReflectionOcclusion/GTSO_LUT.shader: -------------------------------------------------------------------------------- 1 | Shader "GTAO/GroundTruthSpecularOcclusion_LookUpTable" 2 | { 3 | 4 | CGINCLUDE 5 | #include "UnityCG.cginc" 6 | #include "UnityCustomRenderTexture.cginc" 7 | #include "SpecularOcclusionIntegrate.cginc" 8 | 9 | 10 | fixed4 frag_Integrate(v2f_customrendertexture i) : SV_TARGET 11 | { 12 | #if 1 13 | float3 uvw = i.localTexcoord.xyz; 14 | 15 | float thetaRef = uvw.x * 3.14 * 0.5; 16 | float roughness = uvw.y; 17 | 18 | float split = floor(uvw.z * 32); 19 | float cellZ = (split + 0.5) / 32.0; 20 | float cellW = uvw.z * 32 - split; 21 | float alphaV = 3.14 * 0.5 * cellZ; 22 | float beta = 3.14 * cellW; 23 | 24 | 25 | float GTSO_LUT = IntegrateGTSO(alphaV, beta, roughness, thetaRef); 26 | return GTSO_LUT; 27 | #else 28 | float2 uv = i.localTexcoord.xy; 29 | float alphaV = uv.x * 3.14 * 0.5; 30 | float thetaRef = uv.y * 3.14 * 0.5; 31 | float GTSO_LUT = IntegrateGTSO(alphaV, thetaRef, 1, thetaRef); 32 | return GTSO_LUT; 33 | #endif 34 | } 35 | ENDCG 36 | SubShader 37 | { 38 | ZTest Always 39 | Cull Off 40 | ZWrite Off 41 | 42 | Pass 43 | { 44 | CGPROGRAM 45 | #pragma vertex CustomRenderTextureVertexShader 46 | #pragma fragment frag_Integrate 47 | ENDCG 48 | } 49 | 50 | 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/System_LUT/RenderLUT/SystemLUT_IBR_RenderTexture.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!86 &8600000 4 | CustomRenderTexture: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: SystemLUT_IBR_RenderTexture 10 | m_ImageContentsHash: 11 | serializedVersion: 2 12 | Hash: 00000000000000000000000000000000 13 | m_ForcedFallbackFormat: 4 14 | m_DownscaleFallback: 0 15 | m_Width: 1024 16 | m_Height: 1024 17 | m_AntiAliasing: 1 18 | m_DepthFormat: 0 19 | m_ColorFormat: 11 20 | m_MipMap: 0 21 | m_GenerateMips: 1 22 | m_SRGB: 0 23 | m_UseDynamicScale: 0 24 | m_BindMS: 0 25 | m_TextureSettings: 26 | serializedVersion: 2 27 | m_FilterMode: 0 28 | m_Aniso: 0 29 | m_MipBias: 0 30 | m_WrapU: 1 31 | m_WrapV: 1 32 | m_WrapW: 1 33 | m_Dimension: 2 34 | m_VolumeDepth: 1 35 | m_Material: {fileID: 2100000, guid: a5a7314cc1c44954ba16e75ca67a2f6a, type: 2} 36 | m_InitSource: 0 37 | m_InitMaterial: {fileID: 0} 38 | m_InitColor: {r: 1, g: 1, b: 1, a: 1} 39 | m_InitTexture: {fileID: 0} 40 | m_UpdateMode: 1 41 | m_InitializationMode: 1 42 | m_UpdateZoneSpace: 0 43 | m_CurrentUpdateZoneSpace: 0 44 | m_UpdateZones: [] 45 | m_UpdatePeriod: 0 46 | m_ShaderPass: 0 47 | m_CubemapFaceMask: 4294967295 48 | m_DoubleBuffered: 0 49 | m_WrapUpdateZones: 0 50 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/GTAO.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/GroundTruthAmbientOcclusion" 2 | { 3 | CGINCLUDE 4 | #include "GTAO_Pass.cginc" 5 | ENDCG 6 | 7 | SubShader 8 | { 9 | ZTest Always 10 | Cull Off 11 | ZWrite Off 12 | 13 | Pass 14 | { 15 | Name"ResolveGTAO" 16 | CGPROGRAM 17 | #pragma vertex vert 18 | #pragma fragment ResolveGTAO_frag 19 | ENDCG 20 | } 21 | 22 | Pass 23 | { 24 | Name"SpatialGTAO_X" 25 | CGPROGRAM 26 | #pragma vertex vert 27 | #pragma fragment SpatialGTAO_X_frag 28 | ENDCG 29 | } 30 | 31 | Pass 32 | { 33 | Name"SpatialGTAO_Y" 34 | CGPROGRAM 35 | #pragma vertex vert 36 | #pragma fragment SpatialGTAO_Y_frag 37 | ENDCG 38 | } 39 | 40 | Pass 41 | { 42 | Name"TemporalGTAO" 43 | CGPROGRAM 44 | #pragma vertex vert 45 | #pragma fragment TemporalGTAO_frag 46 | ENDCG 47 | } 48 | 49 | Pass 50 | { 51 | Name"CombienGTAO" 52 | CGPROGRAM 53 | #pragma vertex vert 54 | #pragma fragment CombienGTAO_frag 55 | ENDCG 56 | } 57 | 58 | Pass 59 | { 60 | Name"DeBugGTAO" 61 | CGPROGRAM 62 | #pragma vertex vert 63 | #pragma fragment DeBugGTAO_frag 64 | ENDCG 65 | } 66 | 67 | Pass 68 | { 69 | Name"DeBugGTRO" 70 | CGPROGRAM 71 | #pragma vertex vert 72 | #pragma fragment DeBugGTRO_frag 73 | ENDCG 74 | } 75 | 76 | } 77 | } 78 | 79 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/ReflectionOcclusion/GTSO_LUT.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!86 &8600000 4 | CustomRenderTexture: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_Name: GTSO_LUT 10 | m_ImageContentsHash: 11 | serializedVersion: 2 12 | Hash: 00000000000000000000000000000000 13 | m_ForcedFallbackFormat: 4 14 | m_DownscaleFallback: 0 15 | m_Width: 512 16 | m_Height: 512 17 | m_AntiAliasing: 1 18 | m_DepthFormat: 0 19 | m_ColorFormat: 2 20 | m_MipMap: 0 21 | m_GenerateMips: 1 22 | m_SRGB: 0 23 | m_UseDynamicScale: 0 24 | m_BindMS: 0 25 | m_TextureSettings: 26 | serializedVersion: 2 27 | m_FilterMode: 1 28 | m_Aniso: 1 29 | m_MipBias: 0 30 | m_WrapU: 1 31 | m_WrapV: 1 32 | m_WrapW: 1 33 | m_Dimension: 3 34 | m_VolumeDepth: 512 35 | m_Material: {fileID: 2100000, guid: c49da236832bca64c88c3501553c62cf, type: 2} 36 | m_InitSource: 0 37 | m_InitMaterial: {fileID: 0} 38 | m_InitColor: {r: 1, g: 1, b: 1, a: 1} 39 | m_InitTexture: {fileID: 0} 40 | m_UpdateMode: 0 41 | m_InitializationMode: 0 42 | m_UpdateZoneSpace: 0 43 | m_CurrentUpdateZoneSpace: 0 44 | m_UpdateZones: [] 45 | m_UpdatePeriod: 0 46 | m_ShaderPass: 0 47 | m_CubemapFaceMask: 4294967295 48 | m_DoubleBuffered: 0 49 | m_WrapUpdateZones: 0 50 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Resources/Shader/Post/SeparableSubsurfaceScatter.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/SeparableSubsurfaceScatter" { 2 | CGINCLUDE 3 | #include "SeparableSubsurfaceScatterCommon.cginc" 4 | ENDCG 5 | 6 | SubShader { 7 | ZTest Always 8 | ZWrite Off 9 | Cull Off 10 | Stencil { 11 | Ref 5 12 | comp equal 13 | pass keep 14 | } 15 | Pass { 16 | Name "XBlur" 17 | CGPROGRAM 18 | #pragma vertex vert 19 | #pragma fragment XBlur_frag 20 | 21 | float4 XBlur_frag(PixelInput i) : SV_TARGET { 22 | float4 SceneColor = tex2D(_MainTex, i.uv); 23 | float SSSIntencity = (_SSSScale * _CameraDepthTexture_TexelSize.x); 24 | float3 XBlurPlus = SeparableSubsurface(SceneColor, i.uv, float2(SSSIntencity, 0)).rgb; 25 | float3 XBlurNagteiv = SeparableSubsurface(SceneColor, i.uv, float2(-SSSIntencity, 0)).rgb; 26 | float3 XBlur = (XBlurPlus + XBlurNagteiv) / 2; 27 | return float4(XBlur, SceneColor.a); 28 | } 29 | ENDCG 30 | } Pass { 31 | Name "YBlur" 32 | CGPROGRAM 33 | #pragma vertex vert 34 | #pragma fragment YBlur_frag 35 | 36 | float4 YBlur_frag(PixelInput i) : SV_TARGET { 37 | float4 SceneColor = tex2D(_MainTex, i.uv); 38 | float SSSIntencity = (_SSSScale * _CameraDepthTexture_TexelSize.y); 39 | float3 YBlurPlus = SeparableSubsurface(SceneColor, i.uv, float2(0, SSSIntencity)).rgb; 40 | float3 YBlurNagteiv = SeparableSubsurface(SceneColor, i.uv, float2(0, -SSSIntencity)).rgb; 41 | float3 YBlur = (YBlurPlus + YBlurNagteiv) / 2; 42 | return float4(YBlur, SceneColor.a); 43 | } 44 | ENDCG 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Noise_Library.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _Noise_Library_ 2 | #define _Noise_Library_ 3 | 4 | 5 | float RandN(float2 pos, float2 random) 6 | { 7 | return frac(sin(dot(pos.xy + random, float2(12.9898, 78.233))) * 43758.5453); 8 | } 9 | 10 | float2 RandN2(float2 pos, float2 random) 11 | { 12 | return frac(sin(dot(pos.xy + random, float2(12.9898, 78.233))) * float2(43758.5453, 28001.8384)); 13 | } 14 | 15 | float RandS(float2 pos, float2 random) 16 | { 17 | return RandN(pos, random) * 2.0 - 1.0; 18 | } 19 | 20 | float InterleavedGradientNoise (float2 pos, float2 random) 21 | { 22 | float3 magic = float3(0.06711056, 0.00583715, 52.9829189); 23 | return frac(magic.z * frac(dot(pos.xy + random, magic.xy))); 24 | } 25 | 26 | float Step1(float2 uv,float n) 27 | { 28 | float 29 | a = 1.0, 30 | b = 2.0, 31 | c = -12.0, 32 | t = 1.0; 33 | 34 | return (1.0/(a*4.0+b*4.0-c))*( 35 | RandS(uv+float2(-1.0,-1.0)*t,n)*a+ 36 | RandS(uv+float2( 0.0,-1.0)*t,n)*b+ 37 | RandS(uv+float2( 1.0,-1.0)*t,n)*a+ 38 | RandS(uv+float2(-1.0, 0.0)*t,n)*b+ 39 | RandS(uv+float2( 0.0, 0.0)*t,n)*c+ 40 | RandS(uv+float2( 1.0, 0.0)*t,n)*b+ 41 | RandS(uv+float2(-1.0, 1.0)*t,n)*a+ 42 | RandS(uv+float2( 0.0, 1.0)*t,n)*b+ 43 | RandS(uv+float2( 1.0, 1.0)*t,n)*a+ 44 | 0.0); 45 | } 46 | 47 | float Step2(float2 uv,float n) 48 | { 49 | float a=1.0,b=2.0,c=-2.0,t=1.0; 50 | return (4.0/(a*4.0+b*4.0-c))*( 51 | Step1(uv+float2(-1.0,-1.0)*t,n)*a+ 52 | Step1(uv+float2( 0.0,-1.0)*t,n)*b+ 53 | Step1(uv+float2( 1.0,-1.0)*t,n)*a+ 54 | Step1(uv+float2(-1.0, 0.0)*t,n)*b+ 55 | Step1(uv+float2( 0.0, 0.0)*t,n)*c+ 56 | Step1(uv+float2( 1.0, 0.0)*t,n)*b+ 57 | Step1(uv+float2(-1.0, 1.0)*t,n)*a+ 58 | Step1(uv+float2( 0.0, 1.0)*t,n)*b+ 59 | Step1(uv+float2( 1.0, 1.0)*t,n)*a+ 60 | 0.0); 61 | } 62 | 63 | float3 Step3T(float2 uv, float time) 64 | { 65 | float a=Step2(uv, 0.07*(frac(time)+1.0)); 66 | float b=Step2(uv, 0.11*(frac(time)+1.0)); 67 | float c=Step2(uv, 0.13*(frac(time)+1.0)); 68 | return float3(a,b,c); 69 | } 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/ReflectionOcclusion/GTSO.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: GTSO 11 | m_Shader: {fileID: 4800000, guid: 855d44dd94427de46a1d8370398e55a5, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/System_LUT/Material/SystemLUT_IBR_Material.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: SystemLUT_IBR_Material 11 | m_Shader: {fileID: 4800000, guid: e89dca435d9323a4c9caccc3f51a3fbf, type: 3} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 2800000, guid: a39cb4814e9b26b4b8282706720b7a27, type: 3} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/StochasticScreenSpaceReflection/Shaders/Resources/StochasticScreenSpaceReflection.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/StochasticScreenSpaceReflection" { 2 | 3 | CGINCLUDE 4 | #include "SSRPass.cginc" 5 | ENDCG 6 | 7 | SubShader { 8 | ZTest Always 9 | ZWrite Off 10 | Cull Front 11 | 12 | Pass 13 | { 14 | Name"Pass_HierarchicalZBuffer_Pass" 15 | CGPROGRAM 16 | #pragma vertex vert 17 | #pragma fragment Hierarchical_ZBuffer 18 | ENDCG 19 | } 20 | 21 | Pass 22 | { 23 | Name"Pass_Linear_2DTrace_SingleSampler" 24 | CGPROGRAM 25 | #pragma vertex vert 26 | #pragma fragment Linear_2DTrace_SingleSPP 27 | ENDCG 28 | } 29 | 30 | Pass 31 | { 32 | Name"Pass_Hierarchical_ZTrace_SingleSampler" 33 | CGPROGRAM 34 | #pragma vertex vert 35 | #pragma fragment Hierarchical_ZTrace_SingleSPP 36 | ENDCG 37 | } 38 | 39 | Pass 40 | { 41 | Name"Pass_Linear_2DTrace_MultiSampler" 42 | CGPROGRAM 43 | #pragma vertex vert 44 | #pragma fragment Linear_2DTrace_MultiSPP 45 | ENDCG 46 | } 47 | 48 | Pass 49 | { 50 | Name"Pass_Hierarchical_ZTrace_MultiSampler" 51 | CGPROGRAM 52 | #pragma vertex vert 53 | #pragma fragment Hierarchical_ZTrace_MultiSPP 54 | ENDCG 55 | } 56 | 57 | Pass 58 | { 59 | Name"Pass_Spatiofilter_SingleSampler" 60 | CGPROGRAM 61 | #pragma vertex vert 62 | #pragma fragment Spatiofilter_SingleSPP 63 | ENDCG 64 | } 65 | 66 | Pass 67 | { 68 | Name"Pass_Spatiofilter_MultiSampler" 69 | CGPROGRAM 70 | #pragma vertex vert 71 | #pragma fragment Spatiofilter_MultiSPP 72 | ENDCG 73 | } 74 | 75 | 76 | Pass 77 | { 78 | Name"Pass_Temporalfilter_SingleSampler" 79 | CGPROGRAM 80 | #pragma vertex vert 81 | #pragma fragment Temporalfilter_SingleSPP 82 | ENDCG 83 | } 84 | 85 | Pass 86 | { 87 | Name"Pass_Temporalfilter_MultiSampler" 88 | CGPROGRAM 89 | #pragma vertex vert 90 | #pragma fragment Temporalfilter_MultiSPP 91 | ENDCG 92 | } 93 | 94 | Pass 95 | { 96 | Name"Pass_CombineReflection" 97 | CGPROGRAM 98 | #pragma vertex vert 99 | #pragma fragment CombineReflectionColor 100 | ENDCG 101 | } 102 | 103 | Pass 104 | { 105 | Name"Pass_DeBug_SSRColor" 106 | CGPROGRAM 107 | #pragma vertex vert 108 | #pragma fragment DeBug_SSRColor 109 | ENDCG 110 | } 111 | 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/ImageBasedReflection/Shaders/Resources/CustomGBuffer.cginc: -------------------------------------------------------------------------------- 1 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt) 2 | 3 | #ifndef UNITY_GBUFFER_INCLUDED 4 | #define UNITY_GBUFFER_INCLUDED 5 | 6 | //----------------------------------------------------------------------------- 7 | // Main structure that store the data from the standard shader (i.e user input) 8 | struct UnityStandardData 9 | { 10 | half3 diffuseColor; 11 | half occlusion; 12 | 13 | half3 specularColor; 14 | half smoothness; 15 | 16 | float3 normalWorld; // normal in world space 17 | }; 18 | 19 | //----------------------------------------------------------------------------- 20 | // This will encode UnityStandardData into GBuffer 21 | void UnityStandardDataToGbuffer(UnityStandardData data, out half4 outGBuffer0, out half4 outGBuffer1, out half4 outGBuffer2) 22 | { 23 | // RT0: diffuse color (rgb), occlusion (a) - sRGB rendertarget 24 | outGBuffer0 = half4(data.diffuseColor, data.occlusion); 25 | 26 | // RT1: spec color (rgb), smoothness (a) - sRGB rendertarget 27 | outGBuffer1 = half4(data.specularColor, data.smoothness); 28 | 29 | // RT2: normal (rgb), --unused, very low precision-- (a) 30 | outGBuffer2 = half4(data.normalWorld * 0.5f + 0.5f, 1.0f); 31 | } 32 | //----------------------------------------------------------------------------- 33 | // This decode the Gbuffer in a UnityStandardData struct 34 | UnityStandardData UnityStandardDataFromGbuffer(half4 inGBuffer0, half4 inGBuffer1, half4 inGBuffer2) 35 | { 36 | UnityStandardData data; 37 | 38 | data.diffuseColor = inGBuffer0.rgb; 39 | data.occlusion = inGBuffer0.a; 40 | 41 | data.specularColor = inGBuffer1.rgb; 42 | float Roughness = 1 - inGBuffer1.a; 43 | data.smoothness = 1 - Roughness; 44 | 45 | data.normalWorld = normalize((float3)inGBuffer2.rgb * 2 - 1); 46 | 47 | return data; 48 | } 49 | //----------------------------------------------------------------------------- 50 | // In some cases like for terrain, the user want to apply a specific weight to the attribute 51 | // The function below is use for this 52 | void UnityStandardDataApplyWeightToGbuffer(inout half4 inOutGBuffer0, inout half4 inOutGBuffer1, inout half4 inOutGBuffer2, half alpha) 53 | { 54 | // With UnityStandardData current encoding, We can apply the weigth directly on the gbuffer 55 | inOutGBuffer0.rgb *= alpha; // diffuseColor 56 | inOutGBuffer1 *= alpha; // SpecularColor and Smoothness 57 | inOutGBuffer2.rgb *= alpha; // Normal 58 | } 59 | //----------------------------------------------------------------------------- 60 | 61 | #endif // #ifndef UNITY_GBUFFER_INCLUDED 62 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Textures/BlueNoise.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be1a86331b04ef047b7dc25e87ae8982 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 7 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 0 11 | linearTexture: 1 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: -3 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 0 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 0 38 | wrapV: 0 39 | wrapW: 0 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 1024 64 | resizeAlgorithm: 1 65 | textureFormat: 3 66 | textureCompression: 0 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | - serializedVersion: 2 73 | buildTarget: Standalone 74 | maxTextureSize: 1024 75 | resizeAlgorithm: 1 76 | textureFormat: 3 77 | textureCompression: 0 78 | compressionQuality: 50 79 | crunchedCompression: 0 80 | allowsAlphaSplitting: 0 81 | overridden: 0 82 | androidETC2FallbackOverride: 0 83 | spriteSheet: 84 | serializedVersion: 2 85 | sprites: [] 86 | outline: [] 87 | physicsShape: [] 88 | bones: [] 89 | spriteID: 90 | vertices: [] 91 | indices: 92 | edges: [] 93 | weights: [] 94 | spritePackingTag: 95 | pSDRemoveMatte: 0 96 | pSDShowRemoveMatteOption: 0 97 | userData: 98 | assetBundleName: 99 | assetBundleVariant: 100 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Textures/IBR_PreintegratedLUT/PBR_GFD.exr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a39cb4814e9b26b4b8282706720b7a27 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 9 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 0 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 0 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 256 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 2 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | - serializedVersion: 2 73 | buildTarget: Standalone 74 | maxTextureSize: 256 75 | resizeAlgorithm: 0 76 | textureFormat: -1 77 | textureCompression: 2 78 | compressionQuality: 50 79 | crunchedCompression: 0 80 | allowsAlphaSplitting: 0 81 | overridden: 0 82 | androidETC2FallbackOverride: 0 83 | spriteSheet: 84 | serializedVersion: 2 85 | sprites: [] 86 | outline: [] 87 | physicsShape: [] 88 | bones: [] 89 | spriteID: 90 | vertices: [] 91 | indices: 92 | edges: [] 93 | weights: [] 94 | spritePackingTag: 95 | pSDRemoveMatte: 0 96 | pSDShowRemoveMatteOption: 0 97 | userData: 98 | assetBundleName: 99 | assetBundleVariant: 100 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Textures/IBR_PreintegratedLUT/Cloth_PBR_GFD.exr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d712fa13cf8ae24ab72a70329769229 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 9 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 0 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 0 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 256 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 2 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | - serializedVersion: 2 73 | buildTarget: Standalone 74 | maxTextureSize: 256 75 | resizeAlgorithm: 0 76 | textureFormat: -1 77 | textureCompression: 2 78 | compressionQuality: 50 79 | crunchedCompression: 0 80 | allowsAlphaSplitting: 0 81 | overridden: 0 82 | androidETC2FallbackOverride: 0 83 | spriteSheet: 84 | serializedVersion: 2 85 | sprites: [] 86 | outline: [] 87 | physicsShape: [] 88 | bones: [] 89 | spriteID: 90 | vertices: [] 91 | indices: 92 | edges: [] 93 | weights: [] 94 | spritePackingTag: 95 | pSDRemoveMatte: 0 96 | pSDShowRemoveMatteOption: 0 97 | userData: 98 | assetBundleName: 99 | assetBundleVariant: 100 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Textures/IBR_PreintegratedLUT/Cloth_Cloth_GFD.exr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f81c29e686b8f2145b40cbf8ab1264bf 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | externalObjects: {} 6 | serializedVersion: 9 7 | mipmaps: 8 | mipMapMode: 0 9 | enableMipMap: 0 10 | sRGBTexture: 0 11 | linearTexture: 0 12 | fadeOut: 0 13 | borderMipMap: 0 14 | mipMapsPreserveCoverage: 0 15 | alphaTestReferenceValue: 0.5 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: 0.25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | streamingMipmaps: 0 25 | streamingMipmapsPriority: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 0 35 | aniso: -1 36 | mipBias: -100 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spritePixelsToUnits: 100 49 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 50 | spriteGenerateFallbackPhysicsShape: 1 51 | alphaUsage: 1 52 | alphaIsTransparency: 0 53 | spriteTessellationDetail: -1 54 | textureType: 0 55 | textureShape: 1 56 | singleChannelComponent: 0 57 | maxTextureSizeSet: 0 58 | compressionQualitySet: 0 59 | textureFormatSet: 0 60 | platformSettings: 61 | - serializedVersion: 2 62 | buildTarget: DefaultTexturePlatform 63 | maxTextureSize: 256 64 | resizeAlgorithm: 0 65 | textureFormat: -1 66 | textureCompression: 2 67 | compressionQuality: 50 68 | crunchedCompression: 0 69 | allowsAlphaSplitting: 0 70 | overridden: 0 71 | androidETC2FallbackOverride: 0 72 | - serializedVersion: 2 73 | buildTarget: Standalone 74 | maxTextureSize: 256 75 | resizeAlgorithm: 0 76 | textureFormat: -1 77 | textureCompression: 2 78 | compressionQuality: 50 79 | crunchedCompression: 0 80 | allowsAlphaSplitting: 0 81 | overridden: 0 82 | androidETC2FallbackOverride: 0 83 | spriteSheet: 84 | serializedVersion: 2 85 | sprites: [] 86 | outline: [] 87 | physicsShape: [] 88 | bones: [] 89 | spriteID: 90 | vertices: [] 91 | indices: 92 | edges: [] 93 | weights: [] 94 | spritePackingTag: 95 | pSDRemoveMatte: 0 96 | pSDShowRemoveMatteOption: 0 97 | userData: 98 | assetBundleName: 99 | assetBundleVariant: 100 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Resources/Shader/Post/SeparableSubsurfaceScatterCommon.cginc: -------------------------------------------------------------------------------- 1 | #include "UnityCG.cginc" 2 | #define DistanceToProjectionWindow 5.671281819617709 //1.0 / tan(0.5 * radians(20)); 3 | #define DPTimes300 1701.384545885313 //DistanceToProjectionWindow * 300 4 | #define SamplerSteps 25 5 | 6 | uniform float _SSSScale; 7 | uniform float4 _Kernel[SamplerSteps], _Jitter, _NoiseSize, _screenSize, _CameraDepthTexture_TexelSize; 8 | uniform sampler2D _MainTex, _CameraDepthTexture, _Noise; 9 | 10 | struct VertexInput { 11 | float4 vertex : POSITION; 12 | float2 uv : TEXCOORD0; 13 | }; 14 | 15 | struct PixelInput { 16 | float4 pos : SV_POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | PixelInput vert (VertexInput v) { 21 | PixelInput o; 22 | o.pos = v.vertex; 23 | o.uv = v.uv; 24 | return o; 25 | } 26 | 27 | float4 _RandomSeed; 28 | inline int2 ihash(int2 n) 29 | { 30 | n = (n << 13) ^ n; 31 | return (n*(n*n * 15731 + 789221) + 1376312589) & 2147483647; 32 | } 33 | 34 | inline int3 ihash(int3 n) 35 | { 36 | n = (n << 13) ^ n; 37 | return (n*(n*n * 15731 + 789221) + 1376312589) & 2147483647; 38 | } 39 | 40 | inline float2 frand(int2 n) 41 | { 42 | return ihash(n) / 2147483647.0; 43 | } 44 | 45 | inline float3 frand(int3 n) 46 | { 47 | return ihash(n) / 2147483647.0; 48 | } 49 | 50 | inline float2 cellNoise(float2 p) 51 | { 52 | int seed = dot(p, float2(641338.4168541, 963955.16871685)); 53 | return sin(float2(frand(int2(seed, seed - 53))) * _RandomSeed.xy + _RandomSeed.zw); 54 | } 55 | 56 | inline float3 cellNoise(float3 p) 57 | { 58 | int seed = dot(p, float3(641738.4168541, 9646285.16871685, 3186964.168734)); 59 | return sin(float3(frand(int3(seed, seed - 12, seed - 57))) * _RandomSeed.xyz + _RandomSeed.w); 60 | } 61 | 62 | float4 SeparableSubsurface(float4 SceneColor, float2 UV, float2 SSSIntencity) { 63 | float SceneDepth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UV)); 64 | float BlurLength = DistanceToProjectionWindow / SceneDepth; 65 | float2 UVOffset = SSSIntencity * BlurLength; 66 | //float2 jitter = tex2Dlod(_Noise, float4((UV + _Jitter.zw) * _screenSize.xy / _NoiseSize.xy, 0, -255)).xy; 67 | //float2 jitter = cellNoise(UV); 68 | //float2x2 rotateMatrix = float2x2(jitter.x, jitter.y, -jitter.y, jitter.x); 69 | float4 BlurSceneColor = SceneColor; 70 | BlurSceneColor.rgb *= _Kernel[0].rgb; 71 | 72 | UNITY_LOOP 73 | for (int i = 1; i < SamplerSteps; i++) { 74 | 75 | //[flatten] if(abs(_Kernel[i].a) < 0.05) UVOffset = mul(UVOffset, rotateMatrix); 76 | 77 | float2 SSSUV = UV + _Kernel[i].a * UVOffset; 78 | float4 SSSSceneColor = tex2D(_MainTex, SSSUV); 79 | float SSSDepth = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, SSSUV)).r; 80 | float SSSScale = saturate(DPTimes300 * SSSIntencity * abs(SceneDepth - SSSDepth)); 81 | SSSSceneColor.rgb = lerp(SSSSceneColor.rgb, SceneColor.rgb, SSSScale); 82 | BlurSceneColor.rgb += _Kernel[i].rgb * SSSSceneColor.rgb; 83 | 84 | } 85 | return BlurSceneColor; 86 | } -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Script/GraphicsUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | 6 | public static class GraphicsUtility 7 | { 8 | public static Mesh mesh 9 | { 10 | get 11 | { 12 | if (m_mesh != null) 13 | return m_mesh; 14 | m_mesh = new Mesh(); 15 | m_mesh.vertices = new Vector3[] { 16 | new Vector3(-1,-1,0.5f), 17 | new Vector3(-1,1,0.5f), 18 | new Vector3(1,1,0.5f), 19 | new Vector3(1,-1,0.5f) 20 | }; 21 | m_mesh.uv = new Vector2[] { 22 | new Vector2(0,1), 23 | new Vector2(0,0), 24 | new Vector2(1,0), 25 | new Vector2(1,1) 26 | }; 27 | 28 | m_mesh.SetIndices(new int[] { 0, 1, 2, 3 }, MeshTopology.Quads, 0); 29 | return m_mesh; 30 | } 31 | } 32 | 33 | public static Mesh m_mesh; 34 | public static void BlitMRT(this CommandBuffer buffer, RenderTargetIdentifier[] colorIdentifier, RenderTargetIdentifier depthIdentifier, Material mat, int pass) 35 | { 36 | buffer.SetRenderTarget(colorIdentifier, depthIdentifier); 37 | buffer.DrawMesh(mesh, Matrix4x4.identity, mat, 0, pass); 38 | } 39 | 40 | public static void BlitSRT(this CommandBuffer buffer, RenderTargetIdentifier destination, Material mat, int pass) 41 | { 42 | buffer.SetRenderTarget(destination); 43 | buffer.DrawMesh(mesh, Matrix4x4.identity, mat, 0, pass); 44 | } 45 | 46 | public static void BlitMRT(this CommandBuffer buffer, Texture source, RenderTargetIdentifier[] colorIdentifier, RenderTargetIdentifier depthIdentifier, Material mat, int pass) 47 | { 48 | buffer.SetRenderTarget(colorIdentifier, depthIdentifier); 49 | buffer.DrawMesh(mesh, Matrix4x4.identity, mat, 0, pass); 50 | } 51 | 52 | public static void BlitSRT(this CommandBuffer buffer, Texture source, RenderTargetIdentifier destination, Material mat, int pass) 53 | { 54 | buffer.SetGlobalTexture(ShaderIDs._MainTex, source); 55 | buffer.SetRenderTarget(destination); 56 | buffer.DrawMesh(mesh, Matrix4x4.identity, mat, 0, pass); 57 | } 58 | 59 | public static void BlitSRT(this CommandBuffer buffer, RenderTargetIdentifier source, RenderTargetIdentifier destination, Material mat, int pass) 60 | { 61 | buffer.SetGlobalTexture(ShaderIDs._MainTex, source); 62 | buffer.SetRenderTarget(destination); 63 | buffer.DrawMesh(mesh, Matrix4x4.identity, mat, 0, pass); 64 | }//Use This 65 | 66 | public static void BlitStencil(this CommandBuffer buffer, RenderTargetIdentifier colorSrc, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthStencilBuffer, Material mat, int pass) { 67 | buffer.SetGlobalTexture(ShaderIDs._MainTex, colorSrc); 68 | buffer.SetRenderTarget(colorBuffer, depthStencilBuffer); 69 | buffer.DrawMesh(mesh, Matrix4x4.identity, mat, 0, pass); 70 | }//UseThis 71 | 72 | public static void BlitStencil(this CommandBuffer buffer, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthStencilBuffer, Material mat, int pass) 73 | { 74 | buffer.SetRenderTarget(colorBuffer, depthStencilBuffer); 75 | buffer.DrawMesh(mesh, Matrix4x4.identity, mat, 0, pass); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/ReflectionOcclusion/SpecularOcclusionIntegrate.cginc: -------------------------------------------------------------------------------- 1 | #include "UnityStandardBRDF.cginc" 2 | float HaltonSequence (uint index, uint base = 3) { 3 | float result = 0; 4 | float f = 1; 5 | int i = index; 6 | 7 | UNITY_UNROLL 8 | while (i > 0) { 9 | f = f / base; 10 | result = result + f * (i % base); 11 | i = floor(i / base); 12 | } 13 | return result; 14 | } 15 | 16 | float2 Hammersley(int i, int N) { 17 | return float2(float(i) * (1 / float(N)), HaltonSequence(i, 3)); 18 | } 19 | 20 | float4 ImportanceSampleGGX(float2 E, float Roughness) { 21 | float m = Roughness * Roughness; 22 | float m2 = m * m; 23 | 24 | float Phi = 2 * 3.14 * E.x; 25 | float CosTheta = sqrt((1 - E.y) / ( 1 + (m2 - 1) * E.y)); 26 | float SinTheta = sqrt(1 - CosTheta * CosTheta); 27 | 28 | float3 H; 29 | H.x = SinTheta * cos(Phi); 30 | H.y = SinTheta * sin(Phi); 31 | H.z = CosTheta; 32 | 33 | float d = (CosTheta * m2 - CosTheta) * CosTheta + 1; 34 | float D = m2 / (3.14 * d * d); 35 | 36 | float PDF = D * CosTheta; 37 | 38 | return float4(H, PDF); 39 | } 40 | 41 | float FresnelSchlickApprox(float F0, float HoV){ 42 | return F0 + (1 - F0) * Pow5(1 - HoV); 43 | } 44 | 45 | float Beckmann(float NoH, float Roughness) 46 | { 47 | float a = Roughness * Roughness; 48 | float a2 = a * a; 49 | float NoH2 = NoH * NoH; 50 | return exp((NoH2 - 1) / (a2 * NoH2)) / (3.14 * a2 * NoH2 * NoH2); 51 | } 52 | 53 | float GGX(float NoH, float Roughness) 54 | { 55 | float a = Roughness * Roughness; 56 | float a2 = a * a; 57 | float d = (NoH * a2 - NoH) * NoH + 1; 58 | return a2 / (3.14 * d * d); 59 | } 60 | 61 | float Vis_SmithJointApprox(float NoL, float NoV, float Roughness) 62 | { 63 | float a = Roughness * Roughness; 64 | float Vis_SmithV = NoL * (NoV * (1 - a) + a); 65 | float Vis_SmithL = NoV * (NoL * (1 - a) + a); 66 | return 0.5 * rcp(Vis_SmithV + Vis_SmithL); 67 | } 68 | 69 | float CookTorranceBRDF(float NoH, float NoL, float NoV, float VoH, float roughness) 70 | { 71 | roughness = clamp(roughness, 0.04, 1); 72 | float pbr_GGX = GGX(NoH, roughness); 73 | float pbr_Geometry = Vis_SmithJointApprox(NoL, NoV, roughness); 74 | float pbr_Fersnel = FresnelSchlickApprox(0.04, VoH); 75 | return pbr_Geometry * (pbr_GGX * NoL) * pbr_Fersnel; 76 | } 77 | 78 | //注意:thetaOut和beta都与纬度无关 79 | float IntegrateGTSO(float alphaV, float beta, float roughness, float thetaRef) 80 | { 81 | const uint NumSamples = 128; 82 | float3 V = float3(sin(-thetaRef), 0, cos(thetaRef)); 83 | float3 BN = float3(sin(thetaRef - beta), 0, cos(thetaRef - beta)); 84 | float NoV = V.z; 85 | float accV = 0; 86 | float acc = 0; 87 | float brdf = 0; 88 | for (uint i = 0; i < NumSamples; i++) 89 | { 90 | float2 E = Hammersley(i, NumSamples); 91 | float4 sample = ImportanceSampleGGX(E, roughness); 92 | float3 H = sample.xyz; 93 | float3 L = 2 * dot(V, H) * H - V; 94 | 95 | float NoL = saturate(L.z); 96 | float NoH = saturate(H.z); 97 | float VoH = saturate(dot(V, H)); 98 | brdf = CookTorranceBRDF(NoH, NoL, NoV, VoH, roughness); 99 | if (acos(dot(BN, L)) < alphaV) 100 | { 101 | accV += brdf; 102 | } 103 | acc += brdf ; 104 | } 105 | return accV / acc; 106 | } -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Script/SeparableSubsurface/SeparableSSSLibrary.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | public static class SeparableSSSLibrary { 7 | public static void CalculateKernel(List kernel, int nSamples, Vector3 strength, Vector3 falloff){ 8 | float RANGE = nSamples > 20 ? 3.0f : 2.0f; 9 | float EXPONENT = 2.0f; 10 | kernel.Clear(); 11 | 12 | // Calculate the SSS_Offset_UV: 13 | float step = 2.0f * RANGE / (nSamples - 1); 14 | for (int i = 0; i < nSamples; i++){ 15 | float o = -RANGE + i * step; 16 | float sign = o < 0.0f ? -1.0f : 1.0f; 17 | float w = RANGE * sign *Mathf.Abs(Mathf.Pow(o, EXPONENT)) / Mathf.Pow(RANGE, EXPONENT); 18 | kernel.Add(new Vector4(0, 0, 0, w)); 19 | } 20 | // Calculate the SSS_Scale: 21 | for (int i = 0; i < nSamples; i++){ 22 | float w0 = i > 0 ? Mathf.Abs(kernel[i].w - kernel[i - 1].w) : 0.0f; 23 | float w1 = i < nSamples - 1 ? Mathf.Abs(kernel[i].w - kernel[i + 1].w) : 0.0f; 24 | float area = (w0 + w1) / 2.0f; 25 | Vector3 temp = profile(kernel[i].w, falloff); 26 | Vector4 tt = new Vector4(area * temp.x, area * temp.y, area * temp.z, kernel[i].w); 27 | kernel[i] = tt; 28 | } 29 | Vector4 t = kernel[nSamples / 2]; 30 | for (int i = nSamples / 2; i > 0; i--) 31 | kernel[i] = kernel[i - 1]; 32 | kernel[0] = t; 33 | Vector4 sum = Vector4.zero; 34 | 35 | for (int i = 0; i < nSamples; i++){ 36 | sum.x += kernel[i].x; 37 | sum.y += kernel[i].y; 38 | sum.z += kernel[i].z; 39 | } 40 | 41 | for (int i = 0; i < nSamples; i++){ 42 | Vector4 vecx = kernel[i]; 43 | vecx.x /= sum.x; 44 | vecx.y /= sum.y; 45 | vecx.z /= sum.z; 46 | kernel[i] = vecx; 47 | } 48 | 49 | Vector4 vec = kernel[0]; 50 | vec.x = (1.0f - strength.x) * 1.0f + strength.x * vec.x; 51 | vec.y = (1.0f - strength.y) * 1.0f + strength.y * vec.y; 52 | vec.z = (1.0f - strength.z) * 1.0f + strength.z * vec.z; 53 | kernel[0] = vec; 54 | 55 | for (int i = 1; i < nSamples; i++){ 56 | var vect = kernel[i]; 57 | vect.x *= strength.x; 58 | vect.y *= strength.y; 59 | vect.z *= strength.z; 60 | kernel[i] = vect; 61 | } 62 | } 63 | 64 | 65 | private static Vector3 gaussian(float variance, float r, Vector3 falloff){ 66 | Vector3 g; 67 | 68 | float rr1 = r / (0.001f + falloff.x); 69 | g.x = Mathf.Exp((-(rr1 * rr1)) / (2.0f * variance)) / (2.0f * 3.14f * variance); 70 | 71 | float rr2 = r / (0.001f + falloff.y); 72 | g.y = Mathf.Exp((-(rr2 * rr2)) / (2.0f * variance)) / (2.0f * 3.14f * variance); 73 | 74 | float rr3 = r / (0.001f + falloff.z); 75 | g.z = Mathf.Exp((-(rr3 * rr3)) / (2.0f * variance)) / (2.0f * 3.14f * variance); 76 | 77 | return g; 78 | } 79 | private static Vector3 profile(float r, Vector3 falloff){ 80 | return 0.100f * gaussian(0.0484f, r, falloff) + 81 | 0.118f * gaussian(0.187f, r, falloff) + 82 | 0.113f * gaussian(0.567f, r, falloff) + 83 | 0.358f * gaussian(1.99f, r, falloff) + 84 | 0.078f * gaussian(7.41f, r, falloff); 85 | } 86 | } -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/GTAO_Pass.cginc: -------------------------------------------------------------------------------- 1 | #include "GTAO_Common.cginc" 2 | 3 | //////Resolve Pass 4 | half3 ResolveGTAO_frag(PixelInput IN) : SV_Target 5 | { 6 | half2 uv = IN.uv.xy; 7 | 8 | half SSAODepth = 0; 9 | half4 GT_Details = GTAO(uv, (int)_SSAO_DirSampler, (int)_SSAO_SliceSampler, SSAODepth); 10 | 11 | half3 BentNormal = mul((half3x3)_SSAO_CameraToWorldMatrix, half3(GT_Details.rg, -GT_Details.b)); 12 | half3 WorldNormal = tex2D(_CameraGBufferTexture2, uv).rgb * 2 - 1; 13 | half4 Specular = tex2D(_CameraGBufferTexture1, uv); 14 | half Roughness = 1 - Specular.a; 15 | half SceneDepth = tex2D(_CameraDepthTexture, uv).r; 16 | half4 WorldPos = mul(_SSAO_InverseViewProjectionMatrix, half4(half3(uv * 2 - 1, SceneDepth), 1)); 17 | WorldPos.xyz /= WorldPos.w; 18 | half3 ViewDir = normalize(WorldPos.xyz - _WorldSpaceCameraPos.rgb); 19 | half3 ReflectionDir = reflect(ViewDir, WorldNormal); 20 | 21 | //half GTRO = ReflectionOcclusion_LUT(uv, AO.r, Roughness, BentNormal); 22 | half GTRO = ReflectionOcclusion(BentNormal, ReflectionDir, Roughness, 0.5); 23 | half GTAO = lerp(1, GT_Details.a, _SSAO_Intensity); 24 | 25 | return half3(GTAO, GTRO, SSAODepth); 26 | } 27 | 28 | //////Spatial filter 29 | half3 SpatialGTAO_X_frag(PixelInput IN) : SV_Target 30 | { 31 | half2 uv = IN.uv.xy; 32 | half3 AOR = BilateralBlur(uv, half2(1 / _ScreenParams.x, 0)); 33 | return AOR; 34 | } 35 | 36 | half3 SpatialGTAO_Y_frag(PixelInput IN) : SV_Target 37 | { 38 | half2 uv = IN.uv.xy; 39 | half3 AOR = BilateralBlur(uv, half2(0, 1 / _ScreenParams.y)); 40 | return AOR; 41 | } 42 | 43 | //////Temporal filter 44 | half2 TemporalGTAO_frag(PixelInput IN) : SV_Target 45 | { 46 | half2 uv = IN.uv.xy; 47 | half2 velocity = tex2D(_CameraMotionVectorsTexture, uv); 48 | 49 | half SSAO_Variance = 0; 50 | half4 filterColor = 0; 51 | half4 minColor, maxColor; 52 | ResolverAABB(_SSAO_Spatial_RT, 0, 0, _SSAO_TemporalScale, uv, _SSAO_TexelSize.zw, SSAO_Variance, minColor, maxColor, filterColor); 53 | 54 | half4 currColor = filterColor; 55 | half4 lastColor = tex2D(_SSAO_TemporalPrev_RT, uv - velocity); 56 | lastColor = clamp(lastColor, minColor, maxColor); 57 | 58 | half weight = saturate(_SSAO_TemporalWeight * (1 - length(velocity) * 8)); 59 | half4 temporalColor = lerp(currColor, lastColor, weight); 60 | 61 | return temporalColor.rg; 62 | } 63 | 64 | //////Combien Scene Color 65 | half3 CombienGTAO_frag(PixelInput IN) : SV_Target 66 | { 67 | half2 uv = IN.uv.xy; 68 | 69 | //////AO & MultiBounce 70 | half2 GT_Occlusion = tex2D(_SSAO_TemporalCurr_RT, uv).rg; 71 | half3 GTAO = GT_Occlusion.r; 72 | half GTRO = GT_Occlusion.g; 73 | 74 | if (_SSAO_MultiBounce == 1) 75 | { 76 | half3 Albedo = tex2D(_CameraGBufferTexture0, uv); 77 | GTAO = MultiBounce(GTAO, Albedo); 78 | } 79 | 80 | half3 RelfectionColor = tex2D(_CameraReflectionsTexture, uv).rgb; 81 | half3 SceneColor = GTAO * (tex2D(_SSAO_SceneColor_RT, uv) - RelfectionColor); 82 | RelfectionColor *= GTRO; 83 | 84 | return half4(SceneColor + RelfectionColor, GTRO); 85 | } 86 | 87 | //////DeBug AO 88 | half3 DeBugGTAO_frag(PixelInput IN) : SV_Target 89 | { 90 | half2 uv = IN.uv.xy; 91 | 92 | //////AO & MultiBounce 93 | half3 GTAO = tex2D(_SSAO_TemporalCurr_RT, uv).r; 94 | 95 | if (_SSAO_MultiBounce == 1) 96 | { 97 | half3 Albedo = tex2D(_CameraGBufferTexture0, uv); 98 | GTAO = MultiBounce(GTAO, Albedo); 99 | } 100 | 101 | return GTAO; 102 | } 103 | 104 | //////DeBug RO 105 | half3 DeBugGTRO_frag(PixelInput IN) : SV_Target 106 | { 107 | half2 uv = IN.uv.xy; 108 | 109 | //////AO & MultiBounce 110 | half GTRO = tex2D(_SSAO_TemporalCurr_RT, uv).g; 111 | 112 | return GTRO; 113 | } -------------------------------------------------------------------------------- /Assets/TP/CGBull/ImageBasedReflection/Shaders/Resources/Custom-DeferredReflections.shader: -------------------------------------------------------------------------------- 1 | // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt) 2 | 3 | Shader "Hidden/Internal-DeferredReflections" { 4 | Properties { 5 | _PreintegratedLUT ("PreintegratedLUT", 2D) = "black" {} 6 | _SrcBlend ("", Float) = 1 7 | _DstBlend ("", Float) = 1 8 | } 9 | SubShader { 10 | 11 | // Calculates reflection contribution from a single probe (rendered as cubes) or default reflection (rendered as full screen quad) 12 | Pass { 13 | ZWrite Off 14 | ZTest LEqual 15 | Blend [_SrcBlend] [_DstBlend] 16 | CGPROGRAM 17 | #pragma target 3.0 18 | #pragma vertex vert_deferred 19 | #pragma fragment frag 20 | 21 | #include "UnityCG.cginc" 22 | #include "UnityDeferredLibrary.cginc" 23 | #include "UnityStandardUtils.cginc" 24 | #include "CustomGBuffer.cginc" 25 | #include "Assets/TP/CGBull/Common/Shaders/Resources/Include_HLSL.hlsl" 26 | #include "UnityPBSLighting.cginc" 27 | 28 | sampler2D _PreintegratedLUT; 29 | sampler2D _CameraGBufferTexture0; 30 | sampler2D _CameraGBufferTexture1; 31 | sampler2D _CameraGBufferTexture2; 32 | 33 | half3 distanceFromAABB(half3 p, half3 aabbMin, half3 aabbMax) { 34 | return max(max(p - aabbMax, aabbMin - p), half3(0.0, 0.0, 0.0)); 35 | } 36 | 37 | half4 frag (unity_v2f_deferred i) : SV_Target { 38 | i.ray = i.ray * (_ProjectionParams.z / i.ray.z); 39 | float2 uv = i.uv.xy / i.uv.w; 40 | 41 | float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv); 42 | depth = Linear01Depth (depth); 43 | float4 viewPos = float4(i.ray * depth,1); 44 | float3 worldPos = mul (unity_CameraToWorld, viewPos).xyz; 45 | float3 viewDir = normalize(worldPos - _WorldSpaceCameraPos); 46 | 47 | half4 gbuffer0 = tex2D (_CameraGBufferTexture0, uv); 48 | half4 gbuffer1 = tex2D (_CameraGBufferTexture1, uv); 49 | half4 gbuffer2 = tex2D (_CameraGBufferTexture2, uv); 50 | UnityStandardData data = UnityStandardDataFromGbuffer(gbuffer0, gbuffer1, gbuffer2); 51 | 52 | UnityGIInput d; 53 | d.worldPos = worldPos; 54 | d.worldViewDir = -viewDir; 55 | d.probeHDR[0] = unity_SpecCube0_HDR; 56 | d.boxMin[0].w = 1; 57 | 58 | float blendDistance = unity_SpecCube1_ProbePosition.w; 59 | #ifdef UNITY_SPECCUBE_BOX_PROJECTION 60 | d.probePosition[0] = unity_SpecCube0_ProbePosition; 61 | d.boxMin[0].xyz = unity_SpecCube0_BoxMin - float4(blendDistance,blendDistance,blendDistance,0); 62 | d.boxMax[0].xyz = unity_SpecCube0_BoxMax + float4(blendDistance,blendDistance,blendDistance,0); 63 | #endif 64 | 65 | half3 worldNormal = data.normalWorld; 66 | half3 worldViewDir = d.worldViewDir; 67 | half3 specularColor = data.specularColor; 68 | half glossness = data.smoothness; 69 | half NoV = dot(worldNormal, worldViewDir); 70 | Unity_GlossyEnvironmentData g = UnityGlossyEnvironmentSetup(data.smoothness, d.worldViewDir, data.normalWorld, data.specularColor); 71 | half3 env0 = UnityGI_IndirectSpecular(d, data.occlusion, g); 72 | 73 | half3 D = env0.rgb; 74 | half3 EnergyCompensation; 75 | half3 GF = PreintegratedDGF_LUT(_PreintegratedLUT, EnergyCompensation, specularColor, 1 - glossness, NoV).rgb; 76 | half3 distance = distanceFromAABB(worldPos, unity_SpecCube0_BoxMin.xyz, unity_SpecCube0_BoxMax.xyz); 77 | half falloff = saturate(1.0 - length(distance)/blendDistance); 78 | return half4(D * GF * EnergyCompensation, falloff); 79 | } 80 | 81 | ENDCG 82 | } 83 | 84 | // Adds reflection buffer to the lighting buffer 85 | Pass 86 | { 87 | ZWrite Off 88 | ZTest Always 89 | Blend [_SrcBlend] [_DstBlend] 90 | 91 | CGPROGRAM 92 | #pragma target 3.0 93 | #pragma vertex vert 94 | #pragma fragment frag 95 | #pragma multi_compile ___ UNITY_HDR_ON 96 | 97 | #include "UnityCG.cginc" 98 | 99 | sampler2D _CameraReflectionsTexture; 100 | 101 | struct v2f { 102 | float2 uv : TEXCOORD0; 103 | float4 pos : SV_POSITION; 104 | }; 105 | 106 | v2f vert (float4 vertex : POSITION) 107 | { 108 | v2f o; 109 | o.pos = UnityObjectToClipPos(vertex); 110 | o.uv = ComputeScreenPos (o.pos).xy; 111 | return o; 112 | } 113 | 114 | half4 frag (v2f i) : SV_Target 115 | { 116 | half4 c = tex2D (_CameraReflectionsTexture, i.uv); 117 | #ifdef UNITY_HDR_ON 118 | return float4(c.rgb, 0.0f); 119 | #else 120 | return float4(exp2(-c.rgb), 0.0f); 121 | #endif 122 | 123 | } 124 | ENDCG 125 | } 126 | 127 | } 128 | Fallback Off 129 | } 130 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Script/SeparableSubsurface/SeparableSubsurfaceScatter.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine.Rendering; 4 | using UnityEngine; 5 | 6 | [ExecuteInEditMode] 7 | //[ImageEffectAllowedInSceneView] 8 | [RequireComponent(typeof(Camera))] 9 | public class SeparableSubsurfaceScatter : MonoBehaviour { 10 | 11 | public bool DisableFPSLimit = false; 12 | ///////SSS Property 13 | public Texture2D BlueNoise; 14 | 15 | [Range(0,5)] 16 | public float SubsurfaceScaler = 0.25f; 17 | 18 | public Color SubsurfaceColor; 19 | 20 | public Color SubsurfaceFalloff; 21 | 22 | 23 | private Camera RenderCamera = null; 24 | private CommandBuffer SubsurfaceBuffer = null; 25 | private Material SubsurfaceEffects= null; 26 | private List KernelArray = new List(); 27 | 28 | 29 | 30 | ///////SSS Buffer 31 | static int SceneColorID = Shader.PropertyToID("_SceneColor"); 32 | static int Kernel = Shader.PropertyToID("_Kernel"); 33 | static int SSSScaler = Shader.PropertyToID("_SSSScale"); 34 | static int Noise = Shader.PropertyToID("_Noise"); 35 | static int Jitter = Shader.PropertyToID("_Jitter"); 36 | static int screenSize = Shader.PropertyToID("_screenSize"); 37 | static int NoiseSize = Shader.PropertyToID("_NoiseSize"); 38 | 39 | void OnEnable() { 40 | InstanceProperty(); 41 | } 42 | 43 | void OnPreRender() { 44 | UpdateSubsurface(); 45 | } 46 | 47 | void OnDisable() { 48 | if (SubsurfaceBuffer != null) { 49 | RenderCamera.RemoveCommandBuffer(CameraEvent.AfterForwardOpaque, SubsurfaceBuffer); 50 | SubsurfaceEffects = null; 51 | SubsurfaceBuffer = null; 52 | RenderCamera = null; 53 | } 54 | } 55 | 56 | private void OnDestroy() 57 | { 58 | if (SubsurfaceBuffer != null) 59 | { 60 | SubsurfaceBuffer.Dispose(); 61 | } 62 | } 63 | 64 | void InstanceProperty() { 65 | RenderCamera = GetComponent(); 66 | RenderCamera.clearStencilAfterLightingPass = true; //Clear deferred stencil 67 | if (SubsurfaceEffects == null) { 68 | SubsurfaceEffects = new Material(Shader.Find("Hidden/SeparableSubsurfaceScatter")); 69 | SubsurfaceEffects.SetTexture(Noise, BlueNoise); 70 | SubsurfaceEffects.SetVector(NoiseSize, new Vector2(64, 64)); 71 | } 72 | if (SubsurfaceBuffer == null) { 73 | SubsurfaceBuffer = new CommandBuffer(); 74 | SubsurfaceBuffer.name = "Separable Subsurface Scatter"; 75 | RenderCamera.AddCommandBuffer(CameraEvent.AfterForwardOpaque, SubsurfaceBuffer); 76 | } 77 | } 78 | 79 | void UpdateSubsurface() { 80 | ///SSS Color 81 | Vector3 SSSC = Vector3.Normalize(new Vector3 (SubsurfaceColor.r, SubsurfaceColor.g, SubsurfaceColor.b)); 82 | Vector3 SSSFC = Vector3.Normalize(new Vector3 (SubsurfaceFalloff.r, SubsurfaceFalloff.g, SubsurfaceFalloff.b)); 83 | SeparableSSSLibrary.CalculateKernel(KernelArray, 25, SSSC, SSSFC); 84 | Vector2 jitterSample = GenerateRandomOffset(); 85 | if (SubsurfaceEffects != null) { 86 | SubsurfaceEffects.SetVector(Jitter, new Vector4((float)BlueNoise.width, (float)BlueNoise.height, jitterSample.x, jitterSample.y)); 87 | SubsurfaceEffects.SetVector(screenSize, new Vector4((float)RenderCamera.pixelWidth, (float)RenderCamera.pixelHeight, 0, 0)); 88 | SubsurfaceEffects.SetVectorArray(Kernel, KernelArray); 89 | SubsurfaceEffects.SetFloat(SSSScaler, SubsurfaceScaler); 90 | SubsurfaceEffects.SetFloat("_RandomSeed", Random.Range(0, 100)); 91 | } 92 | ///SSS Buffer 93 | SubsurfaceBuffer.Clear(); 94 | SubsurfaceBuffer.GetTemporaryRT (SceneColorID, RenderCamera.pixelWidth, RenderCamera.pixelHeight, 0, FilterMode.Trilinear, RenderTextureFormat.DefaultHDR); 95 | 96 | SubsurfaceBuffer.BlitStencil(BuiltinRenderTextureType.CameraTarget, SceneColorID, BuiltinRenderTextureType.CameraTarget, SubsurfaceEffects, 0); 97 | SubsurfaceBuffer.BlitSRT(SceneColorID, BuiltinRenderTextureType.CameraTarget, SubsurfaceEffects, 1); 98 | } 99 | 100 | private float GetHaltonValue(int index, int radix) { 101 | float result = 0f; 102 | float fraction = 1f / (float)radix; 103 | 104 | while (index > 0) { 105 | result += (float)(index % radix) * fraction; 106 | index /= radix; 107 | fraction /= (float)radix; 108 | } 109 | return result; 110 | } 111 | 112 | private int SampleCount = 64; 113 | private int SampleIndex = 0; 114 | private Vector2 GenerateRandomOffset() { 115 | var offset = new Vector2(GetHaltonValue(SampleIndex & 1023, 2), GetHaltonValue(SampleIndex & 1023, 3)); 116 | if (SampleIndex++ >= SampleCount) 117 | SampleIndex = 0; 118 | return offset; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/ImageBasedLighting.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _ImageBasedLighting_ 2 | #define _ImageBasedLighting_ 3 | 4 | #include "BSDF_Library.hlsl" 5 | #include "ShadingModel.hlsl" 6 | //#include "UnityImageBasedLighting.cginc" 7 | 8 | half PBR_G(half NoL, half NoV, half a) { 9 | half a2 = pow4(a); 10 | half GGXL = NoV * sqrt((-NoL * a2 + NoL) * NoL + a2); 11 | half GGXV = NoL * sqrt((-NoV * a2 + NoV) * NoV + a2); 12 | return (2 * NoL) / (GGXV + GGXL); 13 | } 14 | 15 | //////////////////////////Environment LUT 16 | half Standard_Burley(half Roughness, half NoV) { 17 | half3 V; 18 | V.x = sqrt(1 - NoV * NoV); 19 | V.y = 0; 20 | V.z = NoV; 21 | 22 | half r = 0; 23 | const uint NumSamples = 64; 24 | for (uint i = 0; i < NumSamples; i++) { 25 | half2 E = Hammersley(i, NumSamples, HaltonSequence(i)); 26 | half3 H = CosineSampleHemisphere(E).rgb; 27 | half3 L = 2 * dot(V, H) * H - V; 28 | 29 | //half NoL = saturate(L.z); 30 | 31 | //if (NoL > 0) { 32 | half NoL = saturate(L.b); 33 | half LoH = saturate(dot(L, H)); 34 | half Diffuse = Diffuse_Burley_NoPi(LoH, NoL, NoV, Roughness); 35 | //half Diffuse = Diffuse_RenormalizeBurley_NoPi(LoH, NoL, NoV, Roughness); 36 | //half Diffuse = Diffuse_OrenNayar_NoPi(LoH, NoL, NoV, Roughness); 37 | r += Diffuse; 38 | //} 39 | } 40 | return r / NumSamples; 41 | } 42 | 43 | 44 | half2 Standard_Karis(half Roughness, half NoV) { 45 | half3 V; 46 | V.x = sqrt(1 - NoV * NoV); 47 | V.y = 0; 48 | V.z = NoV; 49 | 50 | half2 r = 0; 51 | const uint NumSamples = 64; 52 | for (uint i = 0; i < NumSamples; i++) { 53 | half2 E = Hammersley(i, NumSamples, HaltonSequence(i)); 54 | half3 H = ImportanceSampleGGX(E, Roughness).rgb; 55 | half3 L = 2 * dot(V, H) * H - V; 56 | 57 | half VoH = saturate(dot(V, H)); 58 | half NoL = saturate(L.z); 59 | half NoH = saturate(H.z); 60 | 61 | if (NoL > 0) { 62 | half G = PBR_G(NoL, NoV, Roughness); 63 | half Gv = G * VoH / NoH; 64 | half Fc = pow(1 - VoH, 5); 65 | //r.x += Gv * (1 - Fc); 66 | r.x += Gv; 67 | r.y += Gv * Fc; 68 | } 69 | } 70 | return r / NumSamples; 71 | } 72 | 73 | half2 Standard_Karis_Approx(half Roughness, half NoV) { 74 | const half4 c0 = half4(-1.0, -0.0275, -0.572, 0.022); 75 | const half4 c1 = half4( 1.0, 0.0425, 1.040, -0.040); 76 | half4 r = Roughness * c0 + c1; 77 | half a004 = min(r.x * r.x, exp2(-9.28 * NoV)) * r.x + r.y; 78 | return half2(-1.04, 1.04) * a004 + r.zw; 79 | } 80 | 81 | half Standard_Karis_Approx_Nonmetal(half Roughness, half NoV) { 82 | const half2 c0 = { -1, -0.0275 }; 83 | const half2 c1 = { 1, 0.0425 }; 84 | half2 r = Roughness * c0 + c1; 85 | return min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y; 86 | } 87 | 88 | 89 | half2 Cloth_Ashikhmin_Approx(half Roughness, half NoV) { 90 | const half4 c0 = half4(0.24, 0.93, 0.01, 0.20); 91 | const half4 c1 = half4(2, -1.30, 0.40, 0.03); 92 | 93 | half s = 1 - NoV; 94 | half e = s - c0.y; 95 | half g = c0.x * exp2(-(e * e) / (2 * c0.z)) + s * c0.w; 96 | half n = Roughness * c1.x + c1.y; 97 | half r = max(1 - n * n, c1.z) * g; 98 | 99 | return half2(r, r * c1.w); 100 | } 101 | 102 | half2 Cloth_Charlie_Approx(half Roughness, half NoV) { 103 | const half3 c0 = half3(0.95, 1250, 0.0095); 104 | const half4 c1 = half4(0.04, 0.2, 0.3, 0.2); 105 | 106 | half a = 1 - NoV; 107 | half b = 1 - (Roughness); 108 | 109 | half n = pow(c1.x + a, 64); 110 | half e = b - c0.x; 111 | half g = exp2(-(e * e) * c0.y); 112 | half f = b + c1.y; 113 | half a2 = a * a; 114 | half a3 = a2 * a; 115 | half c = n * g + c1.z * (a + c1.w) * Roughness + f * f * a3 * a3 * a2; 116 | half r = min(c, 18); 117 | 118 | return half2(r, r * c0.z); 119 | } 120 | 121 | 122 | half3 ImageBasedLighting_Hair(half3 V, float3 N, float3 specularColor, float Roughness, float Scatter) { 123 | float3 Lighting = 0; 124 | uint NumSamples = 32; 125 | 126 | UNITY_LOOP 127 | for( uint i = 0; i < NumSamples; i++ ) { 128 | float2 E = Hammersley(i, NumSamples, HaltonSequence(i)); 129 | float3 L = UniformSampleSphere(E).rgb; 130 | { 131 | float PDF = 1 / (4 * PI); 132 | float InvWeight = PDF * NumSamples; 133 | float Weight = rcp(InvWeight); 134 | 135 | float3 Shading = 0; 136 | Shading = Hair_Lit(L, V, N, specularColor, 0.5, Roughness, 0, Scatter, 0, 0); 137 | 138 | Lighting += Shading * Weight; 139 | } 140 | } 141 | return Lighting; 142 | } 143 | 144 | 145 | //////////Enviornment BRDF 146 | #ifndef Multi_Scatter 147 | #define Multi_Scatter 1 148 | #endif 149 | 150 | half4 PreintegratedDGF_LUT(sampler2D PreintegratedLUT, inout half3 EnergyCompensation, half3 SpecularColor, half Roughness, half NoV) 151 | { 152 | half3 AB = tex2Dlod(PreintegratedLUT, half4(Roughness, NoV, 0, 0)).rgb; 153 | half3 ReflectionGF = lerp(saturate(50 * SpecularColor.g) * AB.ggg, AB.rrr, SpecularColor); 154 | 155 | #if Multi_Scatter 156 | EnergyCompensation = 1 + SpecularColor * (1 / AB.r - 1); 157 | #else 158 | EnergyCompensation = 1; 159 | #endif 160 | 161 | return half4(ReflectionGF, AB.b); 162 | } 163 | 164 | half3 PreintegratedGF_ClothAshikhmin(half3 SpecularColor, half Roughness, half NoV) 165 | { 166 | half2 AB = Cloth_Ashikhmin_Approx(Roughness, NoV); 167 | return SpecularColor * AB.r + AB.g; 168 | } 169 | 170 | half3 PreintegratedGF_ClothCharlie(half3 SpecularColor, half Roughness, half NoV) 171 | { 172 | float2 AB = Cloth_Charlie_Approx(Roughness, NoV); 173 | return SpecularColor * AB.r + AB.g; 174 | } 175 | 176 | #endif 177 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/ShadingModel.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef __SHADING_MODEL__ 2 | #define __SHADING_MODEL__ 3 | 4 | #include "BSDF_Library.hlsl" 5 | 6 | half3 Defult_Lit(BSDFContext LightData, half3 Attenuation, half3 MultiScatterEnergy, half3 AlbedoColor, half3 SpecularColor, half Roughness) 7 | { 8 | half3 Diffuse = Diffuse_RenormalizeBurley(LightData.LoH, LightData.NoL, LightData.NoV, AlbedoColor, Roughness); 9 | 10 | half pbr_GGX = D_GGX(LightData.NoH, Roughness); 11 | half pbr_Vis = Vis_SmithGGXCorrelated(LightData.NoL, LightData.NoV, Roughness); 12 | half3 pbr_Fresnel = F_Schlick(SpecularColor, 1, LightData.LoH); 13 | 14 | half3 Specular = (pbr_Vis * pbr_GGX) * pbr_Fresnel; 15 | Specular *= MultiScatterEnergy; 16 | 17 | return max( 0, (Diffuse + Specular) * Attenuation ); 18 | } 19 | 20 | half3 Skin_Lit(BSDFContext LightData, half3 Attenuation, half3 MultiScatterEnergy, half3 AlbedoColor, half3 SpecularColor, half Roughness) 21 | { 22 | half3 Diffuse = Diffuse_RenormalizeBurley(LightData.LoH, LightData.NoL, LightData.NoV, AlbedoColor, Roughness); 23 | 24 | half pbr_GGX = lerp(D_Beckmann(LightData.NoH, Roughness), D_Beckmann(LightData.NoH, Roughness * 0.5), 0.85); 25 | half pbr_Vis = Vis_SmithGGXCorrelated(LightData.NoL, LightData.NoV, Roughness); 26 | half3 pbr_Fresnel = F_Schlick(SpecularColor, 1, LightData.LoH); 27 | 28 | half3 Specular = (pbr_Vis * pbr_GGX) * pbr_Fresnel; 29 | Specular *= MultiScatterEnergy; 30 | 31 | return max( 0, (Diffuse + Specular) * Attenuation ); 32 | } 33 | 34 | half3 ClearCoat_Lit(BSDFContext LightData, half3 Attenuation, half3 MultiScatterEnergy, half3 ClearCoat_MultiScatterEnergy, half3 AlbedoColor, half3 SpecularColor, half ClearCoat, half ClearCoat_Roughness, half Roughness) 35 | { 36 | half3 Diffuse = Diffuse_RenormalizeBurley(LightData.LoH, LightData.NoL, LightData.NoV, AlbedoColor, Roughness); 37 | 38 | half F0 = pow5(1 - LightData.VoH); 39 | 40 | half ClearCoat_GGX = D_GGX(LightData.NoH, ClearCoat_Roughness); 41 | half ClearCoat_Vis = Vis_Kelemen(LightData.VoH); 42 | half ClearCoat_Fersnel = (F0 + (1 - F0) * 0.05) * ClearCoat; 43 | half ClearCoat_Specular = ClearCoat_GGX * ClearCoat_Vis * ClearCoat_Fersnel; 44 | ClearCoat_Specular *= ClearCoat_MultiScatterEnergy; 45 | 46 | half pbr_GGX = D_GGX(LightData.NoH, Roughness); 47 | half pbr_Vis = Vis_SmithGGXCorrelated(LightData.NoL, LightData.NoV, Roughness); 48 | half3 pbr_Fresnel = saturate(50 * SpecularColor.g) * F0 + (1 - F0) * SpecularColor; 49 | half3 BaseSpecular = (pbr_Vis * pbr_GGX) * pbr_Fresnel; 50 | BaseSpecular *= MultiScatterEnergy; 51 | 52 | 53 | half LayerAttenuation = (1 - ClearCoat_Fersnel); 54 | return max( 0, (Diffuse + BaseSpecular + ClearCoat_Specular) * Attenuation * LayerAttenuation ); 55 | } 56 | 57 | half3 Cloth_Cotton(BSDFContext LightData, half3 Attenuation, half3 AlbedoColor, half3 SpecularColor, half Roughness) 58 | { 59 | half3 Diffuse = Diffuse_Fabric(AlbedoColor, Roughness); 60 | 61 | #if _Ashikhmin_Charlie 62 | half pbr_InvGGX = D_InverseGGX_Charlie(LightData.NoH, Roughness); 63 | half pbr_Vis = Vis_InverseGGX_Charlie(LightData.NoL + 1e-7, LightData.NoV + 1e-7, Roughness); 64 | #else 65 | half pbr_InvGGX = D_InverseGGX_Ashikhmin(LightData.NoH, Roughness); 66 | half pbr_Vis = Vis_InverseGGX_Ashikhmin(LightData.NoL, LightData.NoV); 67 | #endif 68 | half3 pbr_Fresnel = F_Schlick(SpecularColor, 1, LightData.LoH); 69 | 70 | half3 Specular = (pbr_Vis * pbr_InvGGX) * pbr_Fresnel; 71 | 72 | return max( 0, (Diffuse + Specular) * Attenuation ); 73 | } 74 | 75 | half3 Cloth_Silk(BSDFContext LightData, AnisoBSDFContext AnisoLightContext, half3 Attenuation, half3 MultiScatterEnergy, half3 AlbedoColor, half3 SpecularColor, half Roughness, half RoughnessT, half RoughnessB) 76 | { 77 | 78 | half3 Diffuse = Diffuse_Fabric(AlbedoColor, Roughness); 79 | 80 | half pbr_AnisoGGX = D_AnisotropyGGX(AnisoLightContext.ToH, AnisoLightContext.BoH, LightData.NoH, RoughnessT, RoughnessB); 81 | half pbr_Vis = Vis_AnisotropyGGX(AnisoLightContext.ToV, AnisoLightContext.BoV, LightData.NoV, AnisoLightContext.ToL, AnisoLightContext.BoL, LightData.NoL, RoughnessT, RoughnessB); 82 | half3 pbr_Fresnel = F_Schlick(SpecularColor, 1, LightData.LoH); 83 | 84 | half3 Specular = (pbr_Vis * pbr_AnisoGGX) * pbr_Fresnel; 85 | Specular *= MultiScatterEnergy; 86 | 87 | return max(0, (Diffuse + Specular) * Attenuation); 88 | } 89 | 90 | float3 Hair_Lit(float3 L, float3 V, half3 N, float3 SpecularColor, float Specular, float Roughness,float Backlit, float Scatter, float Area, float Shadow) { 91 | Scatter = Scatter / 10; 92 | const float VoL = dot(V,L); 93 | const float SinThetaL = dot(N,L); 94 | const float SinThetaV = dot(N,V); 95 | float CosThetaD = cos(0.5 * abs(asinFast( SinThetaV ) - asinFast( SinThetaL))); 96 | 97 | const float3 Lp = L - SinThetaL * N; 98 | const float3 Vp = V - SinThetaV * N; 99 | const float CosPhi = dot(Lp,Vp) * rsqrt(dot(Lp,Lp) * dot(Vp,Vp) + 1e-4); 100 | const float CosHalfPhi = sqrt(saturate(0.5 + 0.5 * CosPhi)); 101 | 102 | float3 S = 0; 103 | float n = 1.55; 104 | float n_prime = 1.19 / CosThetaD + 0.36 * CosThetaD; 105 | float Shift = 0.035; 106 | 107 | float Alpha[3] = { 108 | -Shift * 2, 109 | Shift, 110 | Shift * 4, 111 | }; 112 | 113 | float B[3] = { 114 | Area + Square(Roughness), 115 | Area + Square(Roughness) / 2, 116 | Area + Square(Roughness) * 2, 117 | }; 118 | 119 | // R 120 | if(1) { 121 | const float sa = sin(Alpha[0]); 122 | const float ca = cos(Alpha[0]); 123 | float Shift = 2*sa* (ca * CosHalfPhi * sqrt(1 - SinThetaV * SinThetaV) + sa * SinThetaV); 124 | float Mp = Vis_Hair(B[0] * sqrt(2.0) * CosHalfPhi, SinThetaL + SinThetaV - Shift); 125 | float Np = 0.25 * CosHalfPhi; 126 | float Fp = F_Hair(sqrt(saturate( 0.5 + 0.5 * VoL))); 127 | S += Specular * Mp * Np * Fp * lerp(1, Backlit, saturate(-VoL)); 128 | } 129 | // TRT 130 | if(1) { 131 | float Mp = Vis_Hair(B[2], SinThetaL + SinThetaV - Alpha[2]); 132 | float f = F_Hair(CosThetaD * 0.5); 133 | float Fp = Square(1 - f) * f; 134 | float3 Tp = pow(SpecularColor, 0.8 / CosThetaD); 135 | float Np = exp(17 * CosPhi - 16.78); 136 | S += Mp * Np * Fp * Tp; 137 | } 138 | // TT 139 | if(1) { 140 | float Mp = Vis_Hair(B[1], SinThetaL + SinThetaV - Alpha[1]); 141 | float a = 1 / n_prime; 142 | float h = CosHalfPhi * (1 + a * (0.6 - 0.8 * CosPhi)); 143 | float f = F_Hair(CosThetaD * sqrt(saturate( 1 - h*h))); 144 | float Fp = Square(1 - f); 145 | float3 Tp = pow(SpecularColor, 0.5 * sqrt(1 - Square(h * a)) / CosThetaD); 146 | float Np = exp(-3.65 * CosPhi - 3.98); 147 | S += Mp * Np * Fp * Tp * Backlit; 148 | } 149 | // Scatter 150 | if(1) { 151 | float3 FakeNormal = normalize(V - N * dot(V, N)); 152 | N = FakeNormal; 153 | float Wrap = 1; 154 | float NoL = saturate((dot(N, L) + Wrap) / Square(1 + Wrap)); 155 | float DiffuseScatter = Inv_PI * NoL * Scatter; 156 | float Luma = Luminance(SpecularColor); 157 | float3 ScatterTint = pow(SpecularColor / Luma, Shadow); 158 | S += sqrt(SpecularColor) * DiffuseScatter * ScatterTint; 159 | } 160 | S = -min(-S, 0); 161 | return S; 162 | } 163 | 164 | #endif -------------------------------------------------------------------------------- /Assets/TP/CGBull/InfinityShader/Hair.shader: -------------------------------------------------------------------------------- 1 | Shader "CGBull/Infinity_Shader/Hair" { 2 | Properties { 3 | _Area ("Area", Range(0, 1)) = 1 4 | 5 | _SpecularColor ("SpecularColor", Color) = (0.7, 0.25, 0.1, 1) 6 | _SpecularIntensity ("SpecularIntensity", Range(0, 1)) = 0 7 | 8 | _Backlit ("Backlit", Range(0, 1)) = 1 9 | _ScatterIntensity ("ScatterIntensity", Range(0, 1)) = 0.2 10 | 11 | _Roughness ("Roughness", Range(0, 1)) = 0.3 12 | _NomralTexture ("NomralTexture", 2D) = "bump" {} 13 | _NormalTile ("NormalTile", Range(0, 100)) = 1 14 | } 15 | SubShader { 16 | Tags { "RenderType" = "Opaque" "Queue"="Geometry"} 17 | LOD 64 18 | Pass { 19 | Name "ForwardBase" 20 | Tags {"LightMode"="ForwardBase"} 21 | Cull Off 22 | 23 | CGPROGRAM 24 | #pragma vertex vert 25 | #pragma fragment frag 26 | 27 | #pragma multi_compile_fwdbase 28 | #pragma multi_compile_fwdbase_fullshadows 29 | #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON 30 | #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE 31 | #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON 32 | #pragma target 4.5 33 | 34 | #define SHOULD_SAMPLE_SH (defined (LIGHTMAP_OFF) && defined (DYNAMICLIGHTMAP_OFF)) 35 | 36 | #include "Assets/TP/CGBull/Common/Shaders/Resources/Include_HLSL.hlsl" 37 | #include "UnityCG.cginc" 38 | #include "AutoLight.cginc" 39 | #include "Lighting.cginc" 40 | #include "UnityPBSLighting.cginc" 41 | 42 | float _NormalTile, _SpecularIntensity, _Backlit, _ScatterIntensity, _Area, _Roughness; 43 | float4 _SpecularColor; 44 | sampler2D _NomralTexture; 45 | 46 | struct VertexInput { 47 | float4 pos : POSITION; 48 | float3 normal : NORMAL; 49 | float4 tangent : TANGENT; 50 | float2 uv0 : TEXCOORD0; 51 | float2 uv1 : TEXCOORD1; 52 | float2 uv2 : TEXCOORD2; 53 | }; 54 | 55 | struct PixelInput { 56 | float4 pos : SV_POSITION; 57 | float2 uv0 : TEXCOORD0; 58 | float2 uv1 : TEXCOORD1; 59 | float2 uv2 : TEXCOORD2; 60 | float4 posWorld : TEXCOORD3; 61 | float4 screenPos : TEXCOORD4; 62 | float3 normalDir : TEXCOORD5; 63 | float3 tangentDir : TEXCOORD6; 64 | float3 bitangentDir : TEXCOORD7; 65 | LIGHTING_COORDS(8,9) 66 | #if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH) 67 | float4 ambientOrLightmapUV : TEXCOORD8; 68 | #endif 69 | }; 70 | 71 | PixelInput vert (VertexInput v) { 72 | PixelInput o = (PixelInput)0; 73 | o.pos = UnityObjectToClipPos(v.pos); 74 | o.uv0 = v.uv0; 75 | o.uv1 = v.uv1; 76 | o.uv2 = v.uv2; 77 | o.posWorld = mul(unity_ObjectToWorld, v.pos); 78 | o.screenPos = ComputeScreenPos(o.pos); 79 | o.normalDir = UnityObjectToWorldNormal(v.normal); 80 | o.tangentDir = normalize(mul(unity_ObjectToWorld, float4(v.tangent.xyz, 0)).xyz); 81 | o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); 82 | #ifdef LIGHTMAP_ON 83 | o.ambientOrLightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 84 | o.ambientOrLightmapUV.zw = 0; 85 | #endif 86 | #ifdef DYNAMICLIGHTMAP_ON 87 | o.ambientOrLightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; 88 | #endif 89 | return o; 90 | } 91 | 92 | float4 frag(PixelInput i) : SV_TARGET { 93 | float2 screenUV = i.screenPos.xy / i.screenPos.w; 94 | float3 worldPos = i.posWorld.xyz; 95 | float3x3 tangentTransform = float3x3(i.tangentDir, i.bitangentDir, normalize(i.normalDir)); 96 | 97 | ////// Lighting Data: 98 | //////CommonData 99 | float3 viewDir = normalize(_WorldSpaceCameraPos.xyz - worldPos); 100 | float3 lightDir = normalize(_WorldSpaceLightPos0.xyz); 101 | float3 lightColor = _LightColor0.rgb; 102 | float lightAtten = UnityComputeForwardShadows(i.ambientOrLightmapUV, worldPos, i.screenPos); 103 | float3 lightAttenColor = lightAtten * _LightColor0.xyz; 104 | float3 halfDir = normalize(viewDir + lightDir); 105 | //////BaseData 106 | float3 nomralDir_Tex = UnpackNormal(tex2D(_NomralTexture, i.uv0 * _NormalTile)); 107 | float3 normalDir = normalize(mul(nomralDir_Tex, tangentTransform)); 108 | 109 | float3 viewReflectDir = reflect(-viewDir, normalDir); 110 | float NoL = saturate(dot(normalDir, lightDir)); 111 | float LoH = saturate(dot(lightDir, halfDir)); 112 | float NoV = abs(dot(normalDir, viewDir)); 113 | float NoH = saturate(dot(normalDir, halfDir)); 114 | 115 | ////// Material Property 116 | float3 specularColor = _SpecularColor; 117 | float specularIntensity = _SpecularIntensity; 118 | float roughness = clamp(_Roughness, 0.04, 1); 119 | 120 | /////// GI Data: 121 | UnityGIInput d; 122 | d.worldPos = worldPos; 123 | 124 | #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) 125 | d.ambient = 0; 126 | d.lightmapUV = i.ambientOrLightmapUV; 127 | #else 128 | d.ambient = i.ambientOrLightmapUV; 129 | #endif 130 | 131 | #if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION 132 | d.boxMin[0] = unity_SpecCube0_BoxMin; 133 | d.boxMin[1] = unity_SpecCube1_BoxMin; 134 | #endif 135 | 136 | #if UNITY_SPECCUBE_BOX_PROJECTION 137 | d.boxMax[0] = unity_SpecCube0_BoxMax; 138 | d.boxMax[1] = unity_SpecCube1_BoxMax; 139 | d.probePosition[0] = unity_SpecCube0_ProbePosition; 140 | d.probePosition[1] = unity_SpecCube1_ProbePosition; 141 | #endif 142 | 143 | d.probeHDR[0] = unity_SpecCube0_HDR; 144 | d.probeHDR[1] = unity_SpecCube1_HDR; 145 | Unity_GlossyEnvironmentData ugls_en_data; 146 | ugls_en_data.roughness = roughness; 147 | ugls_en_data.reflUVW = viewReflectDir; 148 | UnityGI gi = UnityGlobalIllumination(d, 1, normalDir, ugls_en_data); 149 | 150 | 151 | float3 hair_DirectionLighting = Hair_Lit(lightDir, viewDir, normalDir, specularColor, specularIntensity, roughness, _Backlit, _ScatterIntensity, _Area, lightAtten) * lightAttenColor; 152 | float3 hair_inDirectionLighting = ImageBasedLighting_Hair(viewDir, normalDir, specularColor, roughness, _ScatterIntensity); 153 | 154 | /////// Final Color 155 | float3 hair_Lighting = hair_DirectionLighting + hair_inDirectionLighting; 156 | return float4(hair_Lighting, 1); 157 | } 158 | ENDCG 159 | } 160 | } 161 | FallBack "Diffuse" 162 | } 163 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/InfinityShader/SuperStandard.shader: -------------------------------------------------------------------------------- 1 | Shader "CGBull/Infinity_Shader/SuperStandard" { 2 | Properties { 3 | [Header (LUT)] 4 | 5 | [NoScaleOffset]_PreintegratedLUT ("PreintegratedLUT", 2D) = "black" {} 6 | 7 | [Header (Microface)] 8 | 9 | _BaseColor ("BaseColor", Color) = (1, 1, 1, 1) 10 | _SpecularLevel ("SpecularLevel", Range(0, 1)) = 0.5 11 | _Reflectance ("Reflectance", Range(0, 1)) = 0 12 | _Roughness ("Roughness", Range(0, 1)) = 0 13 | 14 | 15 | 16 | [Header (Normal)] 17 | 18 | [NoScaleOffset]_NomralTexture ("NomralTexture", 2D) = "bump" {} 19 | _NormalTile ("NormalTile", Range(0, 100)) = 1 20 | 21 | 22 | 23 | [Header (Iridescence)] 24 | 25 | [Toggle (_Iridescence)] Iridescence ("Iridescence", Range(0, 1)) = 0 26 | _Iridescence_Distance ("Iridescence_Distance", Range(0, 1)) = 1 27 | } 28 | SubShader { 29 | Tags { "RenderType" = "Opaque" "Queue"="Geometry"} 30 | LOD 64 31 | Pass { 32 | Name "ForwardBase" 33 | Tags {"LightMode"="ForwardBase"} 34 | 35 | CGPROGRAM 36 | #pragma vertex vert 37 | #pragma fragment frag 38 | 39 | #pragma shader_feature _Iridescence 40 | 41 | #pragma multi_compile_fwdbase 42 | #pragma multi_compile_fwdbase_fullshadows 43 | #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON 44 | #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE 45 | #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON 46 | #pragma target 4.5 47 | 48 | #define SHOULD_SAMPLE_SH (defined (LIGHTMAP_OFF) && defined (DYNAMICLIGHTMAP_OFF)) 49 | 50 | #include "Assets/TP/CGBull/Common/Shaders/Resources/Include_HLSL.hlsl" 51 | #include "UnityCG.cginc" 52 | #include "AutoLight.cginc" 53 | #include "Lighting.cginc" 54 | #include "UnityPBSLighting.cginc" 55 | 56 | float _NormalTile, _Iridescence_Distance, _Reflectance, _SpecularLevel, _Roughness; 57 | float4 _BaseColor, _TransmissionColor; 58 | sampler2D _PreintegratedLUT, _NomralTexture; 59 | 60 | struct VertexInput { 61 | float4 pos : POSITION; 62 | float3 normal : NORMAL; 63 | float4 tangent : TANGENT; 64 | float2 uv0 : TEXCOORD0; 65 | float2 uv1 : TEXCOORD1; 66 | float2 uv2 : TEXCOORD2; 67 | }; 68 | 69 | struct PixelInput { 70 | float4 pos : SV_POSITION; 71 | float2 uv0 : TEXCOORD0; 72 | float2 uv1 : TEXCOORD1; 73 | float2 uv2 : TEXCOORD2; 74 | float4 posWorld : TEXCOORD3; 75 | float4 screenPos : TEXCOORD4; 76 | float3 normalDir : TEXCOORD5; 77 | float3 tangentDir : TEXCOORD6; 78 | float3 bitangentDir : TEXCOORD7; 79 | LIGHTING_COORDS(8,9) 80 | #if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH) 81 | float4 ambientOrLightmapUV : TEXCOORD8; 82 | #endif 83 | }; 84 | 85 | PixelInput vert (VertexInput v) { 86 | PixelInput o = (PixelInput)0; 87 | o.pos = UnityObjectToClipPos(v.pos); 88 | o.uv0 = v.uv0; 89 | o.uv1 = v.uv1; 90 | o.uv2 = v.uv2; 91 | o.posWorld = mul(unity_ObjectToWorld, v.pos); 92 | o.screenPos = ComputeScreenPos(o.pos); 93 | o.normalDir = UnityObjectToWorldNormal(v.normal); 94 | o.tangentDir = normalize(mul(unity_ObjectToWorld, float4(v.tangent.xyz, 0)).xyz); 95 | o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); 96 | #ifdef LIGHTMAP_ON 97 | o.ambientOrLightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 98 | o.ambientOrLightmapUV.zw = 0; 99 | #endif 100 | #ifdef DYNAMICLIGHTMAP_ON 101 | o.ambientOrLightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; 102 | #endif 103 | return o; 104 | } 105 | 106 | half3 frag(PixelInput i) : SV_TARGET { 107 | half2 screenUV = i.screenPos.xy / i.screenPos.w; 108 | half3 worldPos = i.posWorld.xyz; 109 | half3x3 tangentTransform = half3x3(i.tangentDir, i.bitangentDir, normalize(i.normalDir)); 110 | 111 | ////// Lighting Data: 112 | half3 viewDir = normalize(_WorldSpaceCameraPos.xyz - worldPos); 113 | half3 lightDir = normalize(_WorldSpaceLightPos0.xyz); 114 | half3 halfDir = normalize(viewDir + lightDir); 115 | half3 nomralDir_Tex = UnpackNormal(tex2D(_NomralTexture, i.uv0 * _NormalTile)); 116 | half3 normalDir = normalize(mul(nomralDir_Tex, tangentTransform)); 117 | half3 ReflectDir = reflect(-viewDir, normalDir); 118 | 119 | BSDFContext BSDFContext; 120 | Init(BSDFContext, normalDir, viewDir, lightDir, halfDir); 121 | 122 | half3 Attenuation = UnityComputeForwardShadows(i.ambientOrLightmapUV, worldPos, i.screenPos); 123 | Attenuation *= _LightColor0.rgb * BSDFContext.NoL; 124 | 125 | ////// Material Property 126 | half3 BaseColor = _BaseColor.rgb * (1 - _Reflectance); 127 | half Roughness = clamp(_Roughness, 0.04, 1); 128 | 129 | #if _Iridescence 130 | half3 Iridescence_Color = Flim_Iridescence(1, BSDFContext.NoV, _Iridescence_Distance, 0.04); 131 | half3 SpecularColor = lerp(0.08 * _SpecularLevel, Iridescence_Color, _Reflectance); 132 | #else 133 | half3 SpecularColor = lerp(0.08 * _SpecularLevel, _BaseColor.rgb, _Reflectance); 134 | #endif 135 | 136 | /////// GI Data: 137 | UnityGIInput d; 138 | d.worldPos = worldPos; 139 | 140 | #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) 141 | d.ambient = 0; 142 | d.lightmapUV = i.ambientOrLightmapUV; 143 | #else 144 | d.ambient = i.ambientOrLightmapUV; 145 | #endif 146 | 147 | #if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION 148 | d.boxMin[0] = unity_SpecCube0_BoxMin; 149 | d.boxMin[1] = unity_SpecCube1_BoxMin; 150 | #endif 151 | 152 | #if UNITY_SPECCUBE_BOX_PROJECTION 153 | d.boxMax[0] = unity_SpecCube0_BoxMax; 154 | d.boxMax[1] = unity_SpecCube1_BoxMax; 155 | d.probePosition[0] = unity_SpecCube0_ProbePosition; 156 | d.probePosition[1] = unity_SpecCube1_ProbePosition; 157 | #endif 158 | 159 | d.probeHDR[0] = unity_SpecCube0_HDR; 160 | d.probeHDR[1] = unity_SpecCube1_HDR; 161 | Unity_GlossyEnvironmentData ugls_en_data; 162 | ugls_en_data.roughness = Roughness; 163 | ugls_en_data.reflUVW = ReflectDir; 164 | UnityGI gi = UnityGlobalIllumination(d, 1, normalDir, ugls_en_data); 165 | 166 | 167 | /////// Final Color 168 | half3 MultiScatterEnergy; 169 | half4 Preintegrated_DGF = PreintegratedDGF_LUT(_PreintegratedLUT, MultiScatterEnergy, SpecularColor, Roughness, BSDFContext.NoV); 170 | half3 GlobalIllumination = (BaseColor * gi.indirect.diffuse * Preintegrated_DGF.a) + (gi.indirect.specular * Preintegrated_DGF.rgb * MultiScatterEnergy); 171 | 172 | half3 DefualtShading = Defult_Lit(BSDFContext, Attenuation, MultiScatterEnergy, BaseColor, SpecularColor, Roughness); 173 | 174 | return DefualtShading + GlobalIllumination; 175 | } 176 | ENDCG 177 | } 178 | } 179 | FallBack "Diffuse" 180 | } 181 | 182 | //half3 Transmission = TransmissionBRDF(lightDir, viewDir, normalDir, halfDir, transmissionColor, 1, 0.25); 183 | //half3 directSpecular = HairBRDF_Specular(lightDir, viewDir, normalDir, specularColor, 1, roughness, 1, 0.1, 1, lightAtten) * Energy; 184 | //half3 indirectSpecular = ImageBasedLighting_Hair(viewDir, normalDir, specularColor, roughness, 0.2); 185 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Montcalo_Library.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _Montcalo_Library_ 2 | #define _Montcalo_Library_ 3 | 4 | #include "Common.hlsl" 5 | 6 | uint ReverseBits32(uint bits) 7 | { 8 | bits = (bits << 16) | (bits >> 16); 9 | bits = ((bits & 0x00ff00ff) << 8) | ((bits & 0xff00ff00) >> 8); 10 | bits = ((bits & 0x0f0f0f0f) << 4) | ((bits & 0xf0f0f0f0) >> 4); 11 | bits = ((bits & 0x33333333) << 2) | ((bits & 0xcccccccc) >> 2); 12 | bits = ((bits & 0x55555555) << 1) | ((bits & 0xaaaaaaaa) >> 1); 13 | return bits; 14 | } 15 | 16 | uint2 SobolIndex(uint2 Base, int Index, int Bits = 10) { 17 | uint2 SobolNumbers[10] = { 18 | uint2(0x8680u, 0x4c80u), uint2(0xf240u, 0x9240u), uint2(0x8220u, 0x0e20u), uint2(0x4110u, 0x1610u), uint2(0xa608u, 0x7608u), 19 | uint2(0x8a02u, 0x280au), uint2(0xe204u, 0x9e04u), uint2(0xa400u, 0x4682u), uint2(0xe300u, 0xa74du), uint2(0xb700u, 0x9817u), 20 | }; 21 | 22 | uint2 Result = Base; 23 | [ROLL] 24 | for (int b = 0; b < 10 && b < Bits; ++b) { 25 | Result ^= (Index & (1 << b)) ? SobolNumbers[b] : 0; 26 | } 27 | return Result; 28 | } 29 | 30 | uint HaltonSequence(uint Index, uint base = 3) 31 | { 32 | uint result = 0; 33 | uint f = 1; 34 | uint i = Index; 35 | 36 | UNITY_UNROLL 37 | while (i > 0) { 38 | f = f / base; 39 | result = result + f * (i % base); 40 | i = floor(i / base); 41 | } 42 | return result; 43 | } 44 | 45 | float2 Hammersley(uint Index, uint NumSamples) 46 | { 47 | return float2((float)Index / (float)NumSamples, ReverseBits32(Index)); 48 | } 49 | 50 | float2 Hammersley(uint Index, uint NumSamples, uint2 Random) 51 | { 52 | float E1 = frac((float)Index / NumSamples + float(Random.x & 0xffff) / (1 << 16)); 53 | float E2 = float(ReverseBits32(Index) ^ Random.y) * 2.3283064365386963e-10; 54 | return float2(E1, E2); 55 | } 56 | 57 | float3x3 GetTangentBasis(float3 TangentZ) { 58 | float3 UpVector = abs(TangentZ.z) < 0.999 ? float3(0, 0, 1) : float3(1, 0, 0); 59 | float3 TangentX = normalize(cross( UpVector, TangentZ)); 60 | float3 TangentY = cross(TangentZ, TangentX); 61 | return float3x3(TangentX, TangentY, TangentZ); 62 | } 63 | 64 | float3 TangentToWorld(float3 Vec, float3 TangentZ) 65 | { 66 | return mul(Vec, GetTangentBasis(TangentZ)); 67 | } 68 | 69 | float4 TangentToWorld(float3 Vec, float4 TangentZ) 70 | { 71 | half3 T2W = TangentToWorld(Vec, TangentZ.rgb); 72 | return half4(T2W, TangentZ.a); 73 | } 74 | 75 | float2 RandToCircle(uint2 Rand) { 76 | float2 sf = float2(Rand) * (sqrt(2.) / 0xffff) - sqrt(0.5); 77 | float2 sq = sf*sf; 78 | float root = sqrt(2.*max(sq.x, sq.y) - min(sq.x, sq.y)); 79 | if (sq.x > sq.y) { 80 | sf.x = sf.x > 0 ? root : -root; 81 | } 82 | else { 83 | sf.y = sf.y > 0 ? root : -root; 84 | } 85 | return sf; 86 | } 87 | 88 | float4 UniformSampleSphere(float2 E) { 89 | float Phi = 2 * PI * E.x; 90 | float CosTheta = 1 - 2 * E.y; 91 | float SinTheta = sqrt(1 - CosTheta * CosTheta); 92 | 93 | float3 H; 94 | H.x = SinTheta * cos(Phi); 95 | H.y = SinTheta * sin(Phi); 96 | H.z = CosTheta; 97 | 98 | float PDF = 1 / (4 * PI); 99 | 100 | return float4(H, PDF); 101 | } 102 | 103 | float4 UniformSampleHemisphere(float2 E) { 104 | float Phi = 2 * PI * E.x; 105 | float CosTheta = E.y; 106 | float SinTheta = sqrt(1 - CosTheta * CosTheta); 107 | 108 | float3 H; 109 | H.x = SinTheta * cos( Phi ); 110 | H.y = SinTheta * sin( Phi ); 111 | H.z = CosTheta; 112 | 113 | float PDF = 1.0 / (2 * PI); 114 | return float4(H, PDF); 115 | } 116 | 117 | float2 UniformSampleDisk(float2 Random) { 118 | const float Theta = 2.0f * (float)PI * Random.x; 119 | const float Radius = sqrt(Random.y); 120 | return float2(Radius * cos(Theta), Radius * sin(Theta)); 121 | } 122 | 123 | float4 CosineSampleHemisphere(float2 E) { 124 | float Phi = 2 * PI * E.x; 125 | float CosTheta = sqrt(E.y); 126 | float SinTheta = sqrt(1 - CosTheta * CosTheta); 127 | 128 | float3 H; 129 | H.x = SinTheta * cos(Phi); 130 | H.y = SinTheta * sin(Phi); 131 | H.z = CosTheta; 132 | 133 | float PDF = CosTheta / PI; 134 | return float4(H, PDF); 135 | } 136 | 137 | float4 CosineSampleHemisphere(float2 E, float3 Normal) { 138 | float4 Sampler = CosineSampleHemisphere(E); 139 | return float4(normalize(Normal + Sampler.rgb), Sampler.a); 140 | } 141 | 142 | float4 UniformSampleCone(float2 E, float CosThetaMax) { 143 | float Phi = 2 * PI * E.x; 144 | float CosTheta = lerp(CosThetaMax, 1, E.y); 145 | float SinTheta = sqrt(1 - CosTheta * CosTheta); 146 | 147 | float3 L; 148 | L.x = SinTheta * cos( Phi ); 149 | L.y = SinTheta * sin( Phi ); 150 | L.z = CosTheta; 151 | 152 | float PDF = 1.0 / (2 * PI * (1 - CosThetaMax)); 153 | return float4(L, PDF); 154 | } 155 | 156 | 157 | float4 ImportanceSampleLambert(float2 E) 158 | { 159 | float3 L = CosineSampleHemisphere(E).rgb; 160 | return float4(L, 1); 161 | } 162 | 163 | float4 ImportanceSampleBlinn(float2 E, float Roughness) { 164 | float m = Roughness * Roughness; 165 | float m2 = m * m; 166 | 167 | float Phi = 2 * PI * E.x; 168 | float n = 2 / m2 - 2; 169 | float CosTheta = pow(max(E.y, 0.001), 1 / (n + 1)); 170 | float SinTheta = sqrt(1 - CosTheta * CosTheta); 171 | 172 | float3 H; 173 | H.x = SinTheta * cos(Phi); 174 | H.y = SinTheta * sin(Phi); 175 | H.z = CosTheta; 176 | 177 | float D = (n + 2)/ (2 * PI) * saturate(pow(CosTheta, n)); 178 | float pdf = D * CosTheta; 179 | return float4(H, pdf); 180 | } 181 | 182 | float3 ImportanceSampleGGX(float2 E, float3 N, float Roughness) 183 | { 184 | float a = Roughness * Roughness; 185 | 186 | float phi = 2.0 * PI * E.x; 187 | float cosTheta = sqrt((1.0 - E.y) / (1.0 + (a*a - 1.0) * E.y)); 188 | float sinTheta = sqrt(1.0 - cosTheta*cosTheta); 189 | 190 | // from spherical coordinates to cartesian coordinates - halfway vector 191 | float3 H; 192 | H.x = cos(phi) * sinTheta; 193 | H.y = sin(phi) * sinTheta; 194 | H.z = cosTheta; 195 | 196 | // from tangent-space H vector to world-space sample vector 197 | float3 up = abs(N.z) < 0.999 ? float3(0.0, 0.0, 1.0) : float3(1.0, 0.0, 0.0); 198 | float3 tangent = normalize(cross(up, N)); 199 | float3 bitangent = cross(N, tangent); 200 | 201 | float3 sampleVec = tangent * H.x + bitangent * H.y + N * H.z; 202 | return normalize(sampleVec); 203 | } 204 | 205 | float4 ImportanceSampleGGX(float2 E, float Roughness) { 206 | float m = Roughness * Roughness; 207 | float m2 = m * m; 208 | 209 | float Phi = 2 * PI * E.x; 210 | float CosTheta = sqrt((1 - E.y) / ( 1 + (m2 - 1) * E.y)); 211 | float SinTheta = sqrt(1 - CosTheta * CosTheta); 212 | 213 | float3 H; 214 | H.x = SinTheta * cos(Phi); 215 | H.y = SinTheta * sin(Phi); 216 | H.z = CosTheta; 217 | 218 | float d = (CosTheta * m2 - CosTheta) * CosTheta + 1; 219 | float D = m2 / (PI * d * d); 220 | 221 | float PDF = D * CosTheta; 222 | 223 | return float4(H, PDF); 224 | } 225 | 226 | float4 ImportanceSampleInverseGGX(float2 E, float Roughness) { 227 | float m = Roughness * Roughness; 228 | float m2 = m * m; 229 | float A = 4; 230 | 231 | float Phi = 2 * PI * E.x; 232 | float CosTheta = sqrt((1 - E.y) / ( 1 + (m2 - 1) * E.y)); 233 | float SinTheta = sqrt(1 - CosTheta * CosTheta); 234 | 235 | float3 H; 236 | H.x = SinTheta * cos(Phi); 237 | H.y = SinTheta * sin(Phi); 238 | H.z = CosTheta; 239 | 240 | float d = (CosTheta - m2 * CosTheta) * CosTheta + m2; 241 | float D = rcp(Inv_PI * (1 + A * m2)) * (1 + 4 * m2 * m2 / (d * d)); 242 | 243 | float PDF = D * CosTheta; 244 | 245 | return float4(H, PDF); 246 | } 247 | 248 | void SampleAnisoGGXDir(float2 u, float3 V, float3 N, float3 tX, float3 tY, float roughnessT, float roughnessB, out float3 H, out float3 L) { 249 | H = sqrt(u.x / (1 - u.x)) * (roughnessT * cos(Two_PI * u.y) * tX + roughnessB * sin(Two_PI * u.y) * tY) + N; 250 | H = normalize(H); 251 | L = 2 * saturate(dot(V, H)) * H - V; 252 | } 253 | 254 | void ImportanceSampleAnisoGGX(float2 u, float3 V, float3 N, float3 tX, float3 tY, float roughnessT, float roughnessB, float NoV, out float3 L, out float VoH, out float NoL, out float weightOverPdf) 255 | { 256 | float3 H; 257 | SampleAnisoGGXDir(u, V, N, tX, tY, roughnessT, roughnessB, H, L); 258 | 259 | float NoH = saturate(dot(N, H)); 260 | VoH = saturate(dot(V, H)); 261 | NoL = saturate(dot(N, L)); 262 | 263 | float ToV = dot(tX, V); 264 | float BoV = dot(tY, V); 265 | float ToL = dot(tX, L); 266 | float BoL = dot(tY, L); 267 | 268 | float aT = roughnessT; 269 | float aT2 = aT * aT; 270 | float aB = roughnessB; 271 | float aB2 = aB * aB; 272 | float lambdaV = NoL * sqrt(aT2 * ToV * ToV + aB2 * BoV * BoV + NoV * NoV); 273 | float lambdaL = NoV * sqrt(aT2 * ToL * ToL + aB2 * BoL * BoL + NoL * NoL); 274 | float Vis = 0.5 / (lambdaV + lambdaL); 275 | 276 | weightOverPdf = 4 * Vis * NoL * VoH / NoH; 277 | } 278 | 279 | float MISWeight(uint Num, float PDF, uint OtherNum, float OtherPDF) { 280 | float Weight = Num * PDF; 281 | float OtherWeight = OtherNum * OtherPDF; 282 | return Weight * Weight / (Weight * Weight + OtherWeight * OtherWeight); 283 | } 284 | 285 | #endif -------------------------------------------------------------------------------- /Assets/TP/CGBull/GroundTruthAmbientOcclusion/Shaders/Resources/GTAO_Common.cginc: -------------------------------------------------------------------------------- 1 | #include "UnityCG.cginc" 2 | #include "Assets/TP/CGBull/Common/Shaders/Resources/Include_HLSL.hlsl" 3 | 4 | #define BLUR_RADIUS 8 5 | 6 | int _SSAO_MultiBounce; 7 | 8 | half _SSAO_HalfProjScale, _SSAO_DirSampler, _SSAO_SliceSampler, _SSAO_Intensity, _SSAO_Radius, _SSAO_Power, _SSAO_Sharpeness, _SSAO_TemporalScale, _SSAO_TemporalWeight, _SSAO_TemporalOffsets, _SSAO_TemporalDirections; 9 | 10 | half2 _SSAO_FadeParams; 11 | 12 | half4 _SSAO_UVToView, _SSAO_TexelSize, _SSAO_FadeValues; 13 | 14 | half4x4 _SSAO_WorldToCameraMatrix, _SSAO_CameraToWorldMatrix, _SSAO_InverseViewProjectionMatrix; 15 | 16 | sampler2D _SSAO_SceneColor_RT, _SSAO_Occlusion_RT, _SSAO_Spatial_RT, _SSAO_TemporalPrev_RT, _SSAO_TemporalCurr_RT, _CameraGBufferTexture0, _CameraGBufferTexture1, _CameraGBufferTexture2, _CameraReflectionsTexture, _CameraMotionVectorsTexture, _CameraDepthTexture; 17 | 18 | sampler3D _SSAO_GTSO_LUT; 19 | 20 | struct VertexInput 21 | { 22 | half4 vertex : POSITION; 23 | half4 uv : TEXCOORD0; 24 | }; 25 | 26 | struct PixelInput 27 | { 28 | half4 vertex : SV_POSITION; 29 | half4 uv : TEXCOORD0; 30 | }; 31 | 32 | PixelInput vert_Defualt(VertexInput v) 33 | { 34 | PixelInput o; 35 | o.vertex = UnityObjectToClipPos(v.vertex); 36 | o.uv = v.uv; 37 | return o; 38 | } 39 | 40 | PixelInput vert(VertexInput v) 41 | { 42 | PixelInput o; 43 | o.vertex = v.vertex; 44 | o.uv = v.uv; 45 | return o; 46 | } 47 | 48 | inline half3 GetPosition(half2 uv) 49 | { 50 | half depth = tex2Dlod(_CameraDepthTexture, float4(uv, 0, 0)).r; 51 | half viewDepth = LinearEyeDepth(depth); 52 | return half3((uv * _SSAO_UVToView.xy + _SSAO_UVToView.zw) * viewDepth, viewDepth); 53 | } 54 | 55 | inline half3 GetNormal(half2 uv) 56 | { 57 | half3 Normal = tex2D(_CameraGBufferTexture2, uv).rgb * 2 - 1; 58 | half3 view_Normal = normalize(mul((half3x3)_SSAO_WorldToCameraMatrix, Normal)); 59 | 60 | return half3(view_Normal.xy, -view_Normal.z); 61 | } 62 | 63 | 64 | //---//---//----//----//-------//----//----//----//-----//----//-----//----//----MultiBounce & ReflectionOcclusion//---//---//----//----//-------//----//----//----//-----//----//-----//----//---- 65 | inline float ConeConeIntersection(float ArcLength0, float ArcLength1, float AngleBetweenCones) 66 | { 67 | float AngleDifference = abs(ArcLength0 - ArcLength1); 68 | return smoothstep(0, 1, 1 - saturate((AngleBetweenCones - AngleDifference) / (ArcLength0 + ArcLength1 - AngleDifference))); 69 | } 70 | 71 | inline half ReflectionOcclusion(half3 BentNormal, half3 ReflectionVector, half Roughness, half OcclusionStrength) 72 | { 73 | half BentNormalLength = length(BentNormal); 74 | half ReflectionConeAngle = max(Roughness, 0.1) * PI; 75 | half UnoccludedAngle = BentNormalLength * PI * OcclusionStrength; 76 | half AngleBetween = acos(dot(BentNormal, ReflectionVector) / max(BentNormalLength, 0.001)); 77 | 78 | half ReflectionOcclusion = ConeConeIntersection(ReflectionConeAngle, UnoccludedAngle, AngleBetween); 79 | return lerp(0, ReflectionOcclusion, saturate((UnoccludedAngle - 0.1) / 0.2)); 80 | } 81 | 82 | inline half ReflectionOcclusion_Approch(half NoV, half Roughness, half AO) 83 | { 84 | return saturate(pow(NoV + AO, Roughness * Roughness) - 1 + AO); 85 | } 86 | 87 | half LookUp_SpecularOcclusion(half alphaV, half beta, half roughness, half thetaRef) 88 | { 89 | 90 | half slice = (alphaV * Inv_PI * 2) * 32 - 0.5; 91 | half fslice = floor(slice); 92 | float weight = slice - fslice; 93 | float w1 = (fslice + beta * Inv_PI) / 32; 94 | 95 | half3 uvw = half3(thetaRef * Inv_PI * 2, roughness, w1); 96 | half3 uvw2 = frac(uvw + float3(0, 0, 1 / 32)); 97 | 98 | return lerp(tex3D(_SSAO_GTSO_LUT, uvw).r, tex3D(_SSAO_GTSO_LUT, uvw2).r, weight); 99 | } 100 | 101 | half ReflectionOcclusion_LUT(half2 screenPos, half AO, half Roughness, half3 BN) 102 | { 103 | half3 N = GetNormal(screenPos); 104 | half3 worldPos = GetPosition(screenPos); 105 | half3 viewDir = normalize(0 - worldPos); 106 | half alphaV = acos(sqrt(clamp(1 - AO, 0.01, 1))); 107 | 108 | half3 reflDir = reflect(-viewDir, N); 109 | half thetaRef = acos(dot(reflDir, N)); 110 | half beta = acos(dot(reflDir, BN)); 111 | return LookUp_SpecularOcclusion(alphaV, beta, Roughness, thetaRef); 112 | 113 | } 114 | 115 | inline half3 MultiBounce(half AO, half3 Albedo) 116 | { 117 | half3 A = 2 * Albedo - 0.33; 118 | half3 B = -4.8 * Albedo + 0.64; 119 | half3 C = 2.75 * Albedo + 0.69; 120 | return max(AO, ((AO * A + B) * AO + C) * AO); 121 | } 122 | 123 | 124 | //---//---//----//----//-------//----//----//----//-----//----//-----//----//----BilateralBlur//---//---//----//----//-------//----//----//----//-----//----//-----//----//---- 125 | inline void GetAo_Depth(float2 uv, inout float2 AO_RO, inout float AO_Depth) 126 | { 127 | float3 SSAOTexture = tex2Dlod(_SSAO_Occlusion_RT, float4(uv, 0.0, 0.0)).rgb; 128 | AO_RO = SSAOTexture.xy; 129 | //AO_Depth = SSAOTexture.z; 130 | AO_Depth = LinearEyeDepth(tex2Dlod(_CameraDepthTexture, float4(uv, 0, 0)).r); 131 | } 132 | 133 | inline float CrossBilateralWeight(float r, float d, float d0) 134 | { 135 | const float BlurSigma = (float)BLUR_RADIUS * 0.5; 136 | const float BlurFalloff = 1 / (2 * BlurSigma * BlurSigma); 137 | 138 | float dz = (d0 - d) * _ProjectionParams.z * _SSAO_Sharpeness; 139 | return exp2(-r * r * BlurFalloff - dz * dz); 140 | } 141 | 142 | inline void ProcessSample(float3 AO_RO_Depth, float r, float d0, inout float2 totalAOR, inout float totalW) 143 | { 144 | float w = CrossBilateralWeight(r, d0, AO_RO_Depth.z); 145 | totalW += w; 146 | totalAOR += w * AO_RO_Depth.xy; 147 | } 148 | 149 | inline void ProcessRadius(float2 uv0, float2 deltaUV, float d0, inout float2 totalAO_RO, inout float totalW) 150 | { 151 | float z; 152 | float2 uv, AO_RO; 153 | float r = 1; 154 | 155 | UNITY_UNROLL 156 | for (; r <= BLUR_RADIUS / 2; r += 1) { 157 | uv = uv0 + r * deltaUV; 158 | GetAo_Depth(uv, AO_RO, z); 159 | ProcessSample(float3(AO_RO, z), r, d0, totalAO_RO, totalW); 160 | } 161 | 162 | UNITY_UNROLL 163 | for (; r <= BLUR_RADIUS; r += 2) { 164 | uv = uv0 + (r + 0.5) * deltaUV; 165 | GetAo_Depth(uv, AO_RO, z); 166 | ProcessSample(float3(AO_RO, z), r, d0, totalAO_RO, totalW); 167 | } 168 | 169 | } 170 | 171 | inline float3 BilateralBlur(float2 uv0, float2 deltaUV) 172 | { 173 | float depth; 174 | float2 totalAOR; 175 | GetAo_Depth(uv0, totalAOR, depth); 176 | float totalW = 1; 177 | 178 | ProcessRadius(uv0, -deltaUV, depth, totalAOR, totalW); 179 | ProcessRadius(uv0, deltaUV, depth, totalAOR, totalW); 180 | 181 | totalAOR /= totalW; 182 | return float3(totalAOR, depth); 183 | } 184 | 185 | 186 | //---//---//----//----//-------//----//----//----//-----//----//-----//----//----GTAO//---//---//----//----//-------//----//----//----//-----//----//-----//----//---- 187 | inline half ComputeDistanceFade(const half distance) 188 | { 189 | return saturate(max(0, distance - _SSAO_FadeParams.x) * _SSAO_FadeParams.y); 190 | } 191 | 192 | inline half GTAO_Offsets(half2 uv) 193 | { 194 | int2 position = (int2)(uv * _SSAO_TexelSize.zw); 195 | return 0.25 * (half)((position.y - position.x) & 3); 196 | } 197 | 198 | inline half GTAO_Noise(half2 position) 199 | { 200 | return frac(52.9829189 * frac(dot(position, half2( 0.06711056, 0.00583715)))); 201 | } 202 | 203 | half IntegrateArc_UniformWeight(half2 h) 204 | { 205 | half2 Arc = 1 - cos(h); 206 | return Arc.x + Arc.y; 207 | } 208 | 209 | half IntegrateArc_CosWeight(half2 h, half n) 210 | { 211 | half2 Arc = -cos(2 * h - n) + cos(n) + 2 * h * sin(n); 212 | return 0.25 * (Arc.x + Arc.y); 213 | } 214 | 215 | half4 GTAO(half2 uv, int NumCircle, int NumSlice, inout half Depth) 216 | { 217 | half3 vPos = GetPosition(uv); 218 | half3 viewNormal = GetNormal(uv); 219 | half3 viewDir = normalize(0 - vPos); 220 | 221 | half2 radius_thickness = lerp(half2(_SSAO_Radius, 1), _SSAO_FadeValues.yw, ComputeDistanceFade(vPos.b).xx); 222 | half radius = radius_thickness.x; 223 | half thickness = radius_thickness.y; 224 | 225 | half stepRadius = (max(min((radius * _SSAO_HalfProjScale) / vPos.b, 512), (half)NumSlice)) / ((half)NumSlice + 1); 226 | half noiseOffset = frac(GTAO_Offsets(uv) + _SSAO_TemporalOffsets); 227 | half noiseDirection = GTAO_Noise(uv * _SSAO_TexelSize.zw) + _SSAO_TemporalDirections; 228 | 229 | half Occlusion, angle,BentAngle, wallDarkeningCorrection, sliceLength, n, cos_n; 230 | half2 slideDir_TexelSize, h, H, falloff, uvOffset, h1h2, h1h2Length; 231 | half3 sliceDir, h1, h2, planeNormal, planeTangent, sliceNormal, BentNormal; 232 | half4 uvSlice; 233 | 234 | if (tex2D(_CameraDepthTexture, uv).r <= 1e-7) return 1; 235 | 236 | UNITY_LOOP 237 | for (int i = 0; i < NumCircle; i++) 238 | { 239 | angle = (i + noiseDirection) * (UNITY_PI / (half)NumCircle); 240 | sliceDir = half3(half2(cos(angle), sin(angle)), 0); 241 | 242 | planeNormal = normalize(cross(sliceDir, viewDir)); 243 | planeTangent = cross(viewDir, planeNormal); 244 | sliceNormal = viewNormal - planeNormal * dot(viewNormal, planeNormal); 245 | sliceLength = length(sliceNormal); 246 | 247 | cos_n = clamp(dot(normalize(sliceNormal), viewDir), -1, 1); 248 | n = -sign(dot(sliceNormal, planeTangent)) * acos(cos_n); 249 | h = -1; 250 | 251 | UNITY_LOOP 252 | for (int j = 0; j < NumSlice; j++) 253 | { 254 | uvOffset = (sliceDir.xy * _SSAO_TexelSize.xy) * max(stepRadius * (j + noiseOffset), 1 + j); 255 | uvSlice = uv.xyxy + float4(uvOffset.xy, -uvOffset); 256 | 257 | h1 = GetPosition(uvSlice.xy) - vPos; 258 | h2 = GetPosition(uvSlice.zw) - vPos; 259 | 260 | h1h2 = half2(dot(h1, h1), dot(h2, h2)); 261 | h1h2Length = rsqrt(h1h2); 262 | 263 | falloff = saturate(h1h2 * (2 / pow2(radius))); 264 | 265 | H = half2(dot(h1, viewDir), dot(h2, viewDir)) * h1h2Length; 266 | h.xy = (H.xy > h.xy) ? lerp(H, h, falloff) : lerp(H.xy, h.xy, thickness); 267 | } 268 | 269 | h = acos(clamp(h, -1, 1)); 270 | h.x = n + max(-h.x - n, -UNITY_HALF_PI); 271 | h.y = n + min(h.y - n, UNITY_HALF_PI); 272 | 273 | BentAngle = (h.x + h.y) * 0.5; 274 | BentNormal += viewDir * cos(BentAngle) - planeTangent * sin(BentAngle); 275 | 276 | Occlusion += sliceLength * IntegrateArc_CosWeight(h, n); 277 | //Occlusion += sliceLength * IntegrateArc_UniformWeight(h); 278 | } 279 | 280 | BentNormal = normalize(normalize(BentNormal) - viewDir * 0.5); 281 | Occlusion = saturate(pow(Occlusion / (half)NumCircle, _SSAO_Power)); 282 | Depth = vPos.b; 283 | 284 | return half4(BentNormal, Occlusion); 285 | } 286 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/InfinityShader/Cloth.shader: -------------------------------------------------------------------------------- 1 | Shader "CGBull/Infinity_Shader/Cloth" { 2 | Properties { 3 | [Header (LUT)] 4 | 5 | [NoScaleOffset]_PreintegratedLUT ("PreintegratedLUT", 2D) = "black" {} 6 | 7 | 8 | 9 | [Header (ClothBRDF)] 10 | 11 | [Toggle (_UseSilk)]UseSilk ("UseSilk", Range(0, 1)) = 1 12 | [Toggle (_Ashikhmin_Charlie)]Ashikhmin_Charlie ("Ashikhmin_Charlie", Range(0, 1)) = 1 13 | _Anisotropy ("Anisotropy", Range(-1, 1)) = 0 14 | 15 | 16 | 17 | [Header (MicrofaceData)] 18 | 19 | [Toggle (_UseAlbedoTex)]UseBaseColorTex ("UseBaseColorTex", Range(0, 1)) = 0 20 | [NoScaleOffset]_BaseColorTexture ("BaseColorTexture", 2D) = "gray" {} 21 | _BaseColorTile ("BaseColorTile", Range(0, 100)) = 1 22 | _BaseColor ("BaseColor", Color) = (1, 1, 1, 1) 23 | 24 | _SpecularLevel ("SpecularLevel", Range(0, 1)) = 0.5 25 | _Reflectance ("Reflectance", Range(0, 1)) = 0 26 | _Roughness ("Roughness", Range(0, 1)) = 0 27 | 28 | 29 | 30 | [Header (Normal)] 31 | 32 | [NoScaleOffset]_NomralTexture ("NomralTexture", 2D) = "bump" {} 33 | _NormalTile ("NormalTile", Range(0, 100)) = 1 34 | } 35 | SubShader { 36 | Tags { "RenderType" = "Opaque" "Queue"="Geometry"} 37 | LOD 64 38 | Pass { 39 | Name "ForwardBase" 40 | Tags {"LightMode"="ForwardBase"} 41 | 42 | CGPROGRAM 43 | #pragma vertex vert 44 | #pragma fragment frag 45 | 46 | #pragma shader_feature _UseSilk 47 | #pragma shader_feature _Ashikhmin_Charlie 48 | #pragma shader_feature _UseAlbedoTex 49 | 50 | #pragma multi_compile_fwdbase_fullshadows 51 | #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON 52 | #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE 53 | #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON 54 | #pragma target 4.5 55 | 56 | #define SHOULD_SAMPLE_SH (defined (LIGHTMAP_OFF) && defined (DYNAMICLIGHTMAP_OFF)) 57 | 58 | #include "Assets/TP/CGBull/Common/Shaders/Resources/Include_HLSL.hlsl" 59 | #include "UnityCG.cginc" 60 | #include "AutoLight.cginc" 61 | #include "Lighting.cginc" 62 | #include "UnityPBSLighting.cginc" 63 | 64 | float _Anisotropy, _SpecularLevel, _Roughness, _Reflectance, _BaseColorTile, _NormalTile; 65 | float4 _BaseColor; 66 | sampler2D _PreintegratedLUT, _BaseColorTexture, _NomralTexture; 67 | 68 | struct VertexInput { 69 | float4 pos : POSITION; 70 | float3 normal : NORMAL; 71 | float4 tangent : TANGENT; 72 | float2 uv0 : TEXCOORD0; 73 | float2 uv1 : TEXCOORD1; 74 | float2 uv2 : TEXCOORD2; 75 | }; 76 | 77 | struct PixelInput { 78 | float4 pos : SV_POSITION; 79 | float2 uv0 : TEXCOORD0; 80 | float2 uv1 : TEXCOORD1; 81 | float2 uv2 : TEXCOORD2; 82 | float4 posWorld : TEXCOORD3; 83 | float4 screenPos : TEXCOORD4; 84 | float3 normalDir : TEXCOORD5; 85 | float3 tangentDir : TEXCOORD6; 86 | float3 bitangentDir : TEXCOORD7; 87 | LIGHTING_COORDS(8,9) 88 | #if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH) 89 | float4 ambientOrLightmapUV : TEXCOORD8; 90 | #endif 91 | }; 92 | 93 | PixelInput vert (VertexInput v) { 94 | PixelInput o = (PixelInput)0; 95 | o.pos = UnityObjectToClipPos(v.pos); 96 | o.uv0 = v.uv0; 97 | o.uv1 = v.uv1; 98 | o.uv2 = v.uv2; 99 | o.posWorld = mul(unity_ObjectToWorld, v.pos); 100 | o.screenPos = ComputeScreenPos(o.pos); 101 | o.normalDir = UnityObjectToWorldNormal(v.normal); 102 | o.tangentDir = normalize(mul(unity_ObjectToWorld, float4(v.tangent.xyz, 0)).xyz); 103 | o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); 104 | #ifdef LIGHTMAP_ON 105 | o.ambientOrLightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 106 | o.ambientOrLightmapUV.zw = 0; 107 | #endif 108 | #ifdef DYNAMICLIGHTMAP_ON 109 | o.ambientOrLightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; 110 | #endif 111 | return o; 112 | } 113 | 114 | float3 frag(PixelInput i) : SV_TARGET { 115 | float2 screenUV = i.screenPos.xy / i.screenPos.w; 116 | float3 worldPos = i.posWorld.xyz; 117 | float3x3 tangentTransform = float3x3(i.tangentDir, i.bitangentDir, normalize(i.normalDir)); 118 | 119 | 120 | ////// Material Property 121 | #if _UseBaseColorTex 122 | float3 BaseColor = tex2D(_BaseColorTexture, i.uv0 * _BaseColorTile) * _BaseColor * (1 - _Reflectance); 123 | float3 SpecularColor = lerp(0.08 * _SpecularLevel, BaseColor, _Reflectance); 124 | #else 125 | float3 BaseColor = _BaseColor * (1 - _Reflectance); 126 | float3 SpecularColor = lerp(0.08 * _SpecularLevel, _BaseColor.rgb, _Reflectance); 127 | #endif 128 | 129 | float Roughness = clamp(_Roughness, 0.04, 1); 130 | 131 | 132 | ////// Lighting Data: 133 | float3 viewDir = normalize(_WorldSpaceCameraPos.xyz - worldPos); 134 | float3 lightDir = normalize(_WorldSpaceLightPos0.xyz); 135 | float3 halfDir = normalize(viewDir + lightDir); 136 | float3 nomralDir_Tex = UnpackNormal(tex2D(_NomralTexture, i.uv0 * _NormalTile)); 137 | float3 normalDir = normalize(mul(nomralDir_Tex, tangentTransform)); 138 | 139 | BSDFContext BSDFContext; 140 | Init(BSDFContext, normalDir, viewDir, lightDir, halfDir); 141 | 142 | #if _UseSilk 143 | float Anisotropy = _Anisotropy; 144 | float RoughnessT, RoughnessB; 145 | ConvertAnisotropyToRoughness(Roughness, Anisotropy, RoughnessT, RoughnessB); 146 | 147 | float3 tangentWS = normalize(i.tangentDir - dot(i.tangentDir, normalDir) * normalDir); 148 | float3 bitangentWS = cross(normalDir, tangentWS); 149 | 150 | float3 AnisoNormal = GetAnisotropicModifiedNormal(bitangentWS, normalDir, viewDir, clamp(Anisotropy, -1, 1)); 151 | float3 ReflectDir = reflect(-viewDir, AnisoNormal); 152 | 153 | AnisoBSDFContext AnisoBSDFContext; 154 | Init_Aniso(AnisoBSDFContext, tangentWS, bitangentWS, halfDir, lightDir, viewDir); 155 | #else 156 | float3 ReflectDir = reflect(-viewDir, normalDir); 157 | #endif 158 | 159 | half3 Attenuation = UnityComputeForwardShadows(i.ambientOrLightmapUV, worldPos, i.screenPos); 160 | Attenuation *= _LightColor0.rgb * BSDFContext.NoL; 161 | 162 | 163 | /////// GI Data: 164 | UnityGIInput d; 165 | d.worldPos = worldPos; 166 | 167 | #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) 168 | d.ambient = 0; 169 | d.lightmapUV = i.ambientOrLightmapUV; 170 | #else 171 | d.ambient = i.ambientOrLightmapUV; 172 | #endif 173 | 174 | #if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION 175 | d.boxMin[0] = unity_SpecCube0_BoxMin; 176 | d.boxMin[1] = unity_SpecCube1_BoxMin; 177 | #endif 178 | 179 | #if UNITY_SPECCUBE_BOX_PROJECTION 180 | d.boxMax[0] = unity_SpecCube0_BoxMax; 181 | d.boxMax[1] = unity_SpecCube1_BoxMax; 182 | d.probePosition[0] = unity_SpecCube0_ProbePosition; 183 | d.probePosition[1] = unity_SpecCube1_ProbePosition; 184 | #endif 185 | 186 | d.probeHDR[0] = unity_SpecCube0_HDR; 187 | d.probeHDR[1] = unity_SpecCube1_HDR; 188 | Unity_GlossyEnvironmentData ugls_en_data; 189 | 190 | #if _UseSilk 191 | ugls_en_data.roughness = Roughness; 192 | #else 193 | ugls_en_data.roughness = 1; 194 | #endif 195 | 196 | ugls_en_data.reflUVW = ReflectDir; 197 | UnityGI gi = UnityGlobalIllumination(d, 1, normalDir, ugls_en_data); 198 | 199 | /////// Final Color 200 | half3 EnergyCompensation; 201 | half4 Preintegrated_DGF = PreintegratedDGF_LUT(_PreintegratedLUT, EnergyCompensation, SpecularColor, Roughness, BSDFContext.NoV); 202 | 203 | #if _UseSilk 204 | float3 ClothShading = Cloth_Silk(BSDFContext, AnisoBSDFContext, Attenuation, EnergyCompensation, BaseColor, SpecularColor, Roughness, RoughnessT, RoughnessB); 205 | float3 GlobalIllumination = (BaseColor * gi.indirect.diffuse * Preintegrated_DGF.a) + (gi.indirect.specular * Preintegrated_DGF.rgb); 206 | #else 207 | float3 ClothShading = Cloth_Cotton(BSDFContext, Attenuation, BaseColor, SpecularColor, Roughness); 208 | 209 | #if _Ashikhmin_Charlie 210 | float3 PreintegratedGF = PreintegratedGF_ClothCharlie(SpecularColor, Roughness, BSDFContext.NoV); 211 | #else 212 | float3 PreintegratedGF = PreintegratedGF_ClothAshikhmin(SpecularColor, Roughness, BSDFContext.NoV); 213 | #endif 214 | 215 | float3 GlobalIllumination = (BaseColor * gi.indirect.diffuse * Preintegrated_DGF.a) + (gi.indirect.specular * PreintegratedGF); 216 | #endif 217 | 218 | return ClothShading + GlobalIllumination; 219 | } 220 | ENDCG 221 | } 222 | } 223 | FallBack "Diffuse" 224 | } 225 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/SeparableSubsurfaceScatter/Resources/Shader/Surface/Standard_Skin_Tessellation.shader: -------------------------------------------------------------------------------- 1 | // Made with Amplify Shader Editor 2 | // Available at the Unity Asset Store - http://u3d.as/y3X 3 | Shader "CGBull/CharacterRender/SeparableSubsurfaceScatter/Surface/Standard_Skin_Tessellation" 4 | { 5 | Properties 6 | { 7 | [Toggle(_USEALBEDOTEXTURE_ON)] _UseAlbedoTexture("UseAlbedoTexture", Float) = 1 8 | _AlbedoColor("AlbedoColor", Color) = (1,1,1,0) 9 | _AlbedoTexture("AlbedoTexture", 2D) = "white" {} 10 | _NormalIntencity("NormalIntencity", Range( 0 , 6)) = 0 11 | _NormalTexture("NormalTexture", 2D) = "bump" {} 12 | [Toggle(_USEMETALLICTEXTURE_ON)] _UseMetallicTexture("UseMetallicTexture", Float) = 1 13 | _Metallic("Metallic", Range( 0 , 1)) = 0 14 | _MetallicTexture("MetallicTexture", 2D) = "white" {} 15 | [Toggle(_USEROUGHNESSTEXTURE_ON)] _UseRoughnessTexture("UseRoughnessTexture", Float) = 1 16 | _Roughness("Roughness", Range( 0 , 1)) = 0 17 | _RoughnessTexture("RoughnessTexture", 2D) = "white" {} 18 | _AO_Min("AO_Min", Range( 0 , 1)) = 0 19 | _AO_Max("AO_Max", Range( 0 , 1)) = 0 20 | _AmbientOcclusion("AmbientOcclusion", 2D) = "white" {} 21 | [HideInInspector] _texcoord( "", 2D ) = "white" {} 22 | [HideInInspector] __dirty( "", Int ) = 1 23 | } 24 | 25 | SubShader 26 | { 27 | Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" } 28 | LOD 200 29 | Cull Back 30 | Stencil 31 | { 32 | Ref 5 33 | Comp Always 34 | Pass Replace 35 | } 36 | CGPROGRAM 37 | #include "UnityStandardUtils.cginc" 38 | #pragma target 5.0 39 | #pragma shader_feature _USEALBEDOTEXTURE_ON 40 | #pragma shader_feature _USEMETALLICTEXTURE_ON 41 | #pragma shader_feature _USEROUGHNESSTEXTURE_ON 42 | #pragma surface surf Standard keepalpha addshadow fullforwardshadows 43 | struct Input 44 | { 45 | float2 uv_texcoord; 46 | }; 47 | 48 | uniform float _NormalIntencity; 49 | uniform sampler2D _NormalTexture; 50 | uniform float4 _NormalTexture_ST; 51 | uniform float4 _AlbedoColor; 52 | uniform sampler2D _AlbedoTexture; 53 | uniform float4 _AlbedoTexture_ST; 54 | uniform float _Metallic; 55 | uniform sampler2D _MetallicTexture; 56 | uniform float4 _MetallicTexture_ST; 57 | uniform float _Roughness; 58 | uniform sampler2D _RoughnessTexture; 59 | uniform float4 _RoughnessTexture_ST; 60 | uniform float _AO_Min; 61 | uniform float _AO_Max; 62 | uniform sampler2D _AmbientOcclusion; 63 | uniform float4 _AmbientOcclusion_ST; 64 | 65 | void surf( Input i , inout SurfaceOutputStandard o ) 66 | { 67 | float2 uv_NormalTexture = i.uv_texcoord * _NormalTexture_ST.xy + _NormalTexture_ST.zw; 68 | o.Normal = UnpackScaleNormal( tex2D( _NormalTexture, uv_NormalTexture ), _NormalIntencity ); 69 | float2 uv_AlbedoTexture = i.uv_texcoord * _AlbedoTexture_ST.xy + _AlbedoTexture_ST.zw; 70 | #ifdef _USEALBEDOTEXTURE_ON 71 | float4 staticSwitch4 = tex2D( _AlbedoTexture, uv_AlbedoTexture ); 72 | #else 73 | float4 staticSwitch4 = _AlbedoColor; 74 | #endif 75 | o.Albedo = staticSwitch4.rgb; 76 | float4 temp_cast_1 = (_Metallic).xxxx; 77 | float2 uv_MetallicTexture = i.uv_texcoord * _MetallicTexture_ST.xy + _MetallicTexture_ST.zw; 78 | #ifdef _USEMETALLICTEXTURE_ON 79 | float4 staticSwitch9 = ( _Metallic * tex2D( _MetallicTexture, uv_MetallicTexture ) ); 80 | #else 81 | float4 staticSwitch9 = temp_cast_1; 82 | #endif 83 | o.Metallic = staticSwitch9.r; 84 | float temp_output_3_0 = ( 1.0 - _Roughness ); 85 | float4 temp_cast_3 = (temp_output_3_0).xxxx; 86 | float2 uv_RoughnessTexture = i.uv_texcoord * _RoughnessTexture_ST.xy + _RoughnessTexture_ST.zw; 87 | #ifdef _USEROUGHNESSTEXTURE_ON 88 | float4 staticSwitch7 = ( temp_output_3_0 * tex2D( _RoughnessTexture, uv_RoughnessTexture ) ); 89 | #else 90 | float4 staticSwitch7 = temp_cast_3; 91 | #endif 92 | o.Smoothness = staticSwitch7.r; 93 | float2 uv_AmbientOcclusion = i.uv_texcoord * _AmbientOcclusion_ST.xy + _AmbientOcclusion_ST.zw; 94 | float lerpResult19 = lerp( _AO_Min , _AO_Max , tex2D( _AmbientOcclusion, uv_AmbientOcclusion ).r); 95 | o.Occlusion = lerpResult19; 96 | o.Alpha = 1; 97 | } 98 | 99 | ENDCG 100 | } 101 | Fallback "Mobile/Diffuse" 102 | CustomEditor "ASEMaterialInspector" 103 | } 104 | /*ASEBEGIN 105 | Version=15600 106 | 7;29;1906;1044;1509.951;388.5038;1.328178;True;False 107 | Node;AmplifyShaderEditor.RangedFloatNode;2;-1050.717,536.5583;Float;False;Property;_Roughness;Roughness;9;0;Create;True;0;0;False;0;0;0.43;0;1;0;1;FLOAT;0 108 | Node;AmplifyShaderEditor.RangedFloatNode;8;-904.3417,197.8793;Float;False;Property;_Metallic;Metallic;6;0;Create;True;0;0;False;0;0;0;0;1;0;1;FLOAT;0 109 | Node;AmplifyShaderEditor.SamplerNode;6;-916.2167,623.058;Float;True;Property;_RoughnessTexture;RoughnessTexture;10;0;Create;True;0;0;False;0;None;678687e6283200047ae673c1222a5a19;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 110 | Node;AmplifyShaderEditor.OneMinusNode;3;-782.7167,541.5583;Float;False;1;0;FLOAT;0;False;1;FLOAT;0 111 | Node;AmplifyShaderEditor.SamplerNode;10;-924.3417,286.8793;Float;True;Property;_MetallicTexture;MetallicTexture;7;0;Create;True;0;0;False;0;None;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 112 | Node;AmplifyShaderEditor.RangedFloatNode;13;-771,41;Float;False;Property;_NormalIntencity;NormalIntencity;3;0;Create;True;0;0;False;0;0;1;0;6;0;1;FLOAT;0 113 | Node;AmplifyShaderEditor.SamplerNode;11;-479.7166,797.558;Float;True;Property;_AmbientOcclusion;AmbientOcclusion;13;0;Create;True;0;0;False;0;None;1c702b23c4b924648b3585f7f77af4eb;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 114 | Node;AmplifyShaderEditor.SimpleMultiplyOpNode;17;-611.938,606.5411;Float;False;2;2;0;FLOAT;0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 115 | Node;AmplifyShaderEditor.RangedFloatNode;21;-457.938,715.5411;Float;False;Property;_AO_Min;AO_Min;11;0;Create;True;0;0;False;0;0;1;0;1;0;1;FLOAT;0 116 | Node;AmplifyShaderEditor.ColorNode;5;-694.1708,-359.7635;Float;False;Property;_AlbedoColor;AlbedoColor;1;0;Create;True;0;0;False;0;1,1,1,0;1,1,1,0;0;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 117 | Node;AmplifyShaderEditor.SimpleMultiplyOpNode;18;-624.538,263.7415;Float;False;2;2;0;FLOAT;0;False;1;COLOR;0,0,0,0;False;1;COLOR;0 118 | Node;AmplifyShaderEditor.RangedFloatNode;20;-455.938,636.5411;Float;False;Property;_AO_Max;AO_Max;12;0;Create;True;0;0;False;0;0;1;0;1;0;1;FLOAT;0 119 | Node;AmplifyShaderEditor.SamplerNode;1;-780.1708,-187.7634;Float;True;Property;_AlbedoTexture;AlbedoTexture;2;0;Create;True;0;0;False;0;None;163db8200b9921647b309f6005fd9135;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 120 | Node;AmplifyShaderEditor.SamplerNode;12;-465,-4;Float;True;Property;_NormalTexture;NormalTexture;4;0;Create;True;0;0;False;0;None;a6aeef83de2b12540a15c8efd6040a5f;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4 121 | Node;AmplifyShaderEditor.StaticSwitch;9;-466.3417,198.8793;Float;False;Property;_UseMetallicTexture;UseMetallicTexture;5;0;Create;True;0;0;False;0;0;1;0;True;;Toggle;2;Key0;Key1;9;1;COLOR;0,0,0,0;False;0;COLOR;0,0,0,0;False;2;COLOR;0,0,0,0;False;3;COLOR;0,0,0,0;False;4;COLOR;0,0,0,0;False;5;COLOR;0,0,0,0;False;6;COLOR;0,0,0,0;False;7;COLOR;0,0,0,0;False;8;COLOR;0,0,0,0;False;1;COLOR;0 122 | Node;AmplifyShaderEditor.StaticSwitch;4;-445.1709,-254.7634;Float;False;Property;_UseAlbedoTexture;UseAlbedoTexture;0;0;Create;True;0;0;False;0;0;1;1;True;;Toggle;2;Key0;Key1;9;1;COLOR;0,0,0,0;False;0;COLOR;0,0,0,0;False;2;COLOR;0,0,0,0;False;3;COLOR;0,0,0,0;False;4;COLOR;0,0,0,0;False;5;COLOR;0,0,0,0;False;6;COLOR;0,0,0,0;False;7;COLOR;0,0,0,0;False;8;COLOR;0,0,0,0;False;1;COLOR;0 123 | Node;AmplifyShaderEditor.LerpOp;19;-136.938,647.5411;Float;False;3;0;FLOAT;0;False;1;FLOAT;0;False;2;FLOAT;0;False;1;FLOAT;0 124 | Node;AmplifyShaderEditor.StaticSwitch;7;-469.2166,539.0583;Float;False;Property;_UseRoughnessTexture;UseRoughnessTexture;8;0;Create;True;0;0;False;0;0;1;0;True;;Toggle;2;Key0;Key1;9;1;COLOR;0,0,0,0;False;0;COLOR;0,0,0,0;False;2;COLOR;0,0,0,0;False;3;COLOR;0,0,0,0;False;4;COLOR;0,0,0,0;False;5;COLOR;0,0,0,0;False;6;COLOR;0,0,0,0;False;7;COLOR;0,0,0,0;False;8;COLOR;0,0,0,0;False;1;COLOR;0 125 | Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;470,-52;Float;False;True;7;Float;ASEMaterialInspector;200;0;Standard;CGBull/CharacterRender/SeparableSubsurfaceScatter/Surface/Standard_Skin_Tessellation;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Opaque;0.5;True;True;0;False;Opaque;;Geometry;All;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;0;False;-1;True;5;False;-1;255;False;-1;255;False;-1;7;False;-1;3;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;0;15;10;25;True;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;200;Mobile/Diffuse;-1;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;0;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0 126 | WireConnection;3;0;2;0 127 | WireConnection;17;0;3;0 128 | WireConnection;17;1;6;0 129 | WireConnection;18;0;8;0 130 | WireConnection;18;1;10;0 131 | WireConnection;12;5;13;0 132 | WireConnection;9;1;8;0 133 | WireConnection;9;0;18;0 134 | WireConnection;4;1;5;0 135 | WireConnection;4;0;1;0 136 | WireConnection;19;0;21;0 137 | WireConnection;19;1;20;0 138 | WireConnection;19;2;11;0 139 | WireConnection;7;1;3;0 140 | WireConnection;7;0;17;0 141 | WireConnection;0;0;4;0 142 | WireConnection;0;1;12;0 143 | WireConnection;0;3;9;0 144 | WireConnection;0;4;7;0 145 | WireConnection;0;5;19;0 146 | ASEEND*/ 147 | //CHKSM=B37A3F6B0781B70FC3F3B60C05A5845010EC7A7C -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/AreaLight.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _AREA_LIGHT_ 2 | #define _AREA_LIGHT_ 3 | 4 | #include "ShadingModel.hlsl" 5 | 6 | #define SHARP_EDGE_FIX 1 7 | #define WITHOUT_CORRECT_HORIZON 0 8 | #define WITH_GG_Sphere 1 9 | 10 | float GetSphereLight(float radiusTan, float NoL, float NoV, float VoL) 11 | { 12 | // radiusCos can be precalculated if radiusTan is a directional light 13 | float radiusCos = rsqrt(1 + pow2(radiusTan)); 14 | 15 | // Early out if R falls within the disc 16 | float RoL = 2 * NoL * NoV - VoL; 17 | if (RoL >= radiusCos) 18 | return 1; 19 | 20 | float rOverLengthT = radiusCos * radiusTan * rsqrt(1 - RoL * RoL); 21 | float NoTr = rOverLengthT * (NoV - RoL * NoL); 22 | float VoTr = rOverLengthT * (2 * NoV * NoV - 1 - RoL * VoL); 23 | 24 | #if WITH_GG_Sphere 25 | // Calculate dot(cross(N, L), V). This could already be calculated and available. 26 | float triple = sqrt(saturate(1 - NoL * NoL - NoV * NoV - VoL * VoL + 2 * NoL * NoV * VoL)); 27 | // Do one Newton iteration to improve the bent light vector 28 | float NoBr = rOverLengthT * triple, VoBr = rOverLengthT * (2 * triple * NoV); 29 | float NoLVTr = NoL * radiusCos + NoV + NoTr, VoLVTr = VoL * radiusCos + 1 + VoTr; 30 | float p = NoBr * VoLVTr, q = NoLVTr * VoLVTr, s = VoBr * NoLVTr; 31 | float xNum = q * (-0.5 * p + 0.25 * VoBr * NoLVTr); 32 | float xDenom = p * p + s * ((s - 2 * p)) + NoLVTr * ((NoL * radiusCos + NoV) * VoLVTr * VoLVTr + q * (-0.5 * (VoLVTr + VoL * radiusCos) - 0.5)); 33 | float twoX1 = 2 * xNum / (xDenom * xDenom + xNum * xNum); 34 | float sinTheta = twoX1 * xDenom; 35 | float cosTheta = 1 - twoX1 * xNum; 36 | NoTr = cosTheta * NoTr + sinTheta * NoBr; // use new T to update NoTr 37 | VoTr = cosTheta * VoTr + sinTheta * VoBr; // use new T to update VoTr 38 | #endif 39 | 40 | // Calculate (N.H)^2 based on the bent light vector 41 | float newNoL = NoL * radiusCos + NoTr; 42 | float newVoL = VoL * radiusCos + VoTr; 43 | float NoH = NoV + newNoL; 44 | float HoH = 2 * newVoL + 2; 45 | return max(0, NoH * NoH / HoH); 46 | } 47 | 48 | /* 49 | //Init_Sphere( LightData, saturate( lightRadius * rsqrt( dot(_LightPos.rgb - worldPos, _LightPos.rgb - worldPos) ) * (1 - Pow2(Roughness) ) ) ); 50 | void Init_Sphere(inout BSDFContext Context, float SinAlpha) 51 | { 52 | if (SinAlpha > 0) 53 | { 54 | float CosAlpha = sqrt(1 - Pow2(SinAlpha)); 55 | 56 | float RoL = 2 * Context.NoL * Context.NoV - Context.VoL; 57 | if (RoL >= CosAlpha) 58 | { 59 | Context.NoH = 1; 60 | Context.VoH = abs(Context.NoV); 61 | } 62 | else 63 | { 64 | float rInvLengthT = SinAlpha * rsqrt(1 - RoL * RoL); 65 | float NoTr = rInvLengthT * (Context.NoV - RoL * Context.NoL); 66 | float VoTr = rInvLengthT * (2 * Context.NoV * Context.NoV - 1 - RoL * Context.VoL); 67 | 68 | #if WITH_GG_Sphere 69 | // dot( cross(N,L), V ) 70 | float NxLoV = sqrt(saturate(1 - Pow2(Context.NoL) - Pow2(Context.NoV) - Pow2(Context.VoL) + 2 * Context.NoL * Context.NoV * Context.VoL)); 71 | 72 | float NoBr = rInvLengthT * NxLoV; 73 | float VoBr = rInvLengthT * NxLoV * 2 * Context.NoV; 74 | float NoLVTr = Context.NoL * CosAlpha + Context.NoV + NoTr; 75 | float VoLVTr = Context.VoL * CosAlpha + 1 + VoTr; 76 | 77 | float p = NoBr * VoLVTr; 78 | float q = NoLVTr * VoLVTr; 79 | float s = VoBr * NoLVTr; 80 | 81 | float xNum = q * (-0.5 * p + 0.25 * VoBr * NoLVTr); 82 | float xDenom = p * p + s * (s - 2 * p) + NoLVTr * ((Context.NoL * CosAlpha + Context.NoV) * Pow2(VoLVTr) + q * (-0.5 * (VoLVTr + Context.VoL * CosAlpha) - 0.5)); 83 | float TwoX1 = 2 * xNum / (Pow2(xDenom) + Pow2(xNum)); 84 | float SinTheta = TwoX1 * xDenom; 85 | float CosTheta = 1.0 - TwoX1 * xNum; 86 | NoTr = CosTheta * NoTr + SinTheta * NoBr; 87 | VoTr = CosTheta * VoTr + SinTheta * VoBr; 88 | #endif 89 | 90 | Context.NoL = Context.NoL * CosAlpha + NoTr; 91 | Context.VoL = Context.VoL * CosAlpha + VoTr; 92 | float InvLenH = rsqrt(2 + 2 * Context.VoL); 93 | Context.NoH = saturate((Context.NoL + Context.NoV) * InvLenH); 94 | Context.VoH = saturate(InvLenH + InvLenH * Context.VoL); 95 | } 96 | } 97 | } 98 | */ 99 | 100 | void AreaLightIntegrated(float3 pos, float3 tubeStart, float3 tubeEnd, float3 normal, float tubeRad, float3 ReflectionDir, out float3 outLightDir, out float outNdotL, out half outLightDist) 101 | { 102 | half3 N = normal; 103 | float3 L0 = tubeStart - pos; 104 | float3 L1 = tubeEnd - pos; 105 | float L0dotL0 = dot(L0, L0); 106 | float distL0 = sqrt(L0dotL0); 107 | float distL1 = length(L1); 108 | 109 | float NdotL0 = dot(L0, N) / (2 * distL0); 110 | float NdotL1 = dot(L1, N) / (2 * distL1); 111 | outNdotL = saturate(NdotL0 + NdotL1); 112 | 113 | float3 Ldir = L1 - L0; 114 | float RepdotL0 = dot(ReflectionDir, L0); 115 | float RepdotLdir = dot(ReflectionDir, Ldir); 116 | float L0dotLdir = dot(L0, Ldir); 117 | float LdirdotLdir = dot(Ldir, Ldir); 118 | float distLdir = sqrt(LdirdotLdir); 119 | 120 | #if SHARP_EDGE_FIX 121 | float t = (L0dotLdir * RepdotL0 - L0dotL0 * RepdotLdir) / (L0dotLdir * RepdotLdir - LdirdotLdir * RepdotL0); 122 | t = saturate(t); 123 | 124 | float3 L0xLdir = cross(L0, Ldir); 125 | float3 LdirxR = cross(Ldir, ReflectionDir); 126 | float RepAtLdir = dot(L0xLdir, LdirxR); 127 | 128 | t = lerp(1 - t, t, step(0, RepAtLdir)); 129 | 130 | #else 131 | float t = (RepdotL0 * RepdotLdir - L0dotLdir) / (distLdir * distLdir - RepdotLdir * RepdotLdir); 132 | t = saturate(t); 133 | 134 | #endif 135 | 136 | float3 closestPoint = L0 + Ldir * t; 137 | float3 centerToRay = dot(closestPoint, ReflectionDir) * ReflectionDir - closestPoint; 138 | 139 | closestPoint = closestPoint + centerToRay * saturate(tubeRad / length(centerToRay)); 140 | 141 | outLightDist = length(closestPoint); 142 | outLightDir = closestPoint / outLightDist; 143 | } 144 | 145 | 146 | /////////////////////////////////////////////////////////////////////////***Falloff***///////////////////////////////////////////////////////////////////////// 147 | half GetLumianceIntensity(half lumiance) 148 | { 149 | return max(0, lumiance) / (4 * PI); 150 | } 151 | 152 | float SmoothFalloff(float squaredDistance, float invSqrAttRadius) 153 | { 154 | return Square( saturate( 1 - Square( squaredDistance * Square(invSqrAttRadius) ) ) ); 155 | } 156 | 157 | float DistanceFalloff(float3 unLightDir, float invSqrAttRadius) 158 | { 159 | float Dist = dot(unLightDir, unLightDir); 160 | float attenuation = 1 / (max(Dist, 0.01 * 0.01)); 161 | attenuation *= SmoothFalloff(Dist, invSqrAttRadius); 162 | return attenuation; 163 | } 164 | 165 | half AngleFalloff(half3 normalizedLightVector, half3 lightDir, half lightAngleScale, half lightAngleOffset) 166 | { 167 | // On the CPU 168 | // half lightAngleScale = 1 / max ( 0.001, (cosInner - cosOuter) ); 169 | // half lightAngleOffset = -cosOuter * lightAngleScale ; 170 | 171 | half cd = dot(lightDir, normalizedLightVector); 172 | half attenuation = saturate(cd * lightAngleScale + lightAngleOffset); 173 | attenuation *= attenuation; 174 | return attenuation; 175 | } 176 | 177 | /* 178 | half IESFalloff(half3 L) 179 | { 180 | half3 iesSampleDirection = mul (light worldToLight , -L); 181 | 182 | // Cartesian to spherical 183 | // Texture encoded with cos(phi), scale from -1 - >1 to 0 - >1 184 | half phiCoord = ( iesSampleDirection.z * 0.5) + 0.5; 185 | half theta = atan2 ( iesSampleDirection.y , iesSampleDirection.x); 186 | half thetaCoord = theta * Inv_Two_PI ; 187 | half3 texCoord = half3 (thetaCoord , phiCoord); 188 | half iesProfileScale = iesTexture . SampleLevel (sampler , texCoord , 0).r; 189 | return iesProfileScale ; 190 | } 191 | */ 192 | 193 | /////////////////////////////////////////////////////////////////////////***Energy***///////////////////////////////////////////////////////////////////////// 194 | //////Punctual Energy 195 | half3 Point_Energy(half3 Un_LightDir, half3 lightColor, half lumiance, half range, half NoL) 196 | { 197 | half3 L = normalize(Un_LightDir); 198 | half Falloff = DistanceFalloff(Un_LightDir, (1 / range)); 199 | 200 | // lightColor is the outgoing luminance of the light time the user light color 201 | // i.e with point light and luminous power unit : lightColor = color * phi / (4 * PI) 202 | half3 luminance = Falloff * NoL * ( lightColor * GetLumianceIntensity(lumiance) ); 203 | return luminance; 204 | } 205 | 206 | half3 Spot_Energy(half3 Un_LightDir, half3 lightColor, half lumiance, half range, half NoL) 207 | { 208 | half3 L = normalize(Un_LightDir); 209 | half Falloff = DistanceFalloff(Un_LightDir, (1 / range)); 210 | 211 | ///Falloff *= AngleFalloff(L, lightForward, lightAngleScale, lightAngleOffset); 212 | //half lightAngleScale = 1 / max ( 0.001, (90 - 30) ); 213 | //half lightAngleOffset = -30 * lightAngleScale ; 214 | //Falloff *= AngleFalloff(L, half3(0, 90, 0), lightAngleScale, lightAngleOffset); 215 | 216 | // lightColor is the outgoing luminance of the light time the user light color 217 | // i.e with point light and luminous power unit : lightColor = color * phi / (4 * PI) 218 | half3 luminance = Falloff * NoL * ( lightColor * GetLumianceIntensity(lumiance) ); 219 | return luminance; 220 | } 221 | 222 | 223 | 224 | //////Area Energy 225 | half Sphere_Energy(half3 worldNormal, half3 Un_LightDir, half3 lightPos, half3 lightColor, half radius, half range, half lumiance) 226 | { 227 | half3 L = normalize(Un_LightDir); 228 | half sqrDist = dot (Un_LightDir , Un_LightDir); 229 | half illuminance = 0; 230 | 231 | #if WITHOUT_CORRECT_HORIZON // Analytical solution above horizon 232 | 233 | // Patch to Sphere frontal equation ( Quilez version ) 234 | half sqrLightRadius = radius * radius; 235 | // Do not allow object to penetrate the light ( max ) 236 | // Form factor equation include a (1 / PI ) that need to be cancel 237 | // thus the " PI *" 238 | illuminance = PI * (sqrLightRadius / (max(sqrLightRadius , sqrDist))) * saturate (dot(worldNormal , L)); 239 | 240 | #else // Analytical solution with horizon 241 | 242 | // Tilted patch to sphere equation 243 | half Beta = acos(saturate(dot(worldNormal, L))); 244 | half H = sqrt (sqrDist); 245 | half h = H / radius; 246 | half x = sqrt (h * h - 1); 247 | half y = -x * (1 / tan (Beta)); 248 | 249 | if (h * cos (Beta) > 1) { 250 | illuminance = cos ( Beta ) / (h * h); 251 | } else { 252 | illuminance = (1 / (PI * h * h)) * (cos(Beta) * acos (y) - x * sin(Beta) * sqrt (1 - y * y)) + (1 / PI) * atan (sin (Beta) * sqrt (1 - y * y) / x); 253 | } 254 | illuminance *= PI; 255 | 256 | #endif 257 | 258 | half RangeFalloff = DistanceFalloff(Un_LightDir, (1 / range)); 259 | half LumiancePower = lightColor * GetLumianceIntensity(lumiance); 260 | return illuminance * RangeFalloff * LumiancePower; 261 | } 262 | 263 | #endif -------------------------------------------------------------------------------- /Assets/TP/CGBull/InfinityShader/ClearCoat.shader: -------------------------------------------------------------------------------- 1 | Shader "CGBull/Infinity_Shader/ClearCoat" { 2 | Properties { 3 | [Header (LUT)] 4 | 5 | [NoScaleOffset]_PreintegratedLUT ("PreintegratedLUT", 2D) = "black" {} 6 | 7 | [Header (Microface)] 8 | 9 | _BaseColor ("BaseColor", Color) = (0, 0.75, 1, 1) 10 | _SpecularLevel ("SpecularLevel", Range(0, 1)) = 0.5 11 | _Reflectance ("Reflectance", Range(0, 1)) = 1 12 | _Roughness ("Roughness", Range(0, 1)) = 0.5 13 | 14 | 15 | 16 | [Header (Normal)] 17 | 18 | [NoScaleOffset]_NomralTexture ("NomralTexture", 2D) = "bump" {} 19 | _NormalTile ("NormalTile", Range(0, 100)) = 1 20 | 21 | 22 | 23 | [Header (ClearCoat)] 24 | 25 | _ClearCoat ("ClearCoat", Range(0, 1)) = 1 26 | _ClearCoatRoughness ("ClearCoatRoughness", Range(0, 1)) = 0 27 | [NoScaleOffset]_ClearCoatNomralTexture ("ClearCoatNomralTexture", 2D) = "bump" {} 28 | _ClearCoatNormalTile ("ClearCoatNormalTile", Range(0, 100)) = 1 29 | 30 | 31 | 32 | [Header (Iridescence)] 33 | 34 | [Toggle (_Iridescence)] Iridescence ("Iridescence", Range(0, 1)) = 0 35 | _Iridescence_Distance ("Iridescence_Distance", Range(0, 1)) = 1 36 | } 37 | SubShader { 38 | Tags { "RenderType" = "Opaque" "Queue"="Geometry"} 39 | LOD 64 40 | Pass { 41 | Name "ForwardBase" 42 | Tags {"LightMode"="ForwardBase"} 43 | 44 | CGPROGRAM 45 | #pragma vertex vert 46 | #pragma fragment frag 47 | 48 | #pragma shader_feature _Iridescence 49 | 50 | #pragma multi_compile_fwdbase 51 | #pragma multi_compile_fwdbase_fullshadows 52 | #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON 53 | #pragma multi_compile DIRLIGHTMAP_OFF DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE 54 | #pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON 55 | #pragma target 4.5 56 | 57 | #define SHOULD_SAMPLE_SH (defined (LIGHTMAP_OFF) && defined (DYNAMICLIGHTMAP_OFF)) 58 | 59 | #include "Assets/TP/CGBull/Common/Shaders/Resources/Include_HLSL.hlsl" 60 | #include "UnityCG.cginc" 61 | #include "AutoLight.cginc" 62 | #include "Lighting.cginc" 63 | #include "UnityPBSLighting.cginc" 64 | 65 | float _NormalTile, _ClearCoatNormalTile, _Iridescence_Distance, _SpecularLevel, _Roughness, _Reflectance, _ClearCoat, _ClearCoatRoughness; 66 | float4 _BaseColor, _TransmissionColor; 67 | sampler2D _PreintegratedLUT, _NomralTexture, _ClearCoatNomralTexture; 68 | 69 | struct VertexInput { 70 | float4 pos : POSITION; 71 | float3 normal : NORMAL; 72 | float4 tangent : TANGENT; 73 | float2 uv0 : TEXCOORD0; 74 | float2 uv1 : TEXCOORD1; 75 | float2 uv2 : TEXCOORD2; 76 | }; 77 | 78 | struct PixelInput { 79 | float4 pos : SV_POSITION; 80 | float2 uv0 : TEXCOORD0; 81 | float2 uv1 : TEXCOORD1; 82 | float2 uv2 : TEXCOORD2; 83 | float4 posWorld : TEXCOORD3; 84 | float4 screenPos : TEXCOORD4; 85 | float3 normalDir : TEXCOORD5; 86 | float3 tangentDir : TEXCOORD6; 87 | float3 bitangentDir : TEXCOORD7; 88 | LIGHTING_COORDS(8,9) 89 | #if defined(LIGHTMAP_ON) || defined(UNITY_SHOULD_SAMPLE_SH) 90 | float4 ambientOrLightmapUV : TEXCOORD8; 91 | #endif 92 | }; 93 | 94 | PixelInput vert (VertexInput v) { 95 | PixelInput o = (PixelInput)0; 96 | o.pos = UnityObjectToClipPos(v.pos); 97 | o.uv0 = v.uv0; 98 | o.uv1 = v.uv1; 99 | o.uv2 = v.uv2; 100 | o.posWorld = mul(unity_ObjectToWorld, v.pos); 101 | o.screenPos = ComputeScreenPos(o.pos); 102 | o.normalDir = UnityObjectToWorldNormal(v.normal); 103 | o.tangentDir = normalize(mul(unity_ObjectToWorld, float4(v.tangent.xyz, 0)).xyz); 104 | o.bitangentDir = normalize(cross(o.normalDir, o.tangentDir) * v.tangent.w); 105 | #ifdef LIGHTMAP_ON 106 | o.ambientOrLightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 107 | o.ambientOrLightmapUV.zw = 0; 108 | #endif 109 | #ifdef DYNAMICLIGHTMAP_ON 110 | o.ambientOrLightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; 111 | #endif 112 | return o; 113 | } 114 | 115 | float3 frag(PixelInput i) : SV_TARGET { 116 | float2 screenUV = i.screenPos.xy / i.screenPos.w; 117 | float3 worldPos = i.posWorld.xyz; 118 | float3x3 tangentTransform = float3x3(i.tangentDir, i.bitangentDir, normalize(i.normalDir)); 119 | 120 | ////// Lighting Data: 121 | float3 viewDir = normalize(_WorldSpaceCameraPos.xyz - worldPos); 122 | float3 lightDir = normalize(_WorldSpaceLightPos0.xyz); 123 | float3 halfDir = normalize(viewDir + lightDir); 124 | float3 nomralDir_Tex = UnpackNormal(tex2D(_NomralTexture, i.uv0 * _NormalTile)); 125 | float3 normalDir = normalize(mul(nomralDir_Tex, tangentTransform)); 126 | float3 ReflectDir = reflect(-viewDir, normalDir); 127 | 128 | BSDFContext BSDFContext; 129 | Init(BSDFContext, normalDir, viewDir, lightDir, halfDir); 130 | 131 | half3 Attenuation = UnityComputeForwardShadows(i.ambientOrLightmapUV, worldPos, i.screenPos); 132 | Attenuation *= _LightColor0.rgb * BSDFContext.NoL; 133 | 134 | ////// Material Property 135 | float3 BaseColor = _BaseColor.rgb * (1 - _Reflectance); 136 | float Roughness = clamp(_Roughness, 0.04, 1); 137 | 138 | #if _Iridescence 139 | float3 Iridescence_Color = Flim_Iridescence(1, BSDFContext.NoV, _Iridescence_Distance, 0.04); 140 | float3 SpecularColor = lerp(0.08 * _SpecularLevel, Iridescence_Color, _Reflectance); 141 | #else 142 | float3 SpecularColor = lerp(0.08 * _SpecularLevel, _BaseColor.rgb, _Reflectance); 143 | #endif 144 | 145 | /////// GI Data: 146 | UnityGIInput d; 147 | d.worldPos = worldPos; 148 | 149 | #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) 150 | d.ambient = 0; 151 | d.lightmapUV = i.ambientOrLightmapUV; 152 | #else 153 | d.ambient = i.ambientOrLightmapUV; 154 | #endif 155 | 156 | #if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION 157 | d.boxMin[0] = unity_SpecCube0_BoxMin; 158 | d.boxMin[1] = unity_SpecCube1_BoxMin; 159 | #endif 160 | 161 | #if UNITY_SPECCUBE_BOX_PROJECTION 162 | d.boxMax[0] = unity_SpecCube0_BoxMax; 163 | d.boxMax[1] = unity_SpecCube1_BoxMax; 164 | d.probePosition[0] = unity_SpecCube0_ProbePosition; 165 | d.probePosition[1] = unity_SpecCube1_ProbePosition; 166 | #endif 167 | 168 | d.probeHDR[0] = unity_SpecCube0_HDR; 169 | d.probeHDR[1] = unity_SpecCube1_HDR; 170 | Unity_GlossyEnvironmentData ugls_en_data; 171 | ugls_en_data.roughness = Roughness; 172 | ugls_en_data.reflUVW = ReflectDir; 173 | UnityGI gi = UnityGlobalIllumination(d, 1, normalDir, ugls_en_data); 174 | 175 | 176 | //////////////////////ClearCoat Data 177 | float ClearCoatRoughness = clamp(_ClearCoatRoughness, 0.04, 1); 178 | float3 ClearCoat_NomralTex = UnpackNormal(tex2D(_ClearCoatNomralTexture, i.uv0 * _ClearCoatNormalTile)); 179 | float3 ClearCoat_NormalDir = normalize(mul(ClearCoat_NomralTex, tangentTransform)); 180 | float3 ClarCoat_ReflectDir = reflect(-viewDir, ClearCoat_NormalDir); 181 | 182 | UnityGIInput ClearCoat_Data; 183 | ClearCoat_Data.worldPos = worldPos; 184 | 185 | #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) 186 | ClearCoat_Data.ambient = 0; 187 | ClearCoat_Data.lightmapUV = i.ambientOrLightmapUV; 188 | #else 189 | ClearCoat_Data.ambient = i.ambientOrLightmapUV; 190 | #endif 191 | 192 | #if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION 193 | ClearCoat_Data.boxMin[0] = unity_SpecCube0_BoxMin; 194 | ClearCoat_Data.boxMin[1] = unity_SpecCube1_BoxMin; 195 | #endif 196 | 197 | #if UNITY_SPECCUBE_BOX_PROJECTION 198 | ClearCoat_Data.boxMax[0] = unity_SpecCube0_BoxMax; 199 | ClearCoat_Data.boxMax[1] = unity_SpecCube1_BoxMax; 200 | ClearCoat_Data.probePosition[0] = unity_SpecCube0_ProbePosition; 201 | ClearCoat_Data.probePosition[1] = unity_SpecCube1_ProbePosition; 202 | #endif 203 | 204 | ClearCoat_Data.probeHDR[0] = unity_SpecCube0_HDR; 205 | ClearCoat_Data.probeHDR[1] = unity_SpecCube1_HDR; 206 | Unity_GlossyEnvironmentData ClearCoat_GlossData; 207 | ClearCoat_GlossData.roughness = ClearCoatRoughness; 208 | ClearCoat_GlossData.reflUVW = ClarCoat_ReflectDir; 209 | 210 | /////// Final Color 211 | float ClearCoatIntensity = F_Schlick( 0.05, 1, max( dot (normalize(i.normalDir), viewDir ), 0 ) ) * _ClearCoat; 212 | 213 | half3 ClearCoat_EnergyCompensation; 214 | float3 ClearCoat_GF = PreintegratedDGF_LUT(_PreintegratedLUT, ClearCoat_EnergyCompensation, 1, ClearCoatRoughness, max(dot(ClearCoat_NormalDir, viewDir), 0)).rgb; 215 | float3 ClearCoat_Reflection = UnityGI_IndirectSpecular(ClearCoat_Data, 1, ClearCoat_NormalDir, ClearCoat_GlossData) * ClearCoat_GF * ClearCoat_EnergyCompensation; 216 | 217 | half3 EnergyCompensation; 218 | half4 Preintegrated_DGF = PreintegratedDGF_LUT(_PreintegratedLUT, EnergyCompensation, SpecularColor, Roughness, BSDFContext.NoV); 219 | float3 GlobalIllumination = (BaseColor * gi.indirect.diffuse * Preintegrated_DGF.a) + (lerp(gi.indirect.specular * Preintegrated_DGF.rgb * EnergyCompensation, ClearCoat_Reflection, ClearCoatIntensity)); 220 | 221 | float3 ClearCoat_Shading = ClearCoat_Lit(BSDFContext, Attenuation, EnergyCompensation, ClearCoat_EnergyCompensation, BaseColor, SpecularColor, _ClearCoat, ClearCoatRoughness, Roughness); 222 | 223 | return ClearCoat_Shading + GlobalIllumination; 224 | } 225 | ENDCG 226 | } 227 | } 228 | FallBack "Diffuse" 229 | } 230 | -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Filtter_Library.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _Filtter_Library_ 2 | #define _Filtter_Library_ 3 | 4 | #include "Common.hlsl" 5 | 6 | 7 | //////Color filter 8 | inline half HdrWeight4(half3 Color, half Exposure) 9 | { 10 | return rcp(Luma4(Color) * Exposure + 4); 11 | } 12 | 13 | inline half HdrWeightY(half Color, half Exposure) 14 | { 15 | return rcp(Color * Exposure + 4); 16 | } 17 | 18 | inline half3 RGBToYCoCg(half3 RGB) 19 | { 20 | half Y = dot(RGB, half3(1, 2, 1)); 21 | half Co = dot(RGB, half3(2, 0, -2)); 22 | half Cg = dot(RGB, half3(-1, 2, -1)); 23 | 24 | half3 YCoCg = half3(Y, Co, Cg); 25 | return YCoCg; 26 | } 27 | 28 | inline half3 YCoCgToRGB(half3 YCoCg) 29 | { 30 | half Y = YCoCg.x * 0.25; 31 | half Co = YCoCg.y * 0.25; 32 | half Cg = YCoCg.z * 0.25; 33 | 34 | half R = Y + Co - Cg; 35 | half G = Y + Cg; 36 | half B = Y - Co - Cg; 37 | 38 | half3 RGB = half3(R, G, B); 39 | return RGB; 40 | } 41 | 42 | //////Sampler filter 43 | void Bicubic2DCatmullRom(in float2 UV, in float2 Size, in float2 InvSize, out float2 Sample[3], out float2 Weight[3]) 44 | { 45 | UV *= Size; 46 | 47 | float2 tc = floor(UV - 0.5) + 0.5; 48 | float2 f = UV - tc; 49 | float2 f2 = f * f; 50 | float2 f3 = f2 * f; 51 | 52 | float2 w0 = f2 - 0.5 * (f3 + f); 53 | float2 w1 = 1.5 * f3 - 2.5 * f2 + 1; 54 | float2 w3 = 0.5 * (f3 - f2); 55 | float2 w2 = 1 - w0 - w1 - w3; 56 | 57 | Weight[0] = w0; 58 | Weight[1] = w1 + w2; 59 | Weight[2] = w3; 60 | 61 | Sample[0] = tc - 1; 62 | Sample[1] = tc + w2 / Weight[1]; 63 | Sample[2] = tc + 2; 64 | 65 | Sample[0] *= InvSize; 66 | Sample[1] *= InvSize; 67 | Sample[2] *= InvSize; 68 | } 69 | 70 | #define BICUBIC_CATMULL_ROM_SAMPLES 5 71 | 72 | struct FCatmullRomSamples 73 | { 74 | // Constant number of samples (BICUBIC_CATMULL_ROM_SAMPLES) 75 | uint Count; 76 | 77 | // Constant sign of the UV direction from master UV sampling location. 78 | int2 UVDir[BICUBIC_CATMULL_ROM_SAMPLES]; 79 | 80 | // Bilinear sampling UV coordinates of the samples 81 | float2 UV[BICUBIC_CATMULL_ROM_SAMPLES]; 82 | 83 | // Weights of the samples 84 | float Weight[BICUBIC_CATMULL_ROM_SAMPLES]; 85 | 86 | // Final multiplier (it is faster to multiply 3 RGB values than reweights the 5 weights) 87 | float FinalMultiplier; 88 | }; 89 | 90 | FCatmullRomSamples GetBicubic2DCatmullRomSamples(float2 UV, float2 Size, in float2 InvSize) 91 | { 92 | FCatmullRomSamples Samples; 93 | Samples.Count = BICUBIC_CATMULL_ROM_SAMPLES; 94 | 95 | float2 Weight[3]; 96 | float2 Sample[3]; 97 | Bicubic2DCatmullRom(UV, Size, InvSize, Sample, Weight); 98 | 99 | // Optimized by removing corner samples 100 | Samples.UV[0] = float2(Sample[1].x, Sample[0].y); 101 | Samples.UV[1] = float2(Sample[0].x, Sample[1].y); 102 | Samples.UV[2] = float2(Sample[1].x, Sample[1].y); 103 | Samples.UV[3] = float2(Sample[2].x, Sample[1].y); 104 | Samples.UV[4] = float2(Sample[1].x, Sample[2].y); 105 | 106 | Samples.Weight[0] = Weight[1].x * Weight[0].y; 107 | Samples.Weight[1] = Weight[0].x * Weight[1].y; 108 | Samples.Weight[2] = Weight[1].x * Weight[1].y; 109 | Samples.Weight[3] = Weight[2].x * Weight[1].y; 110 | Samples.Weight[4] = Weight[1].x * Weight[2].y; 111 | 112 | Samples.UVDir[0] = int2(0, -1); 113 | Samples.UVDir[1] = int2(-1, 0); 114 | Samples.UVDir[2] = int2(0, 0); 115 | Samples.UVDir[3] = int2(1, 0); 116 | Samples.UVDir[4] = int2(0, 1); 117 | 118 | // Reweight after removing the corners 119 | float CornerWeights; 120 | CornerWeights = Samples.Weight[0]; 121 | CornerWeights += Samples.Weight[1]; 122 | CornerWeights += Samples.Weight[2]; 123 | CornerWeights += Samples.Weight[3]; 124 | CornerWeights += Samples.Weight[4]; 125 | Samples.FinalMultiplier = 1 / CornerWeights; 126 | 127 | return Samples; 128 | } 129 | 130 | half4 Texture2DSampleBicubic(Texture2D Tex, SamplerState Sampler, half2 UV, half2 Size, in half2 InvSize) 131 | { 132 | FCatmullRomSamples Samples = GetBicubic2DCatmullRomSamples(UV, Size, InvSize); 133 | 134 | half4 OutColor = 0; 135 | for (uint i = 0; i < Samples.Count; i++) 136 | { 137 | OutColor += Tex.SampleLevel(Sampler, Samples.UV[i], 0) * Samples.Weight[i]; 138 | } 139 | OutColor *= Samples.FinalMultiplier; 140 | 141 | return OutColor; 142 | } 143 | 144 | half4 Texture2DSampleBicubic(sampler2D Tex, half2 UV, half2 Size, in half2 InvSize) 145 | { 146 | FCatmullRomSamples Samples = GetBicubic2DCatmullRomSamples(UV, Size, InvSize); 147 | 148 | half4 OutColor = 0; 149 | for (uint i = 0; i < Samples.Count; i++) 150 | { 151 | OutColor += tex2Dlod(Tex, half4(Samples.UV[i], 0.0, 0.0)) * Samples.Weight[i]; 152 | } 153 | OutColor *= Samples.FinalMultiplier; 154 | 155 | return OutColor; 156 | } 157 | 158 | //////Sharpe filter 159 | inline half Sharpe(sampler2D sharpColor, half sharpness, half2 Resolution, half2 UV) 160 | { 161 | half2 step = 1 / Resolution.xy; 162 | 163 | half3 texA = tex2D(sharpColor, UV + half2(-step.x, -step.y) * 1.5); 164 | half3 texB = tex2D(sharpColor, UV + half2(step.x, -step.y) * 1.5); 165 | half3 texC = tex2D(sharpColor, UV + half2(-step.x, step.y) * 1.5); 166 | half3 texD = tex2D(sharpColor, UV + half2(step.x, step.y) * 1.5); 167 | 168 | half3 around = 0.25 * (texA + texB + texC + texD); 169 | half4 center = tex2D(sharpColor, UV); 170 | 171 | half3 color = center.rgb + (center.rgb - around) * sharpness; 172 | return half4(color, center.a); 173 | } 174 | 175 | //////Bilateral filter 176 | #define Blur_Sharpness 5 177 | #define Blur_Radius 0.05 178 | #define Blur_Size 12 179 | 180 | inline half CrossBilateralWeight_1(half x, half Sharp) 181 | { 182 | return 0.39894 * exp(-0.5 * x * x / (Sharp * Sharp)) / Sharp; 183 | } 184 | 185 | inline half CrossBilateralWeight_2(half3 v, half Sharp) 186 | { 187 | return 0.39894 * exp(-0.5 * dot(v, v) / (Sharp * Sharp)) / Sharp; 188 | } 189 | 190 | inline half4 BilateralClearUp(sampler2D Color, half2 Resolution, half2 uv) 191 | { 192 | half4 originColor = tex2D(Color, uv); 193 | 194 | half kernel[Blur_Size]; 195 | const int kernelSize = (Blur_Size - 1) / 2; 196 | 197 | //UNITY_UNROLL 198 | for (int j = 0; j <= kernelSize; j++) 199 | { 200 | kernel[kernelSize + j] = kernel[kernelSize - j] = CrossBilateralWeight_1(half(j), Blur_Sharpness); 201 | } 202 | 203 | half weight, Num_Weight; 204 | half4 blurColor, final_colour; 205 | 206 | //UNITY_UNROLL 207 | for (int i = -kernelSize; i <= kernelSize; i++) 208 | { 209 | //UNITY_UNROLL 210 | for (int j = -kernelSize; j <= kernelSize; j++) 211 | { 212 | blurColor = tex2Dlod(Color, half4( ( (uv * Resolution) + half2( half(i), half(j) ) ) / Resolution, 0, 0) ); 213 | weight = CrossBilateralWeight_2(blurColor - originColor, Blur_Radius) * kernel[kernelSize + j] * kernel[kernelSize + i]; 214 | Num_Weight += weight; 215 | final_colour += weight * blurColor; 216 | } 217 | } 218 | return final_colour / Num_Weight; 219 | } 220 | 221 | ///////////////Temporal filter 222 | #ifndef AA_Filter 223 | #define AA_Filter 1 224 | #endif 225 | 226 | #ifndef AA_BicubicFilter 227 | #define AA_BicubicFilter 0 228 | #endif 229 | 230 | #if defined(UNITY_REVERSED_Z) 231 | #define COMPARE_DEPTH(a, b) step(b, a) 232 | #else 233 | #define COMPARE_DEPTH(a, b) step(a, b) 234 | #endif 235 | 236 | half2 ReprojectedMotionVectorUV(sampler2D _DepthTexture, half2 uv, half2 screenSize) 237 | { 238 | half neighborhood[9]; 239 | neighborhood[0] = tex2D(_DepthTexture, uv + (int2(-1, -1) / screenSize)).z; 240 | neighborhood[1] = tex2D(_DepthTexture, uv + (int2(0, -1) / screenSize)).z; 241 | neighborhood[2] = tex2D(_DepthTexture, uv + (int2(1, -1) / screenSize)).z; 242 | neighborhood[3] = tex2D(_DepthTexture, uv + (int2(-1, 0) / screenSize)).z; 243 | neighborhood[5] = tex2D(_DepthTexture, uv + (int2(1, 0) / screenSize)).z; 244 | neighborhood[6] = tex2D(_DepthTexture, uv + (int2(-1, 1) / screenSize)).z; 245 | neighborhood[7] = tex2D(_DepthTexture, uv + (int2(0, -1) / screenSize)).z; 246 | neighborhood[8] = tex2D(_DepthTexture, uv + (int2(1, 1) / screenSize)).z; 247 | 248 | half3 result = half3(0, 0, tex2D(_DepthTexture, uv).z); 249 | result = lerp(result, half3(-1, -1, neighborhood[0]), COMPARE_DEPTH(neighborhood[0], result.z)); 250 | result = lerp(result, half3(0, -1, neighborhood[1]), COMPARE_DEPTH(neighborhood[1], result.z)); 251 | result = lerp(result, half3(1, -1, neighborhood[2]), COMPARE_DEPTH(neighborhood[2], result.z)); 252 | result = lerp(result, half3(-1, 0, neighborhood[3]), COMPARE_DEPTH(neighborhood[3], result.z)); 253 | result = lerp(result, half3(1, 0, neighborhood[5]), COMPARE_DEPTH(neighborhood[5], result.z)); 254 | result = lerp(result, half3(-1, 1, neighborhood[6]), COMPARE_DEPTH(neighborhood[6], result.z)); 255 | result = lerp(result, half3(0, -1, neighborhood[7]), COMPARE_DEPTH(neighborhood[7], result.z)); 256 | result = lerp(result, half3(1, 1, neighborhood[8]), COMPARE_DEPTH(neighborhood[8], result.z)); 257 | 258 | return (uv + result.xy * screenSize); 259 | } 260 | 261 | inline void ResolverAABB(sampler2D currColor, half Sharpness, half ExposureScale, half AABBScale, half2 uv, half2 TexelSize, inout half Variance, inout half4 MinColor, inout half4 MaxColor, inout half4 FilterColor) 262 | { 263 | const int2 SampleOffset[9] = {int2(-1.0, -1.0), int2(0.0, -1.0), int2(1.0, -1.0), int2(-1.0, 0.0), int2(0.0, 0.0), int2(1.0, 0.0), int2(-1.0, 1.0), int2(0.0, 1.0), int2(1.0, 1.0)}; 264 | 265 | half4 SampleColors[9]; 266 | 267 | for(uint i = 0; i < 9; i++) { 268 | #if AA_BicubicFilter 269 | SampleColors[i] = Texture2DSampleBicubic(currColor, uv + ( SampleOffset[i] / TexelSize), BicubicSize.xy, BicubicSize.zw); 270 | #else 271 | SampleColors[i] = tex2D( currColor, uv + ( SampleOffset[i] / TexelSize) ); 272 | #endif 273 | } 274 | 275 | #if AA_Filter 276 | half SampleWeights[9]; 277 | for(uint j = 0; j < 9; j++) { 278 | SampleWeights[j] = HdrWeight4(SampleColors[j].rgb, ExposureScale); 279 | } 280 | 281 | half TotalWeight = 0; 282 | for(uint k = 0; k < 9; k++) { 283 | TotalWeight += SampleWeights[k]; 284 | } 285 | 286 | SampleColors[4] = (SampleColors[0] * SampleWeights[0] + SampleColors[1] * SampleWeights[1] + SampleColors[2] * SampleWeights[2] 287 | + SampleColors[3] * SampleWeights[3] + SampleColors[4] * SampleWeights[4] + SampleColors[5] * SampleWeights[5] 288 | + SampleColors[6] * SampleWeights[6] + SampleColors[7] * SampleWeights[7] + SampleColors[8] * SampleWeights[8]) / TotalWeight; 289 | #endif 290 | 291 | half4 m1 = 0.0; half4 m2 = 0.0; 292 | for(uint x = 0; x < 9; x++) 293 | { 294 | m1 += SampleColors[x]; 295 | m2 += SampleColors[x] * SampleColors[x]; 296 | } 297 | 298 | half4 mean = m1 / 9.0; 299 | half4 stddev = sqrt( (m2 / 9.0) - pow2(mean) ); 300 | 301 | MinColor = mean - AABBScale * stddev; 302 | MaxColor = mean + AABBScale * stddev; 303 | 304 | FilterColor = SampleColors[4]; 305 | MinColor = min(MinColor, FilterColor); 306 | MaxColor = max(MaxColor, FilterColor); 307 | 308 | half4 TotalVariance = 0; 309 | for(uint z = 0; z < 9; z++) 310 | { 311 | TotalVariance += pow2(SampleColors[z] - mean); 312 | } 313 | Variance = saturate( Luminance(TotalVariance / 4) * 256 ); 314 | Variance *= FilterColor.a; 315 | } 316 | 317 | //////Sharpening 318 | /* 319 | //half4 corners = 4 * (TopLeft + BottomRight) - 2 * filterColor; 320 | //filterColor += (filterColor - (corners * 0.166667)) * 2.718282 * (Sharpness * 0.25); 321 | 322 | half TotalVariance = 0; 323 | for(uint z = 0; z < 9; z++) 324 | { 325 | TotalVariance += pow2(Luminance(SampleColors[z]) - Luminance(mean)); 326 | } 327 | Variance = saturate((TotalVariance / 9) * 256) * FilterColor.a; 328 | */ 329 | 330 | #endif -------------------------------------------------------------------------------- /Assets/TP/CGBull/StochasticScreenSpaceReflection/Shaders/Resources/SSRLibrary.cginc: -------------------------------------------------------------------------------- 1 | #include "UnityStandardBRDF.cginc" 2 | #include "Assets/TP/CGBull/Common/Shaders/Resources/Include_HLSL.hlsl" 3 | 4 | inline half GetScreenFadeBord(half2 pos, half value) 5 | { 6 | half borderDist = min(1 - max(pos.x, pos.y), min(pos.x, pos.y)); 7 | return saturate(borderDist > value ? 1 : borderDist / value); 8 | } 9 | 10 | 11 | /////////////////////////////////////LInear3DTrace///////////////////////////////////// 12 | float4 LinearTraceRay3DSpace(Texture2D _DepthTexture, SamplerState sampler_DepthTexture, int NumSteps, float2 BlueNoise, float3 rayPos, float3 rayDir) { 13 | float mask = 0.0, endDepth = 0.0; 14 | float rayDepth = rayPos.z; 15 | 16 | float2 jitter = BlueNoise + 0.5; 17 | float StepSize = 1 / (float)NumSteps; 18 | StepSize = StepSize * (jitter.x + jitter.y) + StepSize; 19 | 20 | UNITY_LOOP 21 | for (int i = 0; i < NumSteps; i++) { 22 | endDepth = Texture2DSampleLevel(_DepthTexture, sampler_DepthTexture, rayPos.xy, 0.0); 23 | if (rayDepth > endDepth) { 24 | mask = 1; 25 | break; 26 | } 27 | rayPos += rayDir * StepSize; 28 | rayDepth = rayPos.z; 29 | } 30 | return float4(rayPos, mask); 31 | } 32 | 33 | 34 | /////////////////////////////////////Linear2DTrace///////////////////////////////////// 35 | inline half distanceSquared(half2 A, half2 B) 36 | { 37 | A -= B; 38 | return dot(A, A); 39 | } 40 | 41 | inline half distanceSquared(half3 A, half3 B) 42 | { 43 | A -= B; 44 | return dot(A, A); 45 | } 46 | 47 | void swap(inout half v0, inout half v1) 48 | { 49 | half temp = v0; 50 | v0 = v1; 51 | v1 = temp; 52 | } 53 | 54 | bool intersectsDepthBuffer(half rayZMin, half rayZMax, half sceneZ, half layerThickness) 55 | { 56 | return (rayZMax >= sceneZ - layerThickness) && (rayZMin <= sceneZ); 57 | } 58 | 59 | void rayIterations(sampler2D forntDepth, in bool traceBehind_Old, in bool traceBehind, inout half2 P, inout half stepDirection, inout half end, inout int stepCount, inout int maxSteps, inout bool intersecting, 60 | inout half sceneZ, inout half2 dP, inout half3 Q, inout half3 dQ, inout half k, inout half dk, 61 | inout half rayZMin, inout half rayZMax, inout half prevZMaxEstimate, inout bool permute, inout half2 hitPixel, 62 | half2 invSize, inout half layerThickness) 63 | { 64 | bool stop = intersecting; 65 | 66 | for (; (P.x * stepDirection) <= end && stepCount < maxSteps && !stop; P += dP, Q.z += dQ.z, k += dk, stepCount += 1) 67 | { 68 | rayZMin = prevZMaxEstimate; 69 | rayZMax = (dQ.z * 0.5 + Q.z) / (dk * 0.5 + k); 70 | prevZMaxEstimate = rayZMax; 71 | 72 | if (rayZMin > rayZMax) { 73 | swap(rayZMin, rayZMax); 74 | } 75 | 76 | hitPixel = permute ? P.yx : P; 77 | sceneZ = tex2Dlod(forntDepth, half4(hitPixel * invSize, 0, 0)).r; 78 | sceneZ = -LinearEyeDepth(sceneZ); 79 | bool isBehind = (rayZMin <= sceneZ); 80 | 81 | if (traceBehind_Old == 1) { 82 | intersecting = isBehind && (rayZMax >= sceneZ - layerThickness); 83 | } else { 84 | intersecting = (rayZMax >= sceneZ - layerThickness); 85 | } 86 | 87 | stop = traceBehind ? intersecting : isBehind; 88 | } 89 | P -= dP, Q.z -= dQ.z, k -= dk; 90 | } 91 | 92 | bool Linear2D_Trace(sampler2D forntDepth, 93 | half3 csOrigin, 94 | half3 csDirection, 95 | half4x4 projectMatrix, 96 | half2 csZBufferSize, 97 | half jitter, 98 | int maxSteps, 99 | half layerThickness, 100 | half traceDistance, 101 | in out half2 hitPixel, 102 | int stepSize, 103 | bool traceBehind, 104 | in out half3 csHitPoint, 105 | in out half stepCount) 106 | { 107 | 108 | half2 invSize = half2(1 / csZBufferSize.x, 1 / csZBufferSize.y); 109 | hitPixel = half2(-1, -1); 110 | 111 | half nearPlaneZ = -0.01; 112 | half rayLength = ((csOrigin.z + csDirection.z * traceDistance) > nearPlaneZ) ? ((nearPlaneZ - csOrigin.z) / csDirection.z) : traceDistance; 113 | half3 csEndPoint = csDirection * rayLength + csOrigin; 114 | half4 H0 = mul(projectMatrix, half4(csOrigin, 1)); 115 | half4 H1 = mul(projectMatrix, half4(csEndPoint, 1)); 116 | half k0 = 1 / H0.w; 117 | half k1 = 1 / H1.w; 118 | half2 P0 = H0.xy * k0; 119 | half2 P1 = H1.xy * k1; 120 | half3 Q0 = csOrigin * k0; 121 | half3 Q1 = csEndPoint * k1; 122 | 123 | #if 1 124 | half yMax = csZBufferSize.y - 0.5; 125 | half yMin = 0.5; 126 | half xMax = csZBufferSize.x - 0.5; 127 | half xMin = 0.5; 128 | half alpha = 0; 129 | 130 | if (P1.y > yMax || P1.y < yMin) 131 | { 132 | half yClip = (P1.y > yMax) ? yMax : yMin; 133 | half yAlpha = (P1.y - yClip) / (P1.y - P0.y); 134 | alpha = yAlpha; 135 | } 136 | if (P1.x > xMax || P1.x < xMin) 137 | { 138 | half xClip = (P1.x > xMax) ? xMax : xMin; 139 | half xAlpha = (P1.x - xClip) / (P1.x - P0.x); 140 | alpha = max(alpha, xAlpha); 141 | } 142 | 143 | P1 = lerp(P1, P0, alpha); 144 | k1 = lerp(k1, k0, alpha); 145 | Q1 = lerp(Q1, Q0, alpha); 146 | #endif 147 | 148 | P1 = (distanceSquared(P0, P1) < 0.0001) ? P0 + half2(0.01, 0.01) : P1; 149 | half2 delta = P1 - P0; 150 | bool permute = false; 151 | 152 | if (abs(delta.x) < abs(delta.y)) 153 | { 154 | permute = true; 155 | delta = delta.yx; 156 | P1 = P1.yx; 157 | P0 = P0.yx; 158 | } 159 | 160 | half stepDirection = sign(delta.x); 161 | half invdx = stepDirection / delta.x; 162 | half2 dP = half2(stepDirection, invdx * delta.y); 163 | half3 dQ = (Q1 - Q0) * invdx; 164 | half dk = (k1 - k0) * invdx; 165 | 166 | dP *= stepSize; 167 | dQ *= stepSize; 168 | dk *= stepSize; 169 | P0 += dP * jitter; 170 | Q0 += dQ * jitter; 171 | k0 += dk * jitter; 172 | 173 | half3 Q = Q0; 174 | half k = k0; 175 | half prevZMaxEstimate = csOrigin.z; 176 | stepCount = 0; 177 | half rayZMax = prevZMaxEstimate, rayZMin = prevZMaxEstimate; 178 | half sceneZ = 100000; 179 | half end = P1.x * stepDirection; 180 | bool intersecting = intersectsDepthBuffer(rayZMin, rayZMax, sceneZ, layerThickness); 181 | half2 P = P0; 182 | int originalStepCount = 0; 183 | 184 | bool traceBehind_Old = true; 185 | rayIterations(forntDepth, traceBehind_Old, traceBehind, P, stepDirection, end, originalStepCount, maxSteps, intersecting, sceneZ, dP, Q, dQ, k, dk, rayZMin, rayZMax, prevZMaxEstimate, permute, hitPixel, invSize, layerThickness); 186 | 187 | stepCount = originalStepCount; 188 | Q.xy += dQ.xy * stepCount; 189 | csHitPoint = Q * (1 / k); 190 | return intersecting; 191 | } 192 | 193 | inline half3 ReconstructCSPosition(half4 _MainTex_TexelSize, half4 _ProjInfo, half2 S, half z) 194 | { 195 | half linEyeZ = -LinearEyeDepth(z); 196 | return half3((((S.xy * _MainTex_TexelSize.zw)) * _ProjInfo.xy + _ProjInfo.zw) * linEyeZ, linEyeZ); 197 | } 198 | 199 | inline half3 GetPosition(sampler2D depth, half4 _MainTex_TexelSize, half4 _ProjInfo, half2 ssP) 200 | { 201 | half3 P; 202 | P.z = SAMPLE_DEPTH_TEXTURE(depth, ssP.xy).r; 203 | P = ReconstructCSPosition(_MainTex_TexelSize, _ProjInfo, half2(ssP), P.z); 204 | return P; 205 | } 206 | 207 | /////////////////////////////////////Hierarchical_Z Trace///////////////////////////////////// 208 | float2 cell(float2 ray, float2 cell_count) { 209 | return floor(ray.xy * cell_count); 210 | } 211 | 212 | float2 cell_count(float level, float2 ScreenSize) { 213 | return ScreenSize / (level == 0 ? 1 : exp2(level)); 214 | } 215 | 216 | float3 intersectDepth_Plane(float3 rayOrigin, float3 rayDir, float marchSize) 217 | { 218 | return rayOrigin + rayDir * marchSize; 219 | } 220 | 221 | float3 intersect_cell_boundary(float3 rayOrigin, float3 rayDir, float2 cellIndex, float2 cellCount, float2 crossStep, float2 crossOffset) 222 | { 223 | float2 index = cellIndex + crossStep; 224 | index /= cellCount; 225 | index += crossOffset; 226 | 227 | float2 delta = index - rayOrigin.xy; 228 | delta /= rayDir.xy; 229 | 230 | float marchSize = min(delta.x, delta.y); 231 | return intersectDepth_Plane(rayOrigin, rayDir, marchSize); 232 | } 233 | 234 | bool crossed_cell_boundary(float2 cell_id_one, float2 cell_id_two) { 235 | return (int)cell_id_one.x != (int)cell_id_two.x || (int)cell_id_one.y != (int)cell_id_two.y; 236 | } 237 | 238 | float minimum_depth_plane(float2 ray, float2 cell_count, float level, Texture2D SceneDepth) { 239 | return SceneDepth.Load( int3( (ray * cell_count), level ) ); 240 | } 241 | 242 | float3 Hierarchical_Z_Trace(int HiZ_Max_Level, int HiZ_Start_Level, int HiZ_Stop_Level, int NumSteps, float2 screenSize, float3 rayOrigin, float3 rayDir, Texture2D SceneDepth) 243 | { 244 | float level = HiZ_Start_Level; 245 | float2 crossStep = float2(rayDir.x >= 0.0 ? 1.0 : -1.0, rayDir.y >= 0.0 ? 1.0 : -1.0); 246 | float2 crossOffset = float2(crossStep.xy * screenSize); 247 | crossStep.xy = saturate(crossStep.xy); 248 | 249 | float3 ray = rayOrigin.xyz; 250 | 251 | float3 marchSize = rayDir.xyz / rayDir.z; 252 | float3 curr_RayOrigin = intersectDepth_Plane(rayOrigin, marchSize, -rayOrigin.z); 253 | float2 rayCell = cell(ray.xy, screenSize); 254 | 255 | ray = intersect_cell_boundary(curr_RayOrigin, marchSize, rayCell.xy, screenSize, crossStep.xy, crossOffset.xy); 256 | 257 | int iterations = 0.0; float3 tmpRay = 0.0; 258 | 259 | [loop] 260 | while(level >= HiZ_Stop_Level && iterations < NumSteps) 261 | { 262 | float2 cellCount = cell_count(level, screenSize); 263 | float minZ = minimum_depth_plane(ray.xy, cellCount, level, SceneDepth); 264 | float2 oldCellIdx = cell(ray.xy, cellCount); 265 | 266 | tmpRay = intersectDepth_Plane(curr_RayOrigin, marchSize, max(ray.z, minZ)); 267 | float2 newCellIdx = cell(tmpRay.xy, cellCount); 268 | 269 | [branch] 270 | if(crossed_cell_boundary(oldCellIdx, newCellIdx)) 271 | { 272 | tmpRay = intersect_cell_boundary(curr_RayOrigin, rayDir, oldCellIdx, cellCount.xy, crossStep.xy, crossOffset.xy); 273 | level = min(HiZ_Max_Level, level + 2.0); 274 | } 275 | 276 | ray.xyz = tmpRay.xyz; 277 | level--; 278 | iterations++; 279 | } 280 | return ray; 281 | } 282 | 283 | float GetMarchSize(float2 start,float2 end,float2 SamplerPos) 284 | { 285 | float2 dir = abs(end - start); 286 | return length( float2( min(dir.x, SamplerPos.x), min(dir.y, SamplerPos.y) ) ); 287 | } 288 | 289 | float4 Hierarchical_Z_Trace(int HiZ_Max_Level, int HiZ_Start_Level, int HiZ_Stop_Level, int NumSteps, float thickness, float2 RayCastSize, float3 rayStart, float3 rayDir, Texture2D SceneDepth, SamplerState SceneDepth_Sampler) 290 | { 291 | float SamplerSize = GetMarchSize(rayStart.xy, rayStart.xy + rayDir.xy, RayCastSize); 292 | float3 samplePos = rayStart + rayDir * (SamplerSize); 293 | int level = HiZ_Start_Level; float mask = 0.0; 294 | 295 | UNITY_LOOP 296 | for (int i = 0; i < NumSteps; i++) 297 | { 298 | float2 currSamplerPos = RayCastSize * exp2(level + 1.0); 299 | float newSamplerSize = GetMarchSize(samplePos.xy, samplePos.xy + rayDir.xy, currSamplerPos); 300 | float3 newSamplePos = samplePos + rayDir * newSamplerSize; 301 | float sampleMinDepth = Texture2DSampleLevel(SceneDepth, SceneDepth_Sampler, newSamplePos.xy, level); 302 | 303 | UNITY_FLATTEN 304 | if (sampleMinDepth < newSamplePos.z) { 305 | level = min(HiZ_Max_Level, level + 2.0); 306 | samplePos = newSamplePos; 307 | } else { 308 | level--; 309 | } 310 | 311 | UNITY_BRANCH 312 | if (level < HiZ_Stop_Level) { 313 | float delta = (-LinearEyeDepth(sampleMinDepth)) - (-LinearEyeDepth(samplePos.z)); 314 | mask = delta <= thickness && i > 0.0; 315 | return float4(samplePos, mask); 316 | } 317 | } 318 | return float4(samplePos, mask); 319 | } -------------------------------------------------------------------------------- /Assets/TP/CGBull/Common/Shaders/Resources/Common.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef _BaseCommon_ 2 | #define _BaseCommon_ 3 | 4 | #include "UnityCG.cginc" 5 | 6 | #define float half 7 | #define float2 half2 8 | #define float3 half3 9 | #define float4 half4 10 | #define float3x3 half3x3 11 | #define float4x4 half4x4 12 | #define float4x3 half4x3 13 | 14 | #define PI 3.1415926 15 | #define Inv_PI 0.3183091 16 | #define Two_PI 6.2831852 17 | #define Inv_Two_PI 0.15915494 18 | 19 | 20 | half4 Texture1DSample(Texture1D Tex, SamplerState Sampler, half UV) 21 | { 22 | #if COMPUTESHADER 23 | return Tex.SampleLevel(Sampler, UV, 0); 24 | #else 25 | return Tex.Sample(Sampler, UV); 26 | #endif 27 | } 28 | 29 | 30 | half4 Texture2DSample(Texture2D Tex, SamplerState Sampler, half2 UV) 31 | { 32 | #if COMPUTESHADER 33 | return Tex.SampleLevel(Sampler, UV, 0); 34 | #else 35 | return Tex.Sample(Sampler, UV); 36 | #endif 37 | } 38 | 39 | 40 | half4 Texture3DSample(Texture3D Tex, SamplerState Sampler, half3 UV) 41 | { 42 | #if COMPUTESHADER 43 | return Tex.SampleLevel(Sampler, UV, 0); 44 | #else 45 | return Tex.Sample(Sampler, UV); 46 | #endif 47 | } 48 | 49 | 50 | half4 TextureCubeSample(TextureCube Tex, SamplerState Sampler, half3 UV) 51 | { 52 | #if COMPUTESHADER 53 | return Tex.SampleLevel(Sampler, UV, 0); 54 | #else 55 | return Tex.Sample(Sampler, UV); 56 | #endif 57 | } 58 | 59 | 60 | half4 Texture1DSampleLevel(Texture1D Tex, SamplerState Sampler, half UV, half Mip) 61 | { 62 | return Tex.SampleLevel(Sampler, UV, Mip); 63 | } 64 | 65 | 66 | half4 Texture2DSampleLevel(Texture2D Tex, SamplerState Sampler, half2 UV, half Mip) 67 | { 68 | return Tex.SampleLevel(Sampler, UV, Mip); 69 | } 70 | 71 | 72 | half4 Texture2DSampleBias(Texture2D Tex, SamplerState Sampler, half2 UV, half MipBias) 73 | { 74 | #if COMPUTESHADER 75 | return Tex.SampleLevel(Sampler, UV, 0); 76 | #else 77 | return Tex.SampleBias(Sampler, UV, MipBias); 78 | #endif 79 | } 80 | 81 | 82 | half4 Texture2DSampleGrad(Texture2D Tex, SamplerState Sampler, float2 UV, half2 DDX, half2 DDY) 83 | { 84 | return Tex.SampleGrad(Sampler, UV, DDX, DDY); 85 | } 86 | 87 | 88 | half4 Texture3DSampleLevel(Texture3D Tex, SamplerState Sampler, float3 UV, half Mip) 89 | { 90 | return Tex.SampleLevel(Sampler, UV, Mip); 91 | } 92 | 93 | 94 | half4 Texture3DSampleBias(Texture3D Tex, SamplerState Sampler, half3 UV, half MipBias) 95 | { 96 | #if COMPUTESHADER 97 | return Tex.SampleBias(Sampler, UV, 0); 98 | #else 99 | return Tex.SampleBias(Sampler, UV, MipBias); 100 | #endif 101 | } 102 | 103 | 104 | half4 Texture3DSampleGrad(Texture3D Tex, SamplerState Sampler, half3 UV, half3 DDX, half3 DDY) 105 | { 106 | return Tex.SampleGrad(Sampler, UV, DDX, DDY); 107 | } 108 | 109 | 110 | half4 TextureCubeSampleLevel(TextureCube Tex, SamplerState Sampler, half3 UV, half Mip) 111 | { 112 | return Tex.SampleLevel(Sampler, UV, Mip); 113 | } 114 | 115 | 116 | half TextureCubeSampleDepthLevel(TextureCube TexDepth, SamplerState Sampler, half3 UV, half Mip) 117 | { 118 | return TexDepth.SampleLevel(Sampler, UV, Mip).x; 119 | } 120 | 121 | 122 | half4 TextureCubeSampleBias(TextureCube Tex, SamplerState Sampler, half3 UV, half MipBias) 123 | { 124 | #if COMPUTESHADER 125 | return Tex.SampleLevel(Sampler, UV, 0); 126 | #else 127 | return Tex.SampleBias(Sampler, UV, MipBias); 128 | #endif 129 | } 130 | 131 | 132 | half4 TextureCubeSampleGrad(TextureCube Tex, SamplerState Sampler, half3 UV, half3 DDX, half3 DDY) 133 | { 134 | return Tex.SampleGrad(Sampler, UV, DDX, DDY); 135 | } 136 | 137 | //converts an input 1d to 2d position. Useful for locating z frames that have been laid out in a 2d grid like a flipbook. 138 | half2 Tile1Dto2D(float xsize, float idx) 139 | { 140 | float2 xyidx = 0; 141 | xyidx.y = floor(idx / xsize); 142 | xyidx.x = idx - xsize * xyidx.y; 143 | 144 | return xyidx; 145 | } 146 | 147 | half4 PseudoVolumeTexture(Texture2D Tex, SamplerState TexSampler, float3 inPos, float2 xysize, float numframes, 148 | uint mipmode = 0, float miplevel = 0, float2 InDDX = 0, float2 InDDY = 0) 149 | { 150 | float zframe = ceil(inPos.z * numframes); 151 | float zphase = frac(inPos.z * numframes); 152 | 153 | float2 uv = frac(inPos.xy) / xysize; 154 | 155 | float2 curframe = Tile1Dto2D(xysize.x, zframe) / xysize; 156 | float2 nextframe = Tile1Dto2D(xysize.x, zframe + 1) / xysize; 157 | 158 | float4 sampleA = 0, sampleB = 0; 159 | switch (mipmode) 160 | { 161 | case 0: // Mip level 162 | sampleA = Tex.SampleLevel(TexSampler, uv + curframe, miplevel); 163 | sampleB = Tex.SampleLevel(TexSampler, uv + nextframe, miplevel); 164 | break; 165 | case 1: // Gradients automatic from UV 166 | sampleA = Texture2DSample(Tex, TexSampler, uv + curframe); 167 | sampleB = Texture2DSample(Tex, TexSampler, uv + nextframe); 168 | break; 169 | case 2: // Deriviatives provided 170 | sampleA = Tex.SampleGrad(TexSampler, uv + curframe, InDDX, InDDY); 171 | sampleB = Tex.SampleGrad(TexSampler, uv + nextframe, InDDX, InDDY); 172 | break; 173 | default: 174 | break; 175 | } 176 | 177 | return lerp(sampleA, sampleB, zphase); 178 | } 179 | 180 | float Square(float x) 181 | { 182 | return x * x; 183 | } 184 | 185 | float2 Square(float2 x) 186 | { 187 | return x * x; 188 | } 189 | 190 | float3 Square(float3 x) 191 | { 192 | return x * x; 193 | } 194 | 195 | float4 Square(float4 x) 196 | { 197 | return x * x; 198 | } 199 | 200 | float pow2(float x) 201 | { 202 | return x * x; 203 | } 204 | 205 | float2 pow2(float2 x) 206 | { 207 | return x * x; 208 | } 209 | 210 | float3 pow2(float3 x) 211 | { 212 | return x * x; 213 | } 214 | 215 | float4 pow2(float4 x) 216 | { 217 | return x * x; 218 | } 219 | 220 | float pow3(float x) 221 | { 222 | return x * x * x; 223 | } 224 | 225 | float2 pow3(float2 x) 226 | { 227 | return x * x * x; 228 | } 229 | 230 | float3 pow3(float3 x) 231 | { 232 | return x * x * x; 233 | } 234 | 235 | float4 pow3(float4 x) 236 | { 237 | return x * x * x; 238 | } 239 | 240 | float pow4(float x) 241 | { 242 | float xx = x * x; 243 | return xx * xx; 244 | } 245 | 246 | float2 pow4(float2 x) 247 | { 248 | float2 xx = x * x; 249 | return xx * xx; 250 | } 251 | 252 | float3 pow4(float3 x) 253 | { 254 | float3 xx = x * x; 255 | return xx * xx; 256 | } 257 | 258 | float4 pow4(float4 x) 259 | { 260 | float4 xx = x * x; 261 | return xx * xx; 262 | } 263 | 264 | float pow5(float x) 265 | { 266 | float xx = x * x; 267 | return xx * xx * x; 268 | } 269 | 270 | float2 pow5(float2 x) 271 | { 272 | float2 xx = x * x; 273 | return xx * xx * x; 274 | } 275 | 276 | float3 pow5(float3 x) 277 | { 278 | float3 xx = x * x; 279 | return xx * xx * x; 280 | } 281 | 282 | float4 pow5(float4 x) 283 | { 284 | float4 xx = x * x; 285 | return xx * xx * x; 286 | } 287 | 288 | float pow6(float x) 289 | { 290 | float xx = x * x; 291 | return xx * xx * xx; 292 | } 293 | 294 | float2 pow6(float2 x) 295 | { 296 | float2 xx = x * x; 297 | return xx * xx * xx; 298 | } 299 | 300 | float3 pow6(float3 x) 301 | { 302 | float3 xx = x * x; 303 | return xx * xx * xx; 304 | } 305 | 306 | float4 pow6(float4 x) 307 | { 308 | float4 xx = x * x; 309 | return xx * xx * xx; 310 | } 311 | inline half min3(half a, half b, half c) 312 | { 313 | return min(min(a, b), c); 314 | } 315 | 316 | inline half max3(half a, half b, half c) 317 | { 318 | return max(a, max(b, c)); 319 | } 320 | 321 | inline half4 min3(half4 a, half4 b, half4 c) 322 | { 323 | return half4( 324 | min3(a.x, b.x, c.x), 325 | min3(a.y, b.y, c.y), 326 | min3(a.z, b.z, c.z), 327 | min3(a.w, b.w, c.w)); 328 | } 329 | 330 | inline half4 max3(half4 a, half4 b, half4 c) 331 | { 332 | return half4( 333 | max3(a.x, b.x, c.x), 334 | max3(a.y, b.y, c.y), 335 | max3(a.z, b.z, c.z), 336 | max3(a.w, b.w, c.w)); 337 | } 338 | 339 | inline half Luma4(half3 Color) 340 | { 341 | return (Color.g * 2) + (Color.r + Color.b); 342 | } 343 | 344 | inline half acosFast(half inX) 345 | { 346 | half x = abs(inX); 347 | half res = -0.156583f * x + (0.5 * PI); 348 | res *= sqrt(1 - x); 349 | return (inX >= 0) ? res : PI - res; 350 | } 351 | 352 | inline half asinFast(half x) 353 | { 354 | return (0.5 * PI) - acosFast(x); 355 | } 356 | 357 | inline half ClampedPow(half X, half Y) 358 | { 359 | return pow(max(abs(X), 0.000001), Y); 360 | } 361 | 362 | inline float CharlieL(float x, float r) 363 | { 364 | r = saturate(r); 365 | r = 1 - (1 - r) * (1 - r); 366 | 367 | float a = lerp(25.3245, 21.5473, r); 368 | float b = lerp(3.32435, 3.82987, r); 369 | float c = lerp(0.16801, 0.19823, r); 370 | float d = lerp(-1.27393, -1.97760, r); 371 | float e = lerp(-4.85967, -4.32054, r); 372 | 373 | return a / (1 + b * pow(x, c)) + d * x + e; 374 | } 375 | 376 | void ConvertAnisotropyToRoughness(float Roughness, float Anisotropy, out float RoughnessT, out float RoughnessB) { 377 | Roughness *= Roughness; 378 | float AnisoAspect = sqrt(1 - 0.9 * Anisotropy); 379 | RoughnessT = Roughness / AnisoAspect; 380 | RoughnessB = Roughness * AnisoAspect; 381 | } 382 | 383 | float3 ComputeGrainNormal(float3 grainDir, float3 V) { 384 | float3 B = cross(-V, grainDir); 385 | return cross(B, grainDir); 386 | } 387 | 388 | float3 GetAnisotropicModifiedNormal(float3 grainDir, float3 N, float3 V, float Anisotropy) { 389 | float3 grainNormal = ComputeGrainNormal(grainDir, V); 390 | return normalize(lerp(N, grainNormal, Anisotropy)); 391 | } 392 | 393 | 394 | 395 | 396 | 397 | inline half ComputeDepth(half4 clippos) 398 | { 399 | #if defined(SHADER_TARGET_GLSL) || defined(SHADER_API_GLES) || defined(SHADER_API_GLES3) 400 | return (clippos.z / clippos.w) * 0.5 + 0.5; 401 | #else 402 | return clippos.z / clippos.w; 403 | #endif 404 | } 405 | 406 | inline half3 GetViewNormal(half3 normal, half4x4 _WToCMatrix) 407 | { 408 | const half3 viewNormal = mul((half3x3)_WToCMatrix, normal.rgb); 409 | return normalize(viewNormal); 410 | } 411 | 412 | inline half LinearDepthReverseBack(half Depth) 413 | { 414 | half z = ((1 / Depth) - _ZBufferParams.y) / _ZBufferParams.x; 415 | #if defined(UNITY_REVERSED_Z) 416 | z = 1 - z; 417 | #endif 418 | return z; 419 | } 420 | 421 | inline half GetDepth(sampler2D tex, half2 uv) 422 | { 423 | half z = tex2Dlod(tex, half4(uv, 0, 0)).r; 424 | #if defined(UNITY_REVERSED_Z) 425 | z = 1 - z; 426 | #endif 427 | return z; 428 | } 429 | 430 | inline half Get01Depth(sampler2D tex, half2 uv) 431 | { 432 | half z = Linear01Depth(tex2Dlod(tex, half4(uv, 0, 0)).r); 433 | #if defined(UNITY_REVERSED_Z) 434 | z = 1 - z; 435 | #endif 436 | return z; 437 | } 438 | 439 | inline half GetEyeDepth(sampler2D tex, half2 uv) 440 | { 441 | half z = LinearEyeDepth(tex2Dlod(tex, half4(uv, 0, 0)).r); 442 | #if defined(UNITY_REVERSED_Z) 443 | z = 1 - z; 444 | #endif 445 | return z; 446 | } 447 | 448 | inline half3 GetScreenPos(half2 uv, half depth) 449 | { 450 | return half3(uv.xy * 2 - 1, depth.r); 451 | } 452 | 453 | inline half3 GetWorlPos(half3 screenPos, half4x4 _InverseViewProjectionMatrix) 454 | { 455 | half4 worldPos = mul(_InverseViewProjectionMatrix, half4(screenPos, 1)); 456 | return worldPos.xyz / worldPos.w; 457 | } 458 | 459 | inline half3 GetViewRayFromUV(half2 uv, half4x4 _ProjectionMatrix) 460 | { 461 | half4 _CamScreenDir = half4(1 / _ProjectionMatrix[0][0], 1 / _ProjectionMatrix[1][1], 1, 1); 462 | half3 ray = half3(uv.x * 2 - 1, uv.y * 2 - 1, 1); 463 | ray *= _CamScreenDir.xyz; 464 | ray = ray * (_ProjectionParams.z / ray.z); 465 | return ray; 466 | } 467 | 468 | inline half3 GetViewPos(half3 screenPos, half4x4 _InverseProjectionMatrix) 469 | { 470 | half4 viewPos = mul(_InverseProjectionMatrix, half4(screenPos, 1)); 471 | return viewPos.xyz / viewPos.w; 472 | } 473 | 474 | inline half3 GetViewDir(half3 worldPos, half3 ViewPos) 475 | { 476 | return normalize(worldPos - ViewPos); 477 | } 478 | 479 | inline half2 GetRayMotionVector(half rayDepth, half2 inUV, half4x4 _InverseViewProjectionMatrix, half4x4 _PrevViewProjectionMatrix, half4x4 _ViewProjectionMatrix) 480 | { 481 | half3 screenPos = GetScreenPos(inUV, rayDepth); 482 | half4 worldPos = half4(GetWorlPos(screenPos, _InverseViewProjectionMatrix), 1); 483 | 484 | half4 prevClipPos = mul(_PrevViewProjectionMatrix, worldPos); 485 | half4 curClipPos = mul(_ViewProjectionMatrix, worldPos); 486 | 487 | half2 prevHPos = prevClipPos.xy / prevClipPos.w; 488 | half2 curHPos = curClipPos.xy / curClipPos.w; 489 | 490 | half2 vPosPrev = (prevHPos.xy + 1) / 2; 491 | half2 vPosCur = (curHPos.xy + 1) / 2; 492 | return vPosCur - vPosPrev; 493 | } 494 | 495 | #endif 496 | --------------------------------------------------------------------------------