mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-25 02:55:15 +00:00
Airboarder is now More Recolorable! (#889)
- Added the ability to recolor the floor and clouds in Airboarder - also did a few minor visual touchups (clouds look much better, turns out i had them set to the wrong shader whoopsies)
This commit is contained in:
parent
f861be86a3
commit
e96ce2f8b1
51 changed files with 3568 additions and 58 deletions
8
Assets/ColorMask.meta
Normal file
8
Assets/ColorMask.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 22d3654ef7cd63d42af9086792d5957e
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/ColorMask/Scenes.meta
Normal file
9
Assets/ColorMask/Scenes.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c17475dd9320a0a4a99d80c33b85b8be
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1435093464
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/ColorMask/Scenes/ColorMaskDemoScene.meta
Normal file
9
Assets/ColorMask/Scenes/ColorMaskDemoScene.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c762db57443b28e43a6a0e8673fb29d8
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1435094370
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
494
Assets/ColorMask/Scenes/ColorMaskDemoScene.unity
Normal file
494
Assets/ColorMask/Scenes/ColorMaskDemoScene.unity
Normal file
|
@ -0,0 +1,494 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!29 &1
|
||||||
|
OcclusionCullingSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_OcclusionBakeSettings:
|
||||||
|
smallestOccluder: 5
|
||||||
|
smallestHole: 0.25
|
||||||
|
backfaceThreshold: 100
|
||||||
|
m_SceneGUID: 00000000000000000000000000000000
|
||||||
|
m_OcclusionCullingData: {fileID: 0}
|
||||||
|
--- !u!104 &2
|
||||||
|
RenderSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 9
|
||||||
|
m_Fog: 0
|
||||||
|
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
m_FogMode: 3
|
||||||
|
m_FogDensity: 0.01
|
||||||
|
m_LinearFogStart: 0
|
||||||
|
m_LinearFogEnd: 300
|
||||||
|
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||||
|
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||||
|
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||||
|
m_AmbientIntensity: 1
|
||||||
|
m_AmbientMode: 0
|
||||||
|
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||||
|
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_HaloStrength: 0.5
|
||||||
|
m_FlareStrength: 1
|
||||||
|
m_FlareFadeSpeed: 3
|
||||||
|
m_HaloTexture: {fileID: 0}
|
||||||
|
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
m_DefaultReflectionMode: 0
|
||||||
|
m_DefaultReflectionResolution: 128
|
||||||
|
m_ReflectionBounces: 1
|
||||||
|
m_ReflectionIntensity: 1
|
||||||
|
m_CustomReflection: {fileID: 0}
|
||||||
|
m_Sun: {fileID: 1186522133}
|
||||||
|
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
m_UseRadianceAmbientProbe: 0
|
||||||
|
--- !u!157 &4
|
||||||
|
LightmapSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 12
|
||||||
|
m_GIWorkflowMode: 0
|
||||||
|
m_GISettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_BounceScale: 1
|
||||||
|
m_IndirectOutputScale: 1
|
||||||
|
m_AlbedoBoost: 1
|
||||||
|
m_EnvironmentLightingMode: 0
|
||||||
|
m_EnableBakedLightmaps: 0
|
||||||
|
m_EnableRealtimeLightmaps: 1
|
||||||
|
m_LightmapEditorSettings:
|
||||||
|
serializedVersion: 12
|
||||||
|
m_Resolution: 3
|
||||||
|
m_BakeResolution: 40
|
||||||
|
m_AtlasSize: 1024
|
||||||
|
m_AO: 0
|
||||||
|
m_AOMaxDistance: 1
|
||||||
|
m_CompAOExponent: 0
|
||||||
|
m_CompAOExponentDirect: 0
|
||||||
|
m_ExtractAmbientOcclusion: 0
|
||||||
|
m_Padding: 2
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_LightmapsBakeMode: 1
|
||||||
|
m_TextureCompression: 1
|
||||||
|
m_FinalGather: 0
|
||||||
|
m_FinalGatherFiltering: 1
|
||||||
|
m_FinalGatherRayCount: 1024
|
||||||
|
m_ReflectionCompression: 2
|
||||||
|
m_MixedBakeMode: 1
|
||||||
|
m_BakeBackend: 0
|
||||||
|
m_PVRSampling: 1
|
||||||
|
m_PVRDirectSampleCount: 32
|
||||||
|
m_PVRSampleCount: 512
|
||||||
|
m_PVRBounces: 2
|
||||||
|
m_PVREnvironmentSampleCount: 512
|
||||||
|
m_PVREnvironmentReferencePointCount: 2048
|
||||||
|
m_PVRFilteringMode: 0
|
||||||
|
m_PVRDenoiserTypeDirect: 0
|
||||||
|
m_PVRDenoiserTypeIndirect: 0
|
||||||
|
m_PVRDenoiserTypeAO: 0
|
||||||
|
m_PVRFilterTypeDirect: 0
|
||||||
|
m_PVRFilterTypeIndirect: 0
|
||||||
|
m_PVRFilterTypeAO: 0
|
||||||
|
m_PVREnvironmentMIS: 0
|
||||||
|
m_PVRCulling: 1
|
||||||
|
m_PVRFilteringGaussRadiusDirect: 1
|
||||||
|
m_PVRFilteringGaussRadiusIndirect: 5
|
||||||
|
m_PVRFilteringGaussRadiusAO: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||||
|
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||||
|
m_ExportTrainingData: 0
|
||||||
|
m_TrainingDataDestination: TrainingData
|
||||||
|
m_LightProbeSampleCountMultiplier: 4
|
||||||
|
m_LightingDataAsset: {fileID: 112000000, guid: 913305946ad6fe645a82dd766303ac75, type: 2}
|
||||||
|
m_LightingSettings: {fileID: 4890085278179872738, guid: df7b424ca5e90e44780c564886dc1020, type: 2}
|
||||||
|
--- !u!196 &5
|
||||||
|
NavMeshSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_BuildSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
agentTypeID: 0
|
||||||
|
agentRadius: 0.5
|
||||||
|
agentHeight: 2
|
||||||
|
agentSlope: 45
|
||||||
|
agentClimb: 0.4
|
||||||
|
ledgeDropHeight: 0
|
||||||
|
maxJumpAcrossDistance: 0
|
||||||
|
minRegionArea: 2
|
||||||
|
manualCellSize: 0
|
||||||
|
cellSize: 0.16666667
|
||||||
|
manualTileSize: 0
|
||||||
|
tileSize: 256
|
||||||
|
accuratePlacement: 0
|
||||||
|
maxJobWorkers: 0
|
||||||
|
preserveTilesOutsideBounds: 0
|
||||||
|
debug:
|
||||||
|
m_Flags: 0
|
||||||
|
m_NavMeshData: {fileID: 0}
|
||||||
|
--- !u!1 &522608403
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 522608408}
|
||||||
|
- component: {fileID: 522608407}
|
||||||
|
- component: {fileID: 522608405}
|
||||||
|
- component: {fileID: 522608404}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Main Camera
|
||||||
|
m_TagString: MainCamera
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!81 &522608404
|
||||||
|
AudioListener:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 522608403}
|
||||||
|
m_Enabled: 1
|
||||||
|
--- !u!124 &522608405
|
||||||
|
Behaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 522608403}
|
||||||
|
m_Enabled: 1
|
||||||
|
--- !u!20 &522608407
|
||||||
|
Camera:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 522608403}
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 2
|
||||||
|
m_ClearFlags: 1
|
||||||
|
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844}
|
||||||
|
m_projectionMatrixMode: 1
|
||||||
|
m_GateFitMode: 2
|
||||||
|
m_FOVAxisMode: 0
|
||||||
|
m_SensorSize: {x: 36, y: 24}
|
||||||
|
m_LensShift: {x: 0, y: 0}
|
||||||
|
m_FocalLength: 50
|
||||||
|
m_NormalizedViewPortRect:
|
||||||
|
serializedVersion: 2
|
||||||
|
x: 0
|
||||||
|
y: 0
|
||||||
|
width: 1
|
||||||
|
height: 1
|
||||||
|
near clip plane: 0.3
|
||||||
|
far clip plane: 1000
|
||||||
|
field of view: 60
|
||||||
|
orthographic: 0
|
||||||
|
orthographic size: 5
|
||||||
|
m_Depth: -1
|
||||||
|
m_CullingMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_RenderingPath: -1
|
||||||
|
m_TargetTexture: {fileID: 0}
|
||||||
|
m_TargetDisplay: 0
|
||||||
|
m_TargetEye: 3
|
||||||
|
m_HDR: 0
|
||||||
|
m_AllowMSAA: 1
|
||||||
|
m_AllowDynamicResolution: 0
|
||||||
|
m_ForceIntoRT: 0
|
||||||
|
m_OcclusionCulling: 1
|
||||||
|
m_StereoConvergence: 10
|
||||||
|
m_StereoSeparation: 0.022
|
||||||
|
--- !u!4 &522608408
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 522608403}
|
||||||
|
m_LocalRotation: {x: 0.20153812, y: 0.3734672, z: -0.08347983, w: 0.9016295}
|
||||||
|
m_LocalPosition: {x: -1.5, y: 1.5, z: -1.5}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &1186522132
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1186522134}
|
||||||
|
- component: {fileID: 1186522133}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Directional Light
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!108 &1186522133
|
||||||
|
Light:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1186522132}
|
||||||
|
m_Enabled: 1
|
||||||
|
serializedVersion: 10
|
||||||
|
m_Type: 1
|
||||||
|
m_Shape: 0
|
||||||
|
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
||||||
|
m_Intensity: 1
|
||||||
|
m_Range: 10
|
||||||
|
m_SpotAngle: 30
|
||||||
|
m_InnerSpotAngle: 21.80208
|
||||||
|
m_CookieSize: 10
|
||||||
|
m_Shadows:
|
||||||
|
m_Type: 2
|
||||||
|
m_Resolution: -1
|
||||||
|
m_CustomResolution: -1
|
||||||
|
m_Strength: 1
|
||||||
|
m_Bias: 0.02
|
||||||
|
m_NormalBias: 0.01
|
||||||
|
m_NearPlane: 0.2
|
||||||
|
m_CullingMatrixOverride:
|
||||||
|
e00: 1
|
||||||
|
e01: 0
|
||||||
|
e02: 0
|
||||||
|
e03: 0
|
||||||
|
e10: 0
|
||||||
|
e11: 1
|
||||||
|
e12: 0
|
||||||
|
e13: 0
|
||||||
|
e20: 0
|
||||||
|
e21: 0
|
||||||
|
e22: 1
|
||||||
|
e23: 0
|
||||||
|
e30: 0
|
||||||
|
e31: 0
|
||||||
|
e32: 0
|
||||||
|
e33: 1
|
||||||
|
m_UseCullingMatrixOverride: 0
|
||||||
|
m_Cookie: {fileID: 0}
|
||||||
|
m_DrawHalo: 0
|
||||||
|
m_Flare: {fileID: 0}
|
||||||
|
m_RenderMode: 0
|
||||||
|
m_CullingMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_Lightmapping: 4
|
||||||
|
m_LightShadowCasterMode: 0
|
||||||
|
m_AreaSize: {x: 1, y: 1}
|
||||||
|
m_BounceIntensity: 3
|
||||||
|
m_ColorTemperature: 6570
|
||||||
|
m_UseColorTemperature: 0
|
||||||
|
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_UseBoundingSphereOverride: 0
|
||||||
|
m_UseViewFrustumForShadowCasterCull: 1
|
||||||
|
m_ShadowRadius: 0
|
||||||
|
m_ShadowAngle: 0
|
||||||
|
--- !u!4 &1186522134
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1186522132}
|
||||||
|
m_LocalRotation: {x: 0.40821794, y: -0.23456973, z: 0.109381676, w: 0.87542605}
|
||||||
|
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 1
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &1473662018
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1473662022}
|
||||||
|
- component: {fileID: 1473662021}
|
||||||
|
- component: {fileID: 1473662019}
|
||||||
|
- component: {fileID: 1473662023}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Cube
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 4294967295
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!23 &1473662019
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1473662018}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: 223ee43a82931dd428f50eb63062f3d2, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 1
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
|
--- !u!33 &1473662021
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1473662018}
|
||||||
|
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!4 &1473662022
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1473662018}
|
||||||
|
m_LocalRotation: {x: 0, y: 1, z: 0, w: -0.00000016292068}
|
||||||
|
m_LocalPosition: {x: 0, y: 0.5, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 2
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &1473662023
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1473662018}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2b78a7604e40eb145a9646472574ea25, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
material: {fileID: 2100000, guid: 223ee43a82931dd428f50eb63062f3d2, type: 2}
|
||||||
|
renderers:
|
||||||
|
- {fileID: 2142239801}
|
||||||
|
--- !u!1 &2142239800
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 2142239804}
|
||||||
|
- component: {fileID: 2142239803}
|
||||||
|
- component: {fileID: 2142239801}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Plane
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 4294967295
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!23 &2142239801
|
||||||
|
MeshRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2142239800}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_CastShadows: 1
|
||||||
|
m_ReceiveShadows: 1
|
||||||
|
m_DynamicOccludee: 1
|
||||||
|
m_StaticShadowCaster: 0
|
||||||
|
m_MotionVectors: 1
|
||||||
|
m_LightProbeUsage: 1
|
||||||
|
m_ReflectionProbeUsage: 1
|
||||||
|
m_RayTracingMode: 2
|
||||||
|
m_RayTraceProcedural: 0
|
||||||
|
m_RenderingLayerMask: 1
|
||||||
|
m_RendererPriority: 0
|
||||||
|
m_Materials:
|
||||||
|
- {fileID: 2100000, guid: 7fa234d5acd3b6849b139703d841c60f, type: 2}
|
||||||
|
m_StaticBatchInfo:
|
||||||
|
firstSubMesh: 0
|
||||||
|
subMeshCount: 0
|
||||||
|
m_StaticBatchRoot: {fileID: 0}
|
||||||
|
m_ProbeAnchor: {fileID: 0}
|
||||||
|
m_LightProbeVolumeOverride: {fileID: 0}
|
||||||
|
m_ScaleInLightmap: 1
|
||||||
|
m_ReceiveGI: 1
|
||||||
|
m_PreserveUVs: 1
|
||||||
|
m_IgnoreNormalsForChartDetection: 0
|
||||||
|
m_ImportantGI: 0
|
||||||
|
m_StitchLightmapSeams: 1
|
||||||
|
m_SelectedEditorRenderState: 3
|
||||||
|
m_MinimumChartSize: 4
|
||||||
|
m_AutoUVMaxDistance: 0.5
|
||||||
|
m_AutoUVMaxAngle: 89
|
||||||
|
m_LightmapParameters: {fileID: 0}
|
||||||
|
m_SortingLayerID: 0
|
||||||
|
m_SortingLayer: 0
|
||||||
|
m_SortingOrder: 0
|
||||||
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
|
--- !u!33 &2142239803
|
||||||
|
MeshFilter:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2142239800}
|
||||||
|
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
|
--- !u!4 &2142239804
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 2142239800}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_RootOrder: 3
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
8
Assets/ColorMask/Scenes/ColorMaskDemoScene.unity.meta
Normal file
8
Assets/ColorMask/Scenes/ColorMaskDemoScene.unity.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 13e713d152af235469181070b07d11fc
|
||||||
|
timeCreated: 1435094368
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6a6708dc0b2ee8142b43a1214b4c0447
|
||||||
|
timeCreated: 1435262578
|
||||||
|
licenseType: Store
|
||||||
|
NativeFormatImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/ColorMask/Scenes/ColorMaskDemoScene/SkyboxProbe-0.exr
Normal file
BIN
Assets/ColorMask/Scenes/ColorMaskDemoScene/SkyboxProbe-0.exr
Normal file
Binary file not shown.
|
@ -0,0 +1,56 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 56dd085cfa8b6ad46be26650c48467bd
|
||||||
|
timeCreated: 1435262578
|
||||||
|
licenseType: Store
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName:
|
||||||
|
8900000: generatedCubemap
|
||||||
|
serializedVersion: 2
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
linearTexture: 0
|
||||||
|
correctGamma: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: .25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 1
|
||||||
|
cubemapConvolutionSteps: 8
|
||||||
|
cubemapConvolutionExponent: 1.5
|
||||||
|
seamlessCubemap: 1
|
||||||
|
textureFormat: -1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
filterMode: 2
|
||||||
|
aniso: 0
|
||||||
|
mipBias: 0
|
||||||
|
wrapMode: 1
|
||||||
|
nPOTScale: 1
|
||||||
|
lightmap: 0
|
||||||
|
rGBM: 0
|
||||||
|
compressionQuality: 100
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: .5, y: .5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaIsTransparency: 0
|
||||||
|
textureType: 3
|
||||||
|
buildTargetSettings: []
|
||||||
|
spriteSheet:
|
||||||
|
sprites: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
64
Assets/ColorMask/Scenes/ColorMaskDemoSceneSettings.lighting
Normal file
64
Assets/ColorMask/Scenes/ColorMaskDemoSceneSettings.lighting
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!850595691 &4890085278179872738
|
||||||
|
LightingSettings:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name: ColorMaskDemoSceneSettings
|
||||||
|
serializedVersion: 4
|
||||||
|
m_GIWorkflowMode: 0
|
||||||
|
m_EnableBakedLightmaps: 0
|
||||||
|
m_EnableRealtimeLightmaps: 1
|
||||||
|
m_RealtimeEnvironmentLighting: 1
|
||||||
|
m_BounceScale: 1
|
||||||
|
m_AlbedoBoost: 1
|
||||||
|
m_IndirectOutputScale: 1
|
||||||
|
m_UsingShadowmask: 0
|
||||||
|
m_BakeBackend: 0
|
||||||
|
m_LightmapMaxSize: 1024
|
||||||
|
m_BakeResolution: 40
|
||||||
|
m_Padding: 2
|
||||||
|
m_LightmapCompression: 3
|
||||||
|
m_AO: 0
|
||||||
|
m_AOMaxDistance: 1
|
||||||
|
m_CompAOExponent: 0
|
||||||
|
m_CompAOExponentDirect: 0
|
||||||
|
m_ExtractAO: 0
|
||||||
|
m_MixedBakeMode: 1
|
||||||
|
m_LightmapsBakeMode: 1
|
||||||
|
m_FilterMode: 1
|
||||||
|
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_ExportTrainingData: 0
|
||||||
|
m_TrainingDataDestination: TrainingData
|
||||||
|
m_RealtimeResolution: 3
|
||||||
|
m_ForceWhiteAlbedo: 0
|
||||||
|
m_ForceUpdates: 0
|
||||||
|
m_FinalGather: 0
|
||||||
|
m_FinalGatherRayCount: 1024
|
||||||
|
m_FinalGatherFiltering: 1
|
||||||
|
m_PVRCulling: 1
|
||||||
|
m_PVRSampling: 1
|
||||||
|
m_PVRDirectSampleCount: 32
|
||||||
|
m_PVRSampleCount: 512
|
||||||
|
m_PVREnvironmentSampleCount: 512
|
||||||
|
m_PVREnvironmentReferencePointCount: 2048
|
||||||
|
m_LightProbeSampleCountMultiplier: 4
|
||||||
|
m_PVRBounces: 2
|
||||||
|
m_PVRMinBounces: 2
|
||||||
|
m_PVREnvironmentMIS: 0
|
||||||
|
m_PVRFilteringMode: 0
|
||||||
|
m_PVRDenoiserTypeDirect: 0
|
||||||
|
m_PVRDenoiserTypeIndirect: 0
|
||||||
|
m_PVRDenoiserTypeAO: 0
|
||||||
|
m_PVRFilterTypeDirect: 0
|
||||||
|
m_PVRFilterTypeIndirect: 0
|
||||||
|
m_PVRFilterTypeAO: 0
|
||||||
|
m_PVRFilteringGaussRadiusDirect: 1
|
||||||
|
m_PVRFilteringGaussRadiusIndirect: 5
|
||||||
|
m_PVRFilteringGaussRadiusAO: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||||
|
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||||
|
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||||
|
m_PVRTiledBaking: 0
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: df7b424ca5e90e44780c564886dc1020
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 4890085278179872738
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/ColorMask/Scripts.meta
Normal file
9
Assets/ColorMask/Scripts.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5a1bdc87f8cf6f847989b341d67a78b0
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1435095695
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
106
Assets/ColorMask/Scripts/MaterialUpdateExample.cs
Normal file
106
Assets/ColorMask/Scripts/MaterialUpdateExample.cs
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public class MaterialUpdateExample : MonoBehaviour {
|
||||||
|
|
||||||
|
public Material material;
|
||||||
|
public List<Renderer> renderers = new List<Renderer>();
|
||||||
|
|
||||||
|
//If running in the unity editor store the original ColorMask color values so they can be reset when the Game stops running
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
private Color redColorReset;
|
||||||
|
private Color greenColorReset;
|
||||||
|
private Color blueColorReset;
|
||||||
|
private Color alphaColorReset;
|
||||||
|
|
||||||
|
void Start ()
|
||||||
|
{
|
||||||
|
if (material != null)
|
||||||
|
{
|
||||||
|
//Store the original ColorMask color values
|
||||||
|
redColorReset = material.GetColor("_RedColor");
|
||||||
|
greenColorReset = material.GetColor("_GreenColor");
|
||||||
|
blueColorReset = material.GetColor("_BlueColor");
|
||||||
|
alphaColorReset = material.GetColor("_AlphaColor");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDestroy ()
|
||||||
|
{
|
||||||
|
if (material != null)
|
||||||
|
{
|
||||||
|
//Reset to the original ColorMask color values
|
||||||
|
material.SetColor("_RedColor", redColorReset);
|
||||||
|
material.SetColor("_GreenColor", greenColorReset);
|
||||||
|
material.SetColor("_BlueColor", blueColorReset);
|
||||||
|
material.SetColor("_AlphaColor", alphaColorReset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void Update ()
|
||||||
|
{
|
||||||
|
//Esc Exit - PC Standalone Build
|
||||||
|
#if UNITY_STANDALONE_WIN
|
||||||
|
if (Input.GetKey("escape"))
|
||||||
|
Application.Quit();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (material != null)
|
||||||
|
{
|
||||||
|
//Stores a value of time scaled
|
||||||
|
float value = Time.time * 0.12f;
|
||||||
|
|
||||||
|
//Calculates cyclical invert and fade values between zero and one
|
||||||
|
float invert = Mathf.Pow (Mathf.Min(1f + Mathf.Sin(value * Mathf.PI), 1f), 7.5f);
|
||||||
|
float fade = Mathf.Max(invert, Mathf.Pow (Mathf.Min(1f + Mathf.Sin(value * 2f * Mathf.PI), 1f), 7.5f) );
|
||||||
|
|
||||||
|
//Converts value to a number between 0 and 1 which is converted to a color
|
||||||
|
//Also applies fade alpha value to red and green
|
||||||
|
Color redColor = ConvertValueToColor (value % 1f) * new Color(1f, 1f, 1f, fade);
|
||||||
|
Color greenColor = ConvertValueToColor ( (value + 0.03125f) % 1f) * new Color(0.5f, 0.5f, 0.5f, fade);
|
||||||
|
Color blueColor = ConvertValueToColor ( (value + 0.75f) % 1f);
|
||||||
|
Color alphaColor = ConvertValueToColor ( (value + 0.78125f) % 1f) * new Color(0.5f, 0.5f, 0.5f, 1f);
|
||||||
|
|
||||||
|
//Invert set red and alpha colors when invert value approaches zero
|
||||||
|
redColor = Color.Lerp(new Color(1f - redColor.r, 1f - redColor.g, 1f - redColor.b, redColor.a), redColor, invert);
|
||||||
|
alphaColor = Color.Lerp(new Color(1f - alphaColor.r, 1f - alphaColor.g, 1f - alphaColor.b, alphaColor.a), alphaColor, invert);
|
||||||
|
|
||||||
|
//Apply the new colors to the ColorMask material colors
|
||||||
|
material.SetColor("_RedColor", redColor);
|
||||||
|
material.SetColor("_GreenColor", greenColor);
|
||||||
|
material.SetColor("_BlueColor", blueColor);
|
||||||
|
material.SetColor("_AlphaColor", alphaColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
//If a static gameObject which uses a ColorMask shader affects another static gameObject(s)' Precomputed Realtime GI, then this code is necessary to see the updated GI
|
||||||
|
for (int i = 0; i < renderers.Count; i++)
|
||||||
|
{
|
||||||
|
if (renderers[i] != null)
|
||||||
|
{
|
||||||
|
RendererExtensions.UpdateGIMaterials(renderers[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//This converts a value between 0 and 1 to a color between Red, Yellow, Green, Cyan, Blue and Magenta
|
||||||
|
Color ConvertValueToColor (float value)
|
||||||
|
{
|
||||||
|
List<Color> Rainbow = new List<Color>();
|
||||||
|
Rainbow.Add(Color.red);
|
||||||
|
Rainbow.Add(Color.yellow);
|
||||||
|
Rainbow.Add(Color.green);
|
||||||
|
Rainbow.Add(Color.cyan);
|
||||||
|
Rainbow.Add(Color.blue);
|
||||||
|
Rainbow.Add(Color.magenta);
|
||||||
|
Rainbow.Add(Color.red);
|
||||||
|
|
||||||
|
float RainbowCount = Rainbow.Count - 1;
|
||||||
|
float idfloat = value * RainbowCount;
|
||||||
|
int id = (int)idfloat;
|
||||||
|
|
||||||
|
return Color.Lerp(Rainbow[id], Rainbow[id + 1], (idfloat - (float)id) % 1f);
|
||||||
|
}
|
||||||
|
}
|
12
Assets/ColorMask/Scripts/MaterialUpdateExample.cs.meta
Normal file
12
Assets/ColorMask/Scripts/MaterialUpdateExample.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2b78a7604e40eb145a9646472574ea25
|
||||||
|
timeCreated: 1435095700
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/ColorMask/Shaders.meta
Normal file
9
Assets/ColorMask/Shaders.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 54ee3cd77fd9dd5459f496f931ec9367
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1435093421
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
342
Assets/ColorMask/Shaders/ColorMaskStandard.shader
Normal file
342
Assets/ColorMask/Shaders/ColorMaskStandard.shader
Normal file
|
@ -0,0 +1,342 @@
|
||||||
|
Shader "ColorMask/Standard"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
_Color("Color", Color) = (1,1,1,1)
|
||||||
|
_MainTex("Albedo", 2D) = "white" {}
|
||||||
|
|
||||||
|
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||||
|
|
||||||
|
_ColorMaskTex("Color Mask", 2D) = "black" {}
|
||||||
|
_RedColor("Red Color", Color) = (1,1,1,1)
|
||||||
|
_GreenColor("Green Color", Color) = (1,1,1,1)
|
||||||
|
_BlueColor("Blue Color", Color) = (1,1,1,1)
|
||||||
|
_AlphaColor("Alpha Color", Color) = (1,1,1,1)
|
||||||
|
|
||||||
|
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||||
|
_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
|
||||||
|
[Enum(Metallic Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel ("Smoothness texture channel", Float) = 0
|
||||||
|
|
||||||
|
[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
|
||||||
|
_MetallicGlossMap("Metallic", 2D) = "white" {}
|
||||||
|
|
||||||
|
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
||||||
|
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0
|
||||||
|
|
||||||
|
_BumpScale("Scale", Float) = 1.0
|
||||||
|
_BumpMap("Normal Map", 2D) = "bump" {}
|
||||||
|
|
||||||
|
_Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02
|
||||||
|
_ParallaxMap ("Height Map", 2D) = "black" {}
|
||||||
|
|
||||||
|
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
|
||||||
|
_OcclusionMap("Occlusion", 2D) = "white" {}
|
||||||
|
|
||||||
|
_EmissionColor("Color", Color) = (0,0,0)
|
||||||
|
_EmissionMap("Emission", 2D) = "white" {}
|
||||||
|
|
||||||
|
_DetailMask("Detail Mask", 2D) = "white" {}
|
||||||
|
|
||||||
|
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
|
||||||
|
_DetailNormalMapScale("Scale", Float) = 1.0
|
||||||
|
_DetailNormalMap("Normal Map", 2D) = "bump" {}
|
||||||
|
|
||||||
|
[Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0
|
||||||
|
|
||||||
|
|
||||||
|
// Blending state
|
||||||
|
[HideInInspector] _Mode ("__mode", Float) = 0.0
|
||||||
|
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
|
||||||
|
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
|
||||||
|
[HideInInspector] _ZWrite ("__zw", Float) = 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
CGINCLUDE
|
||||||
|
#define UNITY_SETUP_BRDF_INPUT MetallicSetup
|
||||||
|
ENDCG
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
|
||||||
|
LOD 300
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Base forward pass (directional light, emission, lightmaps, ...)
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD"
|
||||||
|
Tags { "LightMode" = "ForwardBase" }
|
||||||
|
|
||||||
|
Blend [_SrcBlend] [_DstBlend]
|
||||||
|
ZWrite [_ZWrite]
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
|
||||||
|
// -------------------------------------
|
||||||
|
|
||||||
|
#pragma shader_feature _NORMALMAP
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _EMISSION
|
||||||
|
#pragma shader_feature _METALLICGLOSSMAP
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||||
|
#pragma shader_feature _ _GLOSSYREFLECTIONS_OFF
|
||||||
|
#pragma shader_feature _PARALLAXMAP
|
||||||
|
|
||||||
|
#pragma multi_compile_fwdbase
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#pragma vertex vertBase
|
||||||
|
#pragma fragment fragBase
|
||||||
|
#include "ColorMaskStandardCoreForward.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Additive forward pass (one light per pass)
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD_DELTA"
|
||||||
|
Tags { "LightMode" = "ForwardAdd" }
|
||||||
|
Blend [_SrcBlend] One
|
||||||
|
Fog { Color (0,0,0,0) } // in additive pass fog should be black
|
||||||
|
ZWrite Off
|
||||||
|
ZTest LEqual
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
|
||||||
|
// -------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
#pragma shader_feature _NORMALMAP
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _METALLICGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
#pragma shader_feature _PARALLAXMAP
|
||||||
|
|
||||||
|
#pragma multi_compile_fwdadd_fullshadows
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
|
||||||
|
#pragma vertex vertAdd
|
||||||
|
#pragma fragment fragAdd
|
||||||
|
#include "ColorMaskStandardCoreForward.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Shadow rendering pass
|
||||||
|
Pass {
|
||||||
|
Name "ShadowCaster"
|
||||||
|
Tags { "LightMode" = "ShadowCaster" }
|
||||||
|
|
||||||
|
ZWrite On ZTest LEqual
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
|
||||||
|
// -------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma multi_compile_shadowcaster
|
||||||
|
|
||||||
|
#pragma vertex vertShadowCaster
|
||||||
|
#pragma fragment fragShadowCaster
|
||||||
|
|
||||||
|
#include "UnityStandardShadow.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Deferred pass
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "DEFERRED"
|
||||||
|
Tags { "LightMode" = "Deferred" }
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma exclude_renderers nomrt
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------
|
||||||
|
|
||||||
|
#pragma shader_feature _NORMALMAP
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _EMISSION
|
||||||
|
#pragma shader_feature _METALLICGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
#pragma shader_feature _PARALLAXMAP
|
||||||
|
|
||||||
|
#pragma multi_compile ___ UNITY_HDR_ON
|
||||||
|
#pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON
|
||||||
|
#pragma multi_compile ___ DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||||
|
#pragma multi_compile DYNAMICLIGHTMAP_OFF DYNAMICLIGHTMAP_ON
|
||||||
|
|
||||||
|
#pragma vertex vertDeferred
|
||||||
|
#pragma fragment fragDeferred
|
||||||
|
|
||||||
|
#include "ColorMaskStandardCore.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Extracts information for lightmapping, GI (emission, albedo, ...)
|
||||||
|
// This pass it not used during regular rendering.
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "META"
|
||||||
|
Tags { "LightMode"="Meta" }
|
||||||
|
|
||||||
|
Cull Off
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 2.5
|
||||||
|
|
||||||
|
#pragma vertex vert_meta
|
||||||
|
#pragma fragment frag_meta
|
||||||
|
|
||||||
|
#pragma shader_feature _EMISSION
|
||||||
|
#pragma shader_feature _METALLICGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
|
||||||
|
#include "ColorMaskStandardMeta.cginc"
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
|
||||||
|
LOD 150
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Base forward pass (directional light, emission, lightmaps, ...)
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD"
|
||||||
|
Tags { "LightMode" = "ForwardBase" }
|
||||||
|
|
||||||
|
Blend [_SrcBlend] [_DstBlend]
|
||||||
|
ZWrite [_ZWrite]
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 2.5
|
||||||
|
|
||||||
|
#pragma shader_feature _NORMALMAP
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _EMISSION
|
||||||
|
#pragma shader_feature _METALLICGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||||
|
#pragma shader_feature _ _GLOSSYREFLECTIONS_OFF
|
||||||
|
// SM2.0: NOT SUPPORTED shader_feature ___ _DETAIL_MULX2
|
||||||
|
// SM2.0: NOT SUPPORTED shader_feature _PARALLAXMAP
|
||||||
|
|
||||||
|
#pragma skip_variants SHADOWS_SOFT DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||||
|
|
||||||
|
#pragma multi_compile_fwdbase
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#pragma vertex vertBase
|
||||||
|
#pragma fragment fragBase
|
||||||
|
#include "ColorMaskStandardCoreForward.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Additive forward pass (one light per pass)
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD_DELTA"
|
||||||
|
Tags { "LightMode" = "ForwardAdd" }
|
||||||
|
Blend [_SrcBlend] One
|
||||||
|
Fog { Color (0,0,0,0) } // in additive pass fog should be black
|
||||||
|
ZWrite Off
|
||||||
|
ZTest LEqual
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 2.5
|
||||||
|
|
||||||
|
#pragma shader_feature _NORMALMAP
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _METALLICGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
// SM2.0: NOT SUPPORTED shader_feature _PARALLAXMAP
|
||||||
|
#pragma skip_variants SHADOWS_SOFT
|
||||||
|
|
||||||
|
#pragma multi_compile_fwdadd_fullshadows
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#pragma vertex vertAdd
|
||||||
|
#pragma fragment fragAdd
|
||||||
|
#include "ColorMaskStandardCoreForward.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Shadow rendering pass
|
||||||
|
Pass {
|
||||||
|
Name "ShadowCaster"
|
||||||
|
Tags { "LightMode" = "ShadowCaster" }
|
||||||
|
|
||||||
|
ZWrite On ZTest LEqual
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 2.0
|
||||||
|
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma skip_variants SHADOWS_SOFT
|
||||||
|
#pragma multi_compile_shadowcaster
|
||||||
|
|
||||||
|
#pragma vertex vertShadowCaster
|
||||||
|
#pragma fragment fragShadowCaster
|
||||||
|
|
||||||
|
#include "UnityStandardShadow.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Extracts information for lightmapping, GI (emission, albedo, ...)
|
||||||
|
// This pass it not used during regular rendering.
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "META"
|
||||||
|
Tags { "LightMode"="Meta" }
|
||||||
|
|
||||||
|
Cull Off
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 2.5
|
||||||
|
|
||||||
|
#pragma vertex vert_meta
|
||||||
|
#pragma fragment frag_meta
|
||||||
|
|
||||||
|
#pragma shader_feature _EMISSION
|
||||||
|
#pragma shader_feature _METALLICGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
|
||||||
|
#include "ColorMaskStandardMeta.cginc"
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FallBack "VertexLit"
|
||||||
|
CustomEditor "ColorMaskStandardShaderGUI"
|
||||||
|
}
|
9
Assets/ColorMask/Shaders/ColorMaskStandard.shader.meta
Normal file
9
Assets/ColorMask/Shaders/ColorMaskStandard.shader.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0179f1693b517f3428e6d259da489c15
|
||||||
|
timeCreated: 1435093425
|
||||||
|
licenseType: Store
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
694
Assets/ColorMask/Shaders/ColorMaskStandardCore.cginc
Normal file
694
Assets/ColorMask/Shaders/ColorMaskStandardCore.cginc
Normal file
|
@ -0,0 +1,694 @@
|
||||||
|
#ifndef UNITY_STANDARD_CORE_INCLUDED
|
||||||
|
#define UNITY_STANDARD_CORE_INCLUDED
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityShaderVariables.cginc"
|
||||||
|
#include "UnityInstancing.cginc"
|
||||||
|
#include "UnityStandardConfig.cginc"
|
||||||
|
#include "ColorMaskStandardInput.cginc"
|
||||||
|
#include "UnityPBSLighting.cginc"
|
||||||
|
#include "UnityStandardUtils.cginc"
|
||||||
|
#include "UnityGBuffer.cginc"
|
||||||
|
#include "UnityStandardBRDF.cginc"
|
||||||
|
|
||||||
|
#include "AutoLight.cginc"
|
||||||
|
//-------------------------------------------------------------------------------------
|
||||||
|
// counterpart for NormalizePerPixelNormal
|
||||||
|
// skips normalization per-vertex and expects normalization to happen per-pixel
|
||||||
|
half3 NormalizePerVertexNormal (float3 n) // takes float to avoid overflow
|
||||||
|
{
|
||||||
|
#if (SHADER_TARGET < 30) || UNITY_STANDARD_SIMPLE
|
||||||
|
return normalize(n);
|
||||||
|
#else
|
||||||
|
return n; // will normalize per-pixel instead
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
half3 NormalizePerPixelNormal (half3 n)
|
||||||
|
{
|
||||||
|
#if (SHADER_TARGET < 30) || UNITY_STANDARD_SIMPLE
|
||||||
|
return n;
|
||||||
|
#else
|
||||||
|
return normalize(n);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------
|
||||||
|
UnityLight MainLight ()
|
||||||
|
{
|
||||||
|
UnityLight l;
|
||||||
|
#if !defined(LIGHTMAP_ON)
|
||||||
|
l.color = _LightColor0.rgb;
|
||||||
|
l.dir = _WorldSpaceLightPos0.xyz;
|
||||||
|
l.ndotl = 0; // Not used
|
||||||
|
#else
|
||||||
|
// no light specified by the engine
|
||||||
|
// analytical light might be extracted from Lightmap data later on in the shader depending on the Lightmap type
|
||||||
|
// Should be ResetUnityLight() call but can't move the function to a UnityLightingCommon.cginc header because it break UBER shader on asset store...
|
||||||
|
l.color = half3(0, 0, 0);
|
||||||
|
l.dir = half3(0, 1, 0); // Irrelevant direction, just not null
|
||||||
|
l.ndotl = 0; // Not used
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnityLight AdditiveLight (half3 lightDir, half atten)
|
||||||
|
{
|
||||||
|
UnityLight l;
|
||||||
|
|
||||||
|
l.color = _LightColor0.rgb;
|
||||||
|
l.dir = lightDir;
|
||||||
|
#ifndef USING_DIRECTIONAL_LIGHT
|
||||||
|
l.dir = NormalizePerPixelNormal(l.dir);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// shadow the light
|
||||||
|
l.color *= atten;
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnityLight DummyLight ()
|
||||||
|
{
|
||||||
|
UnityLight l;
|
||||||
|
l.color = 0;
|
||||||
|
l.dir = half3 (0,1,0);
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnityIndirect ZeroIndirect ()
|
||||||
|
{
|
||||||
|
UnityIndirect ind;
|
||||||
|
ind.diffuse = 0;
|
||||||
|
ind.specular = 0;
|
||||||
|
return ind;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------
|
||||||
|
// Common fragment setup
|
||||||
|
|
||||||
|
// deprecated
|
||||||
|
half3 WorldNormal(half4 tan2world[3])
|
||||||
|
{
|
||||||
|
return normalize(tan2world[2].xyz);
|
||||||
|
}
|
||||||
|
|
||||||
|
// deprecated
|
||||||
|
#ifdef _TANGENT_TO_WORLD
|
||||||
|
half3x3 ExtractTangentToWorldPerPixel(half4 tan2world[3])
|
||||||
|
{
|
||||||
|
half3 t = tan2world[0].xyz;
|
||||||
|
half3 b = tan2world[1].xyz;
|
||||||
|
half3 n = tan2world[2].xyz;
|
||||||
|
|
||||||
|
#if UNITY_TANGENT_ORTHONORMALIZE
|
||||||
|
n = NormalizePerPixelNormal(n);
|
||||||
|
|
||||||
|
// ortho-normalize Tangent
|
||||||
|
t = normalize (t - n * dot(t, n));
|
||||||
|
|
||||||
|
// recalculate Binormal
|
||||||
|
half3 newB = cross(n, t);
|
||||||
|
b = newB * sign (dot (newB, b));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return half3x3(t, b, n);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
half3x3 ExtractTangentToWorldPerPixel(half4 tan2world[3])
|
||||||
|
{
|
||||||
|
return half3x3(0,0,0,0,0,0,0,0,0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half3 PerPixelWorldNormal(float4 i_tex, half4 tangentToWorld[3])
|
||||||
|
{
|
||||||
|
#ifdef _NORMALMAP
|
||||||
|
half3 tangent = tangentToWorld[0].xyz;
|
||||||
|
half3 binormal = tangentToWorld[1].xyz;
|
||||||
|
half3 normal = tangentToWorld[2].xyz;
|
||||||
|
|
||||||
|
#if UNITY_TANGENT_ORTHONORMALIZE
|
||||||
|
normal = NormalizePerPixelNormal(normal);
|
||||||
|
|
||||||
|
// ortho-normalize Tangent
|
||||||
|
tangent = normalize (tangent - normal * dot(tangent, normal));
|
||||||
|
|
||||||
|
// recalculate Binormal
|
||||||
|
half3 newB = cross(normal, tangent);
|
||||||
|
binormal = newB * sign (dot (newB, binormal));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half3 normalTangent = NormalInTangentSpace(i_tex);
|
||||||
|
half3 normalWorld = NormalizePerPixelNormal(tangent * normalTangent.x + binormal * normalTangent.y + normal * normalTangent.z); // @TODO: see if we can squeeze this normalize on SM2.0 as well
|
||||||
|
#else
|
||||||
|
half3 normalWorld = normalize(tangentToWorld[2].xyz);
|
||||||
|
#endif
|
||||||
|
return normalWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _PARALLAXMAP
|
||||||
|
#define IN_VIEWDIR4PARALLAX(i) NormalizePerPixelNormal(half3(i.tangentToWorldAndParallax[0].w,i.tangentToWorldAndParallax[1].w,i.tangentToWorldAndParallax[2].w))
|
||||||
|
#define IN_VIEWDIR4PARALLAX_FWDADD(i) NormalizePerPixelNormal(i.viewDirForParallax.xyz)
|
||||||
|
#else
|
||||||
|
#define IN_VIEWDIR4PARALLAX(i) half3(0,0,0)
|
||||||
|
#define IN_VIEWDIR4PARALLAX_FWDADD(i) half3(0,0,0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||||
|
#define IN_WORLDPOS(i) i.posWorld
|
||||||
|
#else
|
||||||
|
#define IN_WORLDPOS(i) half3(0,0,0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define IN_LIGHTDIR_FWDADD(i) half3(i.tangentToWorldAndLightDir[0].w, i.tangentToWorldAndLightDir[1].w, i.tangentToWorldAndLightDir[2].w)
|
||||||
|
|
||||||
|
#define FRAGMENT_SETUP(x) FragmentCommonData x = \
|
||||||
|
FragmentSetup(i.tex, i.eyeVec, IN_VIEWDIR4PARALLAX(i), i.tangentToWorldAndParallax, IN_WORLDPOS(i));
|
||||||
|
|
||||||
|
#define FRAGMENT_SETUP_FWDADD(x) FragmentCommonData x = \
|
||||||
|
FragmentSetup(i.tex, i.eyeVec, IN_VIEWDIR4PARALLAX_FWDADD(i), i.tangentToWorldAndLightDir, half3(0,0,0));
|
||||||
|
|
||||||
|
struct FragmentCommonData
|
||||||
|
{
|
||||||
|
half3 diffColor, specColor;
|
||||||
|
// Note: smoothness & oneMinusReflectivity for optimization purposes, mostly for DX9 SM2.0 level.
|
||||||
|
// Most of the math is being done on these (1-x) values, and that saves a few precious ALU slots.
|
||||||
|
half oneMinusReflectivity, smoothness;
|
||||||
|
half3 normalWorld, eyeVec, posWorld;
|
||||||
|
half alpha;
|
||||||
|
|
||||||
|
#if UNITY_OPTIMIZE_TEXCUBELOD || UNITY_STANDARD_SIMPLE
|
||||||
|
half3 reflUVW;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_STANDARD_SIMPLE
|
||||||
|
half3 tangentSpaceNormal;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef UNITY_SETUP_BRDF_INPUT
|
||||||
|
#define UNITY_SETUP_BRDF_INPUT SpecularSetup
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline FragmentCommonData SpecularSetup (float4 i_tex)
|
||||||
|
{
|
||||||
|
half4 specGloss = SpecularGloss(i_tex.xy);
|
||||||
|
half3 specColor = specGloss.rgb;
|
||||||
|
half smoothness = specGloss.a;
|
||||||
|
|
||||||
|
half oneMinusReflectivity;
|
||||||
|
half3 diffColor = EnergyConservationBetweenDiffuseAndSpecular (Albedo(i_tex), specColor, /*out*/ oneMinusReflectivity);
|
||||||
|
|
||||||
|
FragmentCommonData o = (FragmentCommonData)0;
|
||||||
|
o.diffColor = diffColor;
|
||||||
|
o.specColor = specColor;
|
||||||
|
o.oneMinusReflectivity = oneMinusReflectivity;
|
||||||
|
o.smoothness = smoothness;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline FragmentCommonData MetallicSetup (float4 i_tex)
|
||||||
|
{
|
||||||
|
half2 metallicGloss = MetallicGloss(i_tex.xy);
|
||||||
|
half metallic = metallicGloss.x;
|
||||||
|
half smoothness = metallicGloss.y; // this is 1 minus the square root of real roughness m.
|
||||||
|
|
||||||
|
half oneMinusReflectivity;
|
||||||
|
half3 specColor;
|
||||||
|
half3 diffColor = DiffuseAndSpecularFromMetallic (Albedo(i_tex), metallic, /*out*/ specColor, /*out*/ oneMinusReflectivity);
|
||||||
|
|
||||||
|
FragmentCommonData o = (FragmentCommonData)0;
|
||||||
|
o.diffColor = diffColor;
|
||||||
|
o.specColor = specColor;
|
||||||
|
o.oneMinusReflectivity = oneMinusReflectivity;
|
||||||
|
o.smoothness = smoothness;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline FragmentCommonData FragmentSetup (float4 i_tex, half3 i_eyeVec, half3 i_viewDirForParallax, half4 tangentToWorld[3], half3 i_posWorld)
|
||||||
|
{
|
||||||
|
i_tex = Parallax(i_tex, i_viewDirForParallax);
|
||||||
|
|
||||||
|
half alpha = Alpha(i_tex.xy);
|
||||||
|
#if defined(_ALPHATEST_ON)
|
||||||
|
clip (alpha - _Cutoff);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FragmentCommonData o = UNITY_SETUP_BRDF_INPUT (i_tex);
|
||||||
|
o.normalWorld = PerPixelWorldNormal(i_tex, tangentToWorld);
|
||||||
|
o.eyeVec = NormalizePerPixelNormal(i_eyeVec);
|
||||||
|
o.posWorld = i_posWorld;
|
||||||
|
|
||||||
|
// NOTE: shader relies on pre-multiply alpha-blend (_SrcBlend = One, _DstBlend = OneMinusSrcAlpha)
|
||||||
|
o.diffColor = PreMultiplyAlpha (o.diffColor, alpha, o.oneMinusReflectivity, /*out*/ o.alpha);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline UnityGI FragmentGI (FragmentCommonData s, half occlusion, half4 i_ambientOrLightmapUV, half atten, UnityLight light, bool reflections)
|
||||||
|
{
|
||||||
|
UnityGIInput d;
|
||||||
|
d.light = light;
|
||||||
|
d.worldPos = s.posWorld;
|
||||||
|
d.worldViewDir = -s.eyeVec;
|
||||||
|
d.atten = atten;
|
||||||
|
#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)
|
||||||
|
d.ambient = 0;
|
||||||
|
d.lightmapUV = i_ambientOrLightmapUV;
|
||||||
|
#else
|
||||||
|
d.ambient = i_ambientOrLightmapUV.rgb;
|
||||||
|
d.lightmapUV = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
d.probeHDR[0] = unity_SpecCube0_HDR;
|
||||||
|
d.probeHDR[1] = unity_SpecCube1_HDR;
|
||||||
|
#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION
|
||||||
|
d.boxMin[0] = unity_SpecCube0_BoxMin; // .w holds lerp value for blending
|
||||||
|
#endif
|
||||||
|
#if UNITY_SPECCUBE_BOX_PROJECTION
|
||||||
|
d.boxMax[0] = unity_SpecCube0_BoxMax;
|
||||||
|
d.probePosition[0] = unity_SpecCube0_ProbePosition;
|
||||||
|
d.boxMax[1] = unity_SpecCube1_BoxMax;
|
||||||
|
d.boxMin[1] = unity_SpecCube1_BoxMin;
|
||||||
|
d.probePosition[1] = unity_SpecCube1_ProbePosition;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(reflections)
|
||||||
|
{
|
||||||
|
Unity_GlossyEnvironmentData g = UnityGlossyEnvironmentSetup(s.smoothness, -s.eyeVec, s.normalWorld, s.specColor);
|
||||||
|
// Replace the reflUVW if it has been compute in Vertex shader. Note: the compiler will optimize the calcul in UnityGlossyEnvironmentSetup itself
|
||||||
|
#if UNITY_OPTIMIZE_TEXCUBELOD || UNITY_STANDARD_SIMPLE
|
||||||
|
g.reflUVW = s.reflUVW;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return UnityGlobalIllumination (d, occlusion, s.normalWorld, g);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return UnityGlobalIllumination (d, occlusion, s.normalWorld);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline UnityGI FragmentGI (FragmentCommonData s, half occlusion, half4 i_ambientOrLightmapUV, half atten, UnityLight light)
|
||||||
|
{
|
||||||
|
return FragmentGI(s, occlusion, i_ambientOrLightmapUV, atten, light, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------
|
||||||
|
half4 OutputForward (half4 output, half alphaFromSurface)
|
||||||
|
{
|
||||||
|
#if defined(_ALPHABLEND_ON) || defined(_ALPHAPREMULTIPLY_ON)
|
||||||
|
output.a = alphaFromSurface;
|
||||||
|
#else
|
||||||
|
UNITY_OPAQUE_ALPHA(output.a);
|
||||||
|
#endif
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline half4 VertexGIForward(VertexInput v, float3 posWorld, half3 normalWorld)
|
||||||
|
{
|
||||||
|
half4 ambientOrLightmapUV = 0;
|
||||||
|
// Static lightmaps
|
||||||
|
#ifdef LIGHTMAP_ON
|
||||||
|
ambientOrLightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||||
|
ambientOrLightmapUV.zw = 0;
|
||||||
|
// Sample light probe for Dynamic objects only (no static or dynamic lightmaps)
|
||||||
|
#elif UNITY_SHOULD_SAMPLE_SH
|
||||||
|
#ifdef VERTEXLIGHT_ON
|
||||||
|
// Approximated illumination from non-important point lights
|
||||||
|
ambientOrLightmapUV.rgb = 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, posWorld, normalWorld);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ambientOrLightmapUV.rgb = ShadeSHPerVertex (normalWorld, ambientOrLightmapUV.rgb);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DYNAMICLIGHTMAP_ON
|
||||||
|
ambientOrLightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ambientOrLightmapUV;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Base forward pass (directional light, emission, lightmaps, ...)
|
||||||
|
|
||||||
|
struct VertexOutputForwardBase
|
||||||
|
{
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float4 tex : TEXCOORD0;
|
||||||
|
half3 eyeVec : TEXCOORD1;
|
||||||
|
half4 tangentToWorldAndParallax[3] : TEXCOORD2; // [3x3:tangentToWorld | 1x3:viewDirForParallax]
|
||||||
|
half4 ambientOrLightmapUV : TEXCOORD5; // SH or Lightmap UV
|
||||||
|
SHADOW_COORDS(6)
|
||||||
|
UNITY_FOG_COORDS(7)
|
||||||
|
|
||||||
|
// next ones would not fit into SM2.0 limits, but they are always for SM3.0+
|
||||||
|
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||||
|
float3 posWorld : TEXCOORD8;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_OPTIMIZE_TEXCUBELOD
|
||||||
|
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||||
|
half3 reflUVW : TEXCOORD9;
|
||||||
|
#else
|
||||||
|
half3 reflUVW : TEXCOORD8;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
VertexOutputForwardBase vertForwardBase (VertexInput v)
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
VertexOutputForwardBase o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(VertexOutputForwardBase, o);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
|
|
||||||
|
float4 posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||||
|
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||||
|
o.posWorld = posWorld.xyz;
|
||||||
|
#endif
|
||||||
|
o.pos = UnityObjectToClipPos(v.vertex);
|
||||||
|
|
||||||
|
o.tex = TexCoords(v);
|
||||||
|
o.eyeVec = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos);
|
||||||
|
float3 normalWorld = UnityObjectToWorldNormal(v.normal);
|
||||||
|
#ifdef _TANGENT_TO_WORLD
|
||||||
|
float4 tangentWorld = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);
|
||||||
|
|
||||||
|
float3x3 tangentToWorld = CreateTangentToWorldPerVertex(normalWorld, tangentWorld.xyz, tangentWorld.w);
|
||||||
|
o.tangentToWorldAndParallax[0].xyz = tangentToWorld[0];
|
||||||
|
o.tangentToWorldAndParallax[1].xyz = tangentToWorld[1];
|
||||||
|
o.tangentToWorldAndParallax[2].xyz = tangentToWorld[2];
|
||||||
|
#else
|
||||||
|
o.tangentToWorldAndParallax[0].xyz = 0;
|
||||||
|
o.tangentToWorldAndParallax[1].xyz = 0;
|
||||||
|
o.tangentToWorldAndParallax[2].xyz = normalWorld;
|
||||||
|
#endif
|
||||||
|
//We need this for shadow receving
|
||||||
|
TRANSFER_SHADOW(o);
|
||||||
|
|
||||||
|
o.ambientOrLightmapUV = VertexGIForward(v, posWorld, normalWorld);
|
||||||
|
|
||||||
|
#ifdef _PARALLAXMAP
|
||||||
|
TANGENT_SPACE_ROTATION;
|
||||||
|
half3 viewDirForParallax = mul (rotation, ObjSpaceViewDir(v.vertex));
|
||||||
|
o.tangentToWorldAndParallax[0].w = viewDirForParallax.x;
|
||||||
|
o.tangentToWorldAndParallax[1].w = viewDirForParallax.y;
|
||||||
|
o.tangentToWorldAndParallax[2].w = viewDirForParallax.z;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_OPTIMIZE_TEXCUBELOD
|
||||||
|
o.reflUVW = reflect(o.eyeVec, normalWorld);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UNITY_TRANSFER_FOG(o,o.pos);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragForwardBaseInternal (VertexOutputForwardBase i)
|
||||||
|
{
|
||||||
|
FRAGMENT_SETUP(s)
|
||||||
|
#if UNITY_OPTIMIZE_TEXCUBELOD
|
||||||
|
s.reflUVW = i.reflUVW;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UnityLight mainLight = MainLight ();
|
||||||
|
half atten = SHADOW_ATTENUATION(i);
|
||||||
|
|
||||||
|
|
||||||
|
half occlusion = Occlusion(i.tex.xy);
|
||||||
|
UnityGI gi = FragmentGI (s, occlusion, i.ambientOrLightmapUV, atten, mainLight);
|
||||||
|
|
||||||
|
half4 c = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.smoothness, s.normalWorld, -s.eyeVec, gi.light, gi.indirect);
|
||||||
|
c.rgb += UNITY_BRDF_GI (s.diffColor, s.specColor, s.oneMinusReflectivity, s.smoothness, s.normalWorld, -s.eyeVec, occlusion, gi);
|
||||||
|
c.rgb += Emission(i.tex.xy);
|
||||||
|
|
||||||
|
UNITY_APPLY_FOG(i.fogCoord, c.rgb);
|
||||||
|
return OutputForward (c, s.alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragForwardBase (VertexOutputForwardBase i) : SV_Target // backward compatibility (this used to be the fragment entry function)
|
||||||
|
{
|
||||||
|
return fragForwardBaseInternal(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Additive forward pass (one light per pass)
|
||||||
|
|
||||||
|
struct VertexOutputForwardAdd
|
||||||
|
{
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float4 tex : TEXCOORD0;
|
||||||
|
half3 eyeVec : TEXCOORD1;
|
||||||
|
half4 tangentToWorldAndLightDir[3] : TEXCOORD2; // [3x3:tangentToWorld | 1x3:lightDir]
|
||||||
|
LIGHTING_COORDS(5,6)
|
||||||
|
UNITY_FOG_COORDS(7)
|
||||||
|
|
||||||
|
// next ones would not fit into SM2.0 limits, but they are always for SM3.0+
|
||||||
|
#if defined(_PARALLAXMAP)
|
||||||
|
half3 viewDirForParallax : TEXCOORD8;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
VertexOutputForwardAdd vertForwardAdd (VertexInput v)
|
||||||
|
{
|
||||||
|
VertexOutputForwardAdd o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(VertexOutputForwardAdd, o);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
|
|
||||||
|
float4 posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||||
|
o.pos = UnityObjectToClipPos(v.vertex);
|
||||||
|
|
||||||
|
o.tex = TexCoords(v);
|
||||||
|
o.eyeVec = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos);
|
||||||
|
float3 normalWorld = UnityObjectToWorldNormal(v.normal);
|
||||||
|
#ifdef _TANGENT_TO_WORLD
|
||||||
|
float4 tangentWorld = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);
|
||||||
|
|
||||||
|
float3x3 tangentToWorld = CreateTangentToWorldPerVertex(normalWorld, tangentWorld.xyz, tangentWorld.w);
|
||||||
|
o.tangentToWorldAndLightDir[0].xyz = tangentToWorld[0];
|
||||||
|
o.tangentToWorldAndLightDir[1].xyz = tangentToWorld[1];
|
||||||
|
o.tangentToWorldAndLightDir[2].xyz = tangentToWorld[2];
|
||||||
|
#else
|
||||||
|
o.tangentToWorldAndLightDir[0].xyz = 0;
|
||||||
|
o.tangentToWorldAndLightDir[1].xyz = 0;
|
||||||
|
o.tangentToWorldAndLightDir[2].xyz = normalWorld;
|
||||||
|
#endif
|
||||||
|
//We need this for shadow receiving
|
||||||
|
TRANSFER_VERTEX_TO_FRAGMENT(o);
|
||||||
|
|
||||||
|
float3 lightDir = _WorldSpaceLightPos0.xyz - posWorld.xyz * _WorldSpaceLightPos0.w;
|
||||||
|
#ifndef USING_DIRECTIONAL_LIGHT
|
||||||
|
lightDir = NormalizePerVertexNormal(lightDir);
|
||||||
|
#endif
|
||||||
|
o.tangentToWorldAndLightDir[0].w = lightDir.x;
|
||||||
|
o.tangentToWorldAndLightDir[1].w = lightDir.y;
|
||||||
|
o.tangentToWorldAndLightDir[2].w = lightDir.z;
|
||||||
|
|
||||||
|
#ifdef _PARALLAXMAP
|
||||||
|
TANGENT_SPACE_ROTATION;
|
||||||
|
o.viewDirForParallax = mul (rotation, ObjSpaceViewDir(v.vertex));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UNITY_TRANSFER_FOG(o,o.pos);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragForwardAddInternal (VertexOutputForwardAdd i)
|
||||||
|
{
|
||||||
|
FRAGMENT_SETUP_FWDADD(s)
|
||||||
|
|
||||||
|
UnityLight light = AdditiveLight (IN_LIGHTDIR_FWDADD(i), LIGHT_ATTENUATION(i));
|
||||||
|
UnityIndirect noIndirect = ZeroIndirect ();
|
||||||
|
|
||||||
|
half4 c = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.smoothness, s.normalWorld, -s.eyeVec, light, noIndirect);
|
||||||
|
|
||||||
|
UNITY_APPLY_FOG_COLOR(i.fogCoord, c.rgb, half4(0,0,0,0)); // fog towards black in additive pass
|
||||||
|
return OutputForward (c, s.alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragForwardAdd (VertexOutputForwardAdd i) : SV_Target // backward compatibility (this used to be the fragment entry function)
|
||||||
|
{
|
||||||
|
return fragForwardAddInternal(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Deferred pass
|
||||||
|
|
||||||
|
struct VertexOutputDeferred
|
||||||
|
{
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float4 tex : TEXCOORD0;
|
||||||
|
half3 eyeVec : TEXCOORD1;
|
||||||
|
half4 tangentToWorldAndParallax[3] : TEXCOORD2; // [3x3:tangentToWorld | 1x3:viewDirForParallax]
|
||||||
|
half4 ambientOrLightmapUV : TEXCOORD5; // SH or Lightmap UVs
|
||||||
|
|
||||||
|
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||||
|
float3 posWorld : TEXCOORD6;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_OPTIMIZE_TEXCUBELOD
|
||||||
|
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||||
|
half3 reflUVW : TEXCOORD7;
|
||||||
|
#else
|
||||||
|
half3 reflUVW : TEXCOORD6;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
VertexOutputDeferred vertDeferred (VertexInput v)
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
VertexOutputDeferred o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(VertexOutputDeferred, o);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
|
|
||||||
|
float4 posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||||
|
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||||
|
o.posWorld = posWorld;
|
||||||
|
#endif
|
||||||
|
o.pos = UnityObjectToClipPos(v.vertex);
|
||||||
|
|
||||||
|
o.tex = TexCoords(v);
|
||||||
|
o.eyeVec = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos);
|
||||||
|
float3 normalWorld = UnityObjectToWorldNormal(v.normal);
|
||||||
|
#ifdef _TANGENT_TO_WORLD
|
||||||
|
float4 tangentWorld = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);
|
||||||
|
|
||||||
|
float3x3 tangentToWorld = CreateTangentToWorldPerVertex(normalWorld, tangentWorld.xyz, tangentWorld.w);
|
||||||
|
o.tangentToWorldAndParallax[0].xyz = tangentToWorld[0];
|
||||||
|
o.tangentToWorldAndParallax[1].xyz = tangentToWorld[1];
|
||||||
|
o.tangentToWorldAndParallax[2].xyz = tangentToWorld[2];
|
||||||
|
#else
|
||||||
|
o.tangentToWorldAndParallax[0].xyz = 0;
|
||||||
|
o.tangentToWorldAndParallax[1].xyz = 0;
|
||||||
|
o.tangentToWorldAndParallax[2].xyz = normalWorld;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
o.ambientOrLightmapUV = 0;
|
||||||
|
#ifdef LIGHTMAP_ON
|
||||||
|
o.ambientOrLightmapUV.xy = v.uv1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
|
||||||
|
#elif UNITY_SHOULD_SAMPLE_SH
|
||||||
|
o.ambientOrLightmapUV.rgb = ShadeSHPerVertex (normalWorld, o.ambientOrLightmapUV.rgb);
|
||||||
|
#endif
|
||||||
|
#ifdef DYNAMICLIGHTMAP_ON
|
||||||
|
o.ambientOrLightmapUV.zw = v.uv2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _PARALLAXMAP
|
||||||
|
TANGENT_SPACE_ROTATION;
|
||||||
|
half3 viewDirForParallax = mul (rotation, ObjSpaceViewDir(v.vertex));
|
||||||
|
o.tangentToWorldAndParallax[0].w = viewDirForParallax.x;
|
||||||
|
o.tangentToWorldAndParallax[1].w = viewDirForParallax.y;
|
||||||
|
o.tangentToWorldAndParallax[2].w = viewDirForParallax.z;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_OPTIMIZE_TEXCUBELOD
|
||||||
|
o.reflUVW = reflect(o.eyeVec, normalWorld);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragDeferred (
|
||||||
|
VertexOutputDeferred i,
|
||||||
|
out half4 outGBuffer0 : SV_Target0,
|
||||||
|
out half4 outGBuffer1 : SV_Target1,
|
||||||
|
out half4 outGBuffer2 : SV_Target2,
|
||||||
|
out half4 outEmission : SV_Target3 // RT3: emission (rgb), --unused-- (a)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
#if (SHADER_TARGET < 30)
|
||||||
|
outGBuffer0 = 1;
|
||||||
|
outGBuffer1 = 1;
|
||||||
|
outGBuffer2 = 0;
|
||||||
|
outEmission = 0;
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FRAGMENT_SETUP(s)
|
||||||
|
#if UNITY_OPTIMIZE_TEXCUBELOD
|
||||||
|
s.reflUVW = i.reflUVW;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// no analytic lights in this pass
|
||||||
|
UnityLight dummyLight = DummyLight ();
|
||||||
|
half atten = 1;
|
||||||
|
|
||||||
|
// only GI
|
||||||
|
half occlusion = Occlusion(i.tex.xy);
|
||||||
|
#if UNITY_ENABLE_REFLECTION_BUFFERS
|
||||||
|
bool sampleReflectionsInDeferred = false;
|
||||||
|
#else
|
||||||
|
bool sampleReflectionsInDeferred = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UnityGI gi = FragmentGI (s, occlusion, i.ambientOrLightmapUV, atten, dummyLight, sampleReflectionsInDeferred);
|
||||||
|
|
||||||
|
half3 emissiveColor = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.smoothness, s.normalWorld, -s.eyeVec, gi.light, gi.indirect).rgb;
|
||||||
|
emissiveColor += UNITY_BRDF_GI (s.diffColor, s.specColor, s.oneMinusReflectivity, s.smoothness, s.normalWorld, -s.eyeVec, occlusion, gi);
|
||||||
|
|
||||||
|
#ifdef _EMISSION
|
||||||
|
emissiveColor += Emission (i.tex.xy);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UNITY_HDR_ON
|
||||||
|
emissiveColor.rgb = exp2(-emissiveColor.rgb);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UnityStandardData data;
|
||||||
|
data.diffuseColor = s.diffColor;
|
||||||
|
data.occlusion = occlusion;
|
||||||
|
data.specularColor = s.specColor;
|
||||||
|
data.smoothness = s.smoothness;
|
||||||
|
data.normalWorld = s.normalWorld;
|
||||||
|
|
||||||
|
UnityStandardDataToGbuffer(data, outGBuffer0, outGBuffer1, outGBuffer2);
|
||||||
|
|
||||||
|
// Emisive lighting buffer
|
||||||
|
outEmission = half4(emissiveColor, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Old FragmentGI signature. Kept only for backward compatibility and will be removed soon
|
||||||
|
//
|
||||||
|
|
||||||
|
inline UnityGI FragmentGI(
|
||||||
|
float3 posWorld,
|
||||||
|
half occlusion, half4 i_ambientOrLightmapUV, half atten, half smoothness, half3 normalWorld, half3 eyeVec,
|
||||||
|
UnityLight light,
|
||||||
|
bool reflections)
|
||||||
|
{
|
||||||
|
// we init only fields actually used
|
||||||
|
FragmentCommonData s = (FragmentCommonData)0;
|
||||||
|
s.smoothness = smoothness;
|
||||||
|
s.normalWorld = normalWorld;
|
||||||
|
s.eyeVec = eyeVec;
|
||||||
|
s.posWorld = posWorld;
|
||||||
|
#if UNITY_OPTIMIZE_TEXCUBELOD
|
||||||
|
s.reflUVW = reflect(eyeVec, normalWorld);
|
||||||
|
#endif
|
||||||
|
return FragmentGI(s, occlusion, i_ambientOrLightmapUV, atten, light, reflections);
|
||||||
|
}
|
||||||
|
inline UnityGI FragmentGI (
|
||||||
|
float3 posWorld,
|
||||||
|
half occlusion, half4 i_ambientOrLightmapUV, half atten, half smoothness, half3 normalWorld, half3 eyeVec,
|
||||||
|
UnityLight light)
|
||||||
|
{
|
||||||
|
return FragmentGI (posWorld, occlusion, i_ambientOrLightmapUV, atten, smoothness, normalWorld, eyeVec, light, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // UNITY_STANDARD_CORE_INCLUDED
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e5dca6b2da6837042a45e61fa0082255
|
||||||
|
timeCreated: 1435093423
|
||||||
|
licenseType: Store
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
24
Assets/ColorMask/Shaders/ColorMaskStandardCoreForward.cginc
Normal file
24
Assets/ColorMask/Shaders/ColorMaskStandardCoreForward.cginc
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef UNITY_STANDARD_CORE_FORWARD_INCLUDED
|
||||||
|
#define UNITY_STANDARD_CORE_FORWARD_INCLUDED
|
||||||
|
|
||||||
|
#if defined(UNITY_NO_FULL_STANDARD_SHADER)
|
||||||
|
# define UNITY_STANDARD_SIMPLE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "UnityStandardConfig.cginc"
|
||||||
|
|
||||||
|
#if UNITY_STANDARD_SIMPLE
|
||||||
|
#include "ColorMaskStandardCoreForwardSimple.cginc"
|
||||||
|
VertexOutputBaseSimple vertBase (VertexInput v) { return vertForwardBaseSimple(v); }
|
||||||
|
VertexOutputForwardAddSimple vertAdd (VertexInput v) { return vertForwardAddSimple(v); }
|
||||||
|
half4 fragBase (VertexOutputBaseSimple i) : SV_Target { return fragForwardBaseSimpleInternal(i); }
|
||||||
|
half4 fragAdd (VertexOutputForwardAddSimple i) : SV_Target { return fragForwardAddSimpleInternal(i); }
|
||||||
|
#else
|
||||||
|
#include "ColorMaskStandardCore.cginc"
|
||||||
|
VertexOutputForwardBase vertBase (VertexInput v) { return vertForwardBase(v); }
|
||||||
|
VertexOutputForwardAdd vertAdd (VertexInput v) { return vertForwardAdd(v); }
|
||||||
|
half4 fragBase (VertexOutputForwardBase i) : SV_Target { return fragForwardBaseInternal(i); }
|
||||||
|
half4 fragAdd (VertexOutputForwardAdd i) : SV_Target { return fragForwardAddInternal(i); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // UNITY_STANDARD_CORE_FORWARD_INCLUDED
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 62e4b8006c4d41942b2c870f78dd9402
|
||||||
|
timeCreated: 1454275320
|
||||||
|
licenseType: Store
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,354 @@
|
||||||
|
#ifndef UNITY_STANDARD_CORE_FORWARD_SIMPLE_INCLUDED
|
||||||
|
#define UNITY_STANDARD_CORE_FORWARD_SIMPLE_INCLUDED
|
||||||
|
|
||||||
|
#include "ColorMaskStandardCore.cginc"
|
||||||
|
|
||||||
|
// Does not support: _PARALLAXMAP, DIRLIGHTMAP_COMBINED, DIRLIGHTMAP_SEPARATE
|
||||||
|
#define GLOSSMAP (defined(_SPECGLOSSMAP) || defined(_METALLICGLOSSMAP))
|
||||||
|
|
||||||
|
#ifndef SPECULAR_HIGHLIGHTS
|
||||||
|
#define SPECULAR_HIGHLIGHTS (!defined(_SPECULAR_HIGHLIGHTS_OFF))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct VertexOutputBaseSimple
|
||||||
|
{
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float4 tex : TEXCOORD0;
|
||||||
|
half4 eyeVec : TEXCOORD1; // w: grazingTerm
|
||||||
|
|
||||||
|
half4 ambientOrLightmapUV : TEXCOORD2; // SH or Lightmap UV
|
||||||
|
SHADOW_COORDS(3)
|
||||||
|
UNITY_FOG_COORDS_PACKED(4, half4) // x: fogCoord, yzw: reflectVec
|
||||||
|
|
||||||
|
half4 normalWorld : TEXCOORD5; // w: fresnelTerm
|
||||||
|
|
||||||
|
#ifdef _NORMALMAP
|
||||||
|
half3 tangentSpaceLightDir : TEXCOORD6;
|
||||||
|
#if SPECULAR_HIGHLIGHTS
|
||||||
|
half3 tangentSpaceEyeVec : TEXCOORD7;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||||
|
float3 posWorld : TEXCOORD8;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
// UNIFORM_REFLECTIVITY(): workaround to get (uniform) reflecivity based on UNITY_SETUP_BRDF_INPUT
|
||||||
|
half MetallicSetup_Reflectivity()
|
||||||
|
{
|
||||||
|
return 1.0h - OneMinusReflectivityFromMetallic(_Metallic);
|
||||||
|
}
|
||||||
|
|
||||||
|
half SpecularSetup_Reflectivity()
|
||||||
|
{
|
||||||
|
return SpecularStrength(_SpecColor.rgb);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define JOIN2(a, b) a##b
|
||||||
|
#define JOIN(a, b) JOIN2(a,b)
|
||||||
|
#define UNIFORM_REFLECTIVITY JOIN(UNITY_SETUP_BRDF_INPUT, _Reflectivity)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _NORMALMAP
|
||||||
|
|
||||||
|
half3 TransformToTangentSpace(half3 tangent, half3 binormal, half3 normal, half3 v)
|
||||||
|
{
|
||||||
|
// Mali400 shader compiler prefers explicit dot product over using a half3x3 matrix
|
||||||
|
return half3(dot(tangent, v), dot(binormal, v), dot(normal, v));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TangentSpaceLightingInput(half3 normalWorld, half4 vTangent, half3 lightDirWorld, half3 eyeVecWorld, out half3 tangentSpaceLightDir, out half3 tangentSpaceEyeVec)
|
||||||
|
{
|
||||||
|
half3 tangentWorld = UnityObjectToWorldDir(vTangent.xyz);
|
||||||
|
half sign = half(vTangent.w) * half(unity_WorldTransformParams.w);
|
||||||
|
half3 binormalWorld = cross(normalWorld, tangentWorld) * sign;
|
||||||
|
tangentSpaceLightDir = TransformToTangentSpace(tangentWorld, binormalWorld, normalWorld, lightDirWorld);
|
||||||
|
#if SPECULAR_HIGHLIGHTS
|
||||||
|
tangentSpaceEyeVec = normalize(TransformToTangentSpace(tangentWorld, binormalWorld, normalWorld, eyeVecWorld));
|
||||||
|
#else
|
||||||
|
tangentSpaceEyeVec = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // _NORMALMAP
|
||||||
|
|
||||||
|
VertexOutputBaseSimple vertForwardBaseSimple (VertexInput v)
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
|
VertexOutputBaseSimple o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(VertexOutputBaseSimple, o);
|
||||||
|
|
||||||
|
float4 posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||||
|
#if UNITY_REQUIRE_FRAG_WORLDPOS
|
||||||
|
o.posWorld = posWorld.xyz;
|
||||||
|
#endif
|
||||||
|
o.pos = UnityObjectToClipPos(v.vertex);
|
||||||
|
o.tex = TexCoords(v);
|
||||||
|
|
||||||
|
half3 eyeVec = normalize(posWorld.xyz - _WorldSpaceCameraPos);
|
||||||
|
half3 normalWorld = UnityObjectToWorldNormal(v.normal);
|
||||||
|
|
||||||
|
o.normalWorld.xyz = normalWorld;
|
||||||
|
o.eyeVec.xyz = eyeVec;
|
||||||
|
|
||||||
|
#ifdef _NORMALMAP
|
||||||
|
half3 tangentSpaceEyeVec;
|
||||||
|
TangentSpaceLightingInput(normalWorld, v.tangent, _WorldSpaceLightPos0.xyz, eyeVec, o.tangentSpaceLightDir, tangentSpaceEyeVec);
|
||||||
|
#if SPECULAR_HIGHLIGHTS
|
||||||
|
o.tangentSpaceEyeVec = tangentSpaceEyeVec;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//We need this for shadow receiving
|
||||||
|
TRANSFER_SHADOW(o);
|
||||||
|
|
||||||
|
o.ambientOrLightmapUV = VertexGIForward(v, posWorld, normalWorld);
|
||||||
|
|
||||||
|
o.fogCoord.yzw = reflect(eyeVec, normalWorld);
|
||||||
|
|
||||||
|
o.normalWorld.w = Pow4(1 - saturate(dot(normalWorld, -eyeVec))); // fresnel term
|
||||||
|
#if !GLOSSMAP
|
||||||
|
o.eyeVec.w = saturate(_Glossiness + UNIFORM_REFLECTIVITY()); // grazing term
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UNITY_TRANSFER_FOG(o, o.pos);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FragmentCommonData FragmentSetupSimple(VertexOutputBaseSimple i)
|
||||||
|
{
|
||||||
|
half alpha = Alpha(i.tex.xy);
|
||||||
|
#if defined(_ALPHATEST_ON)
|
||||||
|
clip (alpha - _Cutoff);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FragmentCommonData s = UNITY_SETUP_BRDF_INPUT (i.tex);
|
||||||
|
|
||||||
|
// NOTE: shader relies on pre-multiply alpha-blend (_SrcBlend = One, _DstBlend = OneMinusSrcAlpha)
|
||||||
|
s.diffColor = PreMultiplyAlpha (s.diffColor, alpha, s.oneMinusReflectivity, /*out*/ s.alpha);
|
||||||
|
|
||||||
|
s.normalWorld = i.normalWorld.xyz;
|
||||||
|
s.eyeVec = i.eyeVec.xyz;
|
||||||
|
s.posWorld = IN_WORLDPOS(i);
|
||||||
|
s.reflUVW = i.fogCoord.yzw;
|
||||||
|
|
||||||
|
#ifdef _NORMALMAP
|
||||||
|
s.tangentSpaceNormal = NormalInTangentSpace(i.tex);
|
||||||
|
#else
|
||||||
|
s.tangentSpaceNormal = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnityLight MainLightSimple(VertexOutputBaseSimple i, FragmentCommonData s)
|
||||||
|
{
|
||||||
|
UnityLight mainLight = MainLight();
|
||||||
|
return mainLight;
|
||||||
|
}
|
||||||
|
|
||||||
|
half PerVertexGrazingTerm(VertexOutputBaseSimple i, FragmentCommonData s)
|
||||||
|
{
|
||||||
|
#if GLOSSMAP
|
||||||
|
return saturate(s.smoothness + (1-s.oneMinusReflectivity));
|
||||||
|
#else
|
||||||
|
return i.eyeVec.w;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
half PerVertexFresnelTerm(VertexOutputBaseSimple i)
|
||||||
|
{
|
||||||
|
return i.normalWorld.w;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !SPECULAR_HIGHLIGHTS
|
||||||
|
# define REFLECTVEC_FOR_SPECULAR(i, s) half3(0, 0, 0)
|
||||||
|
#elif defined(_NORMALMAP)
|
||||||
|
# define REFLECTVEC_FOR_SPECULAR(i, s) reflect(i.tangentSpaceEyeVec, s.tangentSpaceNormal)
|
||||||
|
#else
|
||||||
|
# define REFLECTVEC_FOR_SPECULAR(i, s) s.reflUVW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half3 LightDirForSpecular(VertexOutputBaseSimple i, UnityLight mainLight)
|
||||||
|
{
|
||||||
|
#if SPECULAR_HIGHLIGHTS && defined(_NORMALMAP)
|
||||||
|
return i.tangentSpaceLightDir;
|
||||||
|
#else
|
||||||
|
return mainLight.dir;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
half3 BRDF3DirectSimple(half3 diffColor, half3 specColor, half smoothness, half rl)
|
||||||
|
{
|
||||||
|
#if SPECULAR_HIGHLIGHTS
|
||||||
|
return BRDF3_Direct(diffColor, specColor, Pow4(rl), smoothness);
|
||||||
|
#else
|
||||||
|
return diffColor;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragForwardBaseSimpleInternal (VertexOutputBaseSimple i)
|
||||||
|
{
|
||||||
|
FragmentCommonData s = FragmentSetupSimple(i);
|
||||||
|
|
||||||
|
UnityLight mainLight = MainLightSimple(i, s);
|
||||||
|
|
||||||
|
#if !defined(LIGHTMAP_ON) && defined(_NORMALMAP)
|
||||||
|
half ndotl = saturate(dot(s.tangentSpaceNormal, i.tangentSpaceLightDir));
|
||||||
|
#else
|
||||||
|
half ndotl = saturate(dot(s.normalWorld, mainLight.dir));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half atten = SHADOW_ATTENUATION(i);
|
||||||
|
|
||||||
|
half occlusion = Occlusion(i.tex.xy);
|
||||||
|
half rl = dot(REFLECTVEC_FOR_SPECULAR(i, s), LightDirForSpecular(i, mainLight));
|
||||||
|
|
||||||
|
UnityGI gi = FragmentGI (s, occlusion, i.ambientOrLightmapUV, atten, mainLight);
|
||||||
|
half3 attenuatedLightColor = gi.light.color * ndotl;
|
||||||
|
|
||||||
|
half3 c = BRDF3_Indirect(s.diffColor, s.specColor, gi.indirect, PerVertexGrazingTerm(i, s), PerVertexFresnelTerm(i));
|
||||||
|
c += BRDF3DirectSimple(s.diffColor, s.specColor, s.smoothness, rl) * attenuatedLightColor;
|
||||||
|
c += UNITY_BRDF_GI (s.diffColor, s.specColor, s.oneMinusReflectivity, s.smoothness, s.normalWorld, -s.eyeVec, occlusion, gi);
|
||||||
|
c += Emission(i.tex.xy);
|
||||||
|
|
||||||
|
UNITY_APPLY_FOG(i.fogCoord, c);
|
||||||
|
|
||||||
|
return OutputForward (half4(c, 1), s.alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragForwardBaseSimple (VertexOutputBaseSimple i) : SV_Target // backward compatibility (this used to be the fragment entry function)
|
||||||
|
{
|
||||||
|
return fragForwardBaseSimpleInternal(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct VertexOutputForwardAddSimple
|
||||||
|
{
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float4 tex : TEXCOORD0;
|
||||||
|
|
||||||
|
LIGHTING_COORDS(1,2)
|
||||||
|
|
||||||
|
#if !defined(_NORMALMAP) && SPECULAR_HIGHLIGHTS
|
||||||
|
UNITY_FOG_COORDS_PACKED(3, half4) // x: fogCoord, yzw: reflectVec
|
||||||
|
#else
|
||||||
|
UNITY_FOG_COORDS_PACKED(3, half1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half3 lightDir : TEXCOORD4;
|
||||||
|
|
||||||
|
#if defined(_NORMALMAP)
|
||||||
|
#if SPECULAR_HIGHLIGHTS
|
||||||
|
half3 tangentSpaceEyeVec : TEXCOORD5;
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
half3 normalWorld : TEXCOORD5;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
VertexOutputForwardAddSimple vertForwardAddSimple (VertexInput v)
|
||||||
|
{
|
||||||
|
VertexOutputForwardAddSimple o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(VertexOutputForwardAddSimple, o);
|
||||||
|
|
||||||
|
float4 posWorld = mul(unity_ObjectToWorld, v.vertex);
|
||||||
|
o.pos = UnityObjectToClipPos(v.vertex);
|
||||||
|
o.tex = TexCoords(v);
|
||||||
|
|
||||||
|
//We need this for shadow receiving
|
||||||
|
TRANSFER_VERTEX_TO_FRAGMENT(o);
|
||||||
|
|
||||||
|
half3 lightDir = _WorldSpaceLightPos0.xyz - posWorld.xyz * _WorldSpaceLightPos0.w;
|
||||||
|
#ifndef USING_DIRECTIONAL_LIGHT
|
||||||
|
lightDir = NormalizePerVertexNormal(lightDir);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SPECULAR_HIGHLIGHTS
|
||||||
|
half3 eyeVec = normalize(posWorld.xyz - _WorldSpaceCameraPos);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half3 normalWorld = UnityObjectToWorldNormal(v.normal);
|
||||||
|
|
||||||
|
#ifdef _NORMALMAP
|
||||||
|
#if SPECULAR_HIGHLIGHTS
|
||||||
|
TangentSpaceLightingInput(normalWorld, v.tangent, lightDir, eyeVec, o.lightDir, o.tangentSpaceEyeVec);
|
||||||
|
#else
|
||||||
|
half3 ignore;
|
||||||
|
TangentSpaceLightingInput(normalWorld, v.tangent, lightDir, 0, o.lightDir, ignore);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
o.lightDir = lightDir;
|
||||||
|
o.normalWorld = normalWorld;
|
||||||
|
#if SPECULAR_HIGHLIGHTS
|
||||||
|
o.fogCoord.yzw = reflect(eyeVec, normalWorld);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UNITY_TRANSFER_FOG(o,o.pos);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
FragmentCommonData FragmentSetupSimpleAdd(VertexOutputForwardAddSimple i)
|
||||||
|
{
|
||||||
|
half alpha = Alpha(i.tex.xy);
|
||||||
|
#if defined(_ALPHATEST_ON)
|
||||||
|
clip (alpha - _Cutoff);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
FragmentCommonData s = UNITY_SETUP_BRDF_INPUT (i.tex);
|
||||||
|
|
||||||
|
// NOTE: shader relies on pre-multiply alpha-blend (_SrcBlend = One, _DstBlend = OneMinusSrcAlpha)
|
||||||
|
s.diffColor = PreMultiplyAlpha (s.diffColor, alpha, s.oneMinusReflectivity, /*out*/ s.alpha);
|
||||||
|
|
||||||
|
s.eyeVec = 0;
|
||||||
|
s.posWorld = 0;
|
||||||
|
|
||||||
|
#ifdef _NORMALMAP
|
||||||
|
s.tangentSpaceNormal = NormalInTangentSpace(i.tex);
|
||||||
|
s.normalWorld = 0;
|
||||||
|
#else
|
||||||
|
s.tangentSpaceNormal = 0;
|
||||||
|
s.normalWorld = i.normalWorld;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SPECULAR_HIGHLIGHTS && !defined(_NORMALMAP)
|
||||||
|
s.reflUVW = i.fogCoord.yzw;
|
||||||
|
#else
|
||||||
|
s.reflUVW = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
half3 LightSpaceNormal(VertexOutputForwardAddSimple i, FragmentCommonData s)
|
||||||
|
{
|
||||||
|
#ifdef _NORMALMAP
|
||||||
|
return s.tangentSpaceNormal;
|
||||||
|
#else
|
||||||
|
return i.normalWorld;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragForwardAddSimpleInternal (VertexOutputForwardAddSimple i)
|
||||||
|
{
|
||||||
|
FragmentCommonData s = FragmentSetupSimpleAdd(i);
|
||||||
|
|
||||||
|
half3 c = BRDF3DirectSimple(s.diffColor, s.specColor, s.smoothness, dot(REFLECTVEC_FOR_SPECULAR(i, s), i.lightDir));
|
||||||
|
|
||||||
|
#if SPECULAR_HIGHLIGHTS // else diffColor has premultiplied light color
|
||||||
|
c *= _LightColor0.rgb;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
c *= LIGHT_ATTENUATION(i) * saturate(dot(LightSpaceNormal(i, s), i.lightDir));
|
||||||
|
|
||||||
|
UNITY_APPLY_FOG_COLOR(i.fogCoord, c.rgb, half4(0,0,0,0)); // fog towards black in additive pass
|
||||||
|
return OutputForward (half4(c, 1), s.alpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 fragForwardAddSimple (VertexOutputForwardAddSimple i) : SV_Target // backward compatibility (this used to be the fragment entry function)
|
||||||
|
{
|
||||||
|
return fragForwardAddSimpleInternal(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // UNITY_STANDARD_CORE_FORWARD_SIMPLE_INCLUDED
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c2b809316d7becd45948832df9d72af5
|
||||||
|
timeCreated: 1454275320
|
||||||
|
licenseType: Store
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
249
Assets/ColorMask/Shaders/ColorMaskStandardInput.cginc
Normal file
249
Assets/ColorMask/Shaders/ColorMaskStandardInput.cginc
Normal file
|
@ -0,0 +1,249 @@
|
||||||
|
#ifndef UNITY_STANDARD_INPUT_INCLUDED
|
||||||
|
#define UNITY_STANDARD_INPUT_INCLUDED
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "UnityShaderVariables.cginc"
|
||||||
|
#include "UnityInstancing.cginc"
|
||||||
|
#include "UnityStandardConfig.cginc"
|
||||||
|
#include "UnityPBSLighting.cginc" // TBD: remove
|
||||||
|
#include "UnityStandardUtils.cginc"
|
||||||
|
|
||||||
|
//---------------------------------------
|
||||||
|
// Directional lightmaps & Parallax require tangent space too
|
||||||
|
#if (_NORMALMAP || DIRLIGHTMAP_COMBINED || DIRLIGHTMAP_SEPARATE || _PARALLAXMAP)
|
||||||
|
#define _TANGENT_TO_WORLD 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (_DETAIL_MULX2 || _DETAIL_MUL || _DETAIL_ADD || _DETAIL_LERP)
|
||||||
|
#define _DETAIL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//---------------------------------------
|
||||||
|
half4 _Color;
|
||||||
|
half _Cutoff;
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
|
||||||
|
sampler2D _ColorMaskTex;
|
||||||
|
float4 _ColorMaskTex_ST;
|
||||||
|
|
||||||
|
half4 _RedColor;
|
||||||
|
half4 _GreenColor;
|
||||||
|
half4 _BlueColor;
|
||||||
|
half4 _AlphaColor;
|
||||||
|
|
||||||
|
sampler2D _DetailAlbedoMap;
|
||||||
|
float4 _DetailAlbedoMap_ST;
|
||||||
|
|
||||||
|
sampler2D _BumpMap;
|
||||||
|
half _BumpScale;
|
||||||
|
|
||||||
|
sampler2D _DetailMask;
|
||||||
|
sampler2D _DetailNormalMap;
|
||||||
|
half _DetailNormalMapScale;
|
||||||
|
|
||||||
|
sampler2D _SpecGlossMap;
|
||||||
|
sampler2D _MetallicGlossMap;
|
||||||
|
half _Metallic;
|
||||||
|
half _Glossiness;
|
||||||
|
half _GlossMapScale;
|
||||||
|
|
||||||
|
sampler2D _OcclusionMap;
|
||||||
|
half _OcclusionStrength;
|
||||||
|
|
||||||
|
sampler2D _ParallaxMap;
|
||||||
|
half _Parallax;
|
||||||
|
half _UVSec;
|
||||||
|
|
||||||
|
half4 _EmissionColor;
|
||||||
|
sampler2D _EmissionMap;
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------
|
||||||
|
// Input functions
|
||||||
|
|
||||||
|
struct VertexInput
|
||||||
|
{
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
half3 normal : NORMAL;
|
||||||
|
float2 uv0 : TEXCOORD0;
|
||||||
|
float2 uv1 : TEXCOORD1;
|
||||||
|
#if defined(DYNAMICLIGHTMAP_ON) || defined(UNITY_PASS_META)
|
||||||
|
float2 uv2 : TEXCOORD2;
|
||||||
|
#endif
|
||||||
|
#ifdef _TANGENT_TO_WORLD
|
||||||
|
half4 tangent : TANGENT;
|
||||||
|
#endif
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 TexCoords(VertexInput v)
|
||||||
|
{
|
||||||
|
float4 texcoord;
|
||||||
|
texcoord.xy = TRANSFORM_TEX(v.uv0, _MainTex); // Always source from uv0
|
||||||
|
texcoord.zw = TRANSFORM_TEX(((_UVSec == 0) ? v.uv0 : v.uv1), _DetailAlbedoMap);
|
||||||
|
return texcoord;
|
||||||
|
}
|
||||||
|
|
||||||
|
half DetailMask(float2 uv)
|
||||||
|
{
|
||||||
|
return tex2D (_DetailMask, uv).a;
|
||||||
|
}
|
||||||
|
|
||||||
|
half3 Albedo(float4 texcoords)
|
||||||
|
{
|
||||||
|
|
||||||
|
half3 albedo = tex2D (_MainTex, texcoords.xy).rgb;
|
||||||
|
|
||||||
|
//4 channel color mask - Blend the albedo texture with the user defined colors using the color mask (rgba), then multiply the default color.
|
||||||
|
half4 cM = tex2D (_ColorMaskTex, texcoords.xy);
|
||||||
|
half total = cM.r + cM.g + cM.b + cM.a;
|
||||||
|
half mT = max(total, 0.002);
|
||||||
|
half4 blendColor = _RedColor * cM.r / mT + _GreenColor * cM.g / mT + _BlueColor * cM.b / mT + _AlphaColor * cM.a / mT;
|
||||||
|
//half4 blendColor = _RedColor * cM.r / mT + _GreenColor * cM.g / mT;
|
||||||
|
//half4 blendColor = cM;
|
||||||
|
albedo = lerp(albedo, blendColor.rgb, min(total, 1) * blendColor.a ) * _Color.rgb;
|
||||||
|
//albedo = cM.b + cM.a;
|
||||||
|
|
||||||
|
#if _DETAIL
|
||||||
|
#if (SHADER_TARGET < 30)
|
||||||
|
// SM20: instruction count limitation
|
||||||
|
// SM20: no detail mask
|
||||||
|
half mask = 1;
|
||||||
|
#else
|
||||||
|
half mask = DetailMask(texcoords.xy);
|
||||||
|
#endif
|
||||||
|
half3 detailAlbedo = tex2D (_DetailAlbedoMap, texcoords.zw).rgb;
|
||||||
|
#if _DETAIL_MULX2
|
||||||
|
albedo *= LerpWhiteTo (detailAlbedo * unity_ColorSpaceDouble.rgb, mask);
|
||||||
|
#elif _DETAIL_MUL
|
||||||
|
albedo *= LerpWhiteTo (detailAlbedo, mask);
|
||||||
|
#elif _DETAIL_ADD
|
||||||
|
albedo += detailAlbedo * mask;
|
||||||
|
#elif _DETAIL_LERP
|
||||||
|
albedo = lerp (albedo, detailAlbedo, mask);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return albedo;
|
||||||
|
}
|
||||||
|
|
||||||
|
half Alpha(float2 uv)
|
||||||
|
{
|
||||||
|
#if defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A)
|
||||||
|
return _Color.a;
|
||||||
|
#else
|
||||||
|
return tex2D(_MainTex, uv).a * _Color.a;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
half Occlusion(float2 uv)
|
||||||
|
{
|
||||||
|
#if (SHADER_TARGET < 30)
|
||||||
|
// SM20: instruction count limitation
|
||||||
|
// SM20: simpler occlusion
|
||||||
|
return tex2D(_OcclusionMap, uv).g;
|
||||||
|
#else
|
||||||
|
half occ = tex2D(_OcclusionMap, uv).g;
|
||||||
|
return LerpOneTo (occ, _OcclusionStrength);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 SpecularGloss(float2 uv)
|
||||||
|
{
|
||||||
|
half4 sg;
|
||||||
|
#ifdef _SPECGLOSSMAP
|
||||||
|
#if defined(_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A)
|
||||||
|
sg.rgb = tex2D(_SpecGlossMap, uv).rgb;
|
||||||
|
sg.a = tex2D(_MainTex, uv).a;
|
||||||
|
#else
|
||||||
|
sg = tex2D(_SpecGlossMap, uv);
|
||||||
|
#endif
|
||||||
|
sg.a *= _GlossMapScale;
|
||||||
|
#else
|
||||||
|
sg.rgb = _SpecColor.rgb;
|
||||||
|
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
sg.a = tex2D(_MainTex, uv).a * _GlossMapScale;
|
||||||
|
#else
|
||||||
|
sg.a = _Glossiness;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return sg;
|
||||||
|
}
|
||||||
|
|
||||||
|
half2 MetallicGloss(float2 uv)
|
||||||
|
{
|
||||||
|
half2 mg;
|
||||||
|
|
||||||
|
#ifdef _METALLICGLOSSMAP
|
||||||
|
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
mg.r = tex2D(_MetallicGlossMap, uv).r;
|
||||||
|
mg.g = tex2D(_MainTex, uv).a;
|
||||||
|
#else
|
||||||
|
mg = tex2D(_MetallicGlossMap, uv).ra;
|
||||||
|
#endif
|
||||||
|
mg.g *= _GlossMapScale;
|
||||||
|
#else
|
||||||
|
mg.r = _Metallic;
|
||||||
|
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
mg.g = tex2D(_MainTex, uv).a * _GlossMapScale;
|
||||||
|
#else
|
||||||
|
mg.g = _Glossiness;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return mg;
|
||||||
|
}
|
||||||
|
|
||||||
|
half3 Emission(float2 uv)
|
||||||
|
{
|
||||||
|
#ifndef _EMISSION
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return tex2D(_EmissionMap, uv).rgb * _EmissionColor.rgb;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _NORMALMAP
|
||||||
|
half3 NormalInTangentSpace(float4 texcoords)
|
||||||
|
{
|
||||||
|
half3 normalTangent = UnpackScaleNormal(tex2D (_BumpMap, texcoords.xy), _BumpScale);
|
||||||
|
// SM20: instruction count limitation
|
||||||
|
// SM20: no detail normalmaps
|
||||||
|
#if _DETAIL && !defined(SHADER_API_MOBILE) && (SHADER_TARGET >= 30)
|
||||||
|
half mask = DetailMask(texcoords.xy);
|
||||||
|
half3 detailNormalTangent = UnpackScaleNormal(tex2D (_DetailNormalMap, texcoords.zw), _DetailNormalMapScale);
|
||||||
|
#if _DETAIL_LERP
|
||||||
|
normalTangent = lerp(
|
||||||
|
normalTangent,
|
||||||
|
detailNormalTangent,
|
||||||
|
mask);
|
||||||
|
#else
|
||||||
|
normalTangent = lerp(
|
||||||
|
normalTangent,
|
||||||
|
BlendNormals(normalTangent, detailNormalTangent),
|
||||||
|
mask);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return normalTangent;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float4 Parallax (float4 texcoords, half3 viewDir)
|
||||||
|
{
|
||||||
|
// D3D9/SM30 supports up to 16 samplers, skip the parallax map in case we exceed the limit
|
||||||
|
#define EXCEEDS_D3D9_SM3_MAX_SAMPLER_COUNT (defined(LIGHTMAP_ON) && defined(DIRLIGHTMAP_SEPARATE) && defined(SHADOWS_SCREEN) && defined(_NORMALMAP) && \
|
||||||
|
defined(_EMISSION) && defined(_DETAIL) && (defined(_METALLICGLOSSMAP) || defined(_SPECGLOSSMAP)))
|
||||||
|
|
||||||
|
#if !defined(_PARALLAXMAP) || (SHADER_TARGET < 30) || (defined(SHADER_API_D3D9) && EXCEEDS_D3D9_SM3_MAX_SAMPLER_COUNT)
|
||||||
|
// SM20: instruction count limitation
|
||||||
|
// SM20: no parallax
|
||||||
|
return texcoords;
|
||||||
|
#else
|
||||||
|
half h = tex2D (_ParallaxMap, texcoords.xy).g;
|
||||||
|
float2 offset = ParallaxOffset1Step (h, _Parallax, viewDir);
|
||||||
|
return float4(texcoords.xy + offset, texcoords.zw + offset);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef EXCEEDS_D3D9_SM3_MAX_SAMPLER_COUNT
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // UNITY_STANDARD_INPUT_INCLUDED
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5d44df0214f7ed446bd641e3b25429a0
|
||||||
|
timeCreated: 1435093423
|
||||||
|
licenseType: Store
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
56
Assets/ColorMask/Shaders/ColorMaskStandardMeta.cginc
Normal file
56
Assets/ColorMask/Shaders/ColorMaskStandardMeta.cginc
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#ifndef UNITY_STANDARD_META_INCLUDED
|
||||||
|
#define UNITY_STANDARD_META_INCLUDED
|
||||||
|
|
||||||
|
// Functionality for Standard shader "meta" pass
|
||||||
|
// (extracts albedo/emission for lightmapper etc.)
|
||||||
|
|
||||||
|
// define meta pass before including other files; they have conditions
|
||||||
|
// on that in some places
|
||||||
|
#define UNITY_PASS_META 1
|
||||||
|
|
||||||
|
#include "UnityCG.cginc"
|
||||||
|
#include "ColorMaskStandardInput.cginc"
|
||||||
|
#include "UnityMetaPass.cginc"
|
||||||
|
#include "ColorMaskStandardCore.cginc"
|
||||||
|
|
||||||
|
struct v2f_meta
|
||||||
|
{
|
||||||
|
float4 uv : TEXCOORD0;
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
};
|
||||||
|
|
||||||
|
v2f_meta vert_meta (VertexInput v)
|
||||||
|
{
|
||||||
|
v2f_meta o;
|
||||||
|
o.pos = UnityMetaVertexPosition(v.vertex, v.uv1.xy, v.uv2.xy, unity_LightmapST, unity_DynamicLightmapST);
|
||||||
|
o.uv = TexCoords(v);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Albedo for lightmapping should basically be diffuse color.
|
||||||
|
// But rough metals (black diffuse) still scatter quite a lot of light around, so
|
||||||
|
// we want to take some of that into account too.
|
||||||
|
half3 UnityLightmappingAlbedo (half3 diffuse, half3 specular, half smoothness)
|
||||||
|
{
|
||||||
|
half roughness = SmoothnessToRoughness(smoothness);
|
||||||
|
half3 res = diffuse;
|
||||||
|
res += specular * roughness * 0.5;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
float4 frag_meta (v2f_meta i) : SV_Target
|
||||||
|
{
|
||||||
|
// we're interested in diffuse & specular colors,
|
||||||
|
// and surface roughness to produce final albedo.
|
||||||
|
FragmentCommonData data = UNITY_SETUP_BRDF_INPUT (i.uv);
|
||||||
|
|
||||||
|
UnityMetaInput o;
|
||||||
|
UNITY_INITIALIZE_OUTPUT(UnityMetaInput, o);
|
||||||
|
|
||||||
|
o.Albedo = UnityLightmappingAlbedo (data.diffColor, data.specColor, data.smoothness);
|
||||||
|
o.Emission = Emission(i.uv.xy);
|
||||||
|
|
||||||
|
return UnityMetaFragment(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // UNITY_STANDARD_META_INCLUDED
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ef6599bf52ffb90459f0c70ac32ee0a4
|
||||||
|
timeCreated: 1435099795
|
||||||
|
licenseType: Store
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
340
Assets/ColorMask/Shaders/ColorMaskStandardSpecular.shader
Normal file
340
Assets/ColorMask/Shaders/ColorMaskStandardSpecular.shader
Normal file
|
@ -0,0 +1,340 @@
|
||||||
|
Shader "ColorMask/Standard (Specular setup)"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
_Color("Color", Color) = (1,1,1,1)
|
||||||
|
_MainTex("Albedo", 2D) = "white" {}
|
||||||
|
|
||||||
|
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||||
|
|
||||||
|
_ColorMaskTex("Color Mask", 2D) = "black" {}
|
||||||
|
_RedColor("Red Color", Color) = (1,1,1,1)
|
||||||
|
_GreenColor("Green Color", Color) = (1,1,1,1)
|
||||||
|
_BlueColor("Blue Color", Color) = (1,1,1,1)
|
||||||
|
_AlphaColor("Alpha Color", Color) = (1,1,1,1)
|
||||||
|
|
||||||
|
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||||
|
_GlossMapScale("Smoothness Factor", Range(0.0, 1.0)) = 1.0
|
||||||
|
[Enum(Specular Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel ("Smoothness texture channel", Float) = 0
|
||||||
|
|
||||||
|
_SpecColor("Specular", Color) = (0.2,0.2,0.2)
|
||||||
|
_SpecGlossMap("Specular", 2D) = "white" {}
|
||||||
|
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
|
||||||
|
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0
|
||||||
|
|
||||||
|
_BumpScale("Scale", Float) = 1.0
|
||||||
|
_BumpMap("Normal Map", 2D) = "bump" {}
|
||||||
|
|
||||||
|
_Parallax ("Height Scale", Range (0.005, 0.08)) = 0.02
|
||||||
|
_ParallaxMap ("Height Map", 2D) = "black" {}
|
||||||
|
|
||||||
|
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
|
||||||
|
_OcclusionMap("Occlusion", 2D) = "white" {}
|
||||||
|
|
||||||
|
_EmissionColor("Color", Color) = (0,0,0)
|
||||||
|
_EmissionMap("Emission", 2D) = "white" {}
|
||||||
|
|
||||||
|
_DetailMask("Detail Mask", 2D) = "white" {}
|
||||||
|
|
||||||
|
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
|
||||||
|
_DetailNormalMapScale("Scale", Float) = 1.0
|
||||||
|
_DetailNormalMap("Normal Map", 2D) = "bump" {}
|
||||||
|
|
||||||
|
[Enum(UV0,0,UV1,1)] _UVSec ("UV Set for secondary textures", Float) = 0
|
||||||
|
|
||||||
|
|
||||||
|
// Blending state
|
||||||
|
[HideInInspector] _Mode ("__mode", Float) = 0.0
|
||||||
|
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
|
||||||
|
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
|
||||||
|
[HideInInspector] _ZWrite ("__zw", Float) = 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
CGINCLUDE
|
||||||
|
#define UNITY_SETUP_BRDF_INPUT SpecularSetup
|
||||||
|
ENDCG
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
|
||||||
|
LOD 300
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Base forward pass (directional light, emission, lightmaps, ...)
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD"
|
||||||
|
Tags { "LightMode" = "ForwardBase" }
|
||||||
|
|
||||||
|
Blend [_SrcBlend] [_DstBlend]
|
||||||
|
ZWrite [_ZWrite]
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
|
||||||
|
// -------------------------------------
|
||||||
|
|
||||||
|
#pragma shader_feature _NORMALMAP
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _EMISSION
|
||||||
|
#pragma shader_feature _SPECGLOSSMAP
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||||
|
#pragma shader_feature _ _GLOSSYREFLECTIONS_OFF
|
||||||
|
#pragma shader_feature _PARALLAXMAP
|
||||||
|
|
||||||
|
#pragma multi_compile_fwdbase
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#pragma vertex vertBase
|
||||||
|
#pragma fragment fragBase
|
||||||
|
#include "ColorMaskStandardCoreForward.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Additive forward pass (one light per pass)
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD_DELTA"
|
||||||
|
Tags { "LightMode" = "ForwardAdd" }
|
||||||
|
Blend [_SrcBlend] One
|
||||||
|
Fog { Color (0,0,0,0) } // in additive pass fog should be black
|
||||||
|
ZWrite Off
|
||||||
|
ZTest LEqual
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
|
||||||
|
// -------------------------------------
|
||||||
|
|
||||||
|
#pragma shader_feature _NORMALMAP
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _SPECGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
#pragma shader_feature _PARALLAXMAP
|
||||||
|
|
||||||
|
#pragma multi_compile_fwdadd_fullshadows
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#pragma vertex vertAdd
|
||||||
|
#pragma fragment fragAdd
|
||||||
|
#include "ColorMaskStandardCoreForward.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Shadow rendering pass
|
||||||
|
Pass {
|
||||||
|
Name "ShadowCaster"
|
||||||
|
Tags { "LightMode" = "ShadowCaster" }
|
||||||
|
|
||||||
|
ZWrite On ZTest LEqual
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
|
||||||
|
// -------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _SPECGLOSSMAP
|
||||||
|
#pragma shader_feature _PARALLAXMAP
|
||||||
|
#pragma multi_compile_shadowcaster
|
||||||
|
|
||||||
|
#pragma vertex vertShadowCaster
|
||||||
|
#pragma fragment fragShadowCaster
|
||||||
|
|
||||||
|
#include "UnityStandardShadow.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Deferred pass
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "DEFERRED"
|
||||||
|
Tags { "LightMode" = "Deferred" }
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma exclude_renderers nomrt
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------
|
||||||
|
|
||||||
|
#pragma shader_feature _NORMALMAP
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _EMISSION
|
||||||
|
#pragma shader_feature _SPECGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
#pragma shader_feature _PARALLAXMAP
|
||||||
|
|
||||||
|
#pragma multi_compile ___ UNITY_HDR_ON
|
||||||
|
#pragma multi_compile ___ LIGHTMAP_ON
|
||||||
|
#pragma multi_compile ___ DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||||
|
#pragma multi_compile ___ DYNAMICLIGHTMAP_ON
|
||||||
|
|
||||||
|
#pragma vertex vertDeferred
|
||||||
|
#pragma fragment fragDeferred
|
||||||
|
|
||||||
|
#include "ColorMaskStandardCore.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Extracts information for lightmapping, GI (emission, albedo, ...)
|
||||||
|
// This pass it not used during regular rendering.
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "META"
|
||||||
|
Tags { "LightMode"="Meta" }
|
||||||
|
|
||||||
|
Cull Off
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 2.5
|
||||||
|
|
||||||
|
#pragma vertex vert_meta
|
||||||
|
#pragma fragment frag_meta
|
||||||
|
|
||||||
|
#pragma shader_feature _EMISSION
|
||||||
|
#pragma shader_feature _SPECGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
|
||||||
|
#include "ColorMaskStandardMeta.cginc"
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
|
||||||
|
LOD 150
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Base forward pass (directional light, emission, lightmaps, ...)
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD"
|
||||||
|
Tags { "LightMode" = "ForwardBase" }
|
||||||
|
|
||||||
|
Blend [_SrcBlend] [_DstBlend]
|
||||||
|
ZWrite [_ZWrite]
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 2.5
|
||||||
|
|
||||||
|
#pragma shader_feature _NORMALMAP
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _EMISSION
|
||||||
|
#pragma shader_feature _SPECGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||||
|
#pragma shader_feature _ _GLOSSYREFLECTIONS_OFF
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
// SM2.0: NOT SUPPORTED shader_feature _PARALLAXMAP
|
||||||
|
|
||||||
|
#pragma skip_variants SHADOWS_SOFT DYNAMICLIGHTMAP_ON DIRLIGHTMAP_COMBINED DIRLIGHTMAP_SEPARATE
|
||||||
|
|
||||||
|
#pragma multi_compile_fwdbase
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#pragma vertex vertBase
|
||||||
|
#pragma fragment fragBase
|
||||||
|
#include "ColorMaskStandardCoreForward.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Additive forward pass (one light per pass)
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "FORWARD_DELTA"
|
||||||
|
Tags { "LightMode" = "ForwardAdd" }
|
||||||
|
Blend [_SrcBlend] One
|
||||||
|
Fog { Color (0,0,0,0) } // in additive pass fog should be black
|
||||||
|
ZWrite Off
|
||||||
|
ZTest LEqual
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 2.5
|
||||||
|
|
||||||
|
#pragma shader_feature _NORMALMAP
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _SPECGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature _ _SPECULARHIGHLIGHTS_OFF
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
// SM2.0: NOT SUPPORTED shader_feature _PARALLAXMAP
|
||||||
|
#pragma skip_variants SHADOWS_SOFT
|
||||||
|
|
||||||
|
#pragma multi_compile_fwdadd_fullshadows
|
||||||
|
#pragma multi_compile_fog
|
||||||
|
|
||||||
|
#pragma vertex vertAdd
|
||||||
|
#pragma fragment fragAdd
|
||||||
|
#include "ColorMaskStandardCoreForward.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Shadow rendering pass
|
||||||
|
Pass {
|
||||||
|
Name "ShadowCaster"
|
||||||
|
Tags { "LightMode" = "ShadowCaster" }
|
||||||
|
|
||||||
|
ZWrite On ZTest LEqual
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 2.5
|
||||||
|
|
||||||
|
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
|
||||||
|
#pragma shader_feature _SPECGLOSSMAP
|
||||||
|
#pragma skip_variants SHADOWS_SOFT
|
||||||
|
#pragma multi_compile_shadowcaster
|
||||||
|
|
||||||
|
#pragma vertex vertShadowCaster
|
||||||
|
#pragma fragment fragShadowCaster
|
||||||
|
|
||||||
|
#include "UnityStandardShadow.cginc"
|
||||||
|
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Extracts information for lightmapping, GI (emission, albedo, ...)
|
||||||
|
// This pass it not used during regular rendering.
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "META"
|
||||||
|
Tags { "LightMode"="Meta" }
|
||||||
|
|
||||||
|
Cull Off
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma target 2.5
|
||||||
|
|
||||||
|
#pragma vertex vert_meta
|
||||||
|
#pragma fragment frag_meta
|
||||||
|
|
||||||
|
#pragma shader_feature _EMISSION
|
||||||
|
#pragma shader_feature _SPECGLOSSMAP
|
||||||
|
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
|
||||||
|
#pragma shader_feature ___ _DETAIL_MULX2
|
||||||
|
|
||||||
|
#include "ColorMaskStandardMeta.cginc"
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FallBack "VertexLit"
|
||||||
|
CustomEditor "ColorMaskStandardShaderGUI"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bedf46e927dae18459dcdcdef5201a5f
|
||||||
|
timeCreated: 1435103330
|
||||||
|
licenseType: Store
|
||||||
|
ShaderImporter:
|
||||||
|
defaultTextures: []
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/ColorMask/Shaders/Editor.meta
Normal file
9
Assets/ColorMask/Shaders/Editor.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 276cc93363e40514e8655de2514c9341
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1436031523
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
469
Assets/ColorMask/Shaders/Editor/ColorMaskStandardShaderGUI.cs
Normal file
469
Assets/ColorMask/Shaders/Editor/ColorMaskStandardShaderGUI.cs
Normal file
|
@ -0,0 +1,469 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace UnityEditor
|
||||||
|
{
|
||||||
|
internal class ColorMaskStandardShaderGUI : ShaderGUI
|
||||||
|
{
|
||||||
|
private enum WorkflowMode
|
||||||
|
{
|
||||||
|
Specular,
|
||||||
|
Metallic,
|
||||||
|
Dielectric
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum BlendMode
|
||||||
|
{
|
||||||
|
Opaque,
|
||||||
|
Cutout,
|
||||||
|
Fade, // Old school alpha-blending mode, fresnel does not affect amount of transparency
|
||||||
|
Transparent // Physically plausible transparency mode, implemented as alpha pre-multiply
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum SmoothnessMapChannel
|
||||||
|
{
|
||||||
|
SpecularMetallicAlpha,
|
||||||
|
AlbedoAlpha,
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Styles
|
||||||
|
{
|
||||||
|
public static GUIStyle optionsButton = "PaneOptions";
|
||||||
|
public static GUIContent uvSetLabel = new GUIContent("UV Set");
|
||||||
|
public static GUIContent[] uvSetOptions = new GUIContent[] { new GUIContent("UV channel 0"), new GUIContent("UV channel 1") };
|
||||||
|
|
||||||
|
public static string emptyTootip = "";
|
||||||
|
public static GUIContent albedoText = new GUIContent("Albedo", "Albedo (RGB) and Transparency (A)");
|
||||||
|
public static GUIContent alphaCutoffText = new GUIContent("Alpha Cutoff", "Threshold for alpha cutoff");
|
||||||
|
public static GUIContent colorMaskText = new GUIContent("Color Mask", "Color Mask (R)");
|
||||||
|
public static GUIContent specularMapText = new GUIContent("Specular", "Specular (RGB) and Smoothness (A)");
|
||||||
|
public static GUIContent metallicMapText = new GUIContent("Metallic", "Metallic (R) and Smoothness (A)");
|
||||||
|
public static GUIContent smoothnessText = new GUIContent("Smoothness", "Smoothness value");
|
||||||
|
public static GUIContent smoothnessScaleText = new GUIContent("Smoothness", "Smoothness scale factor");
|
||||||
|
public static GUIContent smoothnessMapChannelText = new GUIContent("Source", "Smoothness texture and channel");
|
||||||
|
public static GUIContent highlightsText = new GUIContent("Specular Highlights", "Specular Highlights");
|
||||||
|
public static GUIContent reflectionsText = new GUIContent("Reflections", "Glossy Reflections");
|
||||||
|
public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map");
|
||||||
|
public static GUIContent heightMapText = new GUIContent("Height Map", "Height Map (G)");
|
||||||
|
public static GUIContent occlusionText = new GUIContent("Occlusion", "Occlusion (G)");
|
||||||
|
public static GUIContent emissionText = new GUIContent("Emission", "Emission (RGB)");
|
||||||
|
public static GUIContent detailMaskText = new GUIContent("Detail Mask", "Mask for Secondary Maps (A)");
|
||||||
|
public static GUIContent detailAlbedoText = new GUIContent("Detail Albedo x2", "Albedo (RGB) multiplied by 2");
|
||||||
|
public static GUIContent detailNormalMapText = new GUIContent("Normal Map", "Normal Map");
|
||||||
|
|
||||||
|
public static string whiteSpaceString = " ";
|
||||||
|
public static string primaryMapsText = "Main Maps";
|
||||||
|
public static string secondaryMapsText = "Secondary Maps";
|
||||||
|
public static string forwardText = "Forward Rendering Options";
|
||||||
|
public static string renderingMode = "Rendering Mode";
|
||||||
|
public static GUIContent emissiveWarning = new GUIContent ("Emissive value is animated but the material has not been configured to support emissive. Please make sure the material itself has some amount of emissive.");
|
||||||
|
public static GUIContent emissiveColorWarning = new GUIContent ("Ensure emissive color is non-black for emission to have effect.");
|
||||||
|
public static readonly string[] blendNames = Enum.GetNames (typeof (BlendMode));
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialProperty blendMode = null;
|
||||||
|
MaterialProperty albedoMap = null;
|
||||||
|
MaterialProperty albedoColor = null;
|
||||||
|
MaterialProperty alphaCutoff = null;
|
||||||
|
MaterialProperty colorMaskMap = null;
|
||||||
|
MaterialProperty redColor = null;
|
||||||
|
MaterialProperty greenColor = null;
|
||||||
|
MaterialProperty blueColor = null;
|
||||||
|
MaterialProperty alphaColor = null;
|
||||||
|
MaterialProperty specularMap = null;
|
||||||
|
MaterialProperty specularColor = null;
|
||||||
|
MaterialProperty metallicMap = null;
|
||||||
|
MaterialProperty metallic = null;
|
||||||
|
MaterialProperty smoothness = null;
|
||||||
|
MaterialProperty smoothnessScale = null;
|
||||||
|
MaterialProperty smoothnessMapChannel = null;
|
||||||
|
MaterialProperty highlights = null;
|
||||||
|
MaterialProperty reflections = null;
|
||||||
|
MaterialProperty bumpScale = null;
|
||||||
|
MaterialProperty bumpMap = null;
|
||||||
|
MaterialProperty occlusionStrength = null;
|
||||||
|
MaterialProperty occlusionMap = null;
|
||||||
|
MaterialProperty heigtMapScale = null;
|
||||||
|
MaterialProperty heightMap = null;
|
||||||
|
MaterialProperty emissionColorForRendering = null;
|
||||||
|
MaterialProperty emissionMap = null;
|
||||||
|
MaterialProperty detailMask = null;
|
||||||
|
MaterialProperty detailAlbedoMap = null;
|
||||||
|
MaterialProperty detailNormalMapScale = null;
|
||||||
|
MaterialProperty detailNormalMap = null;
|
||||||
|
MaterialProperty uvSetSecondary = null;
|
||||||
|
|
||||||
|
MaterialEditor m_MaterialEditor;
|
||||||
|
WorkflowMode m_WorkflowMode = WorkflowMode.Specular;
|
||||||
|
ColorPickerHDRConfig m_ColorPickerHDRConfig = new ColorPickerHDRConfig(0f, 99f, 1/99f, 3f);
|
||||||
|
|
||||||
|
bool m_FirstTimeApply = true;
|
||||||
|
|
||||||
|
public void FindProperties (MaterialProperty[] props)
|
||||||
|
{
|
||||||
|
blendMode = FindProperty ("_Mode", props);
|
||||||
|
albedoMap = FindProperty ("_MainTex", props);
|
||||||
|
albedoColor = FindProperty ("_Color", props);
|
||||||
|
alphaCutoff = FindProperty ("_Cutoff", props);
|
||||||
|
colorMaskMap = FindProperty ("_ColorMaskTex", props);
|
||||||
|
redColor = FindProperty ("_RedColor", props);
|
||||||
|
greenColor = FindProperty ("_GreenColor", props);
|
||||||
|
blueColor = FindProperty ("_BlueColor", props);
|
||||||
|
alphaColor = FindProperty ("_AlphaColor", props);
|
||||||
|
specularMap = FindProperty ("_SpecGlossMap", props, false);
|
||||||
|
specularColor = FindProperty ("_SpecColor", props, false);
|
||||||
|
metallicMap = FindProperty ("_MetallicGlossMap", props, false);
|
||||||
|
metallic = FindProperty ("_Metallic", props, false);
|
||||||
|
if (specularMap != null && specularColor != null)
|
||||||
|
m_WorkflowMode = WorkflowMode.Specular;
|
||||||
|
else if (metallicMap != null && metallic != null)
|
||||||
|
m_WorkflowMode = WorkflowMode.Metallic;
|
||||||
|
else
|
||||||
|
m_WorkflowMode = WorkflowMode.Dielectric;
|
||||||
|
smoothness = FindProperty ("_Glossiness", props);
|
||||||
|
smoothnessScale = FindProperty ("_GlossMapScale", props, false);
|
||||||
|
smoothnessMapChannel = FindProperty ("_SmoothnessTextureChannel", props, false);
|
||||||
|
highlights = FindProperty ("_SpecularHighlights", props, false);
|
||||||
|
reflections = FindProperty ("_GlossyReflections", props, false);
|
||||||
|
bumpScale = FindProperty ("_BumpScale", props);
|
||||||
|
bumpMap = FindProperty ("_BumpMap", props);
|
||||||
|
heigtMapScale = FindProperty ("_Parallax", props);
|
||||||
|
heightMap = FindProperty("_ParallaxMap", props);
|
||||||
|
occlusionStrength = FindProperty ("_OcclusionStrength", props);
|
||||||
|
occlusionMap = FindProperty ("_OcclusionMap", props);
|
||||||
|
emissionColorForRendering = FindProperty ("_EmissionColor", props);
|
||||||
|
emissionMap = FindProperty ("_EmissionMap", props);
|
||||||
|
detailMask = FindProperty ("_DetailMask", props);
|
||||||
|
detailAlbedoMap = FindProperty ("_DetailAlbedoMap", props);
|
||||||
|
detailNormalMapScale = FindProperty ("_DetailNormalMapScale", props);
|
||||||
|
detailNormalMap = FindProperty ("_DetailNormalMap", props);
|
||||||
|
uvSetSecondary = FindProperty ("_UVSec", props);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] props)
|
||||||
|
{
|
||||||
|
FindProperties (props); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
|
||||||
|
m_MaterialEditor = materialEditor;
|
||||||
|
Material material = materialEditor.target as Material;
|
||||||
|
|
||||||
|
// Make sure that needed setup (ie keywords/renderqueue) are set up if we're switching some existing
|
||||||
|
// material to a standard shader.
|
||||||
|
// Do this before any GUI code has been issued to prevent layout issues in subsequent GUILayout statements (case 780071)
|
||||||
|
if (m_FirstTimeApply)
|
||||||
|
{
|
||||||
|
MaterialChanged(material, m_WorkflowMode);
|
||||||
|
m_FirstTimeApply = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShaderPropertiesGUI (material);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShaderPropertiesGUI (Material material)
|
||||||
|
{
|
||||||
|
// Use default labelWidth
|
||||||
|
EditorGUIUtility.labelWidth = 0f;
|
||||||
|
|
||||||
|
// Detect any changes to the material
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
{
|
||||||
|
BlendModePopup();
|
||||||
|
|
||||||
|
// Primary properties
|
||||||
|
GUILayout.Label (Styles.primaryMapsText, EditorStyles.boldLabel);
|
||||||
|
DoAlbedoArea(material);
|
||||||
|
DoColorMaskArea(material);
|
||||||
|
DoSpecularMetallicArea();
|
||||||
|
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null);
|
||||||
|
m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null);
|
||||||
|
m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null);
|
||||||
|
DoEmissionArea(material);
|
||||||
|
m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask);
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
m_MaterialEditor.TextureScaleOffsetProperty(albedoMap);
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
colorMaskMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the color mask texture as well
|
||||||
|
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
m_MaterialEditor.TextureScaleOffsetProperty(albedoMap);
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake
|
||||||
|
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
|
||||||
|
// Secondary properties
|
||||||
|
GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel);
|
||||||
|
m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap);
|
||||||
|
m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale);
|
||||||
|
m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap);
|
||||||
|
m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text);
|
||||||
|
|
||||||
|
// Third properties
|
||||||
|
GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel);
|
||||||
|
if (highlights != null)
|
||||||
|
m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText);
|
||||||
|
if (reflections != null)
|
||||||
|
m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
foreach (var obj in blendMode.targets)
|
||||||
|
MaterialChanged((Material)obj, m_WorkflowMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void DetermineWorkflow(MaterialProperty[] props)
|
||||||
|
{
|
||||||
|
if (FindProperty("_SpecGlossMap", props, false) != null && FindProperty("_SpecColor", props, false) != null)
|
||||||
|
m_WorkflowMode = WorkflowMode.Specular;
|
||||||
|
else if (FindProperty("_MetallicGlossMap", props, false) != null && FindProperty("_Metallic", props, false) != null)
|
||||||
|
m_WorkflowMode = WorkflowMode.Metallic;
|
||||||
|
else
|
||||||
|
m_WorkflowMode = WorkflowMode.Dielectric;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void AssignNewShaderToMaterial (Material material, Shader oldShader, Shader newShader)
|
||||||
|
{
|
||||||
|
// _Emission property is lost after assigning Standard shader to the material
|
||||||
|
// thus transfer it before assigning the new shader
|
||||||
|
if (material.HasProperty("_Emission"))
|
||||||
|
{
|
||||||
|
material.SetColor("_EmissionColor", material.GetColor("_Emission"));
|
||||||
|
}
|
||||||
|
|
||||||
|
base.AssignNewShaderToMaterial(material, oldShader, newShader);
|
||||||
|
|
||||||
|
if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
|
||||||
|
{
|
||||||
|
SetupMaterialWithBlendMode(material, (BlendMode)material.GetFloat("_Mode"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlendMode blendMode = BlendMode.Opaque;
|
||||||
|
if (oldShader.name.Contains("/Transparent/Cutout/"))
|
||||||
|
{
|
||||||
|
blendMode = BlendMode.Cutout;
|
||||||
|
}
|
||||||
|
else if (oldShader.name.Contains("/Transparent/"))
|
||||||
|
{
|
||||||
|
// NOTE: legacy shaders did not provide physically based transparency
|
||||||
|
// therefore Fade mode
|
||||||
|
blendMode = BlendMode.Fade;
|
||||||
|
}
|
||||||
|
material.SetFloat("_Mode", (float)blendMode);
|
||||||
|
|
||||||
|
DetermineWorkflow( MaterialEditor.GetMaterialProperties (new Material[] { material }) );
|
||||||
|
MaterialChanged(material, m_WorkflowMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlendModePopup()
|
||||||
|
{
|
||||||
|
EditorGUI.showMixedValue = blendMode.hasMixedValue;
|
||||||
|
var mode = (BlendMode)blendMode.floatValue;
|
||||||
|
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
mode = (BlendMode)EditorGUILayout.Popup(Styles.renderingMode, (int)mode, Styles.blendNames);
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
m_MaterialEditor.RegisterPropertyChangeUndo("Rendering Mode");
|
||||||
|
blendMode.floatValue = (float)mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
EditorGUI.showMixedValue = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoAlbedoArea(Material material)
|
||||||
|
{
|
||||||
|
m_MaterialEditor.TexturePropertySingleLine(Styles.albedoText, albedoMap, albedoColor);
|
||||||
|
if (((BlendMode)material.GetFloat("_Mode") == BlendMode.Cutout))
|
||||||
|
{
|
||||||
|
m_MaterialEditor.ShaderProperty(alphaCutoff, Styles.alphaCutoffText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoColorMaskArea(Material material)
|
||||||
|
{
|
||||||
|
//4 channel color mask - Texture and colors
|
||||||
|
m_MaterialEditor.TexturePropertySingleLine(Styles.colorMaskText, colorMaskMap);
|
||||||
|
m_MaterialEditor.ColorProperty(redColor, "Red Color");
|
||||||
|
m_MaterialEditor.ColorProperty(greenColor, "Green Color");
|
||||||
|
m_MaterialEditor.ColorProperty(blueColor, "Blue Color");
|
||||||
|
m_MaterialEditor.ColorProperty(alphaColor, "Alpha Color");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoEmissionArea(Material material)
|
||||||
|
{
|
||||||
|
bool showHelpBox = !HasValidEmissiveKeyword(material);
|
||||||
|
|
||||||
|
bool hadEmissionTexture = emissionMap.textureValue != null;
|
||||||
|
|
||||||
|
// Texture and HDR color controls
|
||||||
|
m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, m_ColorPickerHDRConfig, false);
|
||||||
|
|
||||||
|
// If texture was assigned and color was black set color to white
|
||||||
|
float brightness = emissionColorForRendering.colorValue.maxColorComponent;
|
||||||
|
if (emissionMap.textureValue != null && !hadEmissionTexture && brightness <= 0f)
|
||||||
|
emissionColorForRendering.colorValue = Color.white;
|
||||||
|
|
||||||
|
// Emission for GI?
|
||||||
|
m_MaterialEditor.LightmapEmissionProperty (MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
|
||||||
|
|
||||||
|
if (showHelpBox)
|
||||||
|
{
|
||||||
|
EditorGUILayout.HelpBox(Styles.emissiveWarning.text, MessageType.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoSpecularMetallicArea()
|
||||||
|
{
|
||||||
|
bool hasGlossMap = false;
|
||||||
|
if (m_WorkflowMode == WorkflowMode.Specular)
|
||||||
|
{
|
||||||
|
hasGlossMap = specularMap.textureValue != null;
|
||||||
|
m_MaterialEditor.TexturePropertySingleLine(Styles.specularMapText, specularMap, hasGlossMap ? null : specularColor);
|
||||||
|
}
|
||||||
|
else if (m_WorkflowMode == WorkflowMode.Metallic)
|
||||||
|
{
|
||||||
|
hasGlossMap = metallicMap.textureValue != null;
|
||||||
|
m_MaterialEditor.TexturePropertySingleLine(Styles.metallicMapText, metallicMap, hasGlossMap ? null : metallic);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool showSmoothnessScale = hasGlossMap;
|
||||||
|
if (smoothnessMapChannel != null)
|
||||||
|
{
|
||||||
|
int smoothnessChannel = (int) smoothnessMapChannel.floatValue;
|
||||||
|
if (smoothnessChannel == (int) SmoothnessMapChannel.AlbedoAlpha)
|
||||||
|
showSmoothnessScale = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int indentation = 2; // align with labels of texture properties
|
||||||
|
m_MaterialEditor.ShaderProperty(showSmoothnessScale ? smoothnessScale : smoothness, showSmoothnessScale ? Styles.smoothnessScaleText : Styles.smoothnessText, indentation);
|
||||||
|
|
||||||
|
++indentation;
|
||||||
|
if (smoothnessMapChannel != null)
|
||||||
|
m_MaterialEditor.ShaderProperty(smoothnessMapChannel, Styles.smoothnessMapChannelText, indentation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetupMaterialWithBlendMode(Material material, BlendMode blendMode)
|
||||||
|
{
|
||||||
|
switch (blendMode)
|
||||||
|
{
|
||||||
|
case BlendMode.Opaque:
|
||||||
|
material.SetOverrideTag("RenderType", "");
|
||||||
|
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
||||||
|
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
|
||||||
|
material.SetInt("_ZWrite", 1);
|
||||||
|
material.DisableKeyword("_ALPHATEST_ON");
|
||||||
|
material.DisableKeyword("_ALPHABLEND_ON");
|
||||||
|
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
|
||||||
|
material.renderQueue = -1;
|
||||||
|
break;
|
||||||
|
case BlendMode.Cutout:
|
||||||
|
material.SetOverrideTag("RenderType", "TransparentCutout");
|
||||||
|
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
||||||
|
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
|
||||||
|
material.SetInt("_ZWrite", 1);
|
||||||
|
material.EnableKeyword("_ALPHATEST_ON");
|
||||||
|
material.DisableKeyword("_ALPHABLEND_ON");
|
||||||
|
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
|
||||||
|
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.AlphaTest;
|
||||||
|
break;
|
||||||
|
case BlendMode.Fade:
|
||||||
|
material.SetOverrideTag("RenderType", "Transparent");
|
||||||
|
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
|
||||||
|
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
||||||
|
material.SetInt("_ZWrite", 0);
|
||||||
|
material.DisableKeyword("_ALPHATEST_ON");
|
||||||
|
material.EnableKeyword("_ALPHABLEND_ON");
|
||||||
|
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
|
||||||
|
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
|
||||||
|
break;
|
||||||
|
case BlendMode.Transparent:
|
||||||
|
material.SetOverrideTag("RenderType", "Transparent");
|
||||||
|
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
|
||||||
|
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
|
||||||
|
material.SetInt("_ZWrite", 0);
|
||||||
|
material.DisableKeyword("_ALPHATEST_ON");
|
||||||
|
material.DisableKeyword("_ALPHABLEND_ON");
|
||||||
|
material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
|
||||||
|
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static SmoothnessMapChannel GetSmoothnessMapChannel(Material material)
|
||||||
|
{
|
||||||
|
int ch = (int) material.GetFloat("_SmoothnessTextureChannel");
|
||||||
|
if (ch == (int) SmoothnessMapChannel.AlbedoAlpha)
|
||||||
|
return SmoothnessMapChannel.AlbedoAlpha;
|
||||||
|
else
|
||||||
|
return SmoothnessMapChannel.SpecularMetallicAlpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ShouldEmissionBeEnabled(Material mat, Color color)
|
||||||
|
{
|
||||||
|
var realtimeEmission = (mat.globalIlluminationFlags & MaterialGlobalIlluminationFlags.RealtimeEmissive) > 0;
|
||||||
|
return color.maxColorComponent > 0.1f / 255.0f || realtimeEmission;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetMaterialKeywords(Material material, WorkflowMode workflowMode)
|
||||||
|
{
|
||||||
|
// Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
|
||||||
|
// (MaterialProperty value might come from renderer material property block)
|
||||||
|
SetKeyword (material, "_NORMALMAP", material.GetTexture ("_BumpMap") || material.GetTexture ("_DetailNormalMap"));
|
||||||
|
if (workflowMode == WorkflowMode.Specular)
|
||||||
|
SetKeyword (material, "_SPECGLOSSMAP", material.GetTexture ("_SpecGlossMap"));
|
||||||
|
else if (workflowMode == WorkflowMode.Metallic)
|
||||||
|
SetKeyword (material, "_METALLICGLOSSMAP", material.GetTexture ("_MetallicGlossMap"));
|
||||||
|
SetKeyword (material, "_PARALLAXMAP", material.GetTexture ("_ParallaxMap"));
|
||||||
|
SetKeyword (material, "_DETAIL_MULX2", material.GetTexture ("_DetailAlbedoMap") || material.GetTexture ("_DetailNormalMap"));
|
||||||
|
|
||||||
|
bool shouldEmissionBeEnabled = ShouldEmissionBeEnabled (material, material.GetColor("_EmissionColor"));
|
||||||
|
SetKeyword (material, "_EMISSION", shouldEmissionBeEnabled);
|
||||||
|
|
||||||
|
if (material.HasProperty("_SmoothnessTextureChannel"))
|
||||||
|
{
|
||||||
|
SetKeyword (material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", GetSmoothnessMapChannel(material) == SmoothnessMapChannel.AlbedoAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup lightmap emissive flags
|
||||||
|
MaterialGlobalIlluminationFlags flags = material.globalIlluminationFlags;
|
||||||
|
if ((flags & (MaterialGlobalIlluminationFlags.BakedEmissive | MaterialGlobalIlluminationFlags.RealtimeEmissive)) != 0)
|
||||||
|
{
|
||||||
|
flags &= ~MaterialGlobalIlluminationFlags.EmissiveIsBlack;
|
||||||
|
if (!shouldEmissionBeEnabled)
|
||||||
|
flags |= MaterialGlobalIlluminationFlags.EmissiveIsBlack;
|
||||||
|
|
||||||
|
material.globalIlluminationFlags = flags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HasValidEmissiveKeyword (Material material)
|
||||||
|
{
|
||||||
|
// Material animation might be out of sync with the material keyword.
|
||||||
|
// So if the emission support is disabled on the material, but the property blocks have a value that requires it, then we need to show a warning.
|
||||||
|
// (note: (Renderer MaterialPropertyBlock applies its values to emissionColorForRendering))
|
||||||
|
bool hasEmissionKeyword = material.IsKeywordEnabled ("_EMISSION");
|
||||||
|
if (!hasEmissionKeyword && ShouldEmissionBeEnabled (material, emissionColorForRendering.colorValue))
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MaterialChanged(Material material, WorkflowMode workflowMode)
|
||||||
|
{
|
||||||
|
SetupMaterialWithBlendMode(material, (BlendMode)material.GetFloat("_Mode"));
|
||||||
|
|
||||||
|
SetMaterialKeywords(material, workflowMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetKeyword(Material m, string keyword, bool state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
m.EnableKeyword (keyword);
|
||||||
|
else
|
||||||
|
m.DisableKeyword (keyword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace UnityEditor
|
|
@ -0,0 +1,12 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 57c815331559f6549a3f6d3c4f7102c1
|
||||||
|
timeCreated: 1435093423
|
||||||
|
licenseType: Store
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
9
Assets/ColorMask/Textures.meta
Normal file
9
Assets/ColorMask/Textures.meta
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 39b96f3ca7350da4e9d89b1bcf9e31af
|
||||||
|
folderAsset: yes
|
||||||
|
timeCreated: 1435094985
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/ColorMask/readme.pdf
Normal file
BIN
Assets/ColorMask/readme.pdf
Normal file
Binary file not shown.
8
Assets/ColorMask/readme.pdf.meta
Normal file
8
Assets/ColorMask/readme.pdf.meta
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7d724b05fcb887c4aa017dbe4ae8ac8a
|
||||||
|
timeCreated: 1436040334
|
||||||
|
licenseType: Store
|
||||||
|
DefaultImporter:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -319,10 +319,8 @@ MonoBehaviour:
|
||||||
wantsCrouch: 0
|
wantsCrouch: 0
|
||||||
bgMaterial: {fileID: 2100000, guid: d308d6053cbc091489ae82391d36d476, type: 2}
|
bgMaterial: {fileID: 2100000, guid: d308d6053cbc091489ae82391d36d476, type: 2}
|
||||||
fadeMaterial: {fileID: 2100000, guid: 5ad5f9e65ea02ac4c95e42c36fc8d39e, type: 2}
|
fadeMaterial: {fileID: 2100000, guid: 5ad5f9e65ea02ac4c95e42c36fc8d39e, type: 2}
|
||||||
floorMaterial:
|
floorMaterial: {fileID: 2100000, guid: 5c5aa636b730eba44b9a80ea76a7bc4e, type: 2}
|
||||||
- {fileID: 0}
|
cloudMaterial: {fileID: 2100000, guid: 04362130d29b5134fa53ff055e11734e, type: 2}
|
||||||
- {fileID: 0}
|
|
||||||
- {fileID: 0}
|
|
||||||
cameraPivot: {fileID: 2677427256397037315}
|
cameraPivot: {fileID: 2677427256397037315}
|
||||||
cameraPos: {fileID: 2677427256397037315}
|
cameraPos: {fileID: 2677427256397037315}
|
||||||
cameraFOV: 25
|
cameraFOV: 25
|
||||||
|
@ -1012,7 +1010,7 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: -8679921383154817045, guid: 333100bf553a5924d870acafacb4f53a, type: 3}
|
- target: {fileID: -8679921383154817045, guid: 333100bf553a5924d870acafacb4f53a, type: 3}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
value: -0.55
|
value: -0.4
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: -8679921383154817045, guid: 333100bf553a5924d870acafacb4f53a, type: 3}
|
- target: {fileID: -8679921383154817045, guid: 333100bf553a5924d870acafacb4f53a, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
|
@ -2440,10 +2438,34 @@ PrefabInstance:
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: floor_model
|
value: floor_model
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5521721997653780584, guid: ddff1c9d4886fd746bbd2b69bf51f546, type: 3}
|
||||||
|
propertyPath: m_CastShadows
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5521721997653780584, guid: ddff1c9d4886fd746bbd2b69bf51f546, type: 3}
|
||||||
|
propertyPath: m_ReceiveShadows
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5521721997653780584, guid: ddff1c9d4886fd746bbd2b69bf51f546, type: 3}
|
||||||
|
propertyPath: m_DynamicOccludee
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5521721997653780584, guid: ddff1c9d4886fd746bbd2b69bf51f546, type: 3}
|
||||||
|
propertyPath: m_LightProbeUsage
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 5521721997653780584, guid: ddff1c9d4886fd746bbd2b69bf51f546, type: 3}
|
- target: {fileID: 5521721997653780584, guid: ddff1c9d4886fd746bbd2b69bf51f546, type: 3}
|
||||||
propertyPath: m_Materials.Array.size
|
propertyPath: m_Materials.Array.size
|
||||||
value: 1
|
value: 1
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5521721997653780584, guid: ddff1c9d4886fd746bbd2b69bf51f546, type: 3}
|
||||||
|
propertyPath: m_ReflectionProbeUsage
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 5521721997653780584, guid: ddff1c9d4886fd746bbd2b69bf51f546, type: 3}
|
||||||
|
propertyPath: m_SkinnedMotionVectors
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 5521721997653780584, guid: ddff1c9d4886fd746bbd2b69bf51f546, type: 3}
|
- target: {fileID: 5521721997653780584, guid: ddff1c9d4886fd746bbd2b69bf51f546, type: 3}
|
||||||
propertyPath: m_Materials.Array.data[0]
|
propertyPath: m_Materials.Array.data[0]
|
||||||
value:
|
value:
|
||||||
|
|
|
@ -28,7 +28,7 @@ AnimationClip:
|
||||||
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
|
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
|
||||||
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
|
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
time: 0.5
|
time: 1.5
|
||||||
value: {x: 0, y: -0.4, z: 0}
|
value: {x: 0, y: -0.4, z: 0}
|
||||||
inSlope: {x: 0, y: 0, z: 0}
|
inSlope: {x: 0, y: 0, z: 0}
|
||||||
outSlope: {x: 0, y: 0, z: 0}
|
outSlope: {x: 0, y: 0, z: 0}
|
||||||
|
@ -37,7 +37,7 @@ AnimationClip:
|
||||||
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
|
inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
|
||||||
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
|
outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334}
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
time: 1
|
time: 3
|
||||||
value: {x: 0, y: -0.55, z: 0}
|
value: {x: 0, y: -0.55, z: 0}
|
||||||
inSlope: {x: 0, y: 0, z: 0}
|
inSlope: {x: 0, y: 0, z: 0}
|
||||||
outSlope: {x: 0, y: 0, z: 0}
|
outSlope: {x: 0, y: 0, z: 0}
|
||||||
|
@ -72,7 +72,7 @@ AnimationClip:
|
||||||
m_AdditiveReferencePoseClip: {fileID: 0}
|
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||||
m_AdditiveReferencePoseTime: 0
|
m_AdditiveReferencePoseTime: 0
|
||||||
m_StartTime: 0
|
m_StartTime: 0
|
||||||
m_StopTime: 1
|
m_StopTime: 3
|
||||||
m_OrientationOffsetY: 0
|
m_OrientationOffsetY: 0
|
||||||
m_Level: 0
|
m_Level: 0
|
||||||
m_CycleOffset: 0
|
m_CycleOffset: 0
|
||||||
|
@ -101,7 +101,7 @@ AnimationClip:
|
||||||
inWeight: 0.33333334
|
inWeight: 0.33333334
|
||||||
outWeight: 0.33333334
|
outWeight: 0.33333334
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
time: 0.5
|
time: 1.5
|
||||||
value: 0
|
value: 0
|
||||||
inSlope: 0
|
inSlope: 0
|
||||||
outSlope: 0
|
outSlope: 0
|
||||||
|
@ -110,7 +110,7 @@ AnimationClip:
|
||||||
inWeight: 0.33333334
|
inWeight: 0.33333334
|
||||||
outWeight: 0.33333334
|
outWeight: 0.33333334
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
time: 1
|
time: 3
|
||||||
value: 0
|
value: 0
|
||||||
inSlope: 0
|
inSlope: 0
|
||||||
outSlope: 0
|
outSlope: 0
|
||||||
|
@ -138,7 +138,7 @@ AnimationClip:
|
||||||
inWeight: 0.33333334
|
inWeight: 0.33333334
|
||||||
outWeight: 0.33333334
|
outWeight: 0.33333334
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
time: 0.5
|
time: 1.5
|
||||||
value: -0.4
|
value: -0.4
|
||||||
inSlope: 0
|
inSlope: 0
|
||||||
outSlope: 0
|
outSlope: 0
|
||||||
|
@ -147,7 +147,7 @@ AnimationClip:
|
||||||
inWeight: 0.33333334
|
inWeight: 0.33333334
|
||||||
outWeight: 0.33333334
|
outWeight: 0.33333334
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
time: 1
|
time: 3
|
||||||
value: -0.55
|
value: -0.55
|
||||||
inSlope: 0
|
inSlope: 0
|
||||||
outSlope: 0
|
outSlope: 0
|
||||||
|
@ -175,7 +175,7 @@ AnimationClip:
|
||||||
inWeight: 0.33333334
|
inWeight: 0.33333334
|
||||||
outWeight: 0.33333334
|
outWeight: 0.33333334
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
time: 0.5
|
time: 1.5
|
||||||
value: 0
|
value: 0
|
||||||
inSlope: 0
|
inSlope: 0
|
||||||
outSlope: 0
|
outSlope: 0
|
||||||
|
@ -184,7 +184,7 @@ AnimationClip:
|
||||||
inWeight: 0.33333334
|
inWeight: 0.33333334
|
||||||
outWeight: 0.33333334
|
outWeight: 0.33333334
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
time: 1
|
time: 3
|
||||||
value: 0
|
value: 0
|
||||||
inSlope: 0
|
inSlope: 0
|
||||||
outSlope: 0
|
outSlope: 0
|
||||||
|
|
|
@ -81,6 +81,6 @@ Material:
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _EmissionColor: {r: 0.6766883, g: 0.6766883, b: 0.6766883, a: 1}
|
- _EmissionColor: {r: 0.78431374, g: 0.6766883, b: 0.6766883, a: 1}
|
||||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|
|
@ -82,6 +82,6 @@ Material:
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _EmissionColor: {r: 0.6766883, g: 0.6766883, b: 0.6766883, a: 1}
|
- _EmissionColor: {r: 0.78431374, g: 0.6766883, b: 0.6766883, a: 1}
|
||||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|
|
@ -96,7 +96,7 @@ Material:
|
||||||
- _CautionColor: {r: 1, g: 1, b: 1, a: 1}
|
- _CautionColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _CriticalColor: {r: 1, g: 1, b: 1, a: 1}
|
- _CriticalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _EmissionColor: {r: 0.6766883, g: 0.6766883, b: 0.6766883, a: 1}
|
- _EmissionColor: {r: 0.78431374, g: 0.6766883, b: 0.6766883, a: 1}
|
||||||
- _GoodColor: {r: 1, g: 1, b: 1, a: 1}
|
- _GoodColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
- _ReflectColor: {r: 1, g: 1, b: 1, a: 0.5}
|
- _ReflectColor: {r: 1, g: 1, b: 1, a: 0.5}
|
||||||
|
|
|
@ -81,6 +81,6 @@ Material:
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _EmissionColor: {r: 0.6766883, g: 0.6766883, b: 0.6766883, a: 1}
|
- _EmissionColor: {r: 0.78431374, g: 0.6766883, b: 0.6766883, a: 1}
|
||||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|
|
@ -75,6 +75,6 @@ Material:
|
||||||
- _UVSec: 0
|
- _UVSec: 0
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 0.44705883}
|
- _Color: {r: 1, g: 1, b: 1, a: 0.78431374}
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|
|
@ -81,6 +81,6 @@ Material:
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _EmissionColor: {r: 0.6766883, g: 0.6766883, b: 0.6766883, a: 1}
|
- _EmissionColor: {r: 0.78431374, g: 0.6766883, b: 0.6766883, a: 1}
|
||||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|
|
@ -81,6 +81,6 @@ Material:
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _EmissionColor: {r: 0.6766883, g: 0.6766883, b: 0.6766883, a: 1}
|
- _EmissionColor: {r: 0.78431374, g: 0.6766883, b: 0.6766883, a: 1}
|
||||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|
|
@ -75,6 +75,6 @@ Material:
|
||||||
- _UVSec: 0
|
- _UVSec: 0
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 0.78431374}
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|
|
@ -8,7 +8,7 @@ Material:
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: clouds
|
m_Name: clouds
|
||||||
m_Shader: {fileID: 10751, guid: 0000000000000000f000000000000000, type: 0}
|
m_Shader: {fileID: 4800000, guid: 6edf21a3fdd28154ab40e23fb0660133, type: 3}
|
||||||
m_ValidKeywords: []
|
m_ValidKeywords: []
|
||||||
m_InvalidKeywords:
|
m_InvalidKeywords:
|
||||||
- _ALPHATEST_ON
|
- _ALPHATEST_ON
|
||||||
|
|
|
@ -80,7 +80,7 @@ Material:
|
||||||
- _UVSec: 0
|
- _UVSec: 0
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 0.5019608}
|
- _Color: {r: 1, g: 1, b: 1, a: 0.78431374}
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|
|
@ -8,10 +8,12 @@ Material:
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: floorspecular
|
m_Name: floorspecular
|
||||||
m_Shader: {fileID: 45, guid: 0000000000000000f000000000000000, type: 0}
|
m_Shader: {fileID: 4800000, guid: bedf46e927dae18459dcdcdef5201a5f, type: 3}
|
||||||
m_ValidKeywords: []
|
m_ValidKeywords:
|
||||||
m_InvalidKeywords: []
|
- _EMISSION
|
||||||
m_LightmapFlags: 4
|
m_InvalidKeywords:
|
||||||
|
- _METALLICGLOSSMAP
|
||||||
|
m_LightmapFlags: 2
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
m_DoubleSidedGI: 0
|
m_DoubleSidedGI: 0
|
||||||
m_CustomRenderQueue: -1
|
m_CustomRenderQueue: -1
|
||||||
|
@ -24,10 +26,14 @@ Material:
|
||||||
m_Texture: {fileID: 0}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _DetailAlbedoMap:
|
- _ColorMaskTex:
|
||||||
m_Texture: {fileID: 0}
|
m_Texture: {fileID: 2800000, guid: f181c9819c5bc7b488b3eedee117d8e0, type: 3}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
|
- _DetailAlbedoMap:
|
||||||
|
m_Texture: {fileID: 0}
|
||||||
|
m_Scale: {x: 128, y: 1}
|
||||||
|
m_Offset: {x: 128, y: 0}
|
||||||
- _DetailMask:
|
- _DetailMask:
|
||||||
m_Texture: {fileID: 0}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
|
@ -37,19 +43,19 @@ Material:
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _EmissionMap:
|
- _EmissionMap:
|
||||||
m_Texture: {fileID: 2800000, guid: e63f82dce03ddec43891c66e2945190b, type: 3}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 128, y: 0}
|
m_Scale: {x: 128, y: 0}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MainTex:
|
- _MainTex:
|
||||||
m_Texture: {fileID: 2800000, guid: e63f82dce03ddec43891c66e2945190b, type: 3}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 128, y: 0}
|
m_Scale: {x: 128, y: 0}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MetallicGlossMap:
|
- _MetallicGlossMap:
|
||||||
m_Texture: {fileID: 0}
|
m_Texture: {fileID: 2800000, guid: 19bee659c965a1f43821279858da805d, type: 3}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _OcclusionMap:
|
- _OcclusionMap:
|
||||||
m_Texture: {fileID: 0}
|
m_Texture: {fileID: 2800000, guid: f181c9819c5bc7b488b3eedee117d8e0, type: 3}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _ParallaxMap:
|
- _ParallaxMap:
|
||||||
|
@ -63,15 +69,15 @@ Material:
|
||||||
m_Ints: []
|
m_Ints: []
|
||||||
m_Floats:
|
m_Floats:
|
||||||
- _BumpScale: 1
|
- _BumpScale: 1
|
||||||
- _Cutoff: 0.5
|
- _Cutoff: 0
|
||||||
- _DetailNormalMapScale: 1
|
- _DetailNormalMapScale: 1
|
||||||
- _DstBlend: 0
|
- _DstBlend: 0
|
||||||
- _GlossMapScale: 1
|
- _GlossMapScale: 0.05
|
||||||
- _Glossiness: 0.65
|
- _Glossiness: 0.1
|
||||||
- _GlossyReflections: 1
|
- _GlossyReflections: 1
|
||||||
- _Metallic: 0
|
- _Metallic: 0.2
|
||||||
- _Mode: 0
|
- _Mode: 0
|
||||||
- _OcclusionStrength: 1
|
- _OcclusionStrength: 0
|
||||||
- _Parallax: 0.02
|
- _Parallax: 0.02
|
||||||
- _SmoothnessTextureChannel: 0
|
- _SmoothnessTextureChannel: 0
|
||||||
- _SpecularHighlights: 1
|
- _SpecularHighlights: 1
|
||||||
|
@ -79,7 +85,11 @@ Material:
|
||||||
- _UVSec: 0
|
- _UVSec: 0
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _AlphaColor: {r: 0.3773585, g: 0.3773585, b: 0.3773585, a: 1}
|
||||||
- _EmissionColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
- _BlueColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _SpecColor: {r: 0.21960786, g: 0.21960786, b: 0.21960786, a: 1}
|
- _Color: {r: 1, g: 0.97547174, b: 0.97547174, a: 1}
|
||||||
|
- _EmissionColor: {r: 0.078431375, g: 0.078431375, b: 0.078431375, a: 1}
|
||||||
|
- _GreenColor: {r: 1, g: 1, b: 1, a: 0}
|
||||||
|
- _RedColor: {r: 0.8274511, g: 0.1254902, b: 0.8078432, a: 1}
|
||||||
|
- _SpecColor: {r: 0.047169805, g: 0.047169805, b: 0.047169805, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|
|
@ -70,7 +70,7 @@ Material:
|
||||||
- _GlossMapScale: 1
|
- _GlossMapScale: 1
|
||||||
- _Glossiness: 0.65
|
- _Glossiness: 0.65
|
||||||
- _GlossyReflections: 1
|
- _GlossyReflections: 1
|
||||||
- _Metallic: 0
|
- _Metallic: 0.65
|
||||||
- _Mode: 0
|
- _Mode: 0
|
||||||
- _OcclusionStrength: 1
|
- _OcclusionStrength: 1
|
||||||
- _Parallax: 0.02
|
- _Parallax: 0.02
|
||||||
|
@ -81,6 +81,6 @@ Material:
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _EmissionColor: {r: 0.6766883, g: 0.6766883, b: 0.6766883, a: 1}
|
- _EmissionColor: {r: 0.78431374, g: 0.6766883, b: 0.6766883, a: 1}
|
||||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|
|
@ -99,7 +99,7 @@ Material:
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BlendColor: {r: 1, g: 1, b: 1, a: 1}
|
- _BlendColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _EmissionColor: {r: 0.6766883, g: 0.6766883, b: 0.6766883, a: 1}
|
- _EmissionColor: {r: 0.78431374, g: 0.6766883, b: 0.6766883, a: 1}
|
||||||
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
|
||||||
- _Specular: {r: 0, g: 0, b: 0, a: 0}
|
- _Specular: {r: 0, g: 0, b: 0, a: 0}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|
|
@ -103,13 +103,30 @@ namespace HeavenStudio.Games.Loaders
|
||||||
|
|
||||||
new GameAction("fade background", "Background Color")
|
new GameAction("fade background", "Background Color")
|
||||||
{
|
{
|
||||||
function = delegate {Airboarder.instance.BackgroundColor(eventCaller.currentEntity.beat, eventCaller.currentEntity.length, eventCaller.currentEntity["colorStart"], eventCaller.currentEntity["colorEnd"], eventCaller.currentEntity["ease"]); },
|
function = delegate {Airboarder.instance.BackgroundColor(eventCaller.currentEntity.beat, eventCaller.currentEntity.length, eventCaller.currentEntity["colorStart"], eventCaller.currentEntity["colorEnd"], eventCaller.currentEntity["cloudStart"], eventCaller.currentEntity["cloudEnd"], eventCaller.currentEntity["ease"]); },
|
||||||
defaultLength = 4f,
|
defaultLength = 4f,
|
||||||
resizable = true,
|
resizable = true,
|
||||||
parameters = new List<Param>()
|
parameters = new List<Param>()
|
||||||
{
|
{
|
||||||
new Param("colorStart", Color.white, "Start Color", "Set the color at the start of the event."),
|
new Param("colorStart", Airboarder.defaultBGColor, "Sky Start Color", "Set the sky color at the start of the event."),
|
||||||
new Param("colorEnd", Airboarder.defaultBGColor, "End Color", "Set the color at the end of the event."),
|
new Param("colorEnd", Airboarder.defaultBGColor, "Sky End Color", "Set the sky color at the end of the event."),
|
||||||
|
new Param("cloudStart", Color.white, "Cloud Start Color", "Set the cloud color at the start of the event."),
|
||||||
|
new Param("cloudEnd", Color.white, "Cloud End Color", "Set the cloud color at the end of the event."),
|
||||||
|
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
new GameAction("fade floor", "Floor Color")
|
||||||
|
{
|
||||||
|
function = delegate {Airboarder.instance.FloorColor(eventCaller.currentEntity.beat, eventCaller.currentEntity.length, eventCaller.currentEntity["colorStart"], eventCaller.currentEntity["colorEnd"], eventCaller.currentEntity["stripeStart"], eventCaller.currentEntity["stripeEnd"], eventCaller.currentEntity["ease"]);},
|
||||||
|
defaultLength = 4f,
|
||||||
|
resizable = true,
|
||||||
|
parameters = new List<Param>()
|
||||||
|
{
|
||||||
|
new Param("colorStart", Color.white, "Wide Stripe Start Color", "Set the color of the wide stripes at the start of the event."),
|
||||||
|
new Param("colorEnd", Color.white, "Wide Stripe End Color", "Set the color of the wide stripes at the end of the event."),
|
||||||
|
new Param("stripeStart", Airboarder.defaultStripeColor, "Thin Stripe Start Color", "Set the color of the thin stripes at the start of the event."),
|
||||||
|
new Param("stripeEnd", Airboarder.defaultStripeColor, "Thin Stripe End Color", "Set the color of the thin stripes at the end of the event."),
|
||||||
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.")
|
new Param("ease", Util.EasingFunction.Ease.Linear, "Ease", "Set the easing of the action.")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -159,12 +176,20 @@ namespace HeavenStudio.Games
|
||||||
public static Airboarder instance;
|
public static Airboarder instance;
|
||||||
|
|
||||||
public static Color defaultBGColor = new Color(0.9921569f, 0.7686275f, 0.9921569f);
|
public static Color defaultBGColor = new Color(0.9921569f, 0.7686275f, 0.9921569f);
|
||||||
|
public static Color defaultFloorColor = Color.white;
|
||||||
|
public static Color defaultStripeColor = new Color(0.8274511f, 0.1254902f, 0.8078432f);
|
||||||
|
public static Color defaultCloudColor = Color.white;
|
||||||
|
|
||||||
|
private ColorEase bgColorEase = new(defaultBGColor);
|
||||||
|
private ColorEase cloudColorEase = new(defaultCloudColor);
|
||||||
|
private ColorEase[] colorEases = new ColorEase[2];
|
||||||
|
|
||||||
public bool wantsCrouch;
|
public bool wantsCrouch;
|
||||||
[Header("Materials")]
|
[Header("Materials")]
|
||||||
[SerializeField] private Material bgMaterial;
|
[SerializeField] private Material bgMaterial;
|
||||||
[SerializeField] private Material fadeMaterial;
|
[SerializeField] private Material fadeMaterial;
|
||||||
[SerializeField] private Material[] floorMaterial;
|
[SerializeField] private Material floorMaterial;
|
||||||
|
[SerializeField] private Material cloudMaterial;
|
||||||
|
|
||||||
[Header("Camera")]
|
[Header("Camera")]
|
||||||
[SerializeField] Transform cameraPivot;
|
[SerializeField] Transform cameraPivot;
|
||||||
|
@ -204,6 +229,10 @@ namespace HeavenStudio.Games
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
colorEases = new ColorEase[] {
|
||||||
|
new(Color.white),
|
||||||
|
new(new Color (0.8274511F, 0.1254902F, 0.8078432F)),
|
||||||
|
};
|
||||||
instance = this;
|
instance = this;
|
||||||
SetupBopRegion("airboarder", "bop", "auto");
|
SetupBopRegion("airboarder", "bop", "auto");
|
||||||
wantsCrouch = false;
|
wantsCrouch = false;
|
||||||
|
@ -254,6 +283,8 @@ namespace HeavenStudio.Games
|
||||||
EntityPreCheck(Conductor.instance.songPositionInBeatsAsDouble);
|
EntityPreCheck(Conductor.instance.songPositionInBeatsAsDouble);
|
||||||
bgMaterial.color = defaultBGColor;
|
bgMaterial.color = defaultBGColor;
|
||||||
fadeMaterial.color = defaultBGColor;
|
fadeMaterial.color = defaultBGColor;
|
||||||
|
cloudMaterial.color = defaultCloudColor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityPreCheck(double beat)
|
void EntityPreCheck(double beat)
|
||||||
|
@ -305,7 +336,8 @@ namespace HeavenStudio.Games
|
||||||
{
|
{
|
||||||
var cond = Conductor.instance;
|
var cond = Conductor.instance;
|
||||||
var currentBeat = cond.songPositionInBeatsAsDouble;
|
var currentBeat = cond.songPositionInBeatsAsDouble;
|
||||||
BackgroundColorUpdate();
|
|
||||||
|
ColorUpdate();
|
||||||
|
|
||||||
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 5f);
|
float normalizedBeat = Conductor.instance.GetPositionFromBeat(startBeat, 5f);
|
||||||
|
|
||||||
|
@ -313,9 +345,6 @@ namespace HeavenStudio.Games
|
||||||
Floor.speed = 0;
|
Floor.speed = 0;
|
||||||
Dog.Play("run", 0, normalizedBeat*7.5f);
|
Dog.Play("run", 0, normalizedBeat*7.5f);
|
||||||
Dog.Play("wag",1,normalizedBeat*2.5f);
|
Dog.Play("wag",1,normalizedBeat*2.5f);
|
||||||
CPU1.Play("hover",0,normalizedBeat);
|
|
||||||
CPU2.Play("hover",0,normalizedBeat);
|
|
||||||
Player.Play("hover",0,normalizedBeat);
|
|
||||||
|
|
||||||
|
|
||||||
if (cond.isPlaying && !cond.isPaused){
|
if (cond.isPlaying && !cond.isPaused){
|
||||||
|
@ -356,20 +385,32 @@ namespace HeavenStudio.Games
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ColorEase bgColorEase = new(defaultBGColor);
|
|
||||||
|
|
||||||
//call this in update
|
//call this in update
|
||||||
private void BackgroundColorUpdate()
|
private void ColorUpdate()
|
||||||
{
|
{
|
||||||
bgMaterial.color = bgColorEase.GetColor();
|
bgMaterial.color = bgColorEase.GetColor();
|
||||||
fadeMaterial.color = bgColorEase.GetColor();
|
fadeMaterial.color = bgColorEase.GetColor();
|
||||||
|
cloudMaterial.color = cloudColorEase.GetColor();
|
||||||
|
floorMaterial.SetColor("_BlueColor", colorEases[0].GetColor());
|
||||||
|
floorMaterial.SetColor("_RedColor", colorEases[1].GetColor());
|
||||||
|
|
||||||
}
|
}
|
||||||
public void BackgroundColor(double beat, float length, Color startColor, Color endColor, int ease)
|
|
||||||
|
public void BackgroundColor(double beat, float length, Color startColor, Color endColor, Color startCloud, Color endCloud, int ease)
|
||||||
{
|
{
|
||||||
bgColorEase = new(beat, length, startColor, endColor, ease);
|
bgColorEase = new(beat, length, startColor, endColor, ease);
|
||||||
|
cloudColorEase = new(beat, length, startCloud, endCloud, ease);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void FloorColor(double beat, float length, Color startColor, Color endColor, Color startStripe, Color endStripe, int ease)
|
||||||
|
{
|
||||||
|
colorEases = new ColorEase[] {
|
||||||
|
new(beat, length, startColor, endColor, ease),
|
||||||
|
new(beat, length, startStripe, endStripe, ease),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void PersistColor(double beat)
|
private void PersistColor(double beat)
|
||||||
{
|
{
|
||||||
|
@ -378,7 +419,15 @@ namespace HeavenStudio.Games
|
||||||
{
|
{
|
||||||
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
|
allEventsBeforeBeat.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
|
||||||
var lastEvent = allEventsBeforeBeat[^1];
|
var lastEvent = allEventsBeforeBeat[^1];
|
||||||
BackgroundColor(lastEvent.beat, lastEvent.length, lastEvent["colorStart"], lastEvent["colorEnd"], lastEvent["ease"]);
|
BackgroundColor(lastEvent.beat, lastEvent.length, lastEvent["colorStart"], lastEvent["colorEnd"], lastEvent["cloudStart"], lastEvent["cloudEnd"], lastEvent["ease"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var allEventsBeforeBeatF = EventCaller.GetAllInGameManagerList("airboarder", new string[] { "fade floor" }).FindAll(x => x.beat < beat);
|
||||||
|
if (allEventsBeforeBeatF.Count > 0)
|
||||||
|
{
|
||||||
|
allEventsBeforeBeatF.Sort((x, y) => x.beat.CompareTo(y.beat)); //just in case
|
||||||
|
var lastEventF = allEventsBeforeBeatF[^1];
|
||||||
|
FloorColor(lastEventF.beat, lastEventF.length, lastEventF["colorStart"], lastEventF["colorEnd"], lastEventF["stripeStart"], lastEventF["stripeEnd"], lastEventF["ease"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue