1
2
.gitignore
vendored
@@ -351,7 +351,7 @@ PublishScripts/
|
|||||||
# NuGet Symbol Packages
|
# NuGet Symbol Packages
|
||||||
*.snupkg
|
*.snupkg
|
||||||
# The packages folder can be ignored because of Package Restore
|
# The packages folder can be ignored because of Package Restore
|
||||||
**/[Pp]ackages/*
|
# **/[Pp]ackages/*
|
||||||
# except build/, which is used as an MSBuild target.
|
# except build/, which is used as an MSBuild target.
|
||||||
!**/[Pp]ackages/build/
|
!**/[Pp]ackages/build/
|
||||||
# Uncomment if necessary however generally it will be regenerated when needed
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
@@ -0,0 +1,62 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 6
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: 08-08_Sunset_C
|
||||||
|
m_Shader: {fileID: 103, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_ShaderKeywords:
|
||||||
|
m_LightmapFlags: 5
|
||||||
|
m_EnableInstancingVariants: 0
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _BackTex:
|
||||||
|
m_Texture: {fileID: 2800000, guid: f049830bcf9ba274e994f43fa890a4e8, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DownTex:
|
||||||
|
m_Texture: {fileID: 2800000, guid: 24739eef0dc445c458e0b4f37801164c, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _FrontTex:
|
||||||
|
m_Texture: {fileID: 2800000, guid: 0225f227f9d8fc9429127ad3973726e5, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _LeftTex:
|
||||||
|
m_Texture: {fileID: 2800000, guid: ceab4bc314c6f1b40984379ed810d721, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _RightTex:
|
||||||
|
m_Texture: {fileID: 2800000, guid: 46df5162ad219a34aa3b861737e5b402, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _Tex:
|
||||||
|
m_Texture: {fileID: 8900000, guid: 00b9389094b894da58219438ada30b37, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _UpTex:
|
||||||
|
m_Texture: {fileID: 2800000, guid: f7bf49f32cccc004f866e1652b4ab58b, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Floats:
|
||||||
|
- _Exposure: 1
|
||||||
|
- _Rotation: 81
|
||||||
|
- _SkyExponent: 2
|
||||||
|
m_Colors:
|
||||||
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _Tint: {r: 0.46551722, g: 0.46551722, b: 0.46551722, a: 0.5019608}
|
||||||
|
- _TintDay: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _TintNight: {r: 1, g: 1, b: 1, a: 1}
|
@@ -0,0 +1,293 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!21 &2100000
|
||||||
|
Material:
|
||||||
|
serializedVersion: 8
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: MicroSplat
|
||||||
|
m_Shader: {fileID: 4800000, guid: 1066facd47bb54a21b2c84797ca99e04, type: 3}
|
||||||
|
m_ValidKeywords: []
|
||||||
|
m_InvalidKeywords: []
|
||||||
|
m_LightmapFlags: 4
|
||||||
|
m_EnableInstancingVariants: 1
|
||||||
|
m_DoubleSidedGI: 0
|
||||||
|
m_CustomRenderQueue: -1
|
||||||
|
stringTagMap: {}
|
||||||
|
disabledShaderPasses: []
|
||||||
|
m_SavedProperties:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TexEnvs:
|
||||||
|
- _ClusterDiffuse2:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ClusterDiffuse3:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ClusterNoise:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ClusterNormal2:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ClusterNormal3:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ClusterSmoothAOInv:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _Control0:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _Control1:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _Control2:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _Control3:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailNoise:
|
||||||
|
m_Texture: {fileID: 2800000, guid: c3e57cb2426d34f64af1fc986aa89fcf, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _Diffuse:
|
||||||
|
m_Texture: {fileID: 18700000, guid: 6966c6a2271704eeaa4697428c97b571, type: 2}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DistanceNoise:
|
||||||
|
m_Texture: {fileID: 2800000, guid: c3e57cb2426d34f64af1fc986aa89fcf, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DummyTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _GeoCurve:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _GeoNormal:
|
||||||
|
m_Texture: {fileID: 2800000, guid: 192aaea3237044f608d663c9884e0c70, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _GeoTex:
|
||||||
|
m_Texture: {fileID: 2800000, guid: 863f19b183b2443859f959a96f7dce32, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _GlitterWind:
|
||||||
|
m_Texture: {fileID: 2800000, guid: 5c17d279ce2734171a1575aed76f85b8, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _GlobalNormalTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _GlobalTintTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _MainTex:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _NoiseUV:
|
||||||
|
m_Texture: {fileID: 2800000, guid: fb84fc5f3e7e14ae7be5bd45efc3d3c4, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _NormalNoise:
|
||||||
|
m_Texture: {fileID: 2800000, guid: cfa942d94204a4aeb970870316799af2, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _NormalNoise2:
|
||||||
|
m_Texture: {fileID: 2800000, guid: 0dfc76f6aeb2a4b4ab78b17faf5a32ea, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _NormalNoise3:
|
||||||
|
m_Texture: {fileID: 2800000, guid: 993678365290144589d31930a617b969, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _NormalSAO:
|
||||||
|
m_Texture: {fileID: 18700000, guid: ca49526f427194c41b515c21c5dbe465, type: 2}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _PCHeightGradients:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _PCHeightHSV:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _PCSlopeGradients:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _PCSlopeHSV:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _PerPixelNormal:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _PerTexProps:
|
||||||
|
m_Texture: {fileID: -6921013763897310138, guid: 33be7e4182d1f404fb55319a0218209f,
|
||||||
|
type: 2}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ScatterControl:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ScatterDiffuse:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _ScatterNSAO:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _SmoothAO:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _SnowDiff:
|
||||||
|
m_Texture: {fileID: 2800000, guid: b822881b9ef3441f29c88bb6e0ef60cd, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _SnowNormal:
|
||||||
|
m_Texture: {fileID: 2800000, guid: cc22f06eaf78d43f782ee617776c1640, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _SnowNormalNoise:
|
||||||
|
m_Texture: {fileID: 2800000, guid: 3364d9aca19e4401dbdb0a9bcfcd70bc, type: 3}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _Specular:
|
||||||
|
m_Texture: {fileID: 18700000, guid: 4d0dd2b0fcd4748ab9e786fba33c8720, type: 2}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _StreamControl:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _TBAlbedo:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _TBNormal:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _TBOcclusion:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _TBSmoothness:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _TerrainBlendNoise:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _TerrainDesc:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _TerrainHolesTexture:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _VSGrassMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 1, y: 1}
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_Ints: []
|
||||||
|
m_Floats:
|
||||||
|
- _Aniso: 1
|
||||||
|
- _AutoNormalHeightScale: 1.28
|
||||||
|
- _ClusterContrast: 0.8
|
||||||
|
- _ClusterScaleVar: 0.05
|
||||||
|
- _Contrast: 0.357
|
||||||
|
- _GeoHeightContrast: 10
|
||||||
|
- _GeoNormalStrength: 1
|
||||||
|
- _GlobalPorosity: 0.4
|
||||||
|
- _HybridHeightBlendDistance: 326
|
||||||
|
- _Parallax: 0.0825
|
||||||
|
- _Phong: 0.5
|
||||||
|
- _SnowAmount: 1
|
||||||
|
- _SnowParticulateStrength: 1
|
||||||
|
- _SnowParticulateStretch: 0.3
|
||||||
|
- _StochasticContrast: 0.01
|
||||||
|
- _StochasticScale: 1
|
||||||
|
- _TerrainDistance: 1
|
||||||
|
- _TriplanarContrast: 4
|
||||||
|
- _WindParticulateRotation: 0
|
||||||
|
- _WindParticulateStrength: 3
|
||||||
|
- _WindParticulateStretch: 0.3
|
||||||
|
m_Colors:
|
||||||
|
- _AlphaData: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
- _ClusterParams: {r: 80, g: 80, b: 0, a: 0}
|
||||||
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _DetailNoiseScaleStrengthFade: {r: 8, g: 0.5, b: 5, a: 0}
|
||||||
|
- _DistanceNoiseScaleStrengthFade: {r: 10, g: 0.5, b: 100, a: 150}
|
||||||
|
- _GeoCurveParams: {r: 512, g: 0, b: 0, a: 0}
|
||||||
|
- _GeoParams: {r: 1, g: 0.01, b: 0, a: 0}
|
||||||
|
- _GeoRange: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
- _GlobalTextureParams: {r: 0.5, g: 0.5, b: 0, a: 0}
|
||||||
|
- _GlobalTintFade: {r: 50, g: 150, b: 1, a: 1}
|
||||||
|
- _MipDistanceBias: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
- _NoiseUVParams: {r: 1, g: 1, b: 0, a: 0}
|
||||||
|
- _NormalNoiseScaleStrength: {r: 8, g: 1, b: 0, a: 0}
|
||||||
|
- _NormalNoiseScaleStrength2: {r: 8, g: 0.5, b: 0, a: 0}
|
||||||
|
- _NormalNoiseScaleStrength3: {r: 8, g: 0.5, b: 0, a: 0}
|
||||||
|
- _POMParams: {r: 0.078, g: 100, b: 100, a: 9}
|
||||||
|
- _ParallaxParams: {r: 0.08, g: 30, b: 30, a: 0}
|
||||||
|
- _PuddleParams: {r: 6, g: 1, b: 0, a: 0}
|
||||||
|
- _ResampleDistanceParams: {r: 0.1, g: 40, b: 200, a: 0}
|
||||||
|
- _ScatterUVScale: {r: 1, g: 1, b: 0, a: 0}
|
||||||
|
- _SnowDistanceResampleScaleStrengthFade: {r: 0.1, g: 1, b: 30, a: 90}
|
||||||
|
- _SnowHeightAngleRange: {r: 10, g: 50, b: 0.7205205, a: 0.9936518}
|
||||||
|
- _SnowNormalNoiseScaleStrength: {r: 0.1, g: 0.2, b: 0, a: 0}
|
||||||
|
- _SnowParams: {r: 0, g: 0, b: 0.3, a: 0}
|
||||||
|
- _SnowParticulateAngleMask: {r: -1, g: -1, b: 1, a: 1}
|
||||||
|
- _SnowParticulateColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _SnowParticulateHeightMask: {r: 0, g: 0, b: 99999, a: 99999}
|
||||||
|
- _SnowParticulateParams: {r: 1, g: 1, b: 1, a: 0.25}
|
||||||
|
- _SnowParticulateShadow: {r: 0.01, g: 1, b: 0, a: 0}
|
||||||
|
- _SnowParticulateShadowColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
- _SnowTint: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _SnowUVScales: {r: 125, g: 125, b: 0, a: 0}
|
||||||
|
- _SnowUpVector: {r: 0, g: 1, b: 0, a: 0}
|
||||||
|
- _TerrainBlendParams: {r: 1, g: 1, b: 0, a: 0}
|
||||||
|
- _TerrainBounds: {r: 0, g: 0, b: 512, a: 512}
|
||||||
|
- _TessData1: {r: 9.7, g: 1.56, b: 4, a: 15}
|
||||||
|
- _TessData2: {r: 30, g: 60, b: 1, a: 0.25}
|
||||||
|
- _TriplanarUVScale: {r: 0.5, g: 0.5, b: 0, a: 0}
|
||||||
|
- _UVMeshRange: {r: 1, g: 1, b: 0.5, a: 0.5}
|
||||||
|
- _UVScale: {r: 100, g: 100, b: 0, a: 0}
|
||||||
|
- _VSTint: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
- _WindEmissive: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
- _WindParticulateAngleMask: {r: -1, g: -1, b: 1, a: 1}
|
||||||
|
- _WindParticulateColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
- _WindParticulateHeightMask: {r: -999, g: -999, b: 99999, a: 99999}
|
||||||
|
- _WindParticulateParams: {r: 1, g: 1.79, b: 1, a: 0.2}
|
||||||
|
- _WindParticulateShadow: {r: 0.01, g: 1, b: 0, a: 0}
|
||||||
|
- _WindParticulateShadowColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
- _WorldHeightRange: {r: 0, g: 500, b: 0, a: 0}
|
||||||
|
m_BuildTextureStacks: []
|
@@ -0,0 +1,450 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5760785f8c0064b44b588ae7fd6fd268, type: 3}
|
||||||
|
m_Name: MicroSplatConfig
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
diffuseIsLinear: 0
|
||||||
|
antiTileArray: 0
|
||||||
|
emisMetalArray: 0
|
||||||
|
traxArray: 0
|
||||||
|
textureMode: 1
|
||||||
|
clusterMode: 0
|
||||||
|
packingMode: 0
|
||||||
|
pbrWorkflow: 0
|
||||||
|
hash: -1807810560
|
||||||
|
splatArray: {fileID: 0}
|
||||||
|
diffuseArray: {fileID: 18700000, guid: 6966c6a2271704eeaa4697428c97b571, type: 2}
|
||||||
|
normalSAOArray: {fileID: 18700000, guid: ca49526f427194c41b515c21c5dbe465, type: 2}
|
||||||
|
smoothAOArray: {fileID: 18700000, guid: 0e0057bf31ae543788cf58b0a4e58809, type: 2}
|
||||||
|
specularArray: {fileID: 0}
|
||||||
|
diffuseArray2: {fileID: 0}
|
||||||
|
normalSAOArray2: {fileID: 0}
|
||||||
|
smoothAOArray2: {fileID: 0}
|
||||||
|
specularArray2: {fileID: 0}
|
||||||
|
diffuseArray3: {fileID: 0}
|
||||||
|
normalSAOArray3: {fileID: 0}
|
||||||
|
smoothAOArray3: {fileID: 0}
|
||||||
|
specularArray3: {fileID: 0}
|
||||||
|
emisArray: {fileID: 0}
|
||||||
|
emisArray2: {fileID: 0}
|
||||||
|
emisArray3: {fileID: 0}
|
||||||
|
defaultTextureSettings:
|
||||||
|
diffuseSettings:
|
||||||
|
textureSize: 1024
|
||||||
|
compression: 0
|
||||||
|
compressionQuality: 0
|
||||||
|
filterMode: 1
|
||||||
|
Aniso: 1
|
||||||
|
normalSettings:
|
||||||
|
textureSize: 1024
|
||||||
|
compression: 0
|
||||||
|
compressionQuality: 0
|
||||||
|
filterMode: 2
|
||||||
|
Aniso: 5
|
||||||
|
smoothSettings:
|
||||||
|
textureSize: 1024
|
||||||
|
compression: 0
|
||||||
|
compressionQuality: 1
|
||||||
|
filterMode: 1
|
||||||
|
Aniso: 1
|
||||||
|
antiTileSettings:
|
||||||
|
textureSize: 1024
|
||||||
|
compression: 0
|
||||||
|
compressionQuality: 1
|
||||||
|
filterMode: 1
|
||||||
|
Aniso: 1
|
||||||
|
emissiveSettings:
|
||||||
|
textureSize: 1024
|
||||||
|
compression: 0
|
||||||
|
compressionQuality: 1
|
||||||
|
filterMode: 1
|
||||||
|
Aniso: 1
|
||||||
|
specularSettings:
|
||||||
|
textureSize: 1024
|
||||||
|
compression: 0
|
||||||
|
compressionQuality: 1
|
||||||
|
filterMode: 1
|
||||||
|
Aniso: 1
|
||||||
|
traxDiffuseSettings:
|
||||||
|
textureSize: 1024
|
||||||
|
compression: 0
|
||||||
|
compressionQuality: 1
|
||||||
|
filterMode: 1
|
||||||
|
Aniso: 1
|
||||||
|
traxNormalSettings:
|
||||||
|
textureSize: 1024
|
||||||
|
compression: 0
|
||||||
|
compressionQuality: 1
|
||||||
|
filterMode: 1
|
||||||
|
Aniso: 1
|
||||||
|
decalSplatSettings:
|
||||||
|
textureSize: 1024
|
||||||
|
compression: 0
|
||||||
|
compressionQuality: 1
|
||||||
|
filterMode: 1
|
||||||
|
Aniso: 1
|
||||||
|
platformOverrides: []
|
||||||
|
sourceTextureSize: 0
|
||||||
|
allTextureChannelHeight: 1
|
||||||
|
allTextureChannelSmoothness: 1
|
||||||
|
allTextureChannelAO: 1
|
||||||
|
sourceTextures:
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 2800000, guid: 1d6b5702e2d7947a6aca898081729d0f, type: 3}
|
||||||
|
height: {fileID: 2800000, guid: a4803915ed20f45f5a61eac0bbe3e477, type: 3}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 2800000, guid: 294f7637e9ef54b21a1b1ea883dfea32, type: 3}
|
||||||
|
smoothness: {fileID: 2800000, guid: 4a3982fcc24514da1b539cfb39014206, type: 3}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 2800000, guid: f32b234bd5bb84e928d73cbcc11df72b, type: 3}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 2800000, guid: 89b92357cf2dc47ff9ee1c4038027566, type: 3}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 2800000, guid: 66fb879d08c8d4a8d9217a396637cd02, type: 3}
|
||||||
|
height: {fileID: 2800000, guid: 789a0a85e9c004607b33057be6bc8414, type: 3}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 2800000, guid: 440362e15edd043ebad4321a5118e235, type: 3}
|
||||||
|
smoothness: {fileID: 2800000, guid: 5b0e4204820504dc0a10a227b8b6c18b, type: 3}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 2800000, guid: d85f6f03bea454b92b46e99f7bec74b2, type: 3}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 0}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 2800000, guid: a4a9376fca9114840bb973b6693e7ff5, type: 3}
|
||||||
|
height: {fileID: 2800000, guid: 1a8d14e5cac49403e9e88b64d384e29a, type: 3}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 2800000, guid: 0d626c878590d42eca75516512f93565, type: 3}
|
||||||
|
smoothness: {fileID: 2800000, guid: ccdddcfa22e924bb5bde6a40b8ef78df, type: 3}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 2800000, guid: d171d477d7bec40a68abb6b20cde67ec, type: 3}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 0}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 2800000, guid: b2e5c511fff7f41559554175e2005252, type: 3}
|
||||||
|
height: {fileID: 2800000, guid: 369894f65d5984c138a718772bb1c747, type: 3}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 2800000, guid: 0d8f0ee1a15194978ab3e6702762460f, type: 3}
|
||||||
|
smoothness: {fileID: 2800000, guid: 6e74c61dcec3a4dd5ba7d5e40b4ae422, type: 3}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 2800000, guid: f331a9e993c1b48ad9e9f64f4f9013ba, type: 3}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 0}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
||||||
|
sourceTextures2:
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 0}
|
||||||
|
height: {fileID: 0}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 0}
|
||||||
|
smoothness: {fileID: 0}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 0}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 0}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 0}
|
||||||
|
height: {fileID: 0}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 0}
|
||||||
|
smoothness: {fileID: 0}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 0}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 0}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 0}
|
||||||
|
height: {fileID: 0}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 0}
|
||||||
|
smoothness: {fileID: 0}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 0}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 0}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 0}
|
||||||
|
height: {fileID: 0}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 0}
|
||||||
|
smoothness: {fileID: 0}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 0}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 0}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
||||||
|
sourceTextures3:
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 0}
|
||||||
|
height: {fileID: 0}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 0}
|
||||||
|
smoothness: {fileID: 0}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 0}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 0}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 0}
|
||||||
|
height: {fileID: 0}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 0}
|
||||||
|
smoothness: {fileID: 0}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 0}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 0}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 0}
|
||||||
|
height: {fileID: 0}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 0}
|
||||||
|
smoothness: {fileID: 0}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 0}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 0}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
||||||
|
- terrainLayer: {fileID: 0}
|
||||||
|
diffuse: {fileID: 0}
|
||||||
|
height: {fileID: 0}
|
||||||
|
heightChannel: 1
|
||||||
|
normal: {fileID: 0}
|
||||||
|
smoothness: {fileID: 0}
|
||||||
|
smoothnessChannel: 1
|
||||||
|
isRoughness: 0
|
||||||
|
ao: {fileID: 0}
|
||||||
|
aoChannel: 1
|
||||||
|
emis: {fileID: 0}
|
||||||
|
metal: {fileID: 0}
|
||||||
|
metalChannel: 1
|
||||||
|
specular: {fileID: 0}
|
||||||
|
noiseNormal: {fileID: 0}
|
||||||
|
detailNoise: {fileID: 0}
|
||||||
|
detailChannel: 1
|
||||||
|
distanceNoise: {fileID: 0}
|
||||||
|
distanceChannel: 1
|
||||||
|
traxDiffuse: {fileID: 0}
|
||||||
|
traxHeight: {fileID: 0}
|
||||||
|
traxHeightChannel: 1
|
||||||
|
traxNormal: {fileID: 0}
|
||||||
|
traxSmoothness: {fileID: 0}
|
||||||
|
traxSmoothnessChannel: 1
|
||||||
|
traxIsRoughness: 0
|
||||||
|
traxAO: {fileID: 0}
|
||||||
|
traxAOChannel: 1
|
||||||
|
splat: {fileID: 0}
|
@@ -0,0 +1,21 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 007677a8d215f46f78fdc4a57e84fb09, type: 3}
|
||||||
|
m_Name: MicroSplat_keywords
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
keywords:
|
||||||
|
- _MICROSPLAT
|
||||||
|
- _MICROTERRAIN
|
||||||
|
- _HYBRIDHEIGHTBLEND
|
||||||
|
- _USEGRADMIP
|
||||||
|
- _MAX4TEXTURES
|
||||||
|
- _MSRENDERLOOP_SURFACESHADER
|
@@ -0,0 +1,827 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 9233ada6a9d2a403d8f9da33990e3174, type: 3}
|
||||||
|
m_Name: MicroSplat_proceduraltexture
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
valueMode: 0
|
||||||
|
proceduralCurveTextureSize: 256
|
||||||
|
heightGradients:
|
||||||
|
- serializedVersion: 2
|
||||||
|
key0: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key1: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
ctime0: 0
|
||||||
|
ctime1: 65535
|
||||||
|
ctime2: 0
|
||||||
|
ctime3: 0
|
||||||
|
ctime4: 0
|
||||||
|
ctime5: 0
|
||||||
|
ctime6: 0
|
||||||
|
ctime7: 0
|
||||||
|
atime0: 0
|
||||||
|
atime1: 65535
|
||||||
|
atime2: 0
|
||||||
|
atime3: 0
|
||||||
|
atime4: 0
|
||||||
|
atime5: 0
|
||||||
|
atime6: 0
|
||||||
|
atime7: 0
|
||||||
|
m_Mode: 0
|
||||||
|
m_NumColorKeys: 2
|
||||||
|
m_NumAlphaKeys: 2
|
||||||
|
- serializedVersion: 2
|
||||||
|
key0: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key1: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
ctime0: 0
|
||||||
|
ctime1: 65535
|
||||||
|
ctime2: 0
|
||||||
|
ctime3: 0
|
||||||
|
ctime4: 0
|
||||||
|
ctime5: 0
|
||||||
|
ctime6: 0
|
||||||
|
ctime7: 0
|
||||||
|
atime0: 0
|
||||||
|
atime1: 65535
|
||||||
|
atime2: 0
|
||||||
|
atime3: 0
|
||||||
|
atime4: 0
|
||||||
|
atime5: 0
|
||||||
|
atime6: 0
|
||||||
|
atime7: 0
|
||||||
|
m_Mode: 0
|
||||||
|
m_NumColorKeys: 2
|
||||||
|
m_NumAlphaKeys: 2
|
||||||
|
- serializedVersion: 2
|
||||||
|
key0: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key1: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
ctime0: 0
|
||||||
|
ctime1: 65535
|
||||||
|
ctime2: 0
|
||||||
|
ctime3: 0
|
||||||
|
ctime4: 0
|
||||||
|
ctime5: 0
|
||||||
|
ctime6: 0
|
||||||
|
ctime7: 0
|
||||||
|
atime0: 0
|
||||||
|
atime1: 65535
|
||||||
|
atime2: 0
|
||||||
|
atime3: 0
|
||||||
|
atime4: 0
|
||||||
|
atime5: 0
|
||||||
|
atime6: 0
|
||||||
|
atime7: 0
|
||||||
|
m_Mode: 0
|
||||||
|
m_NumColorKeys: 2
|
||||||
|
m_NumAlphaKeys: 2
|
||||||
|
- serializedVersion: 2
|
||||||
|
key0: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key1: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
ctime0: 0
|
||||||
|
ctime1: 65535
|
||||||
|
ctime2: 0
|
||||||
|
ctime3: 0
|
||||||
|
ctime4: 0
|
||||||
|
ctime5: 0
|
||||||
|
ctime6: 0
|
||||||
|
ctime7: 0
|
||||||
|
atime0: 0
|
||||||
|
atime1: 65535
|
||||||
|
atime2: 0
|
||||||
|
atime3: 0
|
||||||
|
atime4: 0
|
||||||
|
atime5: 0
|
||||||
|
atime6: 0
|
||||||
|
atime7: 0
|
||||||
|
m_Mode: 0
|
||||||
|
m_NumColorKeys: 2
|
||||||
|
m_NumAlphaKeys: 2
|
||||||
|
heightHSV:
|
||||||
|
- H:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
S:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
V:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
- H:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
S:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
V:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
- H:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
S:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
V:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
- H:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
S:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
V:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
slopeGradients:
|
||||||
|
- serializedVersion: 2
|
||||||
|
key0: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key1: {r: 0.65719473, g: 0.36464834, b: 0.4312279, a: 1}
|
||||||
|
key2: {r: 0.35162118, g: 0.18977073, b: 0.8602941, a: 0}
|
||||||
|
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
ctime0: 12722
|
||||||
|
ctime1: 24094
|
||||||
|
ctime2: 43754
|
||||||
|
ctime3: 0
|
||||||
|
ctime4: 0
|
||||||
|
ctime5: 0
|
||||||
|
ctime6: 0
|
||||||
|
ctime7: 0
|
||||||
|
atime0: 0
|
||||||
|
atime1: 65535
|
||||||
|
atime2: 0
|
||||||
|
atime3: 0
|
||||||
|
atime4: 0
|
||||||
|
atime5: 0
|
||||||
|
atime6: 0
|
||||||
|
atime7: 0
|
||||||
|
m_Mode: 0
|
||||||
|
m_NumColorKeys: 3
|
||||||
|
m_NumAlphaKeys: 2
|
||||||
|
- serializedVersion: 2
|
||||||
|
key0: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key1: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
ctime0: 0
|
||||||
|
ctime1: 65535
|
||||||
|
ctime2: 0
|
||||||
|
ctime3: 0
|
||||||
|
ctime4: 0
|
||||||
|
ctime5: 0
|
||||||
|
ctime6: 0
|
||||||
|
ctime7: 0
|
||||||
|
atime0: 0
|
||||||
|
atime1: 65535
|
||||||
|
atime2: 0
|
||||||
|
atime3: 0
|
||||||
|
atime4: 0
|
||||||
|
atime5: 0
|
||||||
|
atime6: 0
|
||||||
|
atime7: 0
|
||||||
|
m_Mode: 0
|
||||||
|
m_NumColorKeys: 2
|
||||||
|
m_NumAlphaKeys: 2
|
||||||
|
- serializedVersion: 2
|
||||||
|
key0: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key1: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
ctime0: 0
|
||||||
|
ctime1: 65535
|
||||||
|
ctime2: 0
|
||||||
|
ctime3: 0
|
||||||
|
ctime4: 0
|
||||||
|
ctime5: 0
|
||||||
|
ctime6: 0
|
||||||
|
ctime7: 0
|
||||||
|
atime0: 0
|
||||||
|
atime1: 65535
|
||||||
|
atime2: 0
|
||||||
|
atime3: 0
|
||||||
|
atime4: 0
|
||||||
|
atime5: 0
|
||||||
|
atime6: 0
|
||||||
|
atime7: 0
|
||||||
|
m_Mode: 0
|
||||||
|
m_NumColorKeys: 2
|
||||||
|
m_NumAlphaKeys: 2
|
||||||
|
- serializedVersion: 2
|
||||||
|
key0: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key1: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
key2: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key3: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key4: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key5: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
ctime0: 0
|
||||||
|
ctime1: 65535
|
||||||
|
ctime2: 0
|
||||||
|
ctime3: 0
|
||||||
|
ctime4: 0
|
||||||
|
ctime5: 0
|
||||||
|
ctime6: 0
|
||||||
|
ctime7: 0
|
||||||
|
atime0: 0
|
||||||
|
atime1: 65535
|
||||||
|
atime2: 0
|
||||||
|
atime3: 0
|
||||||
|
atime4: 0
|
||||||
|
atime5: 0
|
||||||
|
atime6: 0
|
||||||
|
atime7: 0
|
||||||
|
m_Mode: 0
|
||||||
|
m_NumColorKeys: 2
|
||||||
|
m_NumAlphaKeys: 2
|
||||||
|
slopeHSV:
|
||||||
|
- H:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
S:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
V:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
- H:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
S:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
V:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
- H:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
S:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
V:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
- H:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
S:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
V:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 0
|
||||||
|
inSlope: 0
|
||||||
|
outSlope: 0
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0.33333334
|
||||||
|
outWeight: 0.33333334
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
layers: []
|
||||||
|
curveTex: {fileID: 0}
|
||||||
|
paramTex: {fileID: 0}
|
||||||
|
heightGradientTex: {fileID: 0}
|
||||||
|
heightHSVTex: {fileID: 0}
|
||||||
|
slopeGradientTex: {fileID: 0}
|
||||||
|
slopeHSVTex: {fileID: 0}
|
@@ -0,0 +1,22 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1953259897 &8574412962073106934
|
||||||
|
TerrainLayer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: microsplat_layer_cliff_albedo_3
|
||||||
|
m_DiffuseTexture: {fileID: 2800000, guid: b2e5c511fff7f41559554175e2005252, type: 3}
|
||||||
|
m_NormalMapTexture: {fileID: 2800000, guid: 0d8f0ee1a15194978ab3e6702762460f, type: 3}
|
||||||
|
m_MaskMapTexture: {fileID: 0}
|
||||||
|
m_TileSize: {x: 33.333332, y: 33.333332}
|
||||||
|
m_TileOffset: {x: 0, y: 0}
|
||||||
|
m_Specular: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
m_Metallic: 0
|
||||||
|
m_Smoothness: 0
|
||||||
|
m_NormalScale: 1
|
||||||
|
m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1}
|
@@ -0,0 +1,22 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1953259897 &8574412962073106934
|
||||||
|
TerrainLayer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: microsplat_layer_moss_albedo_1
|
||||||
|
m_DiffuseTexture: {fileID: 2800000, guid: 66fb879d08c8d4a8d9217a396637cd02, type: 3}
|
||||||
|
m_NormalMapTexture: {fileID: 2800000, guid: 440362e15edd043ebad4321a5118e235, type: 3}
|
||||||
|
m_MaskMapTexture: {fileID: 0}
|
||||||
|
m_TileSize: {x: 33.333332, y: 33.333332}
|
||||||
|
m_TileOffset: {x: 0, y: 0}
|
||||||
|
m_Specular: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
m_Metallic: 0
|
||||||
|
m_Smoothness: 0
|
||||||
|
m_NormalScale: 1
|
||||||
|
m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1}
|
@@ -0,0 +1,22 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1953259897 &8574412962073106934
|
||||||
|
TerrainLayer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: microsplat_layer_rock_cliff_albedo_2
|
||||||
|
m_DiffuseTexture: {fileID: 2800000, guid: a4a9376fca9114840bb973b6693e7ff5, type: 3}
|
||||||
|
m_NormalMapTexture: {fileID: 2800000, guid: 0d626c878590d42eca75516512f93565, type: 3}
|
||||||
|
m_MaskMapTexture: {fileID: 0}
|
||||||
|
m_TileSize: {x: 33.333332, y: 33.333332}
|
||||||
|
m_TileOffset: {x: 0, y: 0}
|
||||||
|
m_Specular: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
m_Metallic: 0
|
||||||
|
m_Smoothness: 0
|
||||||
|
m_NormalScale: 1
|
||||||
|
m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1}
|
@@ -0,0 +1,22 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1953259897 &8574412962073106934
|
||||||
|
TerrainLayer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: microsplat_layer_shore_sand_albedo_0
|
||||||
|
m_DiffuseTexture: {fileID: 2800000, guid: 1d6b5702e2d7947a6aca898081729d0f, type: 3}
|
||||||
|
m_NormalMapTexture: {fileID: 2800000, guid: 294f7637e9ef54b21a1b1ea883dfea32, type: 3}
|
||||||
|
m_MaskMapTexture: {fileID: 0}
|
||||||
|
m_TileSize: {x: 33.333332, y: 33.333332}
|
||||||
|
m_TileOffset: {x: 0, y: 0}
|
||||||
|
m_Specular: {r: 0, g: 0, b: 0, a: 0}
|
||||||
|
m_Metallic: 0
|
||||||
|
m_Smoothness: 0
|
||||||
|
m_NormalScale: 1
|
||||||
|
m_DiffuseRemapMin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_DiffuseRemapMax: {x: 1, y: 1, z: 1, w: 1}
|
||||||
|
m_MaskMapRemapMin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_MaskMapRemapMax: {x: 1, y: 1, z: 1, w: 1}
|
BIN
Packages/com.jbooth.microsplat.core/Examples/Scene/Terrain.unity
Normal file
After Width: | Height: | Size: 2.1 MiB |
After Width: | Height: | Size: 584 KiB |
After Width: | Height: | Size: 303 KiB |
After Width: | Height: | Size: 2.3 MiB |
After Width: | Height: | Size: 635 KiB |
After Width: | Height: | Size: 1.0 MiB |
After Width: | Height: | Size: 856 KiB |
After Width: | Height: | Size: 72 KiB |
After Width: | Height: | Size: 3.0 MiB |
After Width: | Height: | Size: 522 KiB |
After Width: | Height: | Size: 2.3 MiB |
After Width: | Height: | Size: 409 KiB |
After Width: | Height: | Size: 502 KiB |
After Width: | Height: | Size: 4.0 MiB |
After Width: | Height: | Size: 218 KiB |
After Width: | Height: | Size: 2.0 MiB |
After Width: | Height: | Size: 721 KiB |
After Width: | Height: | Size: 319 KiB |
After Width: | Height: | Size: 6.4 MiB |
After Width: | Height: | Size: 621 KiB |
@@ -0,0 +1,586 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
namespace JBooth.MicroSplat
|
||||||
|
{
|
||||||
|
public abstract class FeatureDescriptor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// All versions must match for module to be active
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The version.</returns>
|
||||||
|
public abstract string GetVersion();
|
||||||
|
|
||||||
|
|
||||||
|
public virtual bool HideModule()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// used when you have compiler ordering issues
|
||||||
|
public virtual int CompileSortOrder()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual int DisplaySortOrder()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual string GetHelpPath() { return null; }
|
||||||
|
|
||||||
|
public abstract string ModuleName();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called after the shader is generated, for search/replace operations
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sb"></param>
|
||||||
|
/// <param name="features"></param>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="baseName"></param>
|
||||||
|
/// <param name="auxShader"></param>
|
||||||
|
public virtual void OnPostGeneration(ref StringBuilder sb, string[] features, string name, string baseName = null, MicroSplatShaderGUI.MicroSplatCompiler.AuxShader auxShader = null) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If you wish to generate an addtional shader with special functionality, return one of these
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual MicroSplatShaderGUI.MicroSplatCompiler.AuxShader GetAuxShader () { return null; }
|
||||||
|
/// <summary>
|
||||||
|
/// if you return above, this will be called when your additional shader is about to be compiled, allowing you to modify the keywords list for you extra shader
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="keywords"></param>
|
||||||
|
public virtual void ModifyKeywordsForAuxShader(List<string> keywords) { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Requireses the shader model46.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c>, if shader model46 was requiresed, <c>false</c> otherwise.</returns>
|
||||||
|
public virtual bool RequiresShaderModel46() { return false; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DrawGUI for shader compiler feature options
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mat">Mat.</param>
|
||||||
|
public abstract void DrawFeatureGUI(MicroSplatKeywords keywords);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draw the editor for the shaders options
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="shaderGUI">Shader GU.</param>
|
||||||
|
/// <param name="mat">Mat.</param>
|
||||||
|
/// <param name="materialEditor">Material editor.</param>
|
||||||
|
/// <param name="props">Properties.</param>
|
||||||
|
public abstract void DrawShaderGUI(MicroSplatShaderGUI shaderGUI, MicroSplatKeywords keywords, Material mat, MaterialEditor materialEditor, MaterialProperty[] props);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Got per texture properties? Draw the GUI for them here..
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">Index.</param>
|
||||||
|
/// <param name="shaderGUI">Shader GU.</param>
|
||||||
|
/// <param name="mat">Mat.</param>
|
||||||
|
/// <param name="materialEditor">Material editor.</param>
|
||||||
|
/// <param name="props">Properties.</param>
|
||||||
|
public virtual void DrawPerTextureGUI(int index, MicroSplatKeywords keywords, Material mat, MicroSplatPropData propData)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unpack your keywords from the material
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="keywords">Keywords.</param>
|
||||||
|
public abstract void Unpack(string[] keywords);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// pack keywords to a string[]
|
||||||
|
/// </summary>
|
||||||
|
public abstract string[] Pack();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Init yourself
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="paths">Paths.</param>
|
||||||
|
public abstract void InitCompiler(string[] paths);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// write property definitions to the shader
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="features">Features.</param>
|
||||||
|
/// <param name="sb">Sb.</param>
|
||||||
|
public abstract void WriteProperties(string[] features, StringBuilder sb);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// HDRP/LWRP benifit from declaring variables in CBuffers for instancing
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="features">Features.</param>
|
||||||
|
/// <param name="sb">Sb.</param>
|
||||||
|
public virtual void WritePerMaterialCBuffer(string[] features, StringBuilder sb) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write any functions which might be used by other modules, basically, a prepass so that something can rely on
|
||||||
|
/// code included by another module
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sb">Sb.</param>
|
||||||
|
public virtual void WriteSharedFunctions(string[] features, StringBuilder sb) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Some things, like tessellation in LWRP, require being able to call the vertex function
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sb">Sb.</param>
|
||||||
|
public virtual void WriteAfterVetrexFunctions(StringBuilder sb) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write the core functions you use to the shader
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sb">Sb.</param>
|
||||||
|
public abstract void WriteFunctions(string[] features, StringBuilder sb);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compute rough cost parameters for your section of the shader
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="features">List of material features.<param>
|
||||||
|
/// <param name="arraySampleCount">Array sample count.</param>
|
||||||
|
/// <param name="textureSampleCount">Texture sample count.</param>
|
||||||
|
/// <param name="maxSamples">Max samples.</param>
|
||||||
|
/// <param name="tessellationSamples">Tessellation samples.</param>
|
||||||
|
/// <param name="depTexReadLevel">Dep tex read level.</param>
|
||||||
|
public abstract void ComputeSampleCounts(string[] features, ref int arraySampleCount, ref int textureSampleCount, ref int maxSamples,
|
||||||
|
ref int tessellationSamples, ref int depTexReadLevel);
|
||||||
|
|
||||||
|
|
||||||
|
public void Pack(MicroSplatKeywords keywords)
|
||||||
|
{
|
||||||
|
var pck = Pack();
|
||||||
|
for (int i = 0; i < pck.Length; ++i)
|
||||||
|
{
|
||||||
|
keywords.EnableKeyword(pck[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum Channel
|
||||||
|
{
|
||||||
|
R = 0,
|
||||||
|
G,
|
||||||
|
B,
|
||||||
|
A
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool drawPertexToggle = true;
|
||||||
|
static protected int noPerTexToggleWidth = 20;
|
||||||
|
|
||||||
|
static bool PerTexToggle(MicroSplatKeywords keywords, string keyword)
|
||||||
|
{
|
||||||
|
if (drawPertexToggle)
|
||||||
|
{
|
||||||
|
bool enabled = keywords.IsKeywordEnabled(keyword);
|
||||||
|
bool newEnabled = EditorGUILayout.Toggle(enabled, GUILayout.Width(20));
|
||||||
|
if (enabled != newEnabled)
|
||||||
|
{
|
||||||
|
if (newEnabled)
|
||||||
|
keywords.EnableKeyword(keyword);
|
||||||
|
else
|
||||||
|
keywords.DisableKeyword(keyword);
|
||||||
|
}
|
||||||
|
return newEnabled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EditorGUILayout.LabelField("", GUILayout.Width(noPerTexToggleWidth));
|
||||||
|
drawPertexToggle = true;
|
||||||
|
return keywords.IsKeywordEnabled(keyword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected void InitPropData(int pixel, MicroSplatPropData propData, Color defaultValues)
|
||||||
|
{
|
||||||
|
if (propData == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// we reserve the last row of potential values as an initialization bit.
|
||||||
|
if (propData.GetValue(pixel, 15) == new Color(0,0,0,0))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < propData.maxTextures; ++i)
|
||||||
|
{
|
||||||
|
propData.SetValue(i, pixel, defaultValues);
|
||||||
|
}
|
||||||
|
propData.SetValue(pixel, 15, Color.white);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected bool DrawPerTexFloatSlider(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel,
|
||||||
|
GUIContent label, float min = 0, float max = 0, bool showHeader = true)
|
||||||
|
{
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
bool enabled = keywords.IsKeywordEnabled (keyword);
|
||||||
|
if (showHeader)
|
||||||
|
{
|
||||||
|
enabled = PerTexToggle (keywords, keyword);
|
||||||
|
GUI.enabled = enabled;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
EditorGUILayout.LabelField ("", GUILayout.Width (20));
|
||||||
|
GUI.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color c = propData.GetValue(curIdx, pixel);
|
||||||
|
float v = c[(int)channel];
|
||||||
|
float nv = v;
|
||||||
|
if (min != max)
|
||||||
|
{
|
||||||
|
nv = EditorGUILayout.Slider(label, v, min, max);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nv = EditorGUILayout.FloatField(label, v);
|
||||||
|
}
|
||||||
|
if (nv != v)
|
||||||
|
{
|
||||||
|
c[(int)channel] = nv;
|
||||||
|
propData.SetValue(curIdx, pixel, c);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GUILayout.Button("All", GUILayout.Width(40)))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < propData.maxTextures; ++i)
|
||||||
|
{
|
||||||
|
propData.SetValue(i, pixel, (int)channel, nv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI.enabled = true;
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public enum V2Cannel
|
||||||
|
{
|
||||||
|
RG = 0,
|
||||||
|
BA
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected bool DrawPerTexVector2(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, V2Cannel channel,
|
||||||
|
GUIContent label)
|
||||||
|
{
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
bool enabled = PerTexToggle(keywords, keyword);
|
||||||
|
GUI.enabled = enabled;
|
||||||
|
|
||||||
|
Color c = propData.GetValue(curIdx, pixel);
|
||||||
|
Vector2 v2 = new Vector2(c.r, c.g);
|
||||||
|
if (channel == V2Cannel.BA)
|
||||||
|
{
|
||||||
|
v2.x = c.b;
|
||||||
|
v2.y = c.a;
|
||||||
|
}
|
||||||
|
Vector2 nv = v2;
|
||||||
|
|
||||||
|
nv = EditorGUILayout.Vector2Field(label, v2);
|
||||||
|
|
||||||
|
if (nv != v2)
|
||||||
|
{
|
||||||
|
if (channel == V2Cannel.RG)
|
||||||
|
{
|
||||||
|
c.r = nv.x;
|
||||||
|
c.g = nv.y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c.b = nv.x;
|
||||||
|
c.a = nv.y;
|
||||||
|
}
|
||||||
|
propData.SetValue(curIdx, pixel, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GUILayout.Button("All", GUILayout.Width(40)))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < propData.maxTextures; ++i)
|
||||||
|
{
|
||||||
|
// don't erase other pixels..
|
||||||
|
var fv = propData.GetValue(i, pixel);
|
||||||
|
if (channel == V2Cannel.RG)
|
||||||
|
{
|
||||||
|
c.r = nv.x;
|
||||||
|
c.g = nv.y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c.b = nv.x;
|
||||||
|
c.a = nv.y;
|
||||||
|
}
|
||||||
|
propData.SetValue(i, pixel, fv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GUI.enabled = true;
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static protected bool DrawPerTexVector3 (int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData,
|
||||||
|
GUIContent label)
|
||||||
|
{
|
||||||
|
EditorGUILayout.BeginHorizontal ();
|
||||||
|
bool enabled = PerTexToggle (keywords, keyword);
|
||||||
|
GUI.enabled = enabled;
|
||||||
|
|
||||||
|
Color c = propData.GetValue (curIdx, pixel);
|
||||||
|
Vector3 v = new Vector3 (c.r, c.g, c.b);
|
||||||
|
|
||||||
|
Vector3 nv = EditorGUILayout.Vector2Field (label, v);
|
||||||
|
|
||||||
|
if (nv != v)
|
||||||
|
{
|
||||||
|
c.r = nv.x;
|
||||||
|
c.g = nv.y;
|
||||||
|
c.b = nv.z;
|
||||||
|
propData.SetValue (curIdx, pixel, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GUILayout.Button ("All", GUILayout.Width (40)))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < propData.maxTextures; ++i) {
|
||||||
|
// don't erase other pixels..
|
||||||
|
var fv = propData.GetValue (i, pixel);
|
||||||
|
c.r = nv.x;
|
||||||
|
c.g = nv.y;
|
||||||
|
c.b = nv.z;
|
||||||
|
propData.SetValue (i, pixel, fv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GUI.enabled = true;
|
||||||
|
EditorGUILayout.EndHorizontal ();
|
||||||
|
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static protected bool DrawPerTexVector2Vector2(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData,
|
||||||
|
GUIContent label, GUIContent label2)
|
||||||
|
{
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
bool enabled = PerTexToggle(keywords, keyword);
|
||||||
|
GUI.enabled = enabled;
|
||||||
|
|
||||||
|
Color c = propData.GetValue(curIdx, pixel);
|
||||||
|
Vector2 v1 = new Vector2(c.r, c.g);
|
||||||
|
Vector2 v2 = new Vector2(c.b, c.a);
|
||||||
|
Vector2 nv1 = v1;
|
||||||
|
Vector2 nv2 = v2;
|
||||||
|
EditorGUILayout.BeginVertical();
|
||||||
|
nv1 = EditorGUILayout.Vector2Field(label, v1);
|
||||||
|
nv2 = EditorGUILayout.Vector2Field(label2, v2);
|
||||||
|
EditorGUILayout.EndVertical();
|
||||||
|
|
||||||
|
if (nv1 != v1 || nv2 != v2)
|
||||||
|
{
|
||||||
|
c.r = nv1.x;
|
||||||
|
c.g = nv1.y;
|
||||||
|
c.b = nv2.x;
|
||||||
|
c.a = nv2.y;
|
||||||
|
propData.SetValue(curIdx, pixel, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GUILayout.Button("All", GUILayout.Width(40)))
|
||||||
|
{
|
||||||
|
c.r = nv1.x;
|
||||||
|
c.g = nv1.y;
|
||||||
|
c.b = nv2.x;
|
||||||
|
c.a = nv2.y;
|
||||||
|
for (int i = 0; i < propData.maxTextures; ++i)
|
||||||
|
{
|
||||||
|
propData.SetValue(i, pixel, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GUI.enabled = true;
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool DrawPerTexColor(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData,
|
||||||
|
GUIContent label, bool hasAlpha)
|
||||||
|
{
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
bool enabled = PerTexToggle(keywords, keyword);
|
||||||
|
GUI.enabled = enabled;
|
||||||
|
Color c = propData.GetValue(curIdx, pixel);
|
||||||
|
Color nv = EditorGUILayout.ColorField(label, c);
|
||||||
|
if (nv != c)
|
||||||
|
{
|
||||||
|
if (!hasAlpha)
|
||||||
|
{
|
||||||
|
nv.a = c.a;
|
||||||
|
}
|
||||||
|
propData.SetValue(curIdx, pixel, nv);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GUILayout.Button("All", GUILayout.Width(40)))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < propData.maxTextures; ++i)
|
||||||
|
{
|
||||||
|
if (!hasAlpha)
|
||||||
|
{
|
||||||
|
nv.a = propData.GetValue(i, pixel).a;
|
||||||
|
}
|
||||||
|
propData.SetValue(i, pixel, nv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI.enabled = true;
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected bool DrawPerTexPopUp(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel,
|
||||||
|
GUIContent label, GUIContent[] options)
|
||||||
|
{
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
bool enabled = PerTexToggle(keywords, keyword);
|
||||||
|
GUI.enabled = enabled;
|
||||||
|
Color c = propData.GetValue(curIdx, pixel);
|
||||||
|
float v = c[(int)channel];
|
||||||
|
|
||||||
|
EditorGUI.BeginChangeCheck ();
|
||||||
|
int selected = EditorGUILayout.Popup(label, (int)v, options);
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
c [(int)channel] = selected;
|
||||||
|
propData.SetValue (curIdx, pixel, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GUILayout.Button("All", GUILayout.Width(40)))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < propData.maxTextures; ++i)
|
||||||
|
{
|
||||||
|
Color nv = propData.GetValue(i, pixel);
|
||||||
|
nv[(int)channel] = selected;
|
||||||
|
propData.SetValue(i, pixel, nv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI.enabled = true;
|
||||||
|
drawPertexToggle = true;
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected void DrawPerTexPopUpNoToggle (int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel,
|
||||||
|
GUIContent label, GUIContent [] options)
|
||||||
|
{
|
||||||
|
drawPertexToggle = false;
|
||||||
|
DrawPerTexPopUp (curIdx, pixel, keyword, keywords, propData, channel, label, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static protected void DrawPerTexVector2NoToggle(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, V2Cannel channel,
|
||||||
|
GUIContent label)
|
||||||
|
{
|
||||||
|
drawPertexToggle = false;
|
||||||
|
DrawPerTexVector2(curIdx, pixel, keyword, keywords, propData, channel, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected void DrawPerTexVector2Vector2NoToggle(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData,
|
||||||
|
GUIContent label, GUIContent label2)
|
||||||
|
{
|
||||||
|
drawPertexToggle = false;
|
||||||
|
DrawPerTexVector2Vector2(curIdx, pixel, keyword, keywords, propData, label, label2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected void DrawPerTexFloatSliderNoToggle(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel,
|
||||||
|
GUIContent label, float min = 0, float max = 0)
|
||||||
|
{
|
||||||
|
drawPertexToggle = false;
|
||||||
|
DrawPerTexFloatSlider(curIdx, pixel, keyword, keywords, propData, channel, label, min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected void DrawPerTexColorNoToggle(int curIdx, int pixel, MicroSplatPropData propData, GUIContent label)
|
||||||
|
{
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
EditorGUILayout.LabelField("", GUILayout.Width(20));
|
||||||
|
Color c = propData.GetValue(curIdx, pixel);
|
||||||
|
Color nv = EditorGUILayout.ColorField(label, c);
|
||||||
|
if (nv != c)
|
||||||
|
{
|
||||||
|
propData.SetValue(curIdx, pixel, nv);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GUILayout.Button("All", GUILayout.Width(40)))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < propData.maxTextures; ++i)
|
||||||
|
{
|
||||||
|
propData.SetValue(i, pixel, nv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
drawPertexToggle = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static protected void DrawPerTexPopUpNoToggle(int curIdx, int pixel, string keyword, MicroSplatKeywords keywords, MicroSplatPropData propData, Channel channel,
|
||||||
|
GUIContent label, GUIContent[] options, float[] values)
|
||||||
|
{
|
||||||
|
drawPertexToggle = false;
|
||||||
|
DrawPerTexPopUp(curIdx, pixel, keyword, keywords, propData, channel, label, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GUIStyle globalButtonPressedStyle = null;
|
||||||
|
static GUIContent globalButton = new GUIContent("G", "Make property driven by a global variable. Used to integrate with external weathering systems");
|
||||||
|
protected bool DrawGlobalToggle(string keyword, MicroSplatKeywords keywords)
|
||||||
|
{
|
||||||
|
bool b = keywords.IsKeywordEnabled(keyword);
|
||||||
|
|
||||||
|
if (globalButtonPressedStyle == null)
|
||||||
|
{
|
||||||
|
globalButtonPressedStyle = new GUIStyle(GUI.skin.label);
|
||||||
|
globalButtonPressedStyle.normal.background = new Texture2D(1, 1);
|
||||||
|
globalButtonPressedStyle.normal.background.SetPixel(0, 0, Color.yellow);
|
||||||
|
globalButtonPressedStyle.normal.background.Apply();
|
||||||
|
globalButtonPressedStyle.normal.textColor = Color.black;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pressed = (GUILayout.Button(globalButton, b ? globalButtonPressedStyle : GUI.skin.label, GUILayout.Width(14)));
|
||||||
|
|
||||||
|
if (keywords.IsKeywordEnabled ("_ISOBJECTSHADER"))
|
||||||
|
return b;
|
||||||
|
|
||||||
|
if (pressed)
|
||||||
|
{
|
||||||
|
if (b)
|
||||||
|
{
|
||||||
|
keywords.DisableKeyword(keyword);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
keywords.EnableKeyword(keyword);
|
||||||
|
}
|
||||||
|
b = !b;
|
||||||
|
EditorUtility.SetDirty(keywords);
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,23 @@
|
|||||||
|
Shader "%SHADERNAME%"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
%PROPERTIES%
|
||||||
|
}
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
%TAGS%
|
||||||
|
|
||||||
|
%PASSFORWARD%
|
||||||
|
%PASSFORWARDADD%
|
||||||
|
%PASSGBUFFER%
|
||||||
|
%PASSSHADOW%
|
||||||
|
%PASSMETA%
|
||||||
|
UsePass "Hidden/Nature/Terrain/Utilities/PICKING"
|
||||||
|
UsePass "Hidden/Nature/Terrain/Utilities/SELECTION"
|
||||||
|
|
||||||
|
}
|
||||||
|
%DEPENDENCY%
|
||||||
|
%FALLBACK%
|
||||||
|
%CUSTOMEDITOR%
|
||||||
|
}
|
@@ -0,0 +1,515 @@
|
|||||||
|
// If your looking in here and thinking WTF, yeah, I know. These are taken from the SRPs, to allow us to use the same
|
||||||
|
// texturing library they use. However, since they are not included in the standard pipeline by default, there is no
|
||||||
|
// way to include them in and they have to be inlined, since someone could copy this shader onto another machine without
|
||||||
|
// MicroSplat installed. Unfortunate, but I'd rather do this and have a nice library for texture sampling instead
|
||||||
|
// of the patchy one Unity provides being inlined/emulated in HDRP/URP. Strangely, PSSL and XBoxOne libraries are not
|
||||||
|
// included in the standard SRP code, but they are in tons of Unity own projects on the web, so I grabbed them from there.
|
||||||
|
|
||||||
|
#if defined(SHADER_API_GAMECORE)
|
||||||
|
|
||||||
|
#define ZERO_INITIALIZE(type, name) name = (type)0;
|
||||||
|
#define ZERO_INITIALIZE_ARRAY(type, name, arraySize) { for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { name[arrayIndex] = (type)0; } }
|
||||||
|
|
||||||
|
// Texture util abstraction
|
||||||
|
|
||||||
|
#define CALCULATE_TEXTURE2D_LOD(textureName, samplerName, coord2) textureName.CalculateLevelOfDetail(samplerName, coord2)
|
||||||
|
|
||||||
|
// Texture abstraction
|
||||||
|
|
||||||
|
#define TEXTURE2D(textureName) Texture2D textureName
|
||||||
|
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
|
||||||
|
#define TEXTURECUBE(textureName) TextureCube textureName
|
||||||
|
#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
|
||||||
|
#define TEXTURE3D(textureName) Texture3D textureName
|
||||||
|
|
||||||
|
#define TEXTURE2D_FLOAT(textureName) TEXTURE2D(textureName)
|
||||||
|
#define TEXTURE2D_ARRAY_FLOAT(textureName) TEXTURE2D_ARRAY(textureName)
|
||||||
|
#define TEXTURECUBE_FLOAT(textureName) TEXTURECUBE(textureName)
|
||||||
|
#define TEXTURECUBE_ARRAY_FLOAT(textureName) TEXTURECUBE_ARRAY(textureName)
|
||||||
|
#define TEXTURE3D_FLOAT(textureName) TEXTURE3D(textureName)
|
||||||
|
|
||||||
|
#define TEXTURE2D_HALF(textureName) TEXTURE2D(textureName)
|
||||||
|
#define TEXTURE2D_ARRAY_HALF(textureName) TEXTURE2D_ARRAY(textureName)
|
||||||
|
#define TEXTURECUBE_HALF(textureName) TEXTURECUBE(textureName)
|
||||||
|
#define TEXTURECUBE_ARRAY_HALF(textureName) TEXTURECUBE_ARRAY(textureName)
|
||||||
|
#define TEXTURE3D_HALF(textureName) TEXTURE3D(textureName)
|
||||||
|
|
||||||
|
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
|
||||||
|
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
|
||||||
|
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)
|
||||||
|
#define TEXTURECUBE_ARRAY_SHADOW(textureName) TEXTURECUBE_ARRAY(textureName)
|
||||||
|
|
||||||
|
#define RW_TEXTURE2D(type, textureName) RWTexture2D<type> textureName
|
||||||
|
#define RW_TEXTURE2D_ARRAY(type, textureName) RWTexture2DArray<type> textureName
|
||||||
|
#define RW_TEXTURE3D(type, textureName) RWTexture3D<type> textureName
|
||||||
|
|
||||||
|
#define SAMPLER(samplerName) SamplerState samplerName
|
||||||
|
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
|
||||||
|
#define ASSIGN_SAMPLER(samplerName, samplerValue) samplerName = samplerValue
|
||||||
|
|
||||||
|
#define TEXTURE2D_PARAM(textureName, samplerName) TEXTURE2D(textureName), SAMPLER(samplerName)
|
||||||
|
#define TEXTURE2D_ARRAY_PARAM(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER(samplerName)
|
||||||
|
#define TEXTURECUBE_PARAM(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER(samplerName)
|
||||||
|
#define TEXTURECUBE_ARRAY_PARAM(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER(samplerName)
|
||||||
|
#define TEXTURE3D_PARAM(textureName, samplerName) TEXTURE3D(textureName), SAMPLER(samplerName)
|
||||||
|
|
||||||
|
#define TEXTURE2D_SHADOW_PARAM(textureName, samplerName) TEXTURE2D(textureName), SAMPLER_CMP(samplerName)
|
||||||
|
#define TEXTURE2D_ARRAY_SHADOW_PARAM(textureName, samplerName) TEXTURE2D_ARRAY(textureName), SAMPLER_CMP(samplerName)
|
||||||
|
#define TEXTURECUBE_SHADOW_PARAM(textureName, samplerName) TEXTURECUBE(textureName), SAMPLER_CMP(samplerName)
|
||||||
|
#define TEXTURECUBE_ARRAY_SHADOW_PARAM(textureName, samplerName) TEXTURECUBE_ARRAY(textureName), SAMPLER_CMP(samplerName)
|
||||||
|
|
||||||
|
#define TEXTURE2D_ARGS(textureName, samplerName) textureName, samplerName
|
||||||
|
#define TEXTURE2D_ARRAY_ARGS(textureName, samplerName) textureName, samplerName
|
||||||
|
#define TEXTURECUBE_ARGS(textureName, samplerName) textureName, samplerName
|
||||||
|
#define TEXTURECUBE_ARRAY_ARGS(textureName, samplerName) textureName, samplerName
|
||||||
|
#define TEXTURE3D_ARGS(textureName, samplerName) textureName, samplerName
|
||||||
|
|
||||||
|
#define TEXTURE2D_SHADOW_ARGS(textureName, samplerName) textureName, samplerName
|
||||||
|
#define TEXTURE2D_ARRAY_SHADOW_ARGS(textureName, samplerName) textureName, samplerName
|
||||||
|
#define TEXTURECUBE_SHADOW_ARGS(textureName, samplerName) textureName, samplerName
|
||||||
|
#define TEXTURECUBE_ARRAY_SHADOW_ARGS(textureName, samplerName) textureName, samplerName
|
||||||
|
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) textureName.SampleGrad(samplerName, float3(coord2, index), dpdx, dpdy)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) textureName.SampleBias(samplerName, coord3, bias)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Sample(samplerName, float4(coord3, index))
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) textureName.SampleLevel(samplerName, float4(coord3, index), lod)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURECUBE_ARRAY_BIAS(textureName, samplerName, coord3, index, bias) textureName.SampleBias(samplerName, float4(coord3, index), bias)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURE3D(textureName, samplerName, coord3) textureName.Sample(samplerName, coord3)
|
||||||
|
#define PLATFORM_SAMPLE_TEXTURE3D_LOD(textureName, samplerName, coord3, lod) textureName.SampleLevel(samplerName, coord3, lod)
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) PLATFORM_SAMPLE_TEXTURE2D(textureName, samplerName, coord2)
|
||||||
|
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) PLATFORM_SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) PLATFORM_SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) PLATFORM_SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) PLATFORM_SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) PLATFORM_SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) PLATFORM_SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) PLATFORM_SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy)
|
||||||
|
#define SAMPLE_TEXTURECUBE(textureName, samplerName, coord3) PLATFORM_SAMPLE_TEXTURECUBE(textureName, samplerName, coord3)
|
||||||
|
#define SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod) PLATFORM_SAMPLE_TEXTURECUBE_LOD(textureName, samplerName, coord3, lod)
|
||||||
|
#define SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias) PLATFORM_SAMPLE_TEXTURECUBE_BIAS(textureName, samplerName, coord3, bias)
|
||||||
|
#define SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) PLATFORM_SAMPLE_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index)
|
||||||
|
#define SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod) PLATFORM_SAMPLE_TEXTURECUBE_ARRAY_LOD(textureName, samplerName, coord3, index, lod)
|
||||||
|
#define SAMPLE_TEXTURECUBE_ARRAY_BIAS(textureName, samplerName, coord3, index, bias) PLATFORM_SAMPLE_TEXTURECUBE_ARRAY_BIAS(textureName, samplerName, coord3, index, bias)
|
||||||
|
#define SAMPLE_TEXTURE3D(textureName, samplerName, coord3) PLATFORM_SAMPLE_TEXTURE3D(textureName, samplerName, coord3)
|
||||||
|
#define SAMPLE_TEXTURE3D_LOD(textureName, samplerName, coord3, lod) PLATFORM_SAMPLE_TEXTURE3D_LOD(textureName, samplerName, coord3, lod)
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D_SHADOW(textureName, samplerName, coord3) textureName.SampleCmpLevelZero(samplerName, (coord3).xy, (coord3).z)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_SHADOW(textureName, samplerName, coord3, index) textureName.SampleCmpLevelZero(samplerName, float3((coord3).xy, index), (coord3).z)
|
||||||
|
#define SAMPLE_TEXTURECUBE_SHADOW(textureName, samplerName, coord4) textureName.SampleCmpLevelZero(samplerName, (coord4).xyz, (coord4).w)
|
||||||
|
#define SAMPLE_TEXTURECUBE_ARRAY_SHADOW(textureName, samplerName, coord4, index) textureName.SampleCmpLevelZero(samplerName, float4((coord4).xyz, index), (coord4).w)
|
||||||
|
|
||||||
|
#define SAMPLE_DEPTH_TEXTURE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2).r
|
||||||
|
#define SAMPLE_DEPTH_TEXTURE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod).r
|
||||||
|
|
||||||
|
#define LOAD_TEXTURE2D(textureName, unCoord2) textureName.Load(int3(unCoord2, 0))
|
||||||
|
#define LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) textureName.Load(int3(unCoord2, lod))
|
||||||
|
#define LOAD_TEXTURE2D_MSAA(textureName, unCoord2, sampleIndex) textureName.Load(unCoord2, sampleIndex)
|
||||||
|
#define LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) textureName.Load(int4(unCoord2, index, 0))
|
||||||
|
#define LOAD_TEXTURE2D_ARRAY_MSAA(textureName, unCoord2, index, sampleIndex) textureName.Load(int3(unCoord2, index), sampleIndex)
|
||||||
|
#define LOAD_TEXTURE2D_ARRAY_LOD(textureName, unCoord2, index, lod) textureName.Load(int4(unCoord2, index, lod))
|
||||||
|
#define LOAD_TEXTURE3D(textureName, unCoord3) textureName.Load(int4(unCoord3, 0))
|
||||||
|
#define LOAD_TEXTURE3D_LOD(textureName, unCoord3, lod) textureName.Load(int4(unCoord3, lod))
|
||||||
|
|
||||||
|
#define PLATFORM_SUPPORT_GATHER
|
||||||
|
#define GATHER_TEXTURE2D(textureName, samplerName, coord2) textureName.Gather(samplerName, coord2)
|
||||||
|
#define GATHER_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Gather(samplerName, float3(coord2, index))
|
||||||
|
#define GATHER_TEXTURECUBE(textureName, samplerName, coord3) textureName.Gather(samplerName, coord3)
|
||||||
|
#define GATHER_TEXTURECUBE_ARRAY(textureName, samplerName, coord3, index) textureName.Gather(samplerName, float4(coord3, index))
|
||||||
|
#define GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherRed(samplerName, coord2)
|
||||||
|
#define GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherGreen(samplerName, coord2)
|
||||||
|
#define GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherBlue(samplerName, coord2)
|
||||||
|
#define GATHER_ALPHA_TEXTURE2D(textureName, samplerName, coord2) textureName.GatherAlpha(samplerName, coord2)
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined(SHADER_API_XBOXONE)
|
||||||
|
|
||||||
|
// Initialize arbitrary structure with zero values.
|
||||||
|
// Do not exist on some platform, in this case we need to have a standard name that call a function that will initialize all parameters to 0
|
||||||
|
#define ZERO_INITIALIZE(type, name) name = (type)0;
|
||||||
|
#define ZERO_INITIALIZE_ARRAY(type, name, arraySize) { for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { name[arrayIndex] = (type)0; } }
|
||||||
|
|
||||||
|
// Texture util abstraction
|
||||||
|
|
||||||
|
#define CALCULATE_TEXTURE2D_LOD(textureName, samplerName, coord2) textureName.CalculateLevelOfDetail(samplerName, coord2)
|
||||||
|
|
||||||
|
// Texture abstraction
|
||||||
|
|
||||||
|
#define TEXTURE2D(textureName) Texture2D textureName
|
||||||
|
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
|
||||||
|
|
||||||
|
#define TEXTURE2D_FLOAT(textureName) TEXTURE2D(textureName)
|
||||||
|
#define TEXTURE2D_ARRAY_FLOAT(textureName) TEXTURE2D_ARRAY(textureName)
|
||||||
|
|
||||||
|
#define TEXTURE2D_HALF(textureName) TEXTURE2D(textureName)
|
||||||
|
#define TEXTURE2D_ARRAY_HALF(textureName) TEXTURE2D_ARRAY(textureName)
|
||||||
|
|
||||||
|
|
||||||
|
#define SAMPLER(samplerName) SamplerState samplerName
|
||||||
|
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
|
||||||
|
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) textureName.SampleGrad(samplerName, float3(coord2, index), dpdx, dpdy)
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined(SHADER_API_PSSL)
|
||||||
|
|
||||||
|
// Initialize arbitrary structure with zero values.
|
||||||
|
// Do not exist on some platform, in this case we need to have a standard name that call a function that will initialize all parameters to 0
|
||||||
|
#define ZERO_INITIALIZE(type, name) name = (type)0;
|
||||||
|
#define ZERO_INITIALIZE_ARRAY(type, name, arraySize) { for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { name[arrayIndex] = (type)0; } }
|
||||||
|
|
||||||
|
// Texture util abstraction
|
||||||
|
|
||||||
|
#define CALCULATE_TEXTURE2D_LOD(textureName, samplerName, coord2) textureName.GetLOD(samplerName, coord2)
|
||||||
|
|
||||||
|
// Texture abstraction
|
||||||
|
|
||||||
|
#define TEXTURE2D(textureName) Texture2D textureName
|
||||||
|
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
|
||||||
|
|
||||||
|
#define TEXTURE2D_FLOAT(textureName) TEXTURE2D(textureName)
|
||||||
|
#define TEXTURE2D_ARRAY_FLOAT(textureName) TEXTURE2D_ARRAY(textureName)
|
||||||
|
|
||||||
|
#define TEXTURE2D_HALF(textureName) TEXTURE2D(textureName)
|
||||||
|
#define TEXTURE2D_ARRAY_HALF(textureName) TEXTURE2D_ARRAY(textureName)
|
||||||
|
|
||||||
|
|
||||||
|
#define SAMPLER(samplerName) SamplerState samplerName
|
||||||
|
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
|
||||||
|
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) textureName.SampleGrad(samplerName, float3(coord2, index), dpdx, dpdy)
|
||||||
|
|
||||||
|
|
||||||
|
#elif defined(SHADER_API_D3D11)
|
||||||
|
|
||||||
|
// Initialize arbitrary structure with zero values.
|
||||||
|
// Do not exist on some platform, in this case we need to have a standard name that call a function that will initialize all parameters to 0
|
||||||
|
#define ZERO_INITIALIZE(type, name) name = (type)0;
|
||||||
|
#define ZERO_INITIALIZE_ARRAY(type, name, arraySize) { for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { name[arrayIndex] = (type)0; } }
|
||||||
|
|
||||||
|
// Texture util abstraction
|
||||||
|
|
||||||
|
#define CALCULATE_TEXTURE2D_LOD(textureName, samplerName, coord2) textureName.CalculateLevelOfDetail(samplerName, coord2)
|
||||||
|
|
||||||
|
// Texture abstraction
|
||||||
|
|
||||||
|
#define TEXTURE2D(textureName) Texture2D textureName
|
||||||
|
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
|
||||||
|
|
||||||
|
#define TEXTURE2D_FLOAT(textureName) TEXTURE2D(textureName)
|
||||||
|
#define TEXTURE2D_ARRAY_FLOAT(textureName) TEXTURE2D_ARRAY(textureName)
|
||||||
|
|
||||||
|
#define TEXTURE2D_HALF(textureName) TEXTURE2D(textureName)
|
||||||
|
#define TEXTURE2D_ARRAY_HALF(textureName) TEXTURE2D_ARRAY(textureName)
|
||||||
|
|
||||||
|
#define SAMPLER(samplerName) SamplerState samplerName
|
||||||
|
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
|
||||||
|
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) textureName.SampleGrad(samplerName, float3(coord2, index), dpdx, dpdy)
|
||||||
|
|
||||||
|
#elif defined(SHADER_API_METAL)
|
||||||
|
|
||||||
|
// Initialize arbitrary structure with zero values.
|
||||||
|
// Do not exist on some platform, in this case we need to have a standard name that call a function that will initialize all parameters to 0
|
||||||
|
#define ZERO_INITIALIZE(type, name) name = (type)0;
|
||||||
|
#define ZERO_INITIALIZE_ARRAY(type, name, arraySize) { for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { name[arrayIndex] = (type)0; } }
|
||||||
|
|
||||||
|
// Texture util abstraction
|
||||||
|
|
||||||
|
#define CALCULATE_TEXTURE2D_LOD(textureName, samplerName, coord2) textureName.CalculateLevelOfDetail(samplerName, coord2)
|
||||||
|
|
||||||
|
// Texture abstraction
|
||||||
|
|
||||||
|
#define TEXTURE2D(textureName) Texture2D textureName
|
||||||
|
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
|
||||||
|
|
||||||
|
#define TEXTURE2D_FLOAT(textureName) Texture2D_float textureName
|
||||||
|
#define TEXTURE2D_ARRAY_FLOAT(textureName) Texture2DArray textureName // no support to _float on Array, it's being added
|
||||||
|
|
||||||
|
#define TEXTURE2D_HALF(textureName) Texture2D_half textureName
|
||||||
|
#define TEXTURE2D_ARRAY_HALF(textureName) Texture2DArray textureName // no support to _float on Array, it's being added
|
||||||
|
|
||||||
|
#define SAMPLER(samplerName) SamplerState samplerName
|
||||||
|
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
|
||||||
|
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) textureName.SampleGrad(samplerName, float3(coord2, index), dpdx, dpdy)
|
||||||
|
|
||||||
|
#elif defined(SHADER_API_VULKAN)
|
||||||
|
// This file assume SHADER_API_VULKAN is defined
|
||||||
|
// TODO: This is a straight copy from D3D11.hlsl. Go through all this stuff and adjust where needed.
|
||||||
|
|
||||||
|
|
||||||
|
// Initialize arbitrary structure with zero values.
|
||||||
|
// Do not exist on some platform, in this case we need to have a standard name that call a function that will initialize all parameters to 0
|
||||||
|
#define ZERO_INITIALIZE(type, name) name = (type)0;
|
||||||
|
#define ZERO_INITIALIZE_ARRAY(type, name, arraySize) { for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { name[arrayIndex] = (type)0; } }
|
||||||
|
|
||||||
|
// Texture util abstraction
|
||||||
|
|
||||||
|
#define CALCULATE_TEXTURE2D_LOD(textureName, samplerName, coord2) textureName.CalculateLevelOfDetail(samplerName, coord2)
|
||||||
|
|
||||||
|
// Texture abstraction
|
||||||
|
|
||||||
|
#define TEXTURE2D(textureName) Texture2D textureName
|
||||||
|
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
|
||||||
|
|
||||||
|
#define TEXTURE2D_FLOAT(textureName) Texture2D_float textureName
|
||||||
|
#define TEXTURE2D_ARRAY_FLOAT(textureName) Texture2DArray textureName // no support to _float on Array, it's being added
|
||||||
|
|
||||||
|
#define TEXTURE2D_HALF(textureName) Texture2D_half textureName
|
||||||
|
#define TEXTURE2D_ARRAY_HALF(textureName) Texture2DArray textureName // no support to _float on Array, it's being added
|
||||||
|
|
||||||
|
#define SAMPLER(samplerName) SamplerState samplerName
|
||||||
|
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
|
||||||
|
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) textureName.SampleGrad(samplerName, float3(coord2, index), dpdx, dpdy)
|
||||||
|
|
||||||
|
#elif defined(SHADER_API_SWITCH)
|
||||||
|
// This file assume SHADER_API_SWITCH is defined
|
||||||
|
|
||||||
|
// Initialize arbitrary structure with zero values.
|
||||||
|
// Do not exist on some platform, in this case we need to have a standard name that call a function that will initialize all parameters to 0
|
||||||
|
#define ZERO_INITIALIZE(type, name) name = (type)0;
|
||||||
|
#define ZERO_INITIALIZE_ARRAY(type, name, arraySize) { for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { name[arrayIndex] = (type)0; } }
|
||||||
|
|
||||||
|
// Texture util abstraction
|
||||||
|
|
||||||
|
#define CALCULATE_TEXTURE2D_LOD(textureName, samplerName, coord2) textureName.CalculateLevelOfDetail(samplerName, coord2)
|
||||||
|
|
||||||
|
// Texture abstraction
|
||||||
|
|
||||||
|
#define TEXTURE2D(textureName) Texture2D textureName
|
||||||
|
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
|
||||||
|
|
||||||
|
#define TEXTURE2D_FLOAT(textureName) Texture2D_float textureName
|
||||||
|
#define TEXTURE2D_ARRAY_FLOAT(textureName) Texture2DArray textureName // no support to _float on Array, it's being added
|
||||||
|
|
||||||
|
#define TEXTURE2D_HALF(textureName) Texture2D_half textureName
|
||||||
|
#define TEXTURE2D_ARRAY_HALF(textureName) Texture2DArray textureName // no support to _float on Array, it's being added
|
||||||
|
|
||||||
|
#define SAMPLER(samplerName) SamplerState samplerName
|
||||||
|
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
|
||||||
|
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, dpdx, dpdy) textureName.SampleGrad(samplerName, coord2, dpdx, dpdy)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) textureName.SampleGrad(samplerName, float3(coord2, index), dpdx, dpdy)
|
||||||
|
|
||||||
|
#elif defined(SHADER_API_GLCORE)
|
||||||
|
|
||||||
|
// OpenGL 4.1 SM 5.0 https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html
|
||||||
|
#if (SHADER_TARGET >= 46)
|
||||||
|
#define OPENGL4_1_SM5 1
|
||||||
|
#else
|
||||||
|
#define OPENGL4_1_SM5 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Initialize arbitrary structure with zero values.
|
||||||
|
// Do not exist on some platform, in this case we need to have a standard name that call a function that will initialize all parameters to 0
|
||||||
|
#define ZERO_INITIALIZE(type, name) name = (type)0;
|
||||||
|
#define ZERO_INITIALIZE_ARRAY(type, name, arraySize) { for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { name[arrayIndex] = (type)0; } }
|
||||||
|
|
||||||
|
// Texture util abstraction
|
||||||
|
|
||||||
|
#define CALCULATE_TEXTURE2D_LOD(textureName, samplerName, coord2) textureName.CalculateLevelOfDetail(samplerName, coord2)
|
||||||
|
|
||||||
|
// Texture abstraction
|
||||||
|
|
||||||
|
#define TEXTURE2D(textureName) Texture2D textureName
|
||||||
|
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
|
||||||
|
|
||||||
|
#define TEXTURE2D_FLOAT(textureName) TEXTURE2D(textureName)
|
||||||
|
#define TEXTURE2D_ARRAY_FLOAT(textureName) TEXTURE2D_ARRAY(textureName)
|
||||||
|
|
||||||
|
#define TEXTURE2D_HALF(textureName) TEXTURE2D(textureName)
|
||||||
|
#define TEXTURE2D_ARRAY_HALF(textureName) TEXTURE2D_ARRAY(textureName)
|
||||||
|
|
||||||
|
|
||||||
|
#define SAMPLER(samplerName) SamplerState samplerName
|
||||||
|
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
|
||||||
|
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, ddx, ddy) textureName.SampleGrad(samplerName, coord2, ddx, ddy)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) textureName.SampleGrad(samplerName, float3(coord2, index), dpdx, dpdy)
|
||||||
|
|
||||||
|
#elif defined(SHADER_API_GLES3)
|
||||||
|
|
||||||
|
// GLES 3.1 + AEP shader feature https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html
|
||||||
|
#if (SHADER_TARGET >= 40)
|
||||||
|
#define GLES3_1_AEP 1
|
||||||
|
#else
|
||||||
|
#define GLES3_1_AEP 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Initialize arbitrary structure with zero values.
|
||||||
|
// Do not exist on some platform, in this case we need to have a standard name that call a function that will initialize all parameters to 0
|
||||||
|
#define ZERO_INITIALIZE(type, name) name = (type)0;
|
||||||
|
#define ZERO_INITIALIZE_ARRAY(type, name, arraySize) { for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { name[arrayIndex] = (type)0; } }
|
||||||
|
|
||||||
|
// Texture util abstraction
|
||||||
|
|
||||||
|
#define CALCULATE_TEXTURE2D_LOD(textureName, samplerName, coord2) textureName.CalculateLevelOfDetail(samplerName, coord2)
|
||||||
|
|
||||||
|
// Texture abstraction
|
||||||
|
|
||||||
|
#define TEXTURE2D(textureName) Texture2D textureName
|
||||||
|
#define TEXTURE2D_ARRAY(textureName) Texture2DArray textureName
|
||||||
|
|
||||||
|
#define TEXTURE2D_FLOAT(textureName) Texture2D_float textureName
|
||||||
|
#define TEXTURE2D_ARRAY_FLOAT(textureName) Texture2DArray textureName // no support to _float on Array, it's being added
|
||||||
|
|
||||||
|
#define TEXTURE2D_HALF(textureName) Texture2D_half textureName
|
||||||
|
#define TEXTURE2D_ARRAY_HALF(textureName) Texture2DArray textureName // no support to _float on Array, it's being added
|
||||||
|
|
||||||
|
#define SAMPLER(samplerName) SamplerState samplerName
|
||||||
|
#define SAMPLER_CMP(samplerName) SamplerComparisonState samplerName
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) textureName.Sample(samplerName, coord2)
|
||||||
|
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) textureName.SampleLevel(samplerName, coord2, lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) textureName.SampleBias(samplerName, coord2, bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, ddx, ddy) textureName.SampleGrad(samplerName, coord2, ddx, ddy)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) textureName.Sample(samplerName, float3(coord2, index))
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) textureName.SampleLevel(samplerName, float3(coord2, index), lod)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) textureName.SampleBias(samplerName, float3(coord2, index), bias)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) textureName.SampleGrad(samplerName, float3(coord2, index), dpdx, dpdy)
|
||||||
|
|
||||||
|
#elif defined(SHADER_API_GLES)
|
||||||
|
|
||||||
|
|
||||||
|
#define uint int
|
||||||
|
|
||||||
|
#define rcp(x) 1.0 / (x)
|
||||||
|
#define ddx_fine ddx
|
||||||
|
#define ddy_fine ddy
|
||||||
|
#define asfloat
|
||||||
|
#define asuint(x) asint(x)
|
||||||
|
#define f32tof16
|
||||||
|
#define f16tof32
|
||||||
|
|
||||||
|
#define ERROR_ON_UNSUPPORTED_FUNCTION(funcName) #error #funcName is not supported on GLES 2.0
|
||||||
|
|
||||||
|
// Initialize arbitrary structure with zero values.
|
||||||
|
// Do not exist on some platform, in this case we need to have a standard name that call a function that will initialize all parameters to 0
|
||||||
|
#define ZERO_INITIALIZE(type, name) name = (type)0;
|
||||||
|
#define ZERO_INITIALIZE_ARRAY(type, name, arraySize) { for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { name[arrayIndex] = (type)0; } }
|
||||||
|
|
||||||
|
|
||||||
|
// Texture util abstraction
|
||||||
|
|
||||||
|
#define CALCULATE_TEXTURE2D_LOD(textureName, samplerName, coord2) #error calculate Level of Detail not supported in GLES2
|
||||||
|
|
||||||
|
// Texture abstraction
|
||||||
|
|
||||||
|
#define TEXTURE2D(textureName) sampler2D textureName
|
||||||
|
#define TEXTURE2D_ARRAY(textureName) samplerCUBE textureName // No support to texture2DArray
|
||||||
|
#define TEXTURECUBE(textureName) samplerCUBE textureName
|
||||||
|
#define TEXTURECUBE_ARRAY(textureName) samplerCUBE textureName // No supoport to textureCubeArray and can't emulate with texture2DArray
|
||||||
|
#define TEXTURE3D(textureName) sampler3D textureName
|
||||||
|
|
||||||
|
#define TEXTURE2D_FLOAT(textureName) sampler2D_float textureName
|
||||||
|
#define TEXTURECUBE_FLOAT(textureName) samplerCUBE_float textureName
|
||||||
|
#define TEXTURE2D_ARRAY_FLOAT(textureName) TEXTURECUBE_FLOAT(textureName) // No support to texture2DArray
|
||||||
|
|
||||||
|
#define TEXTURE2D_HALF(textureName) sampler2D_half textureName
|
||||||
|
#define TEXTURE2D_ARRAY_HALF(textureName) TEXTURECUBE_HALF(textureName) // No support to texture2DArray
|
||||||
|
|
||||||
|
#define SAMPLER(samplerName)
|
||||||
|
#define SAMPLER_CMP(samplerName)
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D(textureName, samplerName, coord2) tex2D(textureName, coord2)
|
||||||
|
|
||||||
|
#if (SHADER_TARGET >= 30)
|
||||||
|
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) tex2Dlod(textureName, float4(coord2, 0, lod))
|
||||||
|
#else
|
||||||
|
// No lod support. Very poor approximation with bias.
|
||||||
|
#define SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, lod)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SAMPLE_TEXTURE2D_BIAS(textureName, samplerName, coord2, bias) tex2Dbias(textureName, float4(coord2, 0, bias))
|
||||||
|
#define SAMPLE_TEXTURE2D_GRAD(textureName, samplerName, coord2, ddx, ddy) SAMPLE_TEXTURE2D(textureName, samplerName, coord2)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) ERROR_ON_UNSUPPORTED_FUNCTION(SAMPLE_TEXTURE2D_ARRAY)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) ERROR_ON_UNSUPPORTED_FUNCTION(SAMPLE_TEXTURE2D_ARRAY_LOD)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_BIAS(textureName, samplerName, coord2, index, bias) ERROR_ON_UNSUPPORTED_FUNCTION(SAMPLE_TEXTURE2D_ARRAY_BIAS)
|
||||||
|
#define SAMPLE_TEXTURE2D_ARRAY_GRAD(textureName, samplerName, coord2, index, dpdx, dpdy) ERROR_ON_UNSUPPORTED_FUNCTION(SAMPLE_TEXTURE2D_ARRAY_GRAD)
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error unsupported shader api
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// default flow control attributes
|
||||||
|
#ifndef UNITY_BRANCH
|
||||||
|
# define UNITY_BRANCH
|
||||||
|
#endif
|
||||||
|
#ifndef UNITY_FLATTEN
|
||||||
|
# define UNITY_FLATTEN
|
||||||
|
#endif
|
||||||
|
#ifndef UNITY_UNROLL
|
||||||
|
# define UNITY_UNROLL
|
||||||
|
#endif
|
||||||
|
#ifndef UNITY_UNROLLX
|
||||||
|
# define UNITY_UNROLLX(_x)
|
||||||
|
#endif
|
||||||
|
#ifndef UNITY_LOOP
|
||||||
|
# define UNITY_LOOP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@@ -0,0 +1,333 @@
|
|||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD"
|
||||||
|
Tags { "LightMode" = "ForwardBase" }
|
||||||
|
%FORWARDBASEBLEND%
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
// compile directives
|
||||||
|
%PRAGMAS%
|
||||||
|
|
||||||
|
#pragma target %SHADERTARGET%
|
||||||
|
#pragma multi_compile_instancing
|
||||||
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
#pragma multi_compile_fwdbase
|
||||||
|
#include "HLSLSupport.cginc"
|
||||||
|
|
||||||
|
#define _PASSFORWARD 1
|
||||||
|
|
||||||
|
#include "UnityShaderVariables.cginc"
|
||||||
|
#include "UnityShaderUtilities.cginc"
|
||||||
|
// -------- variant for: <when no other keywords are defined>
|
||||||
|
|
||||||
|
%DEFINES%
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#if _NOMINDIELETRIC
|
||||||
|
// for Standard
|
||||||
|
#ifdef unity_ColorSpaceDielectricSpec
|
||||||
|
#undef unity_ColorSpaceDielectricSpec
|
||||||
|
#endif
|
||||||
|
#define unity_ColorSpaceDielectricSpec half4(0,0,0,1)
|
||||||
|
#endif
|
||||||
|
#include "Lighting.cginc"
|
||||||
|
#include "UnityPBSLighting.cginc"
|
||||||
|
#include "AutoLight.cginc"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if _MICROTERRAIN && !_TERRAINBLENDABLESHADER
|
||||||
|
#define UNITY_ASSUME_UNIFORM_SCALING
|
||||||
|
#define UNITY_DONT_INSTANCE_OBJECT_MATRICES
|
||||||
|
#define UNITY_INSTANCED_LOD_FADE
|
||||||
|
#else
|
||||||
|
#define UNITY_INSTANCED_LOD_FADE
|
||||||
|
#define UNITY_INSTANCED_SH
|
||||||
|
#define UNITY_INSTANCED_LIGHTMAPSTS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// data across stages, stripped like the above.
|
||||||
|
struct VertexToPixel
|
||||||
|
{
|
||||||
|
UNITY_POSITION(pos);
|
||||||
|
float3 worldPos : TEXCOORD0;
|
||||||
|
float3 worldNormal : TEXCOORD1;
|
||||||
|
float4 worldTangent : TEXCOORD2;
|
||||||
|
%UV0% float4 texcoord0 : TEXCCOORD3;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
%UV1% float4 texcoord1 : TEXCCOORD4;
|
||||||
|
%UV2% float4 texcoord2 : TEXCCOORD5;
|
||||||
|
#endif
|
||||||
|
%UV3% float4 texcoord3 : TEXCCOORD6;
|
||||||
|
%SCREENPOS% float4 screenPos : TEXCOORD7;
|
||||||
|
%VERTEXCOLOR% float4 vertexColor : COLOR;
|
||||||
|
float4 lmap : TEXCOORD8;
|
||||||
|
#if UNITY_SHOULD_SAMPLE_SH
|
||||||
|
half3 sh : TEXCOORD9; // SH
|
||||||
|
#endif
|
||||||
|
#ifdef LIGHTMAP_ON
|
||||||
|
UNITY_LIGHTING_COORDS(10,11)
|
||||||
|
UNITY_FOG_COORDS(12)
|
||||||
|
#else
|
||||||
|
UNITY_FOG_COORDS(10)
|
||||||
|
UNITY_SHADOW_COORDS(11)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
%EXTRAV2F0% float4 extraV2F0 : TEXCOORD13;
|
||||||
|
%EXTRAV2F1% float4 extraV2F1 : TEXCOORD14;
|
||||||
|
%EXTRAV2F2% float4 extraV2F2 : TEXCOORD15;
|
||||||
|
%EXTRAV2F3% float4 extraV2F3 : TEXCOORD16;
|
||||||
|
%EXTRAV2F4% float4 extraV2F4 : TEXCOORD17;
|
||||||
|
%EXTRAV2F5% float4 extraV2F5 : TEXCOORD18;
|
||||||
|
%EXTRAV2F6% float4 extraV2F6 : TEXCOORD19;
|
||||||
|
%EXTRAV2F7% float4 extraV2F7 : TEXCOORD20;
|
||||||
|
|
||||||
|
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
%TEMPLATE_SHARED%
|
||||||
|
|
||||||
|
%CBUFFER%
|
||||||
|
|
||||||
|
%CODE%
|
||||||
|
|
||||||
|
%SHADERDESC%
|
||||||
|
|
||||||
|
// vertex shader
|
||||||
|
VertexToPixel Vert (VertexData v)
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
VertexToPixel o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(VertexToPixel,o);
|
||||||
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
|
|
||||||
|
#if !_TESSELLATION_ON
|
||||||
|
ChainModifyVertex(v, o);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
o.pos = UnityObjectToClipPos(v.vertex);
|
||||||
|
%UV0% o.texcoord0 = v.texcoord0;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
%UV1% o.texcoord1 = v.texcoord1;
|
||||||
|
%UV2% o.texcoord2 = v.texcoord2;
|
||||||
|
#endif
|
||||||
|
%UV3% o.texcoord3 = v.texcoord3;
|
||||||
|
%VERTEXCOLOR% o.vertexColor = v.vertexColor;
|
||||||
|
%SCREENPOS% o.screenPos = ComputeScreenPos(o.pos);
|
||||||
|
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||||
|
o.worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||||
|
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
o.worldTangent.xyz = UnityObjectToWorldDir(v.tangent.xyz);
|
||||||
|
fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
|
||||||
|
o.worldTangent.w = tangentSign;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// MS Only
|
||||||
|
ApplyTerrainTangent(o);
|
||||||
|
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
float2 uv1 = v.texcoord1.xy;
|
||||||
|
float2 uv2 = v.texcoord2.xy;
|
||||||
|
#else
|
||||||
|
float2 uv1 = v.texcoord0.xy;
|
||||||
|
float2 uv2 = uv1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DYNAMICLIGHTMAP_ON
|
||||||
|
o.lmap.zw = uv2 * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||||
|
#endif
|
||||||
|
#ifdef LIGHTMAP_ON
|
||||||
|
o.lmap.xy = uv1 * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// SH/ambient and vertex lights
|
||||||
|
#ifndef LIGHTMAP_ON
|
||||||
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||||
|
o.sh = 0;
|
||||||
|
// Approximated illumination from non-important point lights
|
||||||
|
#ifdef VERTEXLIGHT_ON
|
||||||
|
o.sh += Shade4PointLights (
|
||||||
|
unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0,
|
||||||
|
unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb,
|
||||||
|
unity_4LightAtten0, o.worldPos, o.worldNormal);
|
||||||
|
#endif
|
||||||
|
o.sh = ShadeSHPerVertex (o.worldNormal, o.sh);
|
||||||
|
#endif
|
||||||
|
#endif // !LIGHTMAP_ON
|
||||||
|
|
||||||
|
UNITY_TRANSFER_LIGHTING(o, uv1.xy); // pass shadow and, possibly, light cookie coordinates to pixel shader
|
||||||
|
#ifdef FOG_COMBINED_WITH_TSPACE
|
||||||
|
UNITY_TRANSFER_FOG_COMBINED_WITH_TSPACE(o,o.pos); // pass fog coordinates to pixel shader
|
||||||
|
#elif defined (FOG_COMBINED_WITH_WORLD_POS)
|
||||||
|
UNITY_TRANSFER_FOG_COMBINED_WITH_WORLD_POS(o,o.pos); // pass fog coordinates to pixel shader
|
||||||
|
#else
|
||||||
|
UNITY_TRANSFER_FOG(o,o.pos); // pass fog coordinates to pixel shader
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
%TESSELLATION%
|
||||||
|
|
||||||
|
// fragment shader
|
||||||
|
fixed4 Frag (VertexToPixel IN) : SV_Target
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(IN);
|
||||||
|
// prepare and unpack data
|
||||||
|
#ifdef FOG_COMBINED_WITH_TSPACE
|
||||||
|
UNITY_EXTRACT_FOG_FROM_TSPACE(IN);
|
||||||
|
#elif defined (FOG_COMBINED_WITH_WORLD_POS)
|
||||||
|
UNITY_EXTRACT_FOG_FROM_WORLD_POS(IN);
|
||||||
|
#else
|
||||||
|
UNITY_EXTRACT_FOG(IN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ShaderData d = CreateShaderData(IN);
|
||||||
|
|
||||||
|
Surface l = (Surface)0;
|
||||||
|
|
||||||
|
l.Albedo = half3(0.5, 0.5, 0.5);
|
||||||
|
l.Normal = float3(0,0,1);
|
||||||
|
l.Occlusion = 1;
|
||||||
|
l.Alpha = 1;
|
||||||
|
|
||||||
|
ChainSurfaceFunction(l, d);
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef USING_DIRECTIONAL_LIGHT
|
||||||
|
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(d.worldSpacePosition));
|
||||||
|
#else
|
||||||
|
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// compute lighting & shadowing factor
|
||||||
|
UNITY_LIGHT_ATTENUATION(atten, IN, d.worldSpacePosition)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if _USESPECULAR || _USESPECULARWORKFLOW || _SPECULARFROMMETALLIC
|
||||||
|
#ifdef UNITY_COMPILER_HLSL
|
||||||
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
||||||
|
#else
|
||||||
|
SurfaceOutputStandardSpecular o;
|
||||||
|
#endif
|
||||||
|
o.Specular = l.Specular;
|
||||||
|
#elif _BDRFLAMBERT || _BDRF3
|
||||||
|
#ifdef UNITY_COMPILER_HLSL
|
||||||
|
SurfaceOutput o = (SurfaceOutput)0;
|
||||||
|
#else
|
||||||
|
SurfaceOutput o;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef UNITY_COMPILER_HLSL
|
||||||
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
||||||
|
#else
|
||||||
|
SurfaceOutputStandard o;
|
||||||
|
#endif
|
||||||
|
o.Metallic = l.Metallic;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
o.Albedo = l.Albedo;
|
||||||
|
o.Emission = l.Emission;
|
||||||
|
o.Alpha = l.Alpha;
|
||||||
|
o.Normal = normalize(TangentToWorldSpace(d, l.Normal));
|
||||||
|
|
||||||
|
#if _BDRFLAMBERT || _BDRF3
|
||||||
|
o.Specular = l.Specular;
|
||||||
|
o.Gloss = l.Smoothness;
|
||||||
|
#elif _SPECULARFROMMETALLIC
|
||||||
|
o.Occlusion = l.Occlusion;
|
||||||
|
o.Smoothness = l.Smoothness;
|
||||||
|
o.Albedo = MicroSplatDiffuseAndSpecularFromMetallic(l.Albedo, l.Metallic, o.Specular, o.Smoothness);
|
||||||
|
o.Smoothness = 1-o.Smoothness;
|
||||||
|
#elif _USESPECULARWORKFLOW
|
||||||
|
o.Occlusion = l.Occlusion;
|
||||||
|
o.Smoothness = l.Smoothness;
|
||||||
|
o.Specular = l.Specular;
|
||||||
|
#else
|
||||||
|
o.Smoothness = l.Smoothness;
|
||||||
|
o.Metallic = l.Metallic;
|
||||||
|
o.Occlusion = l.Occlusion;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if !_UNLIT
|
||||||
|
fixed4 c = 0;
|
||||||
|
// Setup lighting environment
|
||||||
|
UnityGI gi;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
|
||||||
|
gi.indirect.diffuse = 0;
|
||||||
|
gi.indirect.specular = 0;
|
||||||
|
gi.light.color = _LightColor0.rgb;
|
||||||
|
gi.light.dir = lightDir;
|
||||||
|
// Call GI (lightmaps/SH/reflections) lighting function
|
||||||
|
UnityGIInput giInput;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
|
||||||
|
giInput.light = gi.light;
|
||||||
|
giInput.worldPos = d.worldSpacePosition;
|
||||||
|
giInput.worldViewDir = d.worldSpaceViewDir;
|
||||||
|
giInput.atten = atten;
|
||||||
|
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||||
|
giInput.lightmapUV = IN.lmap;
|
||||||
|
#else
|
||||||
|
giInput.lightmapUV = 0;
|
||||||
|
#endif
|
||||||
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||||
|
giInput.ambient = IN.sh;
|
||||||
|
#else
|
||||||
|
giInput.ambient.rgb = 0.0;
|
||||||
|
#endif
|
||||||
|
giInput.probeHDR[0] = unity_SpecCube0_HDR;
|
||||||
|
giInput.probeHDR[1] = unity_SpecCube1_HDR;
|
||||||
|
#if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION)
|
||||||
|
giInput.boxMin[0] = unity_SpecCube0_BoxMin; // .w holds lerp value for blending
|
||||||
|
#endif
|
||||||
|
#ifdef UNITY_SPECCUBE_BOX_PROJECTION
|
||||||
|
giInput.boxMax[0] = unity_SpecCube0_BoxMax;
|
||||||
|
giInput.probePosition[0] = unity_SpecCube0_ProbePosition;
|
||||||
|
giInput.boxMax[1] = unity_SpecCube1_BoxMax;
|
||||||
|
giInput.boxMin[1] = unity_SpecCube1_BoxMin;
|
||||||
|
giInput.probePosition[1] = unity_SpecCube1_ProbePosition;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _USESPECULAR || _USESPECULARWORKFLOW || _SPECULARFROMMETALLIC
|
||||||
|
LightingStandardSpecular_GI(o, giInput, gi);
|
||||||
|
c += LightingStandardSpecular (o, d.worldSpaceViewDir, gi);
|
||||||
|
#elif _BDRFLAMBERT
|
||||||
|
LightingLambert_GI(o, giInput, gi);
|
||||||
|
c += LightingLambert (o, gi);
|
||||||
|
#elif _BDRF3
|
||||||
|
LightingBlinnPhong_GI(o, giInput, gi);
|
||||||
|
c += LightingBlinnPhong (o, d.worldSpaceViewDir, gi);
|
||||||
|
#else
|
||||||
|
LightingStandard_GI(o, giInput, gi);
|
||||||
|
c += LightingStandard (o, d.worldSpaceViewDir, gi);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
c.rgb += o.Emission;
|
||||||
|
|
||||||
|
UNITY_APPLY_FOG(_unity_fogCoord, c); // apply fog
|
||||||
|
#else
|
||||||
|
fixed4 c = fixed4(o.Albedo.rgb, o.Alpha);
|
||||||
|
UNITY_APPLY_FOG(_unity_fogCoord, c); // apply fog
|
||||||
|
#endif
|
||||||
|
#if !_ALPHABLEND_ON
|
||||||
|
UNITY_OPAQUE_ALPHA(c.a);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ChainFinalColorForward(l, d, c);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
@@ -0,0 +1,266 @@
|
|||||||
|
|
||||||
|
// ---- forward rendering additive lights pass:
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD"
|
||||||
|
Tags { "LightMode" = "ForwardAdd" }
|
||||||
|
ZWrite Off Blend One One
|
||||||
|
%FORWARDADDBLEND%
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
|
||||||
|
%PRAGMAS%
|
||||||
|
|
||||||
|
// compile directives
|
||||||
|
#pragma target %SHADERTARGET%
|
||||||
|
#pragma multi_compile_instancing
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
||||||
|
#pragma multi_compile_fwdadd_fullshadows
|
||||||
|
#include "HLSLSupport.cginc"
|
||||||
|
|
||||||
|
|
||||||
|
#include "UnityShaderVariables.cginc"
|
||||||
|
#include "UnityShaderUtilities.cginc"
|
||||||
|
|
||||||
|
#define _PASSFORWARD 1
|
||||||
|
|
||||||
|
%DEFINES%
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
#if _NOMINDIELETRIC
|
||||||
|
// for Standard
|
||||||
|
#ifdef unity_ColorSpaceDielectricSpec
|
||||||
|
#undef unity_ColorSpaceDielectricSpec
|
||||||
|
#endif
|
||||||
|
#define unity_ColorSpaceDielectricSpec half4(0,0,0,1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Lighting.cginc"
|
||||||
|
#include "UnityPBSLighting.cginc"
|
||||||
|
#include "AutoLight.cginc"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if _MICROTERRAIN && !_TERRAINBLENDABLESHADER
|
||||||
|
#define UNITY_ASSUME_UNIFORM_SCALING
|
||||||
|
#define UNITY_DONT_INSTANCE_OBJECT_MATRICES
|
||||||
|
#define UNITY_INSTANCED_LOD_FADE
|
||||||
|
#else
|
||||||
|
#define UNITY_INSTANCED_LOD_FADE
|
||||||
|
#define UNITY_INSTANCED_SH
|
||||||
|
#define UNITY_INSTANCED_LIGHTMAPSTS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// data across stages, stripped like the above.
|
||||||
|
struct VertexToPixel
|
||||||
|
{
|
||||||
|
UNITY_POSITION(pos); // must be named pos because Unity does stupid macro stuff
|
||||||
|
float3 worldPos : TEXCOORD0;
|
||||||
|
float3 worldNormal : TEXCOORD1;
|
||||||
|
float4 worldTangent : TEXCOORD2;
|
||||||
|
%UV0% float4 texcoord0 : TEXCCOORD3;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
%UV1% float4 texcoord1 : TEXCCOORD4;
|
||||||
|
%UV2% float4 texcoord2 : TEXCCOORD5;
|
||||||
|
#endif
|
||||||
|
%UV3% float4 texcoord3 : TEXCCOORD6;
|
||||||
|
%SCREENPOS% float4 screenPos : TEXCOORD7;
|
||||||
|
%VERTEXCOLOR% float4 vertexColor : COLOR;
|
||||||
|
|
||||||
|
UNITY_LIGHTING_COORDS(8,9)
|
||||||
|
UNITY_FOG_COORDS(10)
|
||||||
|
|
||||||
|
%EXTRAV2F0% float4 extraV2F0 : TEXCOORD11;
|
||||||
|
%EXTRAV2F1% float4 extraV2F1 : TEXCOORD12;
|
||||||
|
%EXTRAV2F2% float4 extraV2F2 : TEXCOORD13;
|
||||||
|
%EXTRAV2F3% float4 extraV2F3 : TEXCOORD14;
|
||||||
|
%EXTRAV2F4% float4 extraV2F4 : TEXCOORD15;
|
||||||
|
%EXTRAV2F5% float4 extraV2F5 : TEXCOORD16;
|
||||||
|
%EXTRAV2F6% float4 extraV2F6 : TEXCOORD17;
|
||||||
|
%EXTRAV2F7% float4 extraV2F7 : TEXCOORD18;
|
||||||
|
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
%TEMPLATE_SHARED%
|
||||||
|
|
||||||
|
%CBUFFER%
|
||||||
|
|
||||||
|
%CODE%
|
||||||
|
|
||||||
|
%SHADERDESC%
|
||||||
|
|
||||||
|
// vertex shader
|
||||||
|
VertexToPixel Vert (VertexData v)
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
VertexToPixel o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(VertexToPixel,o);
|
||||||
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
|
|
||||||
|
#if !_TESSELLATION_ON
|
||||||
|
ChainModifyVertex(v, o);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
o.pos = UnityObjectToClipPos(v.vertex);
|
||||||
|
%UV0% o.texcoord0 = v.texcoord0;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
%UV1% o.texcoord1 = v.texcoord1;
|
||||||
|
%UV2% o.texcoord2 = v.texcoord2;
|
||||||
|
#endif
|
||||||
|
%UV3% o.texcoord3 = v.texcoord3;
|
||||||
|
%VERTEXCOLOR% o.vertexColor = v.vertexColor;
|
||||||
|
%SCREENPOS% o.screenPos = ComputeScreenPos(o.pos);
|
||||||
|
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||||
|
o.worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||||
|
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
o.worldTangent.xyz = UnityObjectToWorldDir(v.tangent.xyz);
|
||||||
|
fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
|
||||||
|
o.worldTangent.w = tangentSign;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// MS Only
|
||||||
|
ApplyTerrainTangent(o);
|
||||||
|
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
float2 uv1 = v.texcoord1.xy;
|
||||||
|
float2 uv2 = v.texcoord2.xy;
|
||||||
|
#else
|
||||||
|
float2 uv1 = v.texcoord0.xy;
|
||||||
|
float2 uv2 = uv1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UNITY_TRANSFER_LIGHTING(o,uv1); // pass shadow and, possibly, light cookie coordinates to pixel shader
|
||||||
|
UNITY_TRANSFER_FOG(o,o.pos); // pass fog coordinates to pixel shader
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
%TESSELLATION%
|
||||||
|
|
||||||
|
// fragment shader
|
||||||
|
fixed4 Frag (VertexToPixel IN) : SV_Target
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(IN);
|
||||||
|
// prepare and unpack data
|
||||||
|
|
||||||
|
#ifdef FOG_COMBINED_WITH_TSPACE
|
||||||
|
UNITY_EXTRACT_FOG_FROM_TSPACE(IN);
|
||||||
|
#elif defined (FOG_COMBINED_WITH_WORLD_POS)
|
||||||
|
UNITY_EXTRACT_FOG_FROM_WORLD_POS(IN);
|
||||||
|
#else
|
||||||
|
UNITY_EXTRACT_FOG(IN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ShaderData d = CreateShaderData(IN);
|
||||||
|
|
||||||
|
Surface l = (Surface)0;
|
||||||
|
|
||||||
|
l.Albedo = half3(0.5, 0.5, 0.5);
|
||||||
|
l.Normal = float3(0,0,1);
|
||||||
|
l.Occlusion = 1;
|
||||||
|
l.Alpha = 1;
|
||||||
|
|
||||||
|
ChainSurfaceFunction(l, d);
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef USING_DIRECTIONAL_LIGHT
|
||||||
|
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(d.worldSpacePosition));
|
||||||
|
#else
|
||||||
|
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
||||||
|
#endif
|
||||||
|
float3 worldViewDir = normalize(UnityWorldSpaceViewDir(d.worldSpacePosition));
|
||||||
|
|
||||||
|
#if _USESPECULAR || _USESPECULARWORKFLOW || _SPECULARFROMMETALLIC
|
||||||
|
#ifdef UNITY_COMPILER_HLSL
|
||||||
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
||||||
|
#else
|
||||||
|
SurfaceOutputStandardSpecular o;
|
||||||
|
#endif
|
||||||
|
o.Specular = l.Specular;
|
||||||
|
#elif _BDRFLAMBERT || _BDRF3
|
||||||
|
#ifdef UNITY_COMPILER_HLSL
|
||||||
|
SurfaceOutput o = (SurfaceOutput)0;
|
||||||
|
#else
|
||||||
|
SurfaceOutput o;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef UNITY_COMPILER_HLSL
|
||||||
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
||||||
|
#else
|
||||||
|
SurfaceOutputStandard o;
|
||||||
|
#endif
|
||||||
|
o.Metallic = l.Metallic;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
o.Albedo = l.Albedo;
|
||||||
|
o.Emission = l.Emission;
|
||||||
|
o.Alpha = l.Alpha;
|
||||||
|
o.Normal = normalize(TangentToWorldSpace(d, l.Normal));
|
||||||
|
|
||||||
|
#if _BDRFLAMBERT || _BDRF3
|
||||||
|
o.Specular = l.Specular;
|
||||||
|
o.Gloss = l.Smoothness;
|
||||||
|
#elif _SPECULARFROMMETALLIC
|
||||||
|
o.Occlusion = l.Occlusion;
|
||||||
|
o.Smoothness = l.Smoothness;
|
||||||
|
o.Albedo = MicroSplatDiffuseAndSpecularFromMetallic(l.Albedo, l.Metallic, o.Specular, o.Smoothness);
|
||||||
|
o.Smoothness = 1-o.Smoothness;
|
||||||
|
#elif _USESPECULARWORKFLOW
|
||||||
|
o.Occlusion = l.Occlusion;
|
||||||
|
o.Smoothness = l.Smoothness;
|
||||||
|
o.Specular = l.Specular;
|
||||||
|
#else
|
||||||
|
o.Smoothness = l.Smoothness;
|
||||||
|
o.Metallic = l.Metallic;
|
||||||
|
o.Occlusion = l.Occlusion;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
UNITY_LIGHT_ATTENUATION(atten, IN, d.worldSpacePosition)
|
||||||
|
half4 c = 0;
|
||||||
|
|
||||||
|
// Setup lighting environment
|
||||||
|
UnityGI gi;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
|
||||||
|
gi.indirect.diffuse = 0;
|
||||||
|
gi.indirect.specular = 0;
|
||||||
|
gi.light.color = _LightColor0.rgb;
|
||||||
|
gi.light.dir = lightDir;
|
||||||
|
gi.light.color *= atten;
|
||||||
|
|
||||||
|
#if _USESPECULAR || _USESPECULARWORKFLOW || _SPECULARFROMMETALLIC
|
||||||
|
c += LightingStandardSpecular (o, worldViewDir, gi);
|
||||||
|
#elif _BDRFLAMBERT
|
||||||
|
c += LightingLambert(o, gi);
|
||||||
|
c.a = 0;
|
||||||
|
#elif _BDRF3
|
||||||
|
c += LightingBlinnPhong (o, worldViewDir, gi);
|
||||||
|
#else
|
||||||
|
c += LightingStandard (o, worldViewDir, gi);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ChainFinalColorForward(l, d, c);
|
||||||
|
|
||||||
|
UNITY_APPLY_FOG(_unity_fogCoord, c); // apply fog
|
||||||
|
|
||||||
|
#if !_ALPHABLEND_ON
|
||||||
|
UNITY_OPAQUE_ALPHA(c.a);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,352 @@
|
|||||||
|
|
||||||
|
// ---- deferred shading pass:
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "DEFERRED"
|
||||||
|
Tags { "LightMode" = "Deferred" }
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
|
||||||
|
%PRAGMAS%
|
||||||
|
|
||||||
|
// compile directives
|
||||||
|
#pragma target %SHADERTARGET%
|
||||||
|
#pragma multi_compile_instancing
|
||||||
|
#pragma exclude_renderers nomrt
|
||||||
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
||||||
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
||||||
|
#pragma multi_compile_prepassfinal
|
||||||
|
#include "HLSLSupport.cginc"
|
||||||
|
#include "UnityShaderVariables.cginc"
|
||||||
|
#include "UnityShaderUtilities.cginc"
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
#define _PASSGBUFFER 1
|
||||||
|
|
||||||
|
%DEFINES%
|
||||||
|
|
||||||
|
#if _NOMINDIELETRIC
|
||||||
|
// for Standard
|
||||||
|
#ifdef unity_ColorSpaceDielectricSpec
|
||||||
|
#undef unity_ColorSpaceDielectricSpec
|
||||||
|
#endif
|
||||||
|
#define unity_ColorSpaceDielectricSpec half4(0,0,0,1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Lighting.cginc"
|
||||||
|
#include "UnityPBSLighting.cginc"
|
||||||
|
|
||||||
|
#if _MICROTERRAIN && !_TERRAINBLENDABLESHADER
|
||||||
|
#define UNITY_ASSUME_UNIFORM_SCALING
|
||||||
|
#define UNITY_DONT_INSTANCE_OBJECT_MATRICES
|
||||||
|
#define UNITY_INSTANCED_LOD_FADE
|
||||||
|
#else
|
||||||
|
#define UNITY_INSTANCED_LOD_FADE
|
||||||
|
#define UNITY_INSTANCED_SH
|
||||||
|
#define UNITY_INSTANCED_LIGHTMAPSTS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// data across stages, stripped like the above.
|
||||||
|
struct VertexToPixel
|
||||||
|
{
|
||||||
|
UNITY_POSITION(pos); // must be named pos because Unity does stupid macro stuff
|
||||||
|
float3 worldPos : TEXCOORD0;
|
||||||
|
float3 worldNormal : TEXCOORD1;
|
||||||
|
float4 worldTangent : TEXCOORD2;
|
||||||
|
%UV0% float4 texcoord0 : TEXCCOORD3;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
%UV1% float4 texcoord1 : TEXCCOORD4;
|
||||||
|
%UV2% float4 texcoord2 : TEXCCOORD5;
|
||||||
|
#endif
|
||||||
|
%UV3% float4 texcoord3 : TEXCCOORD6;
|
||||||
|
%SCREENPOS% float4 screenPos : TEXCOORD7;
|
||||||
|
%VERTEXCOLOR% float4 vertexColor : COLOR;
|
||||||
|
|
||||||
|
#ifndef DIRLIGHTMAP_OFF
|
||||||
|
float3 viewDir : TEXCOORD8;
|
||||||
|
#endif
|
||||||
|
float4 lmap : TEXCOORD9;
|
||||||
|
#ifndef LIGHTMAP_ON
|
||||||
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||||
|
half3 sh : TEXCOORD10; // SH
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef DIRLIGHTMAP_OFF
|
||||||
|
float4 lmapFadePos : TEXCOORD11;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
%EXTRAV2F0% float4 extraV2F0 : TEXCOORD12;
|
||||||
|
%EXTRAV2F1% float4 extraV2F1 : TEXCOORD13;
|
||||||
|
%EXTRAV2F2% float4 extraV2F2 : TEXCOORD14;
|
||||||
|
%EXTRAV2F3% float4 extraV2F3 : TEXCOORD15;
|
||||||
|
%EXTRAV2F4% float4 extraV2F4 : TEXCOORD16;
|
||||||
|
%EXTRAV2F5% float4 extraV2F5 : TEXCOORD17;
|
||||||
|
%EXTRAV2F6% float4 extraV2F6 : TEXCOORD18;
|
||||||
|
%EXTRAV2F7% float4 extraV2F7 : TEXCOORD19;
|
||||||
|
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
%TEMPLATE_SHARED%
|
||||||
|
|
||||||
|
%CBUFFER%
|
||||||
|
|
||||||
|
%CODE%
|
||||||
|
|
||||||
|
%SHADERDESC%
|
||||||
|
|
||||||
|
|
||||||
|
// vertex shader
|
||||||
|
VertexToPixel Vert (VertexData v)
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
VertexToPixel o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(VertexToPixel,o);
|
||||||
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
|
|
||||||
|
#if !_TESSELLATION_ON
|
||||||
|
ChainModifyVertex(v, o);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
o.pos = UnityObjectToClipPos(v.vertex);
|
||||||
|
%UV0% o.texcoord0 = v.texcoord0;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
%UV1% o.texcoord1 = v.texcoord1;
|
||||||
|
%UV2% o.texcoord2 = v.texcoord2;
|
||||||
|
#endif
|
||||||
|
%UV3% o.texcoord3 = v.texcoord3;
|
||||||
|
%VERTEXCOLOR% o.vertexColor = v.vertexColor;
|
||||||
|
%SCREENPOS% o.screenPos = ComputeScreenPos(o.pos);
|
||||||
|
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||||
|
o.worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||||
|
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
o.worldTangent.xyz = UnityObjectToWorldDir(v.tangent.xyz);
|
||||||
|
fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
|
||||||
|
float3 worldBinormal = cross(o.worldNormal, o.worldTangent.xyz) * tangentSign;
|
||||||
|
o.worldTangent.w = tangentSign;
|
||||||
|
#else
|
||||||
|
// MS Only
|
||||||
|
ApplyTerrainTangent(o);
|
||||||
|
float3 worldBinormal = cross(o.worldNormal, o.worldTangent.xyz) * unity_WorldTransformParams.w;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float3 viewDirForLight = UnityWorldSpaceViewDir(o.worldPos);
|
||||||
|
#ifndef DIRLIGHTMAP_OFF
|
||||||
|
o.viewDir.x = dot(viewDirForLight, o.worldTangent.xyz);
|
||||||
|
o.viewDir.y = dot(viewDirForLight, worldBinormal);
|
||||||
|
o.viewDir.z = dot(viewDirForLight, o.worldNormal);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
float2 uv1 = v.texcoord1.xy;
|
||||||
|
float2 uv2 = v.texcoord2.xy;
|
||||||
|
#else
|
||||||
|
float2 uv1 = v.texcoord0.xy;
|
||||||
|
float2 uv2 = uv1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DYNAMICLIGHTMAP_ON
|
||||||
|
o.lmap.zw = uv2 * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||||
|
#else
|
||||||
|
o.lmap.zw = 0;
|
||||||
|
#endif
|
||||||
|
#ifdef LIGHTMAP_ON
|
||||||
|
o.lmap.xy = uv1 * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||||
|
#ifdef DIRLIGHTMAP_OFF
|
||||||
|
o.lmapFadePos.xyz = (mul(unity_ObjectToWorld, v.vertex).xyz - unity_ShadowFadeCenterAndType.xyz) * unity_ShadowFadeCenterAndType.w;
|
||||||
|
o.lmapFadePos.w = (-UnityObjectToViewPos(v.vertex).z) * (1.0 - unity_ShadowFadeCenterAndType.w);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
o.lmap.xy = 0;
|
||||||
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||||
|
o.sh = 0;
|
||||||
|
o.sh = ShadeSHPerVertex (o.worldNormal, o.sh);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
%TESSELLATION%
|
||||||
|
|
||||||
|
#ifdef LIGHTMAP_ON
|
||||||
|
float4 unity_LightmapFade;
|
||||||
|
#endif
|
||||||
|
fixed4 unity_Ambient;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// fragment shader
|
||||||
|
void Frag (VertexToPixel IN,
|
||||||
|
out half4 outGBuffer0 : SV_Target0,
|
||||||
|
out half4 outGBuffer1 : SV_Target1,
|
||||||
|
out half4 outGBuffer2 : SV_Target2,
|
||||||
|
out half4 outEmission : SV_Target3
|
||||||
|
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
||||||
|
, out half4 outShadowMask : SV_Target4
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(IN);
|
||||||
|
// prepare and unpack data
|
||||||
|
|
||||||
|
#ifdef FOG_COMBINED_WITH_TSPACE
|
||||||
|
UNITY_EXTRACT_FOG_FROM_TSPACE(IN);
|
||||||
|
#elif defined (FOG_COMBINED_WITH_WORLD_POS)
|
||||||
|
UNITY_EXTRACT_FOG_FROM_WORLD_POS(IN);
|
||||||
|
#else
|
||||||
|
UNITY_EXTRACT_FOG(IN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
ShaderData d = CreateShaderData(IN);
|
||||||
|
|
||||||
|
Surface l = (Surface)0;
|
||||||
|
|
||||||
|
l.Albedo = half3(0.5, 0.5, 0.5);
|
||||||
|
l.Normal = float3(0,0,1);
|
||||||
|
l.Occlusion = 1;
|
||||||
|
l.Alpha = 1;
|
||||||
|
|
||||||
|
ChainSurfaceFunction(l, d);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef USING_DIRECTIONAL_LIGHT
|
||||||
|
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(d.worldSpacePosition));
|
||||||
|
#else
|
||||||
|
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
||||||
|
#endif
|
||||||
|
float3 worldViewDir = normalize(UnityWorldSpaceViewDir(d.worldSpacePosition));
|
||||||
|
|
||||||
|
#if _USESPECULAR || _USESPECULARWORKFLOW || _SPECULARFROMMETALLIC
|
||||||
|
#ifdef UNITY_COMPILER_HLSL
|
||||||
|
SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0;
|
||||||
|
#else
|
||||||
|
SurfaceOutputStandardSpecular o;
|
||||||
|
#endif
|
||||||
|
o.Specular = l.Specular;
|
||||||
|
#elif _BDRFLAMBERT || _BDRF3
|
||||||
|
#ifdef UNITY_COMPILER_HLSL
|
||||||
|
SurfaceOutput o = (SurfaceOutput)0;
|
||||||
|
#else
|
||||||
|
SurfaceOutput o;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef UNITY_COMPILER_HLSL
|
||||||
|
SurfaceOutputStandard o = (SurfaceOutputStandard)0;
|
||||||
|
#else
|
||||||
|
SurfaceOutputStandard o;
|
||||||
|
#endif
|
||||||
|
o.Metallic = l.Metallic;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
o.Albedo = l.Albedo;
|
||||||
|
o.Emission = l.Emission;
|
||||||
|
o.Alpha = l.Alpha;
|
||||||
|
o.Normal = normalize(TangentToWorldSpace(d, l.Normal));
|
||||||
|
|
||||||
|
#if _BDRFLAMBERT || _BDRF3
|
||||||
|
o.Specular = l.Occlusion;
|
||||||
|
o.Gloss = l.Smoothness;
|
||||||
|
#elif _SPECULARFROMMETALLIC
|
||||||
|
o.Occlusion = l.Occlusion;
|
||||||
|
o.Smoothness = l.Smoothness;
|
||||||
|
o.Albedo = MicroSplatDiffuseAndSpecularFromMetallic(l.Albedo, l.Metallic, o.Specular, o.Smoothness);
|
||||||
|
o.Smoothness = 1-o.Smoothness;
|
||||||
|
#elif _USESPECULARWORKFLOW
|
||||||
|
o.Occlusion = l.Occlusion;
|
||||||
|
o.Smoothness = l.Smoothness;
|
||||||
|
o.Specular = l.Specular;
|
||||||
|
#else
|
||||||
|
o.Smoothness = l.Smoothness;
|
||||||
|
o.Metallic = l.Metallic;
|
||||||
|
o.Occlusion = l.Occlusion;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
half atten = 1;
|
||||||
|
|
||||||
|
// Setup lighting environment
|
||||||
|
UnityGI gi;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(UnityGI, gi);
|
||||||
|
gi.indirect.diffuse = 0;
|
||||||
|
gi.indirect.specular = 0;
|
||||||
|
gi.light.color = 0;
|
||||||
|
gi.light.dir = half3(0,1,0);
|
||||||
|
// Call GI (lightmaps/SH/reflections) lighting function
|
||||||
|
UnityGIInput giInput;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput);
|
||||||
|
giInput.light = gi.light;
|
||||||
|
giInput.worldPos = d.worldSpacePosition;
|
||||||
|
giInput.worldViewDir = worldViewDir;
|
||||||
|
giInput.atten = atten;
|
||||||
|
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||||
|
giInput.lightmapUV = IN.lmap;
|
||||||
|
#else
|
||||||
|
giInput.lightmapUV = 0.0;
|
||||||
|
#endif
|
||||||
|
#if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL
|
||||||
|
giInput.ambient = IN.sh;
|
||||||
|
#else
|
||||||
|
giInput.ambient.rgb = 0.0;
|
||||||
|
#endif
|
||||||
|
giInput.probeHDR[0] = unity_SpecCube0_HDR;
|
||||||
|
giInput.probeHDR[1] = unity_SpecCube1_HDR;
|
||||||
|
#if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION)
|
||||||
|
giInput.boxMin[0] = unity_SpecCube0_BoxMin; // .w holds lerp value for blending
|
||||||
|
#endif
|
||||||
|
#ifdef UNITY_SPECCUBE_BOX_PROJECTION
|
||||||
|
giInput.boxMax[0] = unity_SpecCube0_BoxMax;
|
||||||
|
giInput.probePosition[0] = unity_SpecCube0_ProbePosition;
|
||||||
|
giInput.boxMax[1] = unity_SpecCube1_BoxMax;
|
||||||
|
giInput.boxMin[1] = unity_SpecCube1_BoxMin;
|
||||||
|
giInput.probePosition[1] = unity_SpecCube1_ProbePosition;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _USESPECULAR || _USESPECULARWORKFLOW || _SPECULARFROMMETALLIC
|
||||||
|
LightingStandardSpecular_GI(o, giInput, gi);
|
||||||
|
|
||||||
|
// call lighting function to output g-buffer
|
||||||
|
outEmission = LightingStandardSpecular_Deferred (o, worldViewDir, gi, outGBuffer0, outGBuffer1, outGBuffer2);
|
||||||
|
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
||||||
|
outShadowMask = UnityGetRawBakedOcclusions (IN.lmap.xy, d.worldSpacePosition);
|
||||||
|
#endif
|
||||||
|
#ifndef UNITY_HDR_ON
|
||||||
|
outEmission.rgb = exp2(-outEmission.rgb);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
LightingStandard_GI(o, giInput, gi);
|
||||||
|
|
||||||
|
// call lighting function to output g-buffer
|
||||||
|
outEmission = LightingStandard_Deferred (o, worldViewDir, gi, outGBuffer0, outGBuffer1, outGBuffer2);
|
||||||
|
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
||||||
|
outShadowMask = UnityGetRawBakedOcclusions (IN.lmap.xy, d.worldSpacePosition);
|
||||||
|
#endif
|
||||||
|
#ifndef UNITY_HDR_ON
|
||||||
|
outEmission.rgb = exp2(-outEmission.rgb);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(SHADOWS_SHADOWMASK) && (UNITY_ALLOWED_MRT_COUNT > 4)
|
||||||
|
ChainFinalGBufferStandard(l, d, outGBuffer0, outGBuffer1, outGBuffer2, outEmission, outShadowMask);
|
||||||
|
#else
|
||||||
|
half4 outShadowMask = 0;
|
||||||
|
ChainFinalGBufferStandard(l, d, outGBuffer0, outGBuffer1, outGBuffer2, outEmission, outShadowMask);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@@ -0,0 +1,197 @@
|
|||||||
|
|
||||||
|
// ---- meta information extraction pass:
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "Meta"
|
||||||
|
Tags { "LightMode" = "Meta" }
|
||||||
|
Cull Off
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
|
||||||
|
%PRAGMAS%
|
||||||
|
|
||||||
|
// compile directives
|
||||||
|
#pragma target %SHADERTARGET%
|
||||||
|
#pragma multi_compile_instancing
|
||||||
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
||||||
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
||||||
|
#pragma shader_feature EDITOR_VISUALIZATION
|
||||||
|
|
||||||
|
#include "HLSLSupport.cginc"
|
||||||
|
#include "UnityShaderVariables.cginc"
|
||||||
|
#include "UnityShaderUtilities.cginc"
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
#define _PASSMETA 1
|
||||||
|
|
||||||
|
%DEFINES%
|
||||||
|
|
||||||
|
#if _NOMINDIELETRIC
|
||||||
|
// for Standard
|
||||||
|
#ifdef unity_ColorSpaceDielectricSpec
|
||||||
|
#undef unity_ColorSpaceDielectricSpec
|
||||||
|
#endif
|
||||||
|
#define unity_ColorSpaceDielectricSpec half4(0,0,0,1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "Lighting.cginc"
|
||||||
|
#include "UnityPBSLighting.cginc"
|
||||||
|
#include "UnityMetaPass.cginc"
|
||||||
|
|
||||||
|
|
||||||
|
#if _MICROTERRAIN && !_TERRAINBLENDABLESHADER
|
||||||
|
#define UNITY_ASSUME_UNIFORM_SCALING
|
||||||
|
#define UNITY_DONT_INSTANCE_OBJECT_MATRICES
|
||||||
|
#define UNITY_INSTANCED_LOD_FADE
|
||||||
|
#else
|
||||||
|
#define UNITY_INSTANCED_LOD_FADE
|
||||||
|
#define UNITY_INSTANCED_SH
|
||||||
|
#define UNITY_INSTANCED_LIGHTMAPSTS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// data across stages, stripped like the above.
|
||||||
|
struct VertexToPixel
|
||||||
|
{
|
||||||
|
UNITY_POSITION(pos);
|
||||||
|
float3 worldPos : TEXCOORD0;
|
||||||
|
float3 worldNormal : TEXCOORD1;
|
||||||
|
float4 worldTangent : TEXCOORD2;
|
||||||
|
%UV0% float4 texcoord0 : TEXCCOORD3;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
%UV1% float4 texcoord1 : TEXCCOORD4;
|
||||||
|
%UV2% float4 texcoord2 : TEXCCOORD5;
|
||||||
|
#endif
|
||||||
|
%UV3% float4 texcoord3 : TEXCCOORD6;
|
||||||
|
%SCREENPOS% float4 screenPos : TEXCOORD7;
|
||||||
|
%VERTEXCOLOR% float4 vertexColor : COLOR;
|
||||||
|
#ifdef EDITOR_VISUALIZATION
|
||||||
|
float2 vizUV : TEXCOORD8;
|
||||||
|
float4 lightCoord : TEXCOORD9;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
%EXTRAV2F0% float4 extraV2F0 : TEXCOORD10;
|
||||||
|
%EXTRAV2F1% float4 extraV2F1 : TEXCOORD11;
|
||||||
|
%EXTRAV2F2% float4 extraV2F2 : TEXCOORD12;
|
||||||
|
%EXTRAV2F3% float4 extraV2F3 : TEXCOORD13;
|
||||||
|
%EXTRAV2F4% float4 extraV2F4 : TEXCOORD14;
|
||||||
|
%EXTRAV2F5% float4 extraV2F5 : TEXCOORD15;
|
||||||
|
%EXTRAV2F6% float4 extraV2F6 : TEXCOORD16;
|
||||||
|
%EXTRAV2F7% float4 extraV2F7 : TEXCOORD17;
|
||||||
|
|
||||||
|
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
%TEMPLATE_SHARED%
|
||||||
|
|
||||||
|
%CBUFFER%
|
||||||
|
|
||||||
|
%CODE%
|
||||||
|
|
||||||
|
%SHADERDESC%
|
||||||
|
|
||||||
|
// vertex shader
|
||||||
|
VertexToPixel Vert (VertexData v)
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
VertexToPixel o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(VertexToPixel,o);
|
||||||
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
|
|
||||||
|
#if !_TESSELLATION_ON
|
||||||
|
ChainModifyVertex(v, o);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
float2 uv1 = v.texcoord1.xy;
|
||||||
|
float2 uv2 = v.texcoord2.xy;
|
||||||
|
#else
|
||||||
|
float2 uv1 = v.texcoord0.xy;
|
||||||
|
float2 uv2 = uv1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
o.pos = UnityMetaVertexPosition(v.vertex, uv1, uv2, unity_LightmapST, unity_DynamicLightmapST);
|
||||||
|
|
||||||
|
#ifdef EDITOR_VISUALIZATION
|
||||||
|
o.vizUV = 0;
|
||||||
|
o.lightCoord = 0;
|
||||||
|
if (unity_VisualizationMode == EDITORVIZ_TEXTURE)
|
||||||
|
o.vizUV = UnityMetaVizUV(unity_EditorViz_UVIndex, v.texcoord0.xy, uv1, uv2, unity_EditorViz_Texture_ST);
|
||||||
|
else if (unity_VisualizationMode == EDITORVIZ_SHOWLIGHTMASK)
|
||||||
|
{
|
||||||
|
o.vizUV = uv1 * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||||
|
o.lightCoord = mul(unity_EditorViz_WorldToLight, mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
%UV0% o.texcoord0 = v.texcoord0;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
%UV1% o.texcoord1 = v.texcoord1;
|
||||||
|
%UV2% o.texcoord2 = v.texcoord2;
|
||||||
|
#endif
|
||||||
|
%UV3% o.texcoord3 = v.texcoord3;
|
||||||
|
%VERTEXCOLOR% o.vertexColor = v.vertexColor;
|
||||||
|
%SCREENPOS% o.screenPos = ComputeScreenPos(o.pos);
|
||||||
|
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||||
|
o.worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
o.worldTangent.xyz = UnityObjectToWorldDir(v.tangent.xyz);
|
||||||
|
fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
|
||||||
|
o.worldTangent.w = tangentSign;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// MS Only
|
||||||
|
ApplyTerrainTangent(o);
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
%TESSELLATION%
|
||||||
|
|
||||||
|
// fragment shader
|
||||||
|
fixed4 Frag (VertexToPixel IN) : SV_Target
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(IN);
|
||||||
|
|
||||||
|
#ifdef FOG_COMBINED_WITH_TSPACE
|
||||||
|
UNITY_EXTRACT_FOG_FROM_TSPACE(IN);
|
||||||
|
#elif defined (FOG_COMBINED_WITH_WORLD_POS)
|
||||||
|
UNITY_EXTRACT_FOG_FROM_WORLD_POS(IN);
|
||||||
|
#else
|
||||||
|
UNITY_EXTRACT_FOG(IN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ShaderData d = CreateShaderData(IN);
|
||||||
|
|
||||||
|
Surface l = (Surface)0;
|
||||||
|
|
||||||
|
l.Albedo = half3(0.5, 0.5, 0.5);
|
||||||
|
l.Normal = float3(0,0,1);
|
||||||
|
l.Occlusion = 1;
|
||||||
|
l.Alpha = 1;
|
||||||
|
|
||||||
|
|
||||||
|
ChainSurfaceFunction(l, d);
|
||||||
|
|
||||||
|
UnityMetaInput metaIN;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(UnityMetaInput, metaIN);
|
||||||
|
metaIN.Albedo = l.Albedo;
|
||||||
|
metaIN.Emission = l.Emission;
|
||||||
|
|
||||||
|
#if _USESPECULAR
|
||||||
|
metaIN.SpecularColor = l.Specular;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef EDITOR_VISUALIZATION
|
||||||
|
metaIN.VizUV = IN.vizUV;
|
||||||
|
metaIN.LightCoord = IN.lightCoord;
|
||||||
|
#endif
|
||||||
|
return UnityMetaFragment(metaIN);
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,155 @@
|
|||||||
|
|
||||||
|
Pass {
|
||||||
|
Name "ShadowCaster"
|
||||||
|
Tags { "LightMode" = "ShadowCaster" }
|
||||||
|
ZWrite On ZTest LEqual
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
|
||||||
|
%PRAGMAS%
|
||||||
|
// compile directives
|
||||||
|
#pragma target %SHADERTARGET%
|
||||||
|
#pragma multi_compile_instancing
|
||||||
|
#pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
|
||||||
|
#pragma multi_compile_shadowcaster
|
||||||
|
#pragma multi_compile_local __ _ALPHATEST_ON
|
||||||
|
#include "HLSLSupport.cginc"
|
||||||
|
#include "UnityShaderVariables.cginc"
|
||||||
|
#include "UnityShaderUtilities.cginc"
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "Lighting.cginc"
|
||||||
|
#include "UnityPBSLighting.cginc"
|
||||||
|
|
||||||
|
#define _PASSSHADOW 1
|
||||||
|
|
||||||
|
%DEFINES%
|
||||||
|
|
||||||
|
#if _MICROTERRAIN && !_TERRAINBLENDABLESHADER
|
||||||
|
#define UNITY_ASSUME_UNIFORM_SCALING
|
||||||
|
#define UNITY_DONT_INSTANCE_OBJECT_MATRICES
|
||||||
|
#define UNITY_INSTANCED_LOD_FADE
|
||||||
|
#else
|
||||||
|
#define UNITY_INSTANCED_LOD_FADE
|
||||||
|
#define UNITY_INSTANCED_SH
|
||||||
|
#define UNITY_INSTANCED_LIGHTMAPSTS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// data across stages, stripped like the above.
|
||||||
|
struct VertexToPixel
|
||||||
|
{
|
||||||
|
V2F_SHADOW_CASTER;
|
||||||
|
float3 worldPos : TEXCOORD0;
|
||||||
|
float3 worldNormal : TEXCOORD1;
|
||||||
|
float4 worldTangent : TEXCOORD2;
|
||||||
|
%UV0% float4 texcoord0 : TEXCCOORD3;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
%UV1% float4 texcoord1 : TEXCCOORD4;
|
||||||
|
%UV2% float4 texcoord2 : TEXCCOORD5;
|
||||||
|
#endif
|
||||||
|
%UV3% float4 texcoord3 : TEXCCOORD6;
|
||||||
|
%SCREENPOS% float4 screenPos : TEXCOORD7;
|
||||||
|
%VERTEXCOLOR% float4 vertexColor : COLOR;
|
||||||
|
|
||||||
|
%EXTRAV2F0% float4 extraV2F0 : TEXCOORD8;
|
||||||
|
%EXTRAV2F1% float4 extraV2F1 : TEXCOORD9;
|
||||||
|
%EXTRAV2F2% float4 extraV2F2 : TEXCOORD10;
|
||||||
|
%EXTRAV2F3% float4 extraV2F3 : TEXCOORD11;
|
||||||
|
%EXTRAV2F4% float4 extraV2F4 : TEXCOORD12;
|
||||||
|
%EXTRAV2F5% float4 extraV2F5 : TEXCOORD13;
|
||||||
|
%EXTRAV2F6% float4 extraV2F6 : TEXCOORD14;
|
||||||
|
%EXTRAV2F7% float4 extraV2F7 : TEXCOORD15;
|
||||||
|
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
%TEMPLATE_SHARED%
|
||||||
|
|
||||||
|
%CBUFFER%
|
||||||
|
|
||||||
|
%CODE%
|
||||||
|
|
||||||
|
%SHADERDESC%
|
||||||
|
|
||||||
|
|
||||||
|
// vertex shader
|
||||||
|
VertexToPixel Vert (VertexData v)
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
VertexToPixel o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(VertexToPixel,o);
|
||||||
|
UNITY_TRANSFER_INSTANCE_ID(v,o);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
|
|
||||||
|
#if !_TESSELLATION_ON
|
||||||
|
ChainModifyVertex(v, o);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
%UV0% o.texcoord0 = v.texcoord0;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
%UV1% o.texcoord1 = v.texcoord1;
|
||||||
|
%UV2% o.texcoord2 = v.texcoord2;
|
||||||
|
#endif
|
||||||
|
%UV3% o.texcoord3 = v.texcoord3;
|
||||||
|
%VERTEXCOLOR% o.vertexColor = v.vertexColor;
|
||||||
|
|
||||||
|
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
|
||||||
|
o.worldNormal = UnityObjectToWorldNormal(v.normal);
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
o.worldTangent.xyz = UnityObjectToWorldDir(v.tangent.xyz);
|
||||||
|
fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
|
||||||
|
o.worldTangent.w = tangentSign;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// MS Only
|
||||||
|
ApplyTerrainTangent(o);
|
||||||
|
|
||||||
|
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
|
||||||
|
|
||||||
|
%SCREENPOS% o.screenPos = ComputeScreenPos(o.pos);
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
%TESSELLATION%
|
||||||
|
|
||||||
|
// fragment shader
|
||||||
|
fixed4 Frag (VertexToPixel IN) : SV_Target
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(IN);
|
||||||
|
// prepare and unpack data
|
||||||
|
|
||||||
|
#ifdef FOG_COMBINED_WITH_TSPACE
|
||||||
|
UNITY_EXTRACT_FOG_FROM_TSPACE(IN);
|
||||||
|
#elif defined (FOG_COMBINED_WITH_WORLD_POS)
|
||||||
|
UNITY_EXTRACT_FOG_FROM_WORLD_POS(IN);
|
||||||
|
#else
|
||||||
|
UNITY_EXTRACT_FOG(IN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef USING_DIRECTIONAL_LIGHT
|
||||||
|
fixed3 lightDir = normalize(UnityWorldSpaceLightDir(IN.worldPos));
|
||||||
|
#else
|
||||||
|
fixed3 lightDir = _WorldSpaceLightPos0.xyz;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ShaderData d = CreateShaderData(IN);
|
||||||
|
|
||||||
|
Surface l = (Surface)0;
|
||||||
|
|
||||||
|
l.Albedo = half3(0.5, 0.5, 0.5);
|
||||||
|
l.Normal = float3(0,0,1);
|
||||||
|
l.Occlusion = 1;
|
||||||
|
l.Alpha = 1;
|
||||||
|
|
||||||
|
ChainSurfaceFunction(l, d);
|
||||||
|
|
||||||
|
SHADOW_CASTER_FRAGMENT(IN)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,72 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#if _MESHSUBARRAY
|
||||||
|
half4 _MeshSubArrayIndexes;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float4 _Diffuse_TexelSize;
|
||||||
|
float4 _NormalSAO_TexelSize;
|
||||||
|
|
||||||
|
#if _HYBRIDHEIGHTBLEND
|
||||||
|
float _HybridHeightBlendDistance;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _PACKINGHQ
|
||||||
|
float4 _SmoothAO_TexelSize;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _ALPHATEST_ON
|
||||||
|
float4 _TerrainHolesTexture_TexelSize;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _USESPECULARWORKFLOW
|
||||||
|
float4 _Specular_TexelSize;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _USEEMISSIVEMETAL
|
||||||
|
float4 _EmissiveMetal_TexelSize;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _USEEMISSIVEMETAL
|
||||||
|
half _EmissiveMult;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _AUTONORMAL
|
||||||
|
half _AutoNormalHeightScale;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float4 _UVScale; // scale and offset
|
||||||
|
|
||||||
|
half _Contrast;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if _VSSHADOWMAP
|
||||||
|
float4 gVSSunDirection;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _FORCELOCALSPACE && _PLANETVECTORS
|
||||||
|
float4x4 _PQSToLocal;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _ORIGINSHIFT
|
||||||
|
float4x4 _GlobalOriginMTX;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float4 _Control0_TexelSize;
|
||||||
|
#if _CUSTOMSPLATTEXTURES
|
||||||
|
float4 _CustomControl0_TexelSize;
|
||||||
|
#endif
|
||||||
|
float4 _PerPixelNormal_TexelSize;
|
||||||
|
|
||||||
|
#if _CONTROLNOISEUV || _GLOBALNOISEUV
|
||||||
|
float2 _NoiseUVParams;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float4 _PerTexProps_TexelSize;
|
||||||
|
|
||||||
|
#if _SURFACENORMALS
|
||||||
|
float3 surfTangent;
|
||||||
|
float3 surfBitangent;
|
||||||
|
float3 surfNormal;
|
||||||
|
#endif
|
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
|
||||||
|
// Splats
|
||||||
|
[NoScaleOffset]_Diffuse ("Diffuse Array", 2DArray) = "white" {}
|
||||||
|
[NoScaleOffset]_NormalSAO ("Normal Array", 2DArray) = "bump" {}
|
||||||
|
[NoScaleOffset]_PerTexProps("Per Texture Properties", 2D) = "black" {}
|
||||||
|
[HideInInspector] _TerrainHolesTexture("Holes Map (RGB)", 2D) = "white" {}
|
||||||
|
[HideInInspector] _PerPixelNormal("Per Pixel Normal", 2D) = "bump" {}
|
||||||
|
_Contrast("Blend Contrast", Range(0.01, 0.99)) = 0.4
|
||||||
|
_UVScale("UV Scales", Vector) = (45, 45, 0, 0)
|
||||||
|
|
||||||
|
// for Unity 2020.3 bug
|
||||||
|
_MainTex("Unity Bug", 2D) = "white" {}
|
||||||
|
|
||||||
|
_TerrainHeightmapTexture("", 2D) = "black" {}
|
||||||
|
_TerrainNormalmapTexture("", 2D) = "bump" {}
|
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#undef WorldNormalVector
|
||||||
|
#define WorldNormalVector(data, normal) mul(normal, data.TBN)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -0,0 +1,51 @@
|
|||||||
|
// CHAINS
|
||||||
|
|
||||||
|
void ChainModifyVertex(inout VertexData v, inout VertexToPixel v2p)
|
||||||
|
{
|
||||||
|
ExtraV2F d = (ExtraV2F)0;
|
||||||
|
ModifyVertex(v, d);
|
||||||
|
|
||||||
|
%EXTRAV2F0% v2p.extraV2F0 = d.extraV2F0;
|
||||||
|
%EXTRAV2F1% v2p.extraV2F1 = d.extraV2F1;
|
||||||
|
%EXTRAV2F2% v2p.extraV2F2 = d.extraV2F2;
|
||||||
|
%EXTRAV2F3% v2p.extraV2F3 = d.extraV2F3;
|
||||||
|
%EXTRAV2F4% v2p.extraV2F4 = d.extraV2F4;
|
||||||
|
%EXTRAV2F5% v2p.extraV2F5 = d.extraV2F5;
|
||||||
|
%EXTRAV2F6% v2p.extraV2F6 = d.extraV2F6;
|
||||||
|
%EXTRAV2F7% v2p.extraV2F7 = d.extraV2F7;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChainModifyTessellatedVertex(inout VertexData v, inout VertexToPixel v2p)
|
||||||
|
{
|
||||||
|
ExtraV2F d = (ExtraV2F)0;
|
||||||
|
%EXTRAV2F0% d.extraV2F0 = v2p.extraV2F0;
|
||||||
|
%EXTRAV2F1% d.extraV2F1 = v2p.extraV2F1;
|
||||||
|
%EXTRAV2F2% d.extraV2F2 = v2p.extraV2F2;
|
||||||
|
%EXTRAV2F3% d.extraV2F3 = v2p.extraV2F3;
|
||||||
|
%EXTRAV2F4% d.extraV2F4 = v2p.extraV2F4;
|
||||||
|
%EXTRAV2F5% d.extraV2F5 = v2p.extraV2F5;
|
||||||
|
%EXTRAV2F6% d.extraV2F6 = v2p.extraV2F6;
|
||||||
|
%EXTRAV2F7% d.extraV2F7 = v2p.extraV2F7;
|
||||||
|
|
||||||
|
ModifyTessellatedVertex(v, d);
|
||||||
|
|
||||||
|
%EXTRAV2F0% v2p.extraV2F0 = d.extraV2F0;
|
||||||
|
%EXTRAV2F1% v2p.extraV2F1 = d.extraV2F1;
|
||||||
|
%EXTRAV2F2% v2p.extraV2F2 = d.extraV2F2;
|
||||||
|
%EXTRAV2F3% v2p.extraV2F3 = d.extraV2F3;
|
||||||
|
%EXTRAV2F4% v2p.extraV2F4 = d.extraV2F4;
|
||||||
|
%EXTRAV2F5% v2p.extraV2F5 = d.extraV2F5;
|
||||||
|
%EXTRAV2F6% v2p.extraV2F6 = d.extraV2F6;
|
||||||
|
%EXTRAV2F7% v2p.extraV2F7 = d.extraV2F7;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ChainFinalColorForward(inout Surface l, inout ShaderData d, inout half4 color)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChainFinalGBufferStandard(inout Surface s, inout ShaderData d, inout half4 GBuffer0, inout half4 GBuffer1, inout half4 GBuffer2, inout half4 outEmission, inout half4 outShadowMask)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,47 @@
|
|||||||
|
// SHADERDESC
|
||||||
|
|
||||||
|
ShaderData CreateShaderData(VertexToPixel i)
|
||||||
|
{
|
||||||
|
ShaderData d = (ShaderData)0;
|
||||||
|
d.worldSpacePosition = i.worldPos;
|
||||||
|
|
||||||
|
d.worldSpaceNormal = i.worldNormal;
|
||||||
|
d.worldSpaceTangent = i.worldTangent.xyz;
|
||||||
|
float3 bitangent = cross(i.worldTangent.xyz, i.worldNormal) * i.worldTangent.w * -1;
|
||||||
|
|
||||||
|
|
||||||
|
d.TBNMatrix = float3x3(d.worldSpaceTangent, bitangent, d.worldSpaceNormal);
|
||||||
|
d.worldSpaceViewDir = normalize(_WorldSpaceCameraPos - i.worldPos);
|
||||||
|
d.tangentSpaceViewDir = mul(d.worldSpaceViewDir, d.TBNMatrix);
|
||||||
|
%UV0% d.texcoord0 = i.texcoord0;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
%UV1% d.texcoord1 = i.texcoord1;
|
||||||
|
%UV2% d.texcoord2 = i.texcoord2;
|
||||||
|
#endif
|
||||||
|
%UV3% d.texcoord3 = i.texcoord3;
|
||||||
|
%VERTEXCOLOR% d.vertexColor = i.vertexColor;
|
||||||
|
|
||||||
|
// these rarely get used, so we back transform them. Usually will be stripped.
|
||||||
|
#if _HDRP
|
||||||
|
%LOCALSPACEPOSITION% d.localSpacePosition = mul(unity_WorldToObject, float4(GetCameraRelativePositionWS(i.worldPos), 1));
|
||||||
|
#else
|
||||||
|
%LOCALSPACEPOSITION% d.localSpacePosition = mul(unity_WorldToObject, float4(i.worldPos, 1));
|
||||||
|
#endif
|
||||||
|
%LOCALSPACENORMAL% d.localSpaceNormal = normalize(mul((float3x3)unity_WorldToObject, i.worldNormal));
|
||||||
|
%LOCALSPACETANGENT% d.localSpaceTangent = normalize(mul((float3x3)unity_WorldToObject, i.worldTangent.xyz));
|
||||||
|
|
||||||
|
%SCREENPOS% d.screenPos = i.screenPos;
|
||||||
|
%SCREENPOS% d.screenUV = i.screenPos.xy / i.screenPos.w;
|
||||||
|
|
||||||
|
%EXTRAV2F0% d.extraV2F0 = i.extraV2F0;
|
||||||
|
%EXTRAV2F1% d.extraV2F1 = i.extraV2F1;
|
||||||
|
%EXTRAV2F2% d.extraV2F2 = i.extraV2F2;
|
||||||
|
%EXTRAV2F3% d.extraV2F3 = i.extraV2F3;
|
||||||
|
%EXTRAV2F4% d.extraV2F4 = i.extraV2F4;
|
||||||
|
%EXTRAV2F5% d.extraV2F5 = i.extraV2F5;
|
||||||
|
%EXTRAV2F6% d.extraV2F6 = i.extraV2F6;
|
||||||
|
%EXTRAV2F7% d.extraV2F7 = i.extraV2F7;
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
@@ -0,0 +1,229 @@
|
|||||||
|
// TEMPLATE_SHARED
|
||||||
|
|
||||||
|
// data describing the user output of a pixel
|
||||||
|
struct Surface
|
||||||
|
{
|
||||||
|
half3 Albedo;
|
||||||
|
half Height;
|
||||||
|
half3 Normal;
|
||||||
|
half Smoothness;
|
||||||
|
half3 Emission;
|
||||||
|
half Metallic;
|
||||||
|
half3 Specular;
|
||||||
|
half Occlusion;
|
||||||
|
half Alpha;
|
||||||
|
// HDRP Only
|
||||||
|
half SpecularOcclusion;
|
||||||
|
half SubsurfaceMask;
|
||||||
|
half Thickness;
|
||||||
|
half CoatMask;
|
||||||
|
half Anisotropy;
|
||||||
|
half IridescenceMask;
|
||||||
|
half IridescenceThickness;
|
||||||
|
};
|
||||||
|
|
||||||
|
// data the user might need, this will grow to be big. But easy to strip
|
||||||
|
struct ShaderData
|
||||||
|
{
|
||||||
|
float3 localSpacePosition;
|
||||||
|
float3 localSpaceNormal;
|
||||||
|
float3 localSpaceTangent;
|
||||||
|
|
||||||
|
float3 worldSpacePosition;
|
||||||
|
float3 worldSpaceNormal;
|
||||||
|
float3 worldSpaceTangent;
|
||||||
|
|
||||||
|
float3 worldSpaceViewDir;
|
||||||
|
float3 tangentSpaceViewDir;
|
||||||
|
|
||||||
|
float4 texcoord0;
|
||||||
|
float4 texcoord1;
|
||||||
|
float4 texcoord2;
|
||||||
|
float4 texcoord3;
|
||||||
|
|
||||||
|
float2 screenUV;
|
||||||
|
float4 screenPos;
|
||||||
|
|
||||||
|
float4 vertexColor;
|
||||||
|
|
||||||
|
float4 extraV2F0;
|
||||||
|
float4 extraV2F1;
|
||||||
|
float4 extraV2F2;
|
||||||
|
float4 extraV2F3;
|
||||||
|
float4 extraV2F4;
|
||||||
|
float4 extraV2F5;
|
||||||
|
float4 extraV2F6;
|
||||||
|
float4 extraV2F7;
|
||||||
|
|
||||||
|
float3x3 TBNMatrix;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VertexData
|
||||||
|
{
|
||||||
|
#if SHADER_TARGET > 30 && _PLANETCOMPUTE
|
||||||
|
// %VERTEXID% uint vertexID : SV_VertexID;
|
||||||
|
#endif
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
float4 texcoord0 : TEXCOORD0;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
float4 tangent : TANGENT;
|
||||||
|
float4 texcoord1 : TEXCOORD1;
|
||||||
|
float4 texcoord2 : TEXCOORD2;
|
||||||
|
#endif
|
||||||
|
%UV3% float4 texcoord3 : TEXCOORD3;
|
||||||
|
%VERTEXCOLOR% float4 vertexColor : COLOR;
|
||||||
|
|
||||||
|
|
||||||
|
#if _HDRP && (_PASSMOTIONVECTOR || (_PASSFORWARD && defined(_WRITE_TRANSPARENT_MOTION_VECTOR)))
|
||||||
|
float3 previousPositionOS : TEXCOORD4; // Contain previous transform position (in case of skinning for example)
|
||||||
|
#if defined (_ADD_PRECOMPUTED_VELOCITY)
|
||||||
|
float3 precomputedVelocity : TEXCOORD5; // Add Precomputed Velocity (Alembic computes velocities on runtime side).
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TessVertex
|
||||||
|
{
|
||||||
|
float4 vertex : INTERNALTESSPOS;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
float4 texcoord0 : TEXCOORD0;
|
||||||
|
#if !_MICROTERRAIN || _TERRAINBLENDABLESHADER
|
||||||
|
float4 tangent : TANGENT;
|
||||||
|
float4 texcoord1 : TEXCOORD1;
|
||||||
|
float4 texcoord2 : TEXCOORD2;
|
||||||
|
#endif
|
||||||
|
%UV3% float4 texcoord3 : TEXCOORD3;
|
||||||
|
%VERTEXCOLOR% float4 vertexColor : COLOR;
|
||||||
|
|
||||||
|
|
||||||
|
%EXTRAV2F0% float4 extraV2F0 : TEXCOORD4;
|
||||||
|
%EXTRAV2F1% float4 extraV2F1 : TEXCOORD5;
|
||||||
|
%EXTRAV2F2% float4 extraV2F2 : TEXCOORD6;
|
||||||
|
%EXTRAV2F3% float4 extraV2F3 : TEXCOORD7;
|
||||||
|
%EXTRAV2F4% float4 extraV2F4 : TEXCOORD8;
|
||||||
|
%EXTRAV2F5% float4 extraV2F5 : TEXCOORD9;
|
||||||
|
%EXTRAV2F6% float4 extraV2F6 : TEXCOORD10;
|
||||||
|
%EXTRAV2F7% float4 extraV2F7 : TEXCOORD11;
|
||||||
|
|
||||||
|
#if _HDRP && (_PASSMOTIONVECTOR || (_PASSFORWARD && defined(_WRITE_TRANSPARENT_MOTION_VECTOR)))
|
||||||
|
float3 previousPositionOS : TEXCOORD12; // Contain previous transform position (in case of skinning for example)
|
||||||
|
#if defined (_ADD_PRECOMPUTED_VELOCITY)
|
||||||
|
float3 precomputedVelocity : TEXCOORD13;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ExtraV2F
|
||||||
|
{
|
||||||
|
float4 extraV2F0;
|
||||||
|
float4 extraV2F1;
|
||||||
|
float4 extraV2F2;
|
||||||
|
float4 extraV2F3;
|
||||||
|
float4 extraV2F4;
|
||||||
|
float4 extraV2F5;
|
||||||
|
float4 extraV2F6;
|
||||||
|
float4 extraV2F7;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
float3 WorldToTangentSpace(ShaderData d, float3 normal)
|
||||||
|
{
|
||||||
|
return mul(d.TBNMatrix, normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 TangentToWorldSpace(ShaderData d, float3 normal)
|
||||||
|
{
|
||||||
|
return mul(normal, d.TBNMatrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
// in this case, make standard more like SRPs, because we can't fix
|
||||||
|
// unity_WorldToObject in HDRP, since it already does macro-fu there
|
||||||
|
|
||||||
|
#if _STANDARD
|
||||||
|
float3 TransformWorldToObject(float3 p) { return mul(unity_WorldToObject, float4(p, 1)); };
|
||||||
|
float3 TransformObjectToWorld(float3 p) { return mul(unity_ObjectToWorld, float4(p, 1)); };
|
||||||
|
float4 TransformWorldToObject(float4 p) { return mul(unity_WorldToObject, p); };
|
||||||
|
float4 TransformObjectToWorld(float4 p) { return mul(unity_ObjectToWorld, p); };
|
||||||
|
float4x4 GetWorldToObjectMatrix() { return unity_WorldToObject; }
|
||||||
|
float4x4 GetObjectToWorldMatrix() { return unity_ObjectToWorld; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float3 GetCameraWorldPosition()
|
||||||
|
{
|
||||||
|
#if _HDRP
|
||||||
|
return GetCameraRelativePositionWS(_WorldSpaceCameraPos);
|
||||||
|
#else
|
||||||
|
return _WorldSpaceCameraPos;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if _HDRP
|
||||||
|
|
||||||
|
half3 UnpackNormalmapRGorAG(half4 packednormal)
|
||||||
|
{
|
||||||
|
// This do the trick
|
||||||
|
packednormal.x *= packednormal.w;
|
||||||
|
|
||||||
|
half3 normal;
|
||||||
|
normal.xy = packednormal.xy * 2 - 1;
|
||||||
|
normal.z = sqrt(1 - saturate(dot(normal.xy, normal.xy)));
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
|
half3 UnpackNormal(half4 packednormal)
|
||||||
|
{
|
||||||
|
#if defined(UNITY_NO_DXT5nm)
|
||||||
|
return packednormal.xyz * 2 - 1;
|
||||||
|
#else
|
||||||
|
return UnpackNormalmapRGorAG(packednormal);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if _HDRP || _URP
|
||||||
|
|
||||||
|
half3 UnpackScaleNormal(half4 packednormal, half scale)
|
||||||
|
{
|
||||||
|
#ifndef UNITY_NO_DXT5nm
|
||||||
|
// Unpack normal as DXT5nm (1, y, 1, x) or BC5 (x, y, 0, 1)
|
||||||
|
// Note neutral texture like "bump" is (0, 0, 1, 1) to work with both plain RGB normal and DXT5nm/BC5
|
||||||
|
packednormal.x *= packednormal.w;
|
||||||
|
#endif
|
||||||
|
half3 normal;
|
||||||
|
normal.xy = (packednormal.xy * 2 - 1) * scale;
|
||||||
|
normal.z = sqrt(1 - saturate(dot(normal.xy, normal.xy)));
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void GetSun(out float3 lightDir, out float3 color)
|
||||||
|
{
|
||||||
|
lightDir = float3(0.5, 0.5, 0);
|
||||||
|
color = 1;
|
||||||
|
#if _HDRP
|
||||||
|
if (_DirectionalLightCount > 0)
|
||||||
|
{
|
||||||
|
DirectionalLightData light = _DirectionalLightDatas[0];
|
||||||
|
lightDir = -light.forward.xyz;
|
||||||
|
color = light.color;
|
||||||
|
}
|
||||||
|
#elif _STANDARD
|
||||||
|
lightDir = normalize(_WorldSpaceLightPos0.xyz);
|
||||||
|
color = _LightColor0.rgb;
|
||||||
|
#elif _URP
|
||||||
|
Light light = GetMainLight();
|
||||||
|
lightDir = light.direction;
|
||||||
|
color = light.color;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -0,0 +1,103 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void SurfaceFunction(inout Surface o, inout ShaderData d)
|
||||||
|
{
|
||||||
|
|
||||||
|
float3 worldNormalVertex = d.worldSpaceNormal;
|
||||||
|
#if _MICROVERSEPREVIEW
|
||||||
|
float2 sampleCoords = d.texcoord0.xy;
|
||||||
|
#if _TOONHARDEDGENORMAL
|
||||||
|
sampleCoords = ToonEdgeUV(d.texcoord0.xy);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float3 geomNormal = normalize(SAMPLE_TEXTURE2D(_TerrainNormalmapTexture, shared_linear_clamp_sampler, sampleCoords).xyz * 2 - 1);
|
||||||
|
float3 geomTangent = normalize(cross(geomNormal, float3(0, 0, 1)));
|
||||||
|
float3 geomBitangent = normalize(cross(geomNormal, geomTangent)) * -1;
|
||||||
|
worldNormalVertex = geomNormal;
|
||||||
|
d.worldSpaceNormal = geomNormal;
|
||||||
|
d.worldSpaceTangent = geomTangent;
|
||||||
|
|
||||||
|
d.TBNMatrix = float3x3(geomTangent, geomBitangent, geomNormal);
|
||||||
|
d.tangentSpaceViewDir = mul(d.worldSpaceViewDir, d.TBNMatrix);
|
||||||
|
|
||||||
|
#elif (defined(UNITY_INSTANCING_ENABLED) && _MICROTERRAIN && !_TERRAINBLENDABLESHADER)
|
||||||
|
float2 sampleCoords = (d.texcoord0.xy / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy;
|
||||||
|
#if _TOONHARDEDGENORMAL
|
||||||
|
sampleCoords = ToonEdgeUV(d.texcoord0.xy);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float3 geomNormal = normalize(SAMPLE_TEXTURE2D(_TerrainNormalmapTexture, shared_linear_clamp_sampler, sampleCoords).xyz * 2 - 1);
|
||||||
|
float3 geomTangent = normalize(cross(geomNormal, float3(0, 0, 1)));
|
||||||
|
float3 geomBitangent = normalize(cross(geomNormal, geomTangent)) * -1;
|
||||||
|
worldNormalVertex = geomNormal;
|
||||||
|
d.worldSpaceNormal = geomNormal;
|
||||||
|
d.worldSpaceTangent = geomTangent;
|
||||||
|
|
||||||
|
d.TBNMatrix = float3x3(geomTangent, geomBitangent, geomNormal);
|
||||||
|
d.tangentSpaceViewDir = mul(d.worldSpaceViewDir, d.TBNMatrix);
|
||||||
|
|
||||||
|
#elif _PERPIXNORMAL && (_MICROTERRAIN || _MICROMESHTERRAIN) && !_TERRAINBLENDABLESHADER
|
||||||
|
float2 sampleCoords = (d.texcoord0.xy * _PerPixelNormal_TexelSize.zw + 0.5f) * _PerPixelNormal_TexelSize.xy;
|
||||||
|
#if _TOONHARDEDGENORMAL
|
||||||
|
sampleCoords = ToonEdgeUV(d.texcoord0.xy);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float3 geomNormal = normalize(SAMPLE_TEXTURE2D(_PerPixelNormal, shared_linear_clamp_sampler, sampleCoords).xyz * 2 - 1);
|
||||||
|
|
||||||
|
float3 geomTangent = normalize(cross(geomNormal, float3(0, 0, 1)));
|
||||||
|
|
||||||
|
float3 geomBitangent = normalize(cross(geomTangent, geomNormal)) * -1;
|
||||||
|
#if _MICROMESHTERRAIN
|
||||||
|
geomBitangent *= -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
worldNormalVertex = geomNormal;
|
||||||
|
d.worldSpaceNormal = geomNormal;
|
||||||
|
d.worldSpaceTangent = geomTangent;
|
||||||
|
d.TBNMatrix = float3x3(geomTangent, geomBitangent, geomNormal);
|
||||||
|
d.tangentSpaceViewDir = mul(d.worldSpaceViewDir, d.TBNMatrix);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _TOONPOLYEDGE
|
||||||
|
FlatShade(d);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Input i = DescToInput(d);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if _SRPTERRAINBLEND
|
||||||
|
MicroSplatLayer l = BlendWithTerrain(d);
|
||||||
|
|
||||||
|
#if _DEBUG_WORLDNORMAL
|
||||||
|
ClearAllButAlbedo(l, normalize(TangentToWorldSpace(d, l.Normal)) * saturate(l.Albedo.z+1));
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
MicroSplatLayer l = SurfImpl(i, worldNormalVertex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DoDebugOutput(l);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
o.Albedo = l.Albedo;
|
||||||
|
o.Normal = l.Normal;
|
||||||
|
o.Smoothness = l.Smoothness;
|
||||||
|
o.Occlusion = l.Occlusion;
|
||||||
|
o.Metallic = l.Metallic;
|
||||||
|
o.Emission = l.Emission;
|
||||||
|
#if _USESPECULARWORKFLOW
|
||||||
|
o.Specular = l.Specular;
|
||||||
|
#endif
|
||||||
|
o.Height = l.Height;
|
||||||
|
o.Alpha = l.Alpha;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
|
@@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Input DescToInput(ShaderData IN)
|
||||||
|
{
|
||||||
|
Input s = (Input)0;
|
||||||
|
s.shaderData = IN;
|
||||||
|
s.TBN = IN.TBNMatrix;
|
||||||
|
s.worldNormal = IN.worldSpaceNormal;
|
||||||
|
s.worldPos = IN.worldSpacePosition;
|
||||||
|
s.viewDir = IN.tangentSpaceViewDir;
|
||||||
|
s.uv_Control0 = IN.texcoord0.xy;
|
||||||
|
|
||||||
|
s.worldUpVector = float3(0,1,0);
|
||||||
|
s.worldHeight = IN.worldSpacePosition.y;
|
||||||
|
|
||||||
|
#if _PLANETVECTORS
|
||||||
|
float3 rwp = mul(_PQSToLocal, float4(IN.worldSpacePosition, 1));
|
||||||
|
s.worldHeight = distance(rwp, float3(0,0,0));
|
||||||
|
s.worldUpVector = normalize(rwp);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _MICROMESH && _MESHUV2
|
||||||
|
s.uv2_Diffuse = IN.texcoord1.xy;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _MEGASPLAT
|
||||||
|
UnpackMegaSplat(s, IN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _MICROVERTEXMESH || _MICRODIGGERMESH
|
||||||
|
UnpackVertexWorkflow(s, IN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _PLANETVECTORS
|
||||||
|
DoPlanetDataInputCopy(s, IN);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
@@ -0,0 +1,114 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float4 ConstructTerrainTangent(float3 normal, float3 positiveZ)
|
||||||
|
{
|
||||||
|
// Consider a flat terrain. It should have tangent be (1, 0, 0) and bitangent be (0, 0, 1) as the UV of the terrain grid mesh is a scale of the world XZ position.
|
||||||
|
// In CreateTangentToWorld function (in SpaceTransform.hlsl), it is cross(normal, tangent) * sgn for the bitangent vector.
|
||||||
|
// It is not true in a left-handed coordinate system for the terrain bitangent, if we provide 1 as the tangent.w. It would produce (0, 0, -1) instead of (0, 0, 1).
|
||||||
|
// Also terrain's tangent calculation was wrong in a left handed system because cross((0,0,1), terrainNormalOS) points to the wrong direction as negative X.
|
||||||
|
// Therefore all the 4 xyzw components of the tangent needs to be flipped to correct the tangent frame.
|
||||||
|
// (See TerrainLitData.hlsl - GetSurfaceAndBuiltinData)
|
||||||
|
float3 tangent = normalize(cross(normal, positiveZ));
|
||||||
|
return float4(tangent, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void TerrainInstancing(inout float4 vertex, inout float3 normal, inout float2 uv)
|
||||||
|
{
|
||||||
|
#if _MICROTERRAIN && defined(UNITY_INSTANCING_ENABLED) && !_TERRAINBLENDABLESHADER
|
||||||
|
|
||||||
|
float2 patchVertex = vertex.xy;
|
||||||
|
float4 instanceData = UNITY_ACCESS_INSTANCED_PROP(Terrain, _TerrainPatchInstanceData);
|
||||||
|
|
||||||
|
float2 sampleCoords = (patchVertex.xy + instanceData.xy) * instanceData.z; // (xy + float2(xBase,yBase)) * skipScale
|
||||||
|
uv = sampleCoords * _TerrainHeightmapRecipSize.zw;
|
||||||
|
|
||||||
|
float2 sampleUV = (uv / _TerrainHeightmapRecipSize.zw + 0.5f) * _TerrainHeightmapRecipSize.xy;
|
||||||
|
|
||||||
|
float height = UnpackHeightmap(SAMPLE_TEXTURE2D_LOD(_TerrainHeightmapTexture, shared_linear_clamp_sampler, sampleUV, 0));
|
||||||
|
|
||||||
|
vertex.xz = sampleCoords * _TerrainHeightmapScale.xz;
|
||||||
|
vertex.y = height * _TerrainHeightmapScale.y;
|
||||||
|
|
||||||
|
|
||||||
|
normal = float3(0, 1, 0);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ApplyMeshModification(inout VertexData input)
|
||||||
|
{
|
||||||
|
#if _MICROTERRAIN && !_TERRAINBLENDABLESHADER
|
||||||
|
float2 uv = input.texcoord0.xy;
|
||||||
|
TerrainInstancing(input.vertex, input.normal, uv);
|
||||||
|
input.texcoord0.xy = uv;
|
||||||
|
#endif
|
||||||
|
#if _PERPIXNORMAL && !_TERRAINBLENDABLESHADER
|
||||||
|
input.normal = float3(0,1,0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if _MICROVERSEPREVIEW
|
||||||
|
float4 recipSize = _TerrainHeightmapTexture_TexelSize;
|
||||||
|
recipSize.zw = (1.0f / (_TerrainHeightmapTexture_TexelSize.zw-1));
|
||||||
|
float2 sampleCoords = (input.texcoord0.xy / recipSize.zw + 0.5f) * recipSize.xy;
|
||||||
|
float height = UnpackHeightmap(SAMPLE_TEXTURE2D_LOD(_TerrainHeightmapTexture, shared_linear_clamp_sampler, sampleCoords, 0));
|
||||||
|
input.vertex.xyz += float3(0,1,0) * height * _TerrainHeight * 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// called by the template, so we can remove tangent from VertexData
|
||||||
|
void ApplyTerrainTangent(inout VertexToPixel input)
|
||||||
|
{
|
||||||
|
#if (_MICROTERRAIN || _PERPIXNORMAL) && !_TERRAINBLENDABLESHADER
|
||||||
|
input.worldTangent = ConstructTerrainTangent(input.worldNormal, float3(0, 0, 1));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// digger meshes ain't got no tangent either..
|
||||||
|
#if _MICRODIGGERMESH && !_TERRAINBLENDABLESHADER
|
||||||
|
input.worldTangent = ConstructTerrainTangent(input.worldNormal, float3(0, 0, 1));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ModifyVertex(inout VertexData v, inout ExtraV2F d)
|
||||||
|
{
|
||||||
|
ApplyMeshModification(v);
|
||||||
|
|
||||||
|
#if _MICROVERTEXMESH || _MICRODIGGERMESH
|
||||||
|
EncodeVertexWorkflow(v, d);
|
||||||
|
#elif _MEGASPLAT
|
||||||
|
EncodeMegaSplatVertex(v, d);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ModifyTessellatedVertex(inout VertexData v, inout ExtraV2F d)
|
||||||
|
{
|
||||||
|
#if _MICROVERSEPREVIEW
|
||||||
|
v.vertex.y = OffsetVertex(v, d).y;
|
||||||
|
#elif _TESSDISTANCE || _TESSEDGE
|
||||||
|
v.vertex.xyz += OffsetVertex(v, d);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
float3 GetTessFactors ()
|
||||||
|
{
|
||||||
|
#if _TESSEDGE
|
||||||
|
return float3(_TessData1.x, _TessData1.w, 0);
|
||||||
|
#endif
|
||||||
|
#if _TESSDISTANCE
|
||||||
|
return float3(_TessData2.x, _TessData2.y, _TessData1.x);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -0,0 +1,38 @@
|
|||||||
|
// This contains functions that the MicroSplat compiler explicitly strips so that we
|
||||||
|
// don't add more cruft to the v2f structure. I'm not crazy about the way this is done,
|
||||||
|
// but without BS having a proper code parser this works.. Note that in most cases,
|
||||||
|
// the module system naturally doesn't add code it's not using to the shader, so
|
||||||
|
// the only stuff that has to go here is stuff that happens in the vertex stage.
|
||||||
|
|
||||||
|
|
||||||
|
void UnpackVertexWorkflow(inout Input i, ShaderData d)
|
||||||
|
{
|
||||||
|
i.w0.xy = d.texcoord0.zw;
|
||||||
|
i.w0.zw = d.texcoord1.zw;
|
||||||
|
%MAX8% i.w1 = d.vertexColor;
|
||||||
|
%MAX12% i.w2 = d.extraV2F0;
|
||||||
|
%MAX16% i.w3 = d.extraV2F1;
|
||||||
|
%MAX20% i.w4 = d.extraV2F2;
|
||||||
|
%MAX24% i.w5 = d.extraV2F3;
|
||||||
|
%MAX28% i.w6 = d.extraV2F4;
|
||||||
|
%FX% i.fx = d.extraV2F5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EncodeVertexWorkflow(inout VertexData i, inout ExtraV2F d)
|
||||||
|
{
|
||||||
|
float4 data0 = DecodeToFloat4(i.vertexColor.r);
|
||||||
|
|
||||||
|
|
||||||
|
%MAX12% d.extraV2F0 = DecodeToFloat4(i.vertexColor.b);
|
||||||
|
%MAX16% d.extraV2F1 = DecodeToFloat4(i.vertexColor.a);
|
||||||
|
%MAX8% i.vertexColor = DecodeToFloat4(i.vertexColor.g);
|
||||||
|
|
||||||
|
%MAX20% d.extraV2F2 = DecodeToFloat4(i.texcoord1.z);
|
||||||
|
%MAX24% d.extraV2F3 = DecodeToFloat4(i.texcoord1.w);
|
||||||
|
%MAX28% d.extraV2F4 = DecodeToFloat4(i.texcoord2.z);
|
||||||
|
%FX% d.extraV2F5 = DecodeToFloat4(i.texcoord2.w);
|
||||||
|
|
||||||
|
i.texcoord0.zw = data0.xy;
|
||||||
|
i.texcoord1.zw = data0.zw;
|
||||||
|
}
|
||||||
|
|
@@ -0,0 +1,72 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
#if UNITY_2020_2_OR_NEWER
|
||||||
|
using UnityEditor.AssetImporters;
|
||||||
|
#else
|
||||||
|
using UnityEditor.Experimental.AssetImporters;
|
||||||
|
#endif
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
// Allows you to read/write any texture format from unity as if it's a native format.
|
||||||
|
namespace JBooth.MicroSplat
|
||||||
|
{
|
||||||
|
[ScriptedImporter (1, "hdtexture")]
|
||||||
|
public class HDTextureImporter : ScriptedImporter
|
||||||
|
{
|
||||||
|
public static void Write (Texture2D r, string path, bool mips, bool linear)
|
||||||
|
{
|
||||||
|
using (var bw = new BinaryWriter (File.Open (path + ".hdtexture", FileMode.OpenOrCreate)))
|
||||||
|
{
|
||||||
|
bw.Write (0);
|
||||||
|
bw.Write ((int)r.format);
|
||||||
|
bw.Write (r.width);
|
||||||
|
bw.Write (r.height);
|
||||||
|
bw.Write (mips);
|
||||||
|
bw.Write (linear);
|
||||||
|
bw.Write ((int)r.wrapMode);
|
||||||
|
bw.Write ((int)r.filterMode);
|
||||||
|
|
||||||
|
var bytes = r.GetRawTextureData ();
|
||||||
|
bw.Write (bytes.Length);
|
||||||
|
bw.Write (r.GetRawTextureData ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnImportAsset (AssetImportContext ctx)
|
||||||
|
{
|
||||||
|
using (var r = new BinaryReader (File.Open (ctx.assetPath, FileMode.Open)))
|
||||||
|
{
|
||||||
|
int version = r.ReadInt32 ();
|
||||||
|
if (version != 0)
|
||||||
|
{
|
||||||
|
Debug.LogError ("Version mismatch in hdtexture aseset");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TextureFormat format = (TextureFormat)r.ReadInt32 ();
|
||||||
|
|
||||||
|
int width = r.ReadInt32 ();
|
||||||
|
int height = r.ReadInt32 ();
|
||||||
|
bool mips = r.ReadBoolean ();
|
||||||
|
FilterMode filterMode = (FilterMode)(r.ReadInt32 ());
|
||||||
|
TextureWrapMode wrapMode = (TextureWrapMode)(r.ReadInt32 ());
|
||||||
|
|
||||||
|
bool linear = r.ReadBoolean ();
|
||||||
|
int length = r.ReadInt32 ();
|
||||||
|
|
||||||
|
byte [] bytes = r.ReadBytes (length);
|
||||||
|
var tex = new Texture2D (width, height, format, mips, linear);
|
||||||
|
tex.wrapMode = wrapMode;
|
||||||
|
tex.filterMode = filterMode;
|
||||||
|
tex.LoadRawTextureData (bytes);
|
||||||
|
tex.Apply ();
|
||||||
|
ctx.AddObjectToAsset ("main obj", tex);
|
||||||
|
ctx.SetMainObject (tex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,26 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace JBooth.MicroSplat
|
||||||
|
{
|
||||||
|
public interface IRenderLoopAdapter
|
||||||
|
{
|
||||||
|
string GetDisplayName();
|
||||||
|
string GetRenderLoopKeyword();
|
||||||
|
string GetShaderExtension();
|
||||||
|
void Init(string[] paths);
|
||||||
|
StringBuilder WriteShader(string[] features,
|
||||||
|
MicroSplatShaderGUI.MicroSplatCompiler compiler,
|
||||||
|
MicroSplatShaderGUI.MicroSplatCompiler.AuxShader auxShader,
|
||||||
|
string name,
|
||||||
|
string baseName);
|
||||||
|
string GetVersion();
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,54 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Shader "Hidden/MicroSplat/ClearNonNormalData"
|
||||||
|
{
|
||||||
|
Properties {
|
||||||
|
_MainTex ("Base (RGB)", 2D) = "bump" {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
Pass {
|
||||||
|
ZTest Always Cull Off ZWrite Off
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert_img
|
||||||
|
#pragma fragment frag
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
float _Swizzle;
|
||||||
|
|
||||||
|
|
||||||
|
half BlendOverlay(half base, half blend) { return (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend))); }
|
||||||
|
|
||||||
|
|
||||||
|
fixed4 frag(v2f_img i) : SV_Target
|
||||||
|
{
|
||||||
|
half4 data = tex2D(_MainTex, i.uv);
|
||||||
|
if (_Swizzle > 0.5)
|
||||||
|
{
|
||||||
|
data.ga = data.gr;
|
||||||
|
}
|
||||||
|
data.r = 0;
|
||||||
|
data.b = 1;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Fallback off
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,51 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Shader "Hidden/MicroSplat/HeightFromNormal"
|
||||||
|
{
|
||||||
|
// generate a height map from a normalSAO map
|
||||||
|
Properties {
|
||||||
|
_MainTex ("Base (RGB)", 2D) = "bump" {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
Pass {
|
||||||
|
ZTest Always Cull Off ZWrite Off
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert_img
|
||||||
|
#pragma fragment frag
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
|
||||||
|
float4 _MainTex_TexelSize;
|
||||||
|
|
||||||
|
|
||||||
|
half BlendOverlay(half base, half blend) { return (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend))); }
|
||||||
|
|
||||||
|
|
||||||
|
fixed4 frag(v2f_img i) : SV_Target
|
||||||
|
{
|
||||||
|
half2 n0 = tex2Dbias(_MainTex, float4(i.uv, 0, 0)).ga;
|
||||||
|
half n = BlendOverlay(n0.x, n0.y);
|
||||||
|
return fixed4(n,n,n,n);
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Fallback off
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,110 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Shader "Hidden/MicroSplat/MergeInChannel"
|
||||||
|
{
|
||||||
|
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||||
|
_TargetTex("Target", 2D) = "white" {}
|
||||||
|
_TargetChannel("Target Channel", Int) = 0
|
||||||
|
_MergeChannel("Merge Channel", Int) = 0
|
||||||
|
_Invert("Invert", Int) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
Pass {
|
||||||
|
ZTest Always Cull Off ZWrite Off
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert_img
|
||||||
|
#pragma fragment frag
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
sampler2D _TargetTex;
|
||||||
|
float4 _MainTex_TexelSize;
|
||||||
|
int _TargetChannel;
|
||||||
|
int _MergeChannel;
|
||||||
|
int _Invert;
|
||||||
|
|
||||||
|
float4 frag(v2f_img i) : SV_Target
|
||||||
|
{
|
||||||
|
float4 main = tex2D(_MainTex, i.uv);
|
||||||
|
float4 target = tex2D(_TargetTex, i.uv);
|
||||||
|
|
||||||
|
// why not array access? Throws compile error!
|
||||||
|
// target[_TargetChannel] = main[_MergeChannel];
|
||||||
|
|
||||||
|
if (_TargetChannel == 0)
|
||||||
|
{
|
||||||
|
if (_MergeChannel == 0)
|
||||||
|
target.r = main.r;
|
||||||
|
else if (_MergeChannel == 1)
|
||||||
|
target.r = main.g;
|
||||||
|
else if (_MergeChannel == 2)
|
||||||
|
target.r = main.b;
|
||||||
|
else
|
||||||
|
target.r = main.a;
|
||||||
|
}
|
||||||
|
else if (_TargetChannel == 1)
|
||||||
|
{
|
||||||
|
if (_MergeChannel == 0)
|
||||||
|
target.g = main.r;
|
||||||
|
else if (_MergeChannel == 1)
|
||||||
|
target.g = main.g;
|
||||||
|
else if (_MergeChannel == 2)
|
||||||
|
target.g = main.b;
|
||||||
|
else
|
||||||
|
target.g = main.a;
|
||||||
|
}
|
||||||
|
else if (_TargetChannel == 2)
|
||||||
|
{
|
||||||
|
if (_MergeChannel == 0)
|
||||||
|
target.b = main.r;
|
||||||
|
else if (_MergeChannel == 1)
|
||||||
|
target.b = main.g;
|
||||||
|
else if (_MergeChannel == 2)
|
||||||
|
target.b = main.b;
|
||||||
|
else
|
||||||
|
target.b = main.a;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_MergeChannel == 0)
|
||||||
|
target.a = main.r;
|
||||||
|
else if (_MergeChannel == 1)
|
||||||
|
target.a = main.g;
|
||||||
|
else if (_MergeChannel == 2)
|
||||||
|
target.a = main.b;
|
||||||
|
else
|
||||||
|
target.a = main.a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (_Invert > 0.5)
|
||||||
|
{
|
||||||
|
if (_TargetChannel == 0)
|
||||||
|
target.r = 1.0 - target.r;
|
||||||
|
else if (_TargetChannel == 1)
|
||||||
|
target.g = 1.0 - target.g;
|
||||||
|
else if (_TargetChannel == 1)
|
||||||
|
target.b = 1.0 - target.b;
|
||||||
|
else
|
||||||
|
target.a = 1.0 - target.a;
|
||||||
|
}
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Fallback off
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,102 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Shader "Hidden/MicroSplat/NormalSAOFromDiffuse"
|
||||||
|
{
|
||||||
|
// generate a full NormalSAO texture from just a diffuse image
|
||||||
|
Properties {
|
||||||
|
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
Pass {
|
||||||
|
ZTest Always Cull Off ZWrite Off
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert_img
|
||||||
|
#pragma fragment frag
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
|
||||||
|
|
||||||
|
float4 _MainTex_TexelSize;
|
||||||
|
|
||||||
|
float4 GenerateNormal(float2 uv, float uvOffset, float amplitude, float bias)
|
||||||
|
{
|
||||||
|
float pixX = _MainTex_TexelSize.x;
|
||||||
|
float pixY = _MainTex_TexelSize.y;
|
||||||
|
|
||||||
|
float3 gx = tex2Dbias(_MainTex, float4(uv + float2(pixX, 0), 0, bias)).rgb;
|
||||||
|
float3 gy = tex2Dbias(_MainTex, float4(uv + float2(0, pixY), 0, bias)).rgb;
|
||||||
|
float3 gxb = tex2Dbias(_MainTex, float4(uv + float2(-pixX, 0), 0, bias)).rgb;
|
||||||
|
float3 gyb = tex2Dbias(_MainTex, float4(uv + float2(0, -pixY), 0, bias)).rgb;
|
||||||
|
|
||||||
|
gx = saturate( Luminance(gx + uvOffset));
|
||||||
|
gy = saturate( Luminance(gy + uvOffset));
|
||||||
|
gxb = saturate( Luminance(gxb + uvOffset));
|
||||||
|
gyb = saturate( Luminance(gyb + uvOffset));
|
||||||
|
|
||||||
|
|
||||||
|
gx = (gx - gxb) * -1;
|
||||||
|
gy = (gy - gyb) * -1;
|
||||||
|
|
||||||
|
half4 ret = half4(0.5, 0.5, 0, 1);
|
||||||
|
|
||||||
|
float len = sqrt( gx * gx + gy * gy + 1 );
|
||||||
|
|
||||||
|
if(len > 0)
|
||||||
|
{
|
||||||
|
ret.r = 10*amplitude*gx/len * 0.5 + 0.5;
|
||||||
|
ret.g = 10*amplitude*gy/len * 0.5 + 0.5;
|
||||||
|
ret.b = 1.0 / len;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed4 frag(v2f_img i) : SV_Target
|
||||||
|
{
|
||||||
|
float4 finalNorm = 0;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.1, 0.8, 6) * 6;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.2, 0.7, 5) * 5;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.3, 0.6, 4) * 4;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.4, 0.5, 3) * 3;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.5, 0.4, 2) * 2;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.6, 0.3, 1);
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.7, 0.2, 0) * 2;
|
||||||
|
finalNorm /= 23.0;
|
||||||
|
|
||||||
|
finalNorm.xy -= 0.5;
|
||||||
|
finalNorm.xy *= 12;
|
||||||
|
finalNorm.xy += 0.5;
|
||||||
|
|
||||||
|
// ao is just the normal maps length
|
||||||
|
finalNorm.w = sqrt(1 - saturate(dot(finalNorm.xy - 0.5, finalNorm.xy - 0.5)));
|
||||||
|
|
||||||
|
// smoothness, be conservative
|
||||||
|
//finalNorm.b = 0.1 * (finalNorm.b + ((finalNorm.x + finalNorm.y)/2));
|
||||||
|
// Nope, people can't seem to understand that it generates a smoothness
|
||||||
|
// value, yet can totally understand it generates a normal, so fuck it,
|
||||||
|
// no smoothness it is.
|
||||||
|
finalNorm.b = 0;
|
||||||
|
// swizzle to Smoothness/NormalY/AO/NormalX format, which looks better for most cases
|
||||||
|
|
||||||
|
finalNorm.rgba = finalNorm.bgar;
|
||||||
|
return finalNorm;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Fallback off
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,107 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Shader "Hidden/MicroSplat/NormalSAOFromHeight"
|
||||||
|
{
|
||||||
|
// generate a full NormalSAO texture from just a diffuse image
|
||||||
|
Properties {
|
||||||
|
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
Pass {
|
||||||
|
ZTest Always Cull Off ZWrite Off
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert_img
|
||||||
|
#pragma fragment frag
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
|
||||||
|
int _Channel;
|
||||||
|
|
||||||
|
float4 _MainTex_TexelSize;
|
||||||
|
|
||||||
|
float4 GenerateNormal(float2 uv, float uvOffset, float amplitude, float bias)
|
||||||
|
{
|
||||||
|
float pixX = _MainTex_TexelSize.x;
|
||||||
|
float pixY = _MainTex_TexelSize.y;
|
||||||
|
|
||||||
|
float3 gx = tex2Dbias(_MainTex, float4(uv + float2(pixX, 0), 0, bias))[_Channel];
|
||||||
|
float3 gy = tex2Dbias(_MainTex, float4(uv + float2(0, pixY), 0, bias))[_Channel];
|
||||||
|
float3 gxb = tex2Dbias(_MainTex, float4(uv + float2(-pixX, 0), 0, bias))[_Channel];
|
||||||
|
float3 gyb = tex2Dbias(_MainTex, float4(uv + float2(0, -pixY), 0, bias))[_Channel];
|
||||||
|
|
||||||
|
gx = saturate( Luminance(gx + uvOffset));
|
||||||
|
gy = saturate( Luminance(gy + uvOffset));
|
||||||
|
gxb = saturate( Luminance(gxb + uvOffset));
|
||||||
|
gyb = saturate( Luminance(gyb + uvOffset));
|
||||||
|
|
||||||
|
|
||||||
|
gx = (gx - gxb) * -1;
|
||||||
|
gy = (gy - gyb) * -1;
|
||||||
|
|
||||||
|
half4 ret = half4(0.5, 0.5, 0, 1);
|
||||||
|
|
||||||
|
float len = sqrt( gx * gx + gy * gy + 1 );
|
||||||
|
|
||||||
|
if(len > 0)
|
||||||
|
{
|
||||||
|
ret.r = 10*amplitude*gx/len * 0.5 + 0.5;
|
||||||
|
ret.g = 10*amplitude*gy/len * 0.5 + 0.5;
|
||||||
|
ret.b = 1.0 / len;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed4 frag(v2f_img i) : SV_Target
|
||||||
|
{
|
||||||
|
float4 finalNorm = 0;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.1, 0.8, 6) * 6;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.2, 0.7, 5) * 5;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.3, 0.6, 4) * 4;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.4, 0.5, 3) * 3;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.5, 0.4, 2) * 2;
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.6, 0.3, 1);
|
||||||
|
finalNorm += GenerateNormal(i.uv, 0.7, 0.2, 0) * 2;
|
||||||
|
finalNorm /= 23.0;
|
||||||
|
|
||||||
|
finalNorm.xy -= 0.5;
|
||||||
|
finalNorm.xy *= 10;
|
||||||
|
finalNorm.xy += 0.5;
|
||||||
|
finalNorm.xy = saturate(finalNorm.xy);
|
||||||
|
|
||||||
|
// ao is just the normal maps length
|
||||||
|
finalNorm.w = sqrt(1 - saturate(dot(finalNorm.xy - 0.5, finalNorm.xy - 0.5)));
|
||||||
|
|
||||||
|
// smoothness, be conservative
|
||||||
|
//finalNorm.b = 0.1 * (finalNorm.b + ((finalNorm.x + finalNorm.y)/2));
|
||||||
|
|
||||||
|
// Nope, people can't seem to understand that it generates a smoothness
|
||||||
|
// value, yet can totally understand it generates a normal, so fuck it,
|
||||||
|
// no smoothness it is.
|
||||||
|
finalNorm.b = 0;
|
||||||
|
|
||||||
|
// swizzle to better format.
|
||||||
|
finalNorm.rgba = finalNorm.bgar;
|
||||||
|
|
||||||
|
return finalNorm;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Fallback off
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,60 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Shader "Hidden/MicroSplat/NormalSAOFromNormal"
|
||||||
|
{
|
||||||
|
// generate a full NormalSAO texture from just a diffuse image
|
||||||
|
Properties {
|
||||||
|
_MainTex ("Base (RGB)", 2D) = "bump" {}
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
Pass {
|
||||||
|
ZTest Always Cull Off ZWrite Off
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex vert_img
|
||||||
|
#pragma fragment frag
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
|
||||||
|
struct v2f {
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
};
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
|
||||||
|
fixed4 frag(v2f_img i) : SV_Target
|
||||||
|
{
|
||||||
|
half4 norm = tex2D(_MainTex, i.uv);
|
||||||
|
|
||||||
|
|
||||||
|
half3 un = UnpackNormal(norm);
|
||||||
|
un.xy *= 0.5;
|
||||||
|
un.xy += 0.5;
|
||||||
|
half4 nsao = 0;
|
||||||
|
nsao.xy = un.xy;
|
||||||
|
// ao is just the normal maps length
|
||||||
|
nsao.w = un.b * un.b;
|
||||||
|
// smoothness, be conservative
|
||||||
|
//nsao.z = un.b * 0.07;
|
||||||
|
|
||||||
|
// Nope, people can't seem to understand that it generates a smoothness
|
||||||
|
// value, yet can totally understand it generates a normal, so fuck it,
|
||||||
|
// no smoothness it is.
|
||||||
|
|
||||||
|
nsao.z = 0;
|
||||||
|
|
||||||
|
return nsao.bgar;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Fallback off
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"name": "JBooth.MicroSplat.Core.Editor",
|
||||||
|
"references": [
|
||||||
|
"GUID:4bdfb2239705740718731d0b4d54061d"
|
||||||
|
],
|
||||||
|
"includePlatforms": [
|
||||||
|
"Editor"
|
||||||
|
],
|
||||||
|
"excludePlatforms": [],
|
||||||
|
"allowUnsafeCode": false,
|
||||||
|
"overrideReferences": true,
|
||||||
|
"precompiledReferences": [
|
||||||
|
"Substance.Game.dll"
|
||||||
|
],
|
||||||
|
"autoReferenced": true,
|
||||||
|
"defineConstraints": [],
|
||||||
|
"versionDefines": [
|
||||||
|
{
|
||||||
|
"name": "com.unity.modules.ui",
|
||||||
|
"expression": "",
|
||||||
|
"define": "__MICROSPLAT__"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "com.unity.render-pipelines.universal",
|
||||||
|
"expression": "",
|
||||||
|
"define": "USING_URP"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "com.unity.render-pipelines.high-definition",
|
||||||
|
"expression": "",
|
||||||
|
"define": "USING_HDRP"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"noEngineReferences": false
|
||||||
|
}
|
@@ -0,0 +1,459 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
// This class can be used as part of your build process to automatically compress splat maps
|
||||||
|
// and other data before a build. See the DrawGUI function for an example of how you can do this.
|
||||||
|
|
||||||
|
namespace JBooth.MicroSplat
|
||||||
|
{
|
||||||
|
public class MicroSplatCompressor
|
||||||
|
{
|
||||||
|
|
||||||
|
static GUIContent CCompSplatMaps = new GUIContent ("Compress Splat Maps", "This will compress terrain and mesh splat maps. Note that terrain editing will not work until splat maps are reverted from this mode");
|
||||||
|
static GUIContent CCompStreamMap = new GUIContent ("Compress Stream Map", "This will compress the map holding wetness, puddles, streams and lava painting");
|
||||||
|
static GUIContent CCompSnowMaps = new GUIContent ("Compress Snow Maps", "This will compress snow masking maps");
|
||||||
|
static GUIContent CCompBiomeMaps = new GUIContent ("Compress Biome Maps", "This will compress procedural biome masks");
|
||||||
|
static GUIContent CCompTintMaps = new GUIContent ("Compress Tint Maps", "This will compress any tint maps");
|
||||||
|
|
||||||
|
public static void DrawGUI (MicroSplatObject mso, Options o)
|
||||||
|
{
|
||||||
|
if (MicroSplatUtilities.DrawRollup ("Compressor", false))
|
||||||
|
{
|
||||||
|
EditorGUILayout.HelpBox ("You can use this section to automatically covert various maps to compressed formats before a build. Please note, that once compressed, external files will be used for things like the terrain splat maps, and changing the terrain through Unity's tools will have no effect", MessageType.Info);
|
||||||
|
EditorGUILayout.LabelField ("Compression Options");
|
||||||
|
|
||||||
|
o.splatMaps = EditorGUILayout.Toggle (CCompSplatMaps, o.splatMaps);
|
||||||
|
if (o.splatMaps)
|
||||||
|
{
|
||||||
|
EditorGUILayout.HelpBox ("This will remove the terrain painting from your terrain file to save memory! The Uncompress button will restore this from the output textures, but if you delete or unhook them your painting may be lost.", MessageType.Error);
|
||||||
|
}
|
||||||
|
o.streamMaps = EditorGUILayout.Toggle (CCompStreamMap, o.streamMaps);
|
||||||
|
o.snowMask = EditorGUILayout.Toggle (CCompSnowMaps, o.snowMask);
|
||||||
|
o.biomeMask = EditorGUILayout.Toggle (CCompBiomeMaps, o.biomeMask);
|
||||||
|
o.tintMap = EditorGUILayout.Toggle (CCompTintMaps, o.tintMap);
|
||||||
|
|
||||||
|
EditorGUILayout.BeginHorizontal ();
|
||||||
|
EditorGUILayout.Space ();
|
||||||
|
if (GUILayout.Button ("Compress"))
|
||||||
|
{
|
||||||
|
var gos = Selection.gameObjects;
|
||||||
|
foreach (var go in gos)
|
||||||
|
{
|
||||||
|
var m = go.GetComponent<MicroSplatTerrain>();
|
||||||
|
if (m != null)
|
||||||
|
{
|
||||||
|
MicroSplatCompressor comp = new MicroSplatCompressor();
|
||||||
|
comp.Compress(m, o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (GUILayout.Button ("Uncompress"))
|
||||||
|
{
|
||||||
|
var gos = Selection.gameObjects;
|
||||||
|
foreach (var go in gos)
|
||||||
|
{
|
||||||
|
var m = go.GetComponent<MicroSplatTerrain>();
|
||||||
|
if (m != null)
|
||||||
|
{
|
||||||
|
MicroSplatCompressor comp = new MicroSplatCompressor();
|
||||||
|
comp.Revert(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
EditorGUILayout.Space ();
|
||||||
|
EditorGUILayout.EndHorizontal ();
|
||||||
|
|
||||||
|
EditorGUILayout.BeginHorizontal ();
|
||||||
|
EditorGUILayout.Space ();
|
||||||
|
if (GUILayout.Button ("Compress Scene"))
|
||||||
|
{
|
||||||
|
MicroSplatCompressor comp = new MicroSplatCompressor ();
|
||||||
|
MicroSplatObject [] objs = GameObject.FindObjectsOfType<MicroSplatObject> ();
|
||||||
|
foreach (var obj in objs)
|
||||||
|
{
|
||||||
|
comp.Compress (obj, o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (GUILayout.Button ("Uncompress Scene"))
|
||||||
|
{
|
||||||
|
MicroSplatCompressor comp = new MicroSplatCompressor ();
|
||||||
|
MicroSplatObject [] objs = GameObject.FindObjectsOfType<MicroSplatObject> ();
|
||||||
|
foreach (var obj in objs)
|
||||||
|
{
|
||||||
|
comp.Revert (obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EditorGUILayout.Space ();
|
||||||
|
EditorGUILayout.EndHorizontal ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class Options
|
||||||
|
{
|
||||||
|
public bool splatMaps = false;
|
||||||
|
public bool streamMaps = true;
|
||||||
|
public bool snowMask = true;
|
||||||
|
public bool biomeMask = true;
|
||||||
|
public bool tintMap = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture2D CompressTexture(string path, bool sRGB)
|
||||||
|
{
|
||||||
|
AssetImporter ai = AssetImporter.GetAtPath (path);
|
||||||
|
if (ai == null)
|
||||||
|
return null;
|
||||||
|
TextureImporter ti = (TextureImporter)ai;
|
||||||
|
if (ti != null)
|
||||||
|
{
|
||||||
|
ti.compressionQuality = 100;
|
||||||
|
ti.wrapMode = TextureWrapMode.Clamp;
|
||||||
|
ti.textureCompression = TextureImporterCompression.Compressed;
|
||||||
|
ti.sRGBTexture = sRGB;
|
||||||
|
ti.isReadable = false;
|
||||||
|
TextureImporterPlatformSettings settings = new TextureImporterPlatformSettings();
|
||||||
|
settings.format = TextureImporterFormat.Automatic;
|
||||||
|
settings.compressionQuality = 100;
|
||||||
|
settings.textureCompression = TextureImporterCompression.Compressed;
|
||||||
|
ti.SetPlatformTextureSettings(settings);
|
||||||
|
ti.SaveAndReimport();
|
||||||
|
}
|
||||||
|
return AssetDatabase.LoadAssetAtPath<Texture2D> (path);
|
||||||
|
}
|
||||||
|
|
||||||
|
Texture2D UncompressTexture (string path)
|
||||||
|
{
|
||||||
|
AssetImporter ai = AssetImporter.GetAtPath (path);
|
||||||
|
if (ai == null)
|
||||||
|
return null;
|
||||||
|
TextureImporter ti = (TextureImporter)ai;
|
||||||
|
if (ti != null)
|
||||||
|
{
|
||||||
|
ti.compressionQuality = 100;
|
||||||
|
ti.wrapMode = TextureWrapMode.Clamp;
|
||||||
|
ti.textureCompression = TextureImporterCompression.Uncompressed;
|
||||||
|
ti.isReadable = true;
|
||||||
|
ti.sRGBTexture = false;
|
||||||
|
TextureImporterPlatformSettings settings = new TextureImporterPlatformSettings();
|
||||||
|
settings.format = TextureImporterFormat.RGBA32;
|
||||||
|
settings.textureCompression = TextureImporterCompression.Uncompressed;
|
||||||
|
ti.SetPlatformTextureSettings(settings);
|
||||||
|
ti.SaveAndReimport();
|
||||||
|
}
|
||||||
|
return AssetDatabase.LoadAssetAtPath<Texture2D> (path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompressTerrainSplats (MicroSplatTerrain t)
|
||||||
|
{
|
||||||
|
int splatCount = t.terrain.terrainData.alphamapTextureCount;
|
||||||
|
// write out
|
||||||
|
for (int i = 0; i < splatCount; ++i)
|
||||||
|
{
|
||||||
|
var tex = t.terrain.terrainData.GetAlphamapTexture (i);
|
||||||
|
var path = MicroSplatUtilities.RelativePathFromAsset (t);
|
||||||
|
path += "/" + t.name + "_splat" + i + ".tga";
|
||||||
|
System.IO.File.WriteAllBytes (path, tex.EncodeToTGA ());
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetDatabase.Refresh ();
|
||||||
|
// load and adjust importer
|
||||||
|
for (int i = 0; i < splatCount; ++i)
|
||||||
|
{
|
||||||
|
var path = MicroSplatUtilities.RelativePathFromAsset (t);
|
||||||
|
path += "/" + t.name + "_splat" + i + ".tga";
|
||||||
|
|
||||||
|
var tex = CompressTexture (path, false);
|
||||||
|
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
t.customControl0 = tex;
|
||||||
|
}
|
||||||
|
else if (i == 1)
|
||||||
|
{
|
||||||
|
t.customControl1 = tex;
|
||||||
|
}
|
||||||
|
else if (i == 2)
|
||||||
|
{
|
||||||
|
t.customControl2 = tex;
|
||||||
|
}
|
||||||
|
else if (i == 3)
|
||||||
|
{
|
||||||
|
t.customControl3 = tex;
|
||||||
|
}
|
||||||
|
else if (i == 4)
|
||||||
|
{
|
||||||
|
t.customControl4 = tex;
|
||||||
|
}
|
||||||
|
else if (i == 5)
|
||||||
|
{
|
||||||
|
t.customControl5 = tex;
|
||||||
|
}
|
||||||
|
else if (i == 6)
|
||||||
|
{
|
||||||
|
t.customControl6 = tex;
|
||||||
|
}
|
||||||
|
else if (i == 7)
|
||||||
|
{
|
||||||
|
t.customControl7 = tex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EditorUtility.SetDirty (t);
|
||||||
|
|
||||||
|
MicroSplatKeywords keywords = MicroSplatUtilities.FindOrCreateKeywords (t.templateMaterial);
|
||||||
|
if (!keywords.IsKeywordEnabled("_CUSTOMSPLATTEXTURES"))
|
||||||
|
{
|
||||||
|
keywords.EnableKeyword ("_CUSTOMSPLATTEXTURES");
|
||||||
|
MicroSplatShaderGUI.MicroSplatCompiler compiler = new MicroSplatShaderGUI.MicroSplatCompiler ();
|
||||||
|
compiler.Compile (t.templateMaterial);
|
||||||
|
MicroSplatTerrain.SyncAll ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructive operation
|
||||||
|
t.terrain.terrainData.alphamapResolution = 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtractSplats(ref float[,,] maps, Texture2D tex, int index, int layers)
|
||||||
|
{
|
||||||
|
if (tex == null)
|
||||||
|
return;
|
||||||
|
int size = tex.width;
|
||||||
|
|
||||||
|
if (tex != null)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < size; ++x)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < size; ++y)
|
||||||
|
{
|
||||||
|
Color c = tex.GetPixel (x, y);
|
||||||
|
if (index < layers)
|
||||||
|
{
|
||||||
|
maps [y, x, index + 0] = c.r;
|
||||||
|
}
|
||||||
|
if (index + 1 < layers)
|
||||||
|
{
|
||||||
|
maps [y, x, index + 1] = c.g;
|
||||||
|
}
|
||||||
|
if (index + 2 < layers)
|
||||||
|
{
|
||||||
|
maps [y, x, index + 2] = c.b;
|
||||||
|
}
|
||||||
|
if (index + 3 < layers)
|
||||||
|
{
|
||||||
|
maps [y, x, index + 3] = c.a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RevertTerrainSplats(MicroSplatTerrain t)
|
||||||
|
{
|
||||||
|
MicroSplatKeywords keywords = MicroSplatUtilities.FindOrCreateKeywords (t.templateMaterial);
|
||||||
|
if (keywords.IsKeywordEnabled ("_CUSTOMSPLATTEXTURES"))
|
||||||
|
{
|
||||||
|
if (t.customControl0 == null)
|
||||||
|
{
|
||||||
|
Debug.LogError ("Could not revert terrain because textures are missing!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UncompressTexture (t.customControl0);
|
||||||
|
UncompressTexture (t.customControl1);
|
||||||
|
UncompressTexture (t.customControl2);
|
||||||
|
UncompressTexture (t.customControl3);
|
||||||
|
UncompressTexture (t.customControl4);
|
||||||
|
UncompressTexture (t.customControl5);
|
||||||
|
UncompressTexture (t.customControl6);
|
||||||
|
UncompressTexture (t.customControl7);
|
||||||
|
|
||||||
|
int size = t.customControl0.width;
|
||||||
|
int layers = t.terrain.terrainData.alphamapLayers;
|
||||||
|
t.terrain.terrainData.alphamapResolution = size;
|
||||||
|
var maps = t.terrain.terrainData.GetAlphamaps (0, 0, size, size);
|
||||||
|
|
||||||
|
ExtractSplats (ref maps, t.customControl0, 0, layers);
|
||||||
|
ExtractSplats (ref maps, t.customControl1, 4, layers);
|
||||||
|
ExtractSplats (ref maps, t.customControl2, 8, layers);
|
||||||
|
ExtractSplats (ref maps, t.customControl3, 12, layers);
|
||||||
|
ExtractSplats (ref maps, t.customControl4, 16, layers);
|
||||||
|
ExtractSplats (ref maps, t.customControl5, 20, layers);
|
||||||
|
ExtractSplats (ref maps, t.customControl6, 24, layers);
|
||||||
|
ExtractSplats (ref maps, t.customControl7, 28, layers);
|
||||||
|
|
||||||
|
t.terrain.terrainData.SetAlphamaps (0, 0, maps);
|
||||||
|
EditorUtility.SetDirty (t.terrain.terrainData);
|
||||||
|
|
||||||
|
|
||||||
|
keywords.DisableKeyword ("_CUSTOMSPLATTEXTURES");
|
||||||
|
MicroSplatShaderGUI.MicroSplatCompiler compiler = new MicroSplatShaderGUI.MicroSplatCompiler ();
|
||||||
|
compiler.Compile (t.templateMaterial);
|
||||||
|
t.customControl0 = null;
|
||||||
|
t.customControl1 = null;
|
||||||
|
t.customControl2 = null;
|
||||||
|
t.customControl3 = null;
|
||||||
|
t.customControl4 = null;
|
||||||
|
t.customControl5 = null;
|
||||||
|
t.customControl6 = null;
|
||||||
|
t.customControl7 = null;
|
||||||
|
EditorUtility.SetDirty (t);
|
||||||
|
MicroSplatTerrain.SyncAll ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompressTexture (Texture2D tex, bool sRGB)
|
||||||
|
{
|
||||||
|
if (tex != null)
|
||||||
|
{
|
||||||
|
CompressTexture (AssetDatabase.GetAssetPath (tex), sRGB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UncompressTexture (Texture2D tex)
|
||||||
|
{
|
||||||
|
if (tex != null)
|
||||||
|
{
|
||||||
|
UncompressTexture (AssetDatabase.GetAssetPath (tex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CompressTexture(Material mat, string name, bool sRGB)
|
||||||
|
{
|
||||||
|
if (mat.HasProperty(name))
|
||||||
|
{
|
||||||
|
CompressTexture (mat.GetTexture (name) as Texture2D, sRGB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UncompressTexture (Material mat, string name)
|
||||||
|
{
|
||||||
|
if (mat.HasProperty (name))
|
||||||
|
{
|
||||||
|
UncompressTexture (mat.GetTexture (name) as Texture2D);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Compress (MicroSplatObject mso, Options opt)
|
||||||
|
{
|
||||||
|
MicroSplatTerrain t = mso as MicroSplatTerrain;
|
||||||
|
if (t != null)
|
||||||
|
{
|
||||||
|
if (t.templateMaterial == null)
|
||||||
|
{
|
||||||
|
Debug.LogError ("MicroSplatTerrain " + mso.gameObject.name + " does not have template material");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (opt.splatMaps)
|
||||||
|
{
|
||||||
|
CompressTerrainSplats (t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __MICROSPLAT_MESH__
|
||||||
|
MicroSplatMesh msm = mso as MicroSplatMesh;
|
||||||
|
if (msm != null)
|
||||||
|
{
|
||||||
|
foreach (var subMesh in msm.subMeshEntries)
|
||||||
|
{
|
||||||
|
foreach (var tex in subMesh.subMeshOverride.controlTextures)
|
||||||
|
{
|
||||||
|
CompressTexture (tex, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __MICROSPLAT_PROCTEX__
|
||||||
|
if (opt.biomeMask)
|
||||||
|
{
|
||||||
|
CompressTexture (mso.procBiomeMask, false);
|
||||||
|
CompressTexture (mso.procBiomeMask2, false);
|
||||||
|
CompressTexture (mso.templateMaterial, "_ProcTexBiomeMask", false);
|
||||||
|
CompressTexture (mso.templateMaterial, "_ProcTexBiomeMask2", false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if __MICROSPLAT_SNOW__
|
||||||
|
if (opt.snowMask)
|
||||||
|
{
|
||||||
|
CompressTexture (mso.snowMaskOverride, false);
|
||||||
|
CompressTexture (mso.templateMaterial, "_SnowMask", false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if __MICROSPLAT_STREAMS__
|
||||||
|
if (opt.streamMaps)
|
||||||
|
{
|
||||||
|
CompressTexture (mso.streamTexture, false);
|
||||||
|
CompressTexture (mso.templateMaterial, "_StreamControl", false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if __MICROSPLAT_GLOBALTEXTURE__
|
||||||
|
if (opt.tintMap)
|
||||||
|
{
|
||||||
|
CompressTexture (mso.streamTexture, true);
|
||||||
|
CompressTexture (mso.templateMaterial, "_GlobalTintTex", true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Revert(MicroSplatObject mso)
|
||||||
|
{
|
||||||
|
MicroSplatTerrain t = mso as MicroSplatTerrain;
|
||||||
|
if (t != null)
|
||||||
|
{
|
||||||
|
if (t.templateMaterial == null)
|
||||||
|
{
|
||||||
|
Debug.LogError ("MicroSplatTerrain " + mso.gameObject.name + " does not have template material");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RevertTerrainSplats (t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if __MICROSPLAT_MESH__
|
||||||
|
MicroSplatMesh msm = mso as MicroSplatMesh;
|
||||||
|
if (msm != null)
|
||||||
|
{
|
||||||
|
foreach (var subMesh in msm.subMeshEntries)
|
||||||
|
{
|
||||||
|
foreach (var tex in subMesh.subMeshOverride.controlTextures)
|
||||||
|
{
|
||||||
|
UncompressTexture (tex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __MICROSPLAT_PROCTEX__
|
||||||
|
UncompressTexture (mso.procBiomeMask);
|
||||||
|
UncompressTexture (mso.procBiomeMask2);
|
||||||
|
UncompressTexture (mso.templateMaterial, "_ProcTexBiomeMask");
|
||||||
|
UncompressTexture (mso.templateMaterial, "_ProcTexBiomeMask2");
|
||||||
|
#endif
|
||||||
|
#if __MICROSPLAT_SNOW__
|
||||||
|
UncompressTexture (mso.snowMaskOverride);
|
||||||
|
UncompressTexture (mso.templateMaterial, "_SnowMask");
|
||||||
|
#endif
|
||||||
|
#if __MICROSPLAT_STREAMS__
|
||||||
|
UncompressTexture (mso.streamTexture);
|
||||||
|
UncompressTexture (mso.templateMaterial, "_StreamControl");
|
||||||
|
#endif
|
||||||
|
#if __MICROSPLAT_GLOBALTEXTURE__
|
||||||
|
UncompressTexture (mso.streamTexture);
|
||||||
|
UncompressTexture (mso.templateMaterial, "_GlobalTintTex");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,79 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.Callbacks;
|
||||||
|
|
||||||
|
namespace JBooth.MicroSplat
|
||||||
|
{
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public class MicroSplatDefines
|
||||||
|
{
|
||||||
|
const string sMicroSplatDefine = "__MICROSPLAT__";
|
||||||
|
static MicroSplatDefines ()
|
||||||
|
{
|
||||||
|
InitDefine (sMicroSplatDefine);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasDefine (string def)
|
||||||
|
{
|
||||||
|
var target = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||||
|
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup (target);
|
||||||
|
return defines.Contains (def);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void InitDefine (string def)
|
||||||
|
{
|
||||||
|
var target = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||||
|
string defines = PlayerSettings.GetScriptingDefineSymbolsForGroup (target);
|
||||||
|
if (!defines.Contains (def))
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty (defines))
|
||||||
|
{
|
||||||
|
PlayerSettings.SetScriptingDefineSymbolsForGroup (target, def);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!defines [defines.Length - 1].Equals (';'))
|
||||||
|
{
|
||||||
|
defines += ';';
|
||||||
|
}
|
||||||
|
defines += def;
|
||||||
|
PlayerSettings.SetScriptingDefineSymbolsForGroup (target, defines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[PostProcessSceneAttribute (0)]
|
||||||
|
public static void OnPostprocessScene ()
|
||||||
|
{
|
||||||
|
InitDefine (sMicroSplatDefine);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string link_globalTexture = "https://assetstore.unity.com/packages/tools/terrain/microsplat-global-texturing-96482?aid=25047";
|
||||||
|
public static string link_snow = "https://assetstore.unity.com/packages/tools/terrain/microsplat-dynamic-snow-96486?aid=25047";
|
||||||
|
public static string link_tessellation = "https://assetstore.unity.com/packages/tools/terrain/microsplat-tessellation-and-parallax-96484?aid=25047";
|
||||||
|
public static string link_antitile = "https://assetstore.unity.com/packages/tools/terrain/microsplat-anti-tiling-module-96480?aid=25047";
|
||||||
|
public static string link_terrainblend = "https://assetstore.unity.com/packages/tools/terrain/microsplat-terrain-blending-97364?aid=25047";
|
||||||
|
public static string link_streams = "https://assetstore.unity.com/packages/tools/terrain/microsplat-puddles-streams-lava-wetness-97993?aid=25047";
|
||||||
|
public static string link_alphahole = "https://assetstore.unity.com/packages/tools/terrain/microsplat-terrain-holes-97495?aid=25047";
|
||||||
|
public static string link_triplanar = "https://assetstore.unity.com/packages/tools/terrain/microsplat-triplanar-uvs-96777?aid=25047";
|
||||||
|
public static string link_textureclusters = "https://assetstore.unity.com/packages/tools/terrain/microsplat-texture-clusters-104223?aid=25047";
|
||||||
|
public static string link_windglitter = "https://assetstore.unity.com/packages/tools/terrain/microsplat-wind-and-glitter-105627?aid=25047";
|
||||||
|
public static string link_proctex = "https://assetstore.unity.com/packages/tools/terrain/microsplat-runtime-procedural-texturing-143039?aid=25047";
|
||||||
|
public static string link_lowpoly = "https://assetstore.unity.com/packages/tools/terrain/microsplat-low-poly-look-146119?aid=1011l37NJ&aid=25047";
|
||||||
|
public static string link_meshterrain = "https://assetstore.unity.com/packages/tools/terrain/microsplat-mesh-terrains-157356?aid=1011l37NJ&aid=25047";
|
||||||
|
public static string link_meshworkflow = "https://assetstore.unity.com/packages/tools/painting/microsplat-mesh-workflow-beta-120008?aid=1011l37NJ&aid=25047";
|
||||||
|
public static string link_digger = "https://assetstore.unity.com/packages/tools/terrain/microsplat-digger-integration-162840?pubref=25047";
|
||||||
|
public static string link_trax = "https://assetstore.unity.com/packages/tools/terrain/microsplat-trax-166218?pubref=25047";
|
||||||
|
public static string link_polaris = "https://assetstore.unity.com/packages/tools/terrain/microsplat-polaris-integration-166851?pubref=25047";
|
||||||
|
public static string link_scatter = "https://assetstore.unity.com/packages/tools/terrain/microsplat-scatter-170299?pubref=25047";
|
||||||
|
public static string link_decal = "https://assetstore.unity.com/packages/tools/terrain/microsplat-decals-178765?aid=25047";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,431 @@
|
|||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// MicroSplat
|
||||||
|
// Copyright (c) Jason Booth
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using System.Text;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace JBooth.MicroSplat
|
||||||
|
{
|
||||||
|
public static class StringExtensions
|
||||||
|
{
|
||||||
|
public static string RemoveBetween(this string s, char begin, char end)
|
||||||
|
{
|
||||||
|
Regex regex = new Regex(string.Format("\\{0}.*?\\{1}", begin, end));
|
||||||
|
return regex.Replace(s, string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string StripComments(this string str)
|
||||||
|
{
|
||||||
|
var blockComments = @"/\*(.*?)\*/";
|
||||||
|
var lineComments = @"//(.*?)\r?\n";
|
||||||
|
var strings = @"""((\\[^\n]|[^""\n])*)""";
|
||||||
|
var verbatimStrings = @"@(""[^""]*"")+";
|
||||||
|
|
||||||
|
string noComments = Regex.Replace(str, blockComments + "|" + lineComments + "|" + strings + "|" + verbatimStrings, me =>
|
||||||
|
{
|
||||||
|
if (me.Value.StartsWith("/*") || me.Value.StartsWith("//"))
|
||||||
|
return me.Value.StartsWith("//") ? System.Environment.NewLine : "";
|
||||||
|
return me.Value;
|
||||||
|
},
|
||||||
|
RegexOptions.Singleline);
|
||||||
|
|
||||||
|
return noComments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string[] ToLines(this string str)
|
||||||
|
{
|
||||||
|
return str.Split("\n\r".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Blocks
|
||||||
|
{
|
||||||
|
public string cbuffer;
|
||||||
|
public string defines;
|
||||||
|
public string code;
|
||||||
|
public string properties;
|
||||||
|
public string options;
|
||||||
|
}
|
||||||
|
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public class MicroSplatGenerator
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
void WriteOptions(string[] features, StringBuilder sb, MicroSplatShaderGUI.MicroSplatCompiler compiler, MicroSplatShaderGUI.MicroSplatCompiler.AuxShader auxShader, string baseName)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (features.Contains("_TESSEDGE"))
|
||||||
|
{
|
||||||
|
sb.AppendLine("Tessellation \"Edge\"");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_TESSDISTANCE"))
|
||||||
|
{
|
||||||
|
sb.AppendLine("Tessellation \"Distance\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sb.Append(" Tags {\"RenderType\" = \"Opaque\" \"Queue\" = \"Geometry+100\" \"IgnoreProjector\" = \"False\" ");
|
||||||
|
|
||||||
|
if (features.Contains("_MICROTERRAIN") || features.Contains("_MEGASPLATTEXTURE"))
|
||||||
|
{
|
||||||
|
sb.Append(" \"TerrainCompatible\" = \"true\" ");
|
||||||
|
}
|
||||||
|
if (features.Contains("_MAX4TEXTURES"))
|
||||||
|
{
|
||||||
|
sb.Append("\"SplatCount\" = \"4\"");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_MAX8TEXTURES"))
|
||||||
|
{
|
||||||
|
sb.Append("\"SplatCount\" = \"8\"");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_MAX12TEXTURES"))
|
||||||
|
{
|
||||||
|
sb.Append("\"SplatCount\" = \"12\"");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_MAX20TEXTURES"))
|
||||||
|
{
|
||||||
|
sb.Append("\"SplatCount\" = \"20\"");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_MAX24TEXTURES"))
|
||||||
|
{
|
||||||
|
sb.Append("\"SplatCount\" = \"24\"");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_MAX28TEXTURES"))
|
||||||
|
{
|
||||||
|
sb.Append("\"SplatCount\" = \"28\"");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_MAX32TEXTURES"))
|
||||||
|
{
|
||||||
|
sb.Append("\"SplatCount\" = \"32\"");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append("\"SplatCount\" = \"16\"");
|
||||||
|
}
|
||||||
|
sb.AppendLine("}");
|
||||||
|
|
||||||
|
if (features.Contains("_MESHOVERLAYSPLATS"))
|
||||||
|
{
|
||||||
|
sb.AppendLine(" Alpha \"Blend\"");
|
||||||
|
}
|
||||||
|
if (auxShader != null && !string.IsNullOrEmpty(auxShader.customEditor))
|
||||||
|
{
|
||||||
|
sb.AppendLine(" CustomEditor \"" + auxShader.customEditor + "\"");
|
||||||
|
}
|
||||||
|
if (auxShader != null && !string.IsNullOrEmpty(auxShader.options))
|
||||||
|
{
|
||||||
|
sb.AppendLine(auxShader.options);
|
||||||
|
}
|
||||||
|
else if (auxShader != null)
|
||||||
|
{
|
||||||
|
sb.AppendLine(" CustomEditor \"MicroSplatShaderGUI\"");
|
||||||
|
}
|
||||||
|
else if (baseName == null)
|
||||||
|
{
|
||||||
|
sb.AppendLine(" CustomEditor \"MicroSplatShaderGUI\"");
|
||||||
|
}
|
||||||
|
else if (baseName != null)
|
||||||
|
{
|
||||||
|
if (features.Contains ("_MICROTERRAIN") && !features.Contains ("_TERRAINBLENDABLESHADER"))
|
||||||
|
{
|
||||||
|
sb.AppendLine(" Dependency {\"BaseMapShader\" = \"" + baseName + "\"}");
|
||||||
|
}
|
||||||
|
sb.AppendLine(" CustomEditor \"MicroSplatShaderGUI\"");
|
||||||
|
}
|
||||||
|
sb.AppendLine(" Fallback \"Nature/Terrain/Diffuse\"");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static TextAsset adapter;
|
||||||
|
static TextAsset sharedInc;
|
||||||
|
static TextAsset terrainBody;
|
||||||
|
static TextAsset terrainBlendBody;
|
||||||
|
static TextAsset terrainBlendCBuffer;
|
||||||
|
static TextAsset sharedHD;
|
||||||
|
static TextAsset vertex;
|
||||||
|
static TextAsset vertexData;
|
||||||
|
static TextAsset megasplatData;
|
||||||
|
static TextAsset mainFunc;
|
||||||
|
|
||||||
|
|
||||||
|
public void Init(string[] paths)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < paths.Length; ++i)
|
||||||
|
{
|
||||||
|
string p = paths[i];
|
||||||
|
if (p.EndsWith("microsplat_template_adapter.txt"))
|
||||||
|
{
|
||||||
|
adapter = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
||||||
|
}
|
||||||
|
if (p.EndsWith("microsplat_terrainblend_body.txt"))
|
||||||
|
{
|
||||||
|
terrainBlendBody = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
||||||
|
}
|
||||||
|
if (p.EndsWith("microsplat_terrainblend_cbuffer.txt"))
|
||||||
|
{
|
||||||
|
terrainBlendCBuffer = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.EndsWith("microsplat_terrain_body.txt"))
|
||||||
|
{
|
||||||
|
terrainBody = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
||||||
|
}
|
||||||
|
if (p.EndsWith("microsplat_shared.txt"))
|
||||||
|
{
|
||||||
|
sharedInc = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
||||||
|
}
|
||||||
|
if (p.EndsWith("microsplat_terrain_core_shared.txt"))
|
||||||
|
{
|
||||||
|
sharedHD = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
||||||
|
}
|
||||||
|
if (p.EndsWith("microsplat_terrain_core_vertex.txt"))
|
||||||
|
{
|
||||||
|
vertex = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
||||||
|
}
|
||||||
|
if (p.EndsWith("microsplat_terrain_core_vertexdata.txt"))
|
||||||
|
{
|
||||||
|
vertexData = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
||||||
|
}
|
||||||
|
if (p.EndsWith("microsplat_terrain_core_megasplat.txt"))
|
||||||
|
{
|
||||||
|
megasplatData = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
||||||
|
}
|
||||||
|
if (p.EndsWith("microsplat_terrain_core_mainfunc.txt"))
|
||||||
|
{
|
||||||
|
mainFunc = AssetDatabase.LoadAssetAtPath<TextAsset>(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string StripMegaSplat(string[] features)
|
||||||
|
{
|
||||||
|
if (features.Contains("_MEGASPLAT") && megasplatData != null)
|
||||||
|
{
|
||||||
|
var lines = megasplatData.text.ToLines();
|
||||||
|
var stripList = new List<string>();
|
||||||
|
stripList.Add("%SCATTER%");
|
||||||
|
stripList.Add("%SCATTER2%");
|
||||||
|
stripList.Add("%FX%");
|
||||||
|
stripList.Add("%FX2%");
|
||||||
|
|
||||||
|
if (features.Contains("_SCATTER"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%SCATTER%");
|
||||||
|
}
|
||||||
|
if (features.Contains("_SCATTERSECONDLAYER"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%SCATTER2%");
|
||||||
|
}
|
||||||
|
if (features.Contains("_WETNESS") || features.Contains("_PUDDLES") || features.Contains("_STREAMS") || features.Contains("_LAVA"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%FX%");
|
||||||
|
}
|
||||||
|
if (features.Contains("_SNOW") && features.Contains("_SNOWMASK"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%FX2%");
|
||||||
|
}
|
||||||
|
// strip any lines we need to remove
|
||||||
|
for (int i = 0; i < lines.Length; ++i)
|
||||||
|
{
|
||||||
|
string l = lines[i];
|
||||||
|
foreach (var s in stripList)
|
||||||
|
{
|
||||||
|
if (l.Contains(s))
|
||||||
|
{
|
||||||
|
lines[i] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// strip lines remaining.
|
||||||
|
string result = string.Join("\n", lines);
|
||||||
|
result = result.Replace("%SCATTER%", "");
|
||||||
|
result = result.Replace("%SCATTER2%", "");
|
||||||
|
result = result.Replace("%FX%", "");
|
||||||
|
result = result.Replace("%FX2%", "");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
string StripVertexWorkflow(string[] features)
|
||||||
|
{
|
||||||
|
if (vertexData != null &&
|
||||||
|
(features.Contains("_MICROVERTEXMESH") || features.Contains("_MICRODIGGERMESH"))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
var lines = vertexData.text.ToLines();
|
||||||
|
|
||||||
|
var stripList = new List<string>();
|
||||||
|
stripList.Add("%MAX8%");
|
||||||
|
stripList.Add("%MAX12%");
|
||||||
|
stripList.Add("%MAX16%");
|
||||||
|
stripList.Add("%MAX20%");
|
||||||
|
stripList.Add("%MAX24%");
|
||||||
|
stripList.Add("%MAX28%");
|
||||||
|
stripList.Add("%FX%");
|
||||||
|
stripList.Add("%FX2%");
|
||||||
|
|
||||||
|
if (features.Contains("_MAX8TEXTURES"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%MAX8%");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_MAX12TEXTURES"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%MAX8%");
|
||||||
|
stripList.Remove("%MAX12%");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_MAX20TEXTURES"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%MAX8%");
|
||||||
|
stripList.Remove("%MAX12%");
|
||||||
|
stripList.Remove("%MAX16%");
|
||||||
|
stripList.Remove("%MAX20%");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_MAX24TEXTURES"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%MAX8%");
|
||||||
|
stripList.Remove("%MAX12%");
|
||||||
|
stripList.Remove("%MAX16%");
|
||||||
|
stripList.Remove("%MAX20%");
|
||||||
|
stripList.Remove("%MAX24%");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_MAX28TEXTURES"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%MAX8%");
|
||||||
|
stripList.Remove("%MAX12%");
|
||||||
|
stripList.Remove("%MAX16%");
|
||||||
|
stripList.Remove("%MAX20%");
|
||||||
|
stripList.Remove("%MAX24%");
|
||||||
|
stripList.Remove("%MAX28%");
|
||||||
|
}
|
||||||
|
else if (features.Contains("_MAX32TEXTURES"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%MAX8%");
|
||||||
|
stripList.Remove("%MAX12%");
|
||||||
|
stripList.Remove("%MAX16%");
|
||||||
|
stripList.Remove("%MAX20%");
|
||||||
|
stripList.Remove("%MAX24%");
|
||||||
|
stripList.Remove("%MAX28%");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stripList.Remove("%MAX8%");
|
||||||
|
stripList.Remove("%MAX12%");
|
||||||
|
stripList.Remove("%MAX16%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (features.Contains("_WETNESS") || features.Contains("_PUDDLES") || features.Contains("_STREAMS") || features.Contains("_LAVA"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%FX%");
|
||||||
|
}
|
||||||
|
if (features.Contains("_SNOW") && features.Contains("_SNOWMASK"))
|
||||||
|
{
|
||||||
|
stripList.Remove("%FX2%");
|
||||||
|
}
|
||||||
|
// strip any lines we need to remove
|
||||||
|
for (int i = 0; i < lines.Length; ++i)
|
||||||
|
{
|
||||||
|
string l = lines[i];
|
||||||
|
foreach (var s in stripList)
|
||||||
|
{
|
||||||
|
if (l.Contains(s))
|
||||||
|
{
|
||||||
|
lines[i] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// strip lines remaining.
|
||||||
|
string result = string.Join("\n", lines);
|
||||||
|
result = result.Replace("%MAX8%", "");
|
||||||
|
result = result.Replace("%MAX12%", "");
|
||||||
|
result = result.Replace("%MAX16%", "");
|
||||||
|
result = result.Replace("%MAX20%", "");
|
||||||
|
result = result.Replace("%MAX24%", "");
|
||||||
|
result = result.Replace("%MAX28%", "");
|
||||||
|
result = result.Replace("%FX%", "");
|
||||||
|
result = result.Replace("%FX2%", "");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Blocks GetShaderBlocks(string[] features,
|
||||||
|
MicroSplatShaderGUI.MicroSplatCompiler compiler,
|
||||||
|
MicroSplatShaderGUI.MicroSplatCompiler.AuxShader auxShader)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
StringBuilder defines = new StringBuilder();
|
||||||
|
compiler.WriteDefines(features, defines);
|
||||||
|
if (auxShader != null && auxShader.trigger == "_TERRAINBLENDING")
|
||||||
|
{
|
||||||
|
defines.AppendLine(" #define _SRPTERRAINBLEND 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (features.Contains("_USESPECULARWORKFLOW"))
|
||||||
|
{
|
||||||
|
defines.AppendLine(" #define _SPECULAR_SETUP");
|
||||||
|
}
|
||||||
|
if (features.Contains("_MICROTERRAIN") && !features.Contains("_TERRAINBLENDABLESHADER")) // digger? mesh terrain?
|
||||||
|
{
|
||||||
|
defines.AppendLine("#pragma instancing_options assumeuniformscaling nomatrices nolightprobe nolightmap forwardadd");
|
||||||
|
}
|
||||||
|
StringBuilder cbuffer = new StringBuilder();
|
||||||
|
compiler.WritePerMaterialCBuffer(features, cbuffer);
|
||||||
|
if (auxShader != null && auxShader.trigger == "_TERRAINBLENDING")
|
||||||
|
{
|
||||||
|
cbuffer.AppendLine(terrainBlendCBuffer.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder options = new StringBuilder();
|
||||||
|
WriteOptions(features, options, compiler, auxShader, null);
|
||||||
|
StringBuilder properties = new StringBuilder();
|
||||||
|
compiler.WriteProperties(features, properties, auxShader);
|
||||||
|
|
||||||
|
StringBuilder ext = new StringBuilder();
|
||||||
|
compiler.WriteExtensions(features, ext);
|
||||||
|
|
||||||
|
StringBuilder afterVertex = new StringBuilder();
|
||||||
|
foreach (var e in compiler.extensions)
|
||||||
|
{
|
||||||
|
e.WriteAfterVetrexFunctions(afterVertex);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder code = new StringBuilder(100000);
|
||||||
|
code.AppendLine(adapter.text);
|
||||||
|
code.AppendLine(sharedInc.text);
|
||||||
|
code.AppendLine(StripVertexWorkflow(features));
|
||||||
|
code.AppendLine((StripMegaSplat(features)));
|
||||||
|
code.AppendLine(sharedHD.text);
|
||||||
|
code.AppendLine(ext.ToString());
|
||||||
|
code.AppendLine(terrainBody.text);
|
||||||
|
code.AppendLine(vertex.text);
|
||||||
|
if (auxShader != null && auxShader.trigger == "_TERRAINBLENDING")
|
||||||
|
{
|
||||||
|
code.AppendLine(terrainBlendBody.text);
|
||||||
|
}
|
||||||
|
code.AppendLine(mainFunc.text);
|
||||||
|
code.AppendLine(afterVertex.ToString());
|
||||||
|
|
||||||
|
Blocks b = new Blocks();
|
||||||
|
b.code = code.ToString();
|
||||||
|
b.cbuffer = cbuffer.ToString();
|
||||||
|
b.properties = properties.ToString();
|
||||||
|
b.defines = defines.ToString();
|
||||||
|
b.options = options.ToString();
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|