1
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,206 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &-7953337332898741536
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Jupiter/Sky
|
||||
m_Shader: {fileID: 4800000, guid: 3129e3b90193a0547900ecf4cf4e9864, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- ALLOW_STEP_EFFECT
|
||||
- HORIZON_CLOUD
|
||||
- MOON
|
||||
- OVERHEAD_CLOUD
|
||||
- STARS
|
||||
- STARS_LAYER_0
|
||||
- STARS_LAYER_1
|
||||
- STARS_LAYER_2
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _DetailOverlayCubemap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MoonCubemap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MoonTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _StarsCubemap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _StarsTwinkleMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SunCubemap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SunTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _DetailOverlayLayer: 0
|
||||
- _DetailOverlayRotationSpeed: 0
|
||||
- _HorizonCloudAnimationSpeed: 50
|
||||
- _HorizonCloudEnd: 0.35
|
||||
- _HorizonCloudSize: 4.47
|
||||
- _HorizonCloudStart: -0.01
|
||||
- _HorizonCloudStep: 25
|
||||
- _HorizonExponent: 5
|
||||
- _HorizonStep: 1000
|
||||
- _HorizonThickness: 1
|
||||
- _MoonGlow: 0.24
|
||||
- _MoonSize: 0.07
|
||||
- _MoonSoftEdge: 0.22
|
||||
- _OverheadCloudAltitude: 1000
|
||||
- _OverheadCloudAnimationSpeed: 50
|
||||
- _OverheadCloudFlowX: 1
|
||||
- _OverheadCloudFlowZ: 1
|
||||
- _OverheadCloudSize: 10
|
||||
- _OverheadCloudStep: 2
|
||||
- _StarsDensity0: 0.4
|
||||
- _StarsDensity1: 0.34
|
||||
- _StarsDensity2: 0.45
|
||||
- _StarsEnd: 1
|
||||
- _StarsGlow0: 0.01
|
||||
- _StarsGlow1: 0.01
|
||||
- _StarsGlow2: 0.01
|
||||
- _StarsOpacity: 1
|
||||
- _StarsSize0: 0.42
|
||||
- _StarsSize1: 0.53
|
||||
- _StarsSize2: 0.46
|
||||
- _StarsStart: 0.25
|
||||
- _StarsTwinkle0: 5
|
||||
- _StarsTwinkle1: 6
|
||||
- _StarsTwinkle2: 2
|
||||
- _SunGlow: 0
|
||||
- _SunSize: 0
|
||||
- _SunSoftEdge: 0
|
||||
m_Colors:
|
||||
- _DetailOverlayColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _GroundColor: {r: 0.1981132, g: 0.1981132, b: 0.1981132, a: 1}
|
||||
- _HorizonCloudColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _HorizonColor: {r: 0.38431373, g: 0.48638386, b: 0.6509804, a: 1}
|
||||
- _MoonColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _MoonDirection: {r: 0, g: 0, b: 1, a: 0}
|
||||
- _OverheadCloudColor: {r: 1, g: 1, b: 1, a: 0.09803922}
|
||||
- _SkyColor: {r: 0.10090523, g: 0.06363475, b: 0.20754719, a: 1}
|
||||
- _StarsColor0: {r: 0.9254902, g: 0.88081425, b: 0.5432628, a: 1}
|
||||
- _StarsColor1: {r: 1, g: 0.24056602, b: 0.8628801, a: 1}
|
||||
- _StarsColor2: {r: 0, g: 0.8351569, b: 1, a: 1}
|
||||
- _SunColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _SunDirection: {r: -1, g: -1, b: -1, a: 0}
|
||||
m_BuildTextureStacks: []
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fa5278d11d9502245b5cc174a196561b, type: 3}
|
||||
m_Name: StarryNight
|
||||
m_EditorClassIdentifier:
|
||||
skyColor: {r: 0.10090523, g: 0.06363475, b: 0.20754719, a: 1}
|
||||
horizonColor: {r: 0.38431373, g: 0.48638386, b: 0.6509804, a: 1}
|
||||
groundColor: {r: 0.1981132, g: 0.1981132, b: 0.1981132, a: 1}
|
||||
horizonThickness: 1
|
||||
horizonExponent: 5
|
||||
horizonStep: 1000
|
||||
fogSyncOption: 2
|
||||
fogColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
enableStars: 1
|
||||
starsStartPosition: 0.25
|
||||
starsEndPosition: 1
|
||||
starsOpacity: 1
|
||||
starsLayerCount: 3
|
||||
starsColor0: {r: 0.9254902, g: 0.88081425, b: 0.5432628, a: 1}
|
||||
starsColor1: {r: 1, g: 0.24056602, b: 0.8628801, a: 1}
|
||||
starsColor2: {r: 0, g: 0.8351569, b: 1, a: 1}
|
||||
starsDensity0: 0.4
|
||||
starsDensity1: 0.34
|
||||
starsDensity2: 0.45
|
||||
starsSize0: 0.42
|
||||
starsSize1: 0.53
|
||||
starsSize2: 0.46
|
||||
starsGlow0: 0.01
|
||||
starsGlow1: 0.01
|
||||
starsGlow2: 0.01
|
||||
starsTwinkle0: 5
|
||||
starsTwinkle1: 6
|
||||
starsTwinkle2: 2
|
||||
useBakedStars: 0
|
||||
starsCubemap: {fileID: 0}
|
||||
starsTwinkleMap: {fileID: 0}
|
||||
enableSun: 0
|
||||
sunTexture: {fileID: 0}
|
||||
sunColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
sunSize: 0
|
||||
sunSoftEdge: 0
|
||||
sunGlow: 0
|
||||
useBakedSun: 0
|
||||
sunCubemap: {fileID: 0}
|
||||
sunLightColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
sunLightIntensity: 0
|
||||
enableMoon: 1
|
||||
moonTexture: {fileID: 0}
|
||||
moonColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
moonSize: 0.07
|
||||
moonSoftEdge: 0.22
|
||||
moonGlow: 0.24
|
||||
useBakedMoon: 0
|
||||
moonCubemap: {fileID: 0}
|
||||
moonLightColor: {r: 0.8443396, g: 0.9841163, b: 1, a: 1}
|
||||
moonLightIntensity: 0.2
|
||||
customCloudTexture: {fileID: 0}
|
||||
enableHorizonCloud: 1
|
||||
horizonCloudColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
horizonCloudStartPosition: -0.01
|
||||
horizonCloudEndPosition: 0.35
|
||||
horizonCloudSize: 4.47
|
||||
horizonCloudStep: 25
|
||||
horizonCloudAnimationSpeed: 50
|
||||
enableOverheadCloud: 1
|
||||
overheadCloudColor: {r: 1, g: 1, b: 1, a: 0.09803922}
|
||||
overheadCloudAltitude: 1000
|
||||
overheadCloudSize: 10
|
||||
overheadCloudStep: 2
|
||||
overheadCloudAnimationSpeed: 50
|
||||
overheadCloudFlowDirectionX: 1
|
||||
overheadCloudFlowDirectionZ: 1
|
||||
overheadCloudRemapMin: 0
|
||||
overheadCloudRemapMax: 1
|
||||
overheadCloudCastShadow: 0
|
||||
overheadCloudShadowClipMask: 0
|
||||
enableDetailOverlay: 0
|
||||
detailOverlayTintColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
detailOverlayCubeMap: {fileID: 0}
|
||||
detailOverlayLayer: 0
|
||||
detailOverlayRotationSpeed: 0
|
||||
allowStepEffect: 0
|
||||
material: {fileID: -7953337332898741536}
|
||||
shadowMaterial: {fileID: 0}
|
@@ -0,0 +1,202 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fa5278d11d9502245b5cc174a196561b, type: 3}
|
||||
m_Name: SunnyDay
|
||||
m_EditorClassIdentifier:
|
||||
skyColor: {r: 0.2264151, g: 0.6028122, b: 0.9056604, a: 1}
|
||||
horizonColor: {r: 1, g: 0.94944346, b: 0.839, a: 1}
|
||||
groundColor: {r: 0.4339623, g: 0.4339623, b: 0.4339623, a: 1}
|
||||
horizonThickness: 1
|
||||
horizonExponent: 3
|
||||
horizonStep: 500
|
||||
fogSyncOption: 2
|
||||
fogColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
enableStars: 0
|
||||
starsStartPosition: 0
|
||||
starsEndPosition: 0
|
||||
starsOpacity: 0
|
||||
starsLayerCount: 0
|
||||
starsColor0: {r: 0, g: 0, b: 0, a: 0}
|
||||
starsColor1: {r: 0, g: 0, b: 0, a: 0}
|
||||
starsColor2: {r: 0, g: 0, b: 0, a: 0}
|
||||
starsDensity0: 0
|
||||
starsDensity1: 0
|
||||
starsDensity2: 0
|
||||
starsSize0: 0
|
||||
starsSize1: 0
|
||||
starsSize2: 0
|
||||
starsGlow0: 0
|
||||
starsGlow1: 0
|
||||
starsGlow2: 0
|
||||
starsTwinkle0: 0
|
||||
starsTwinkle1: 0
|
||||
starsTwinkle2: 0
|
||||
useBakedStars: 0
|
||||
starsCubemap: {fileID: 0}
|
||||
starsTwinkleMap: {fileID: 0}
|
||||
enableSun: 1
|
||||
sunTexture: {fileID: 0}
|
||||
sunColor: {r: 1, g: 0.9700814, b: 0.9009434, a: 1}
|
||||
sunSize: 0.07
|
||||
sunSoftEdge: 0.5
|
||||
sunGlow: 0.45
|
||||
useBakedSun: 0
|
||||
sunCubemap: {fileID: 0}
|
||||
sunLightColor: {r: 1, g: 0.9929226, b: 0.9009434, a: 1}
|
||||
sunLightIntensity: 1
|
||||
enableMoon: 0
|
||||
moonTexture: {fileID: 0}
|
||||
moonColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
moonSize: 0
|
||||
moonSoftEdge: 0
|
||||
moonGlow: 0
|
||||
useBakedMoon: 0
|
||||
moonCubemap: {fileID: 0}
|
||||
moonLightColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
moonLightIntensity: 0
|
||||
customCloudTexture: {fileID: 0}
|
||||
enableHorizonCloud: 0
|
||||
horizonCloudColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
horizonCloudStartPosition: -0.1
|
||||
horizonCloudEndPosition: 0.65
|
||||
horizonCloudSize: 4.91
|
||||
horizonCloudStep: 25
|
||||
horizonCloudAnimationSpeed: 50
|
||||
enableOverheadCloud: 1
|
||||
overheadCloudColor: {r: 1, g: 1, b: 1, a: 0.5647059}
|
||||
overheadCloudAltitude: 1000
|
||||
overheadCloudSize: 10
|
||||
overheadCloudStep: 2
|
||||
overheadCloudAnimationSpeed: 50
|
||||
overheadCloudFlowDirectionX: 1
|
||||
overheadCloudFlowDirectionZ: 1
|
||||
overheadCloudRemapMin: 0
|
||||
overheadCloudRemapMax: 1
|
||||
overheadCloudCastShadow: 0
|
||||
overheadCloudShadowClipMask: 0
|
||||
enableDetailOverlay: 1
|
||||
detailOverlayTintColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
detailOverlayCubeMap: {fileID: 0}
|
||||
detailOverlayLayer: 0
|
||||
detailOverlayRotationSpeed: 0
|
||||
allowStepEffect: 0
|
||||
material: {fileID: 683795580653540547}
|
||||
shadowMaterial: {fileID: 0}
|
||||
--- !u!21 &683795580653540547
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Jupiter/Sky
|
||||
m_Shader: {fileID: 4800000, guid: 3129e3b90193a0547900ecf4cf4e9864, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- ALLOW_STEP_EFFECT
|
||||
- DETAIL_OVERLAY
|
||||
- OVERHEAD_CLOUD
|
||||
- SUN
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _DetailOverlayCubemap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MoonCubemap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MoonTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _StarsCubemap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _StarsTwinkleMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SunCubemap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SunTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _DetailOverlayLayer: 0
|
||||
- _DetailOverlayRotationSpeed: 0
|
||||
- _HorizonCloudAnimationSpeed: 50
|
||||
- _HorizonCloudEnd: 0.65
|
||||
- _HorizonCloudSize: 4.91
|
||||
- _HorizonCloudStart: -0.1
|
||||
- _HorizonCloudStep: 25
|
||||
- _HorizonExponent: 3
|
||||
- _HorizonStep: 500
|
||||
- _HorizonThickness: 1
|
||||
- _MoonGlow: 0
|
||||
- _MoonSize: 0
|
||||
- _MoonSoftEdge: 0
|
||||
- _OverheadCloudAltitude: 1000
|
||||
- _OverheadCloudAnimationSpeed: 50
|
||||
- _OverheadCloudFlowX: 1
|
||||
- _OverheadCloudFlowZ: 1
|
||||
- _OverheadCloudSize: 10
|
||||
- _OverheadCloudStep: 2
|
||||
- _StarsDensity0: 0
|
||||
- _StarsDensity1: 0
|
||||
- _StarsDensity2: 0
|
||||
- _StarsEnd: 0
|
||||
- _StarsGlow0: 0
|
||||
- _StarsGlow1: 0
|
||||
- _StarsGlow2: 0
|
||||
- _StarsOpacity: 0
|
||||
- _StarsSize0: 0
|
||||
- _StarsSize1: 0
|
||||
- _StarsSize2: 0
|
||||
- _StarsStart: 0
|
||||
- _StarsTwinkle0: 0
|
||||
- _StarsTwinkle1: 0
|
||||
- _StarsTwinkle2: 0
|
||||
- _SunGlow: 0.45
|
||||
- _SunSize: 0.07
|
||||
- _SunSoftEdge: 0.5
|
||||
m_Colors:
|
||||
- _DetailOverlayColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _GroundColor: {r: 0.4339623, g: 0.4339623, b: 0.4339623, a: 1}
|
||||
- _HorizonCloudColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _HorizonColor: {r: 1, g: 0.94944346, b: 0.839, a: 1}
|
||||
- _MoonColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _MoonDirection: {r: 1, g: 1, b: 1, a: 0}
|
||||
- _OverheadCloudColor: {r: 1, g: 1, b: 1, a: 0.5647059}
|
||||
- _SkyColor: {r: 0.2264151, g: 0.6028122, b: 0.9056604, a: 1}
|
||||
- _StarsColor0: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _StarsColor1: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _StarsColor2: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _SunColor: {r: 1, g: 0.9700814, b: 0.9009434, a: 1}
|
||||
- _SunDirection: {r: -0.3213938, g: -0.76604444, b: 0.5566705, a: 0}
|
||||
m_BuildTextureStacks: []
|
@@ -0,0 +1,28 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4602ffc9ae1863b4b9155331571220f2, type: 3}
|
||||
m_Name: JupiterSettings
|
||||
m_EditorClassIdentifier:
|
||||
defaultSkybox: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
noiseTexture: {fileID: 2800000, guid: 7f313a2cde54f8e4ba19db94edca915b, type: 3}
|
||||
cloudTexture: {fileID: 2800000, guid: 433abcf8c760aa746a5580cd0a190b51, type: 3}
|
||||
defaultProfileSunnyDay: {fileID: 11400000, guid: b4b856d2b3d3c164fbcf5c87fc2abee2,
|
||||
type: 2}
|
||||
defaultProfileStarryNight: {fileID: 11400000, guid: 8585bdf0dc6491649be0609424d9661b,
|
||||
type: 2}
|
||||
defaultDayNightCycleProfile: {fileID: 11400000, guid: 038b4db3822d0934bafe44586a5925fe,
|
||||
type: 2}
|
||||
internalShaders:
|
||||
skyShader: {fileID: 4800000, guid: 3129e3b90193a0547900ecf4cf4e9864, type: 3}
|
||||
skyShadowShader: {fileID: 4800000, guid: 561c1777fd66e5d488ef1b85ed82bbaa, type: 3}
|
||||
copyTextureShader: {fileID: 4800000, guid: b3f0e74bdb60b6b478290fc44ebf68f6, type: 3}
|
||||
solidColorShader: {fileID: 4800000, guid: 3fe9e551ea5d3fe41b879f13cf0e6a1b, type: 3}
|
@@ -0,0 +1,485 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine.Rendering;
|
||||
using DateTime = System.DateTime;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
public static class JCommon
|
||||
{
|
||||
public static string SUPPORT_EMAIL = "support@pinwheel.studio";
|
||||
public static string BUSINESS_EMAIL = "hello@pinwheel.studio";
|
||||
public static string YOUTUBE_CHANNEL = "https://www.youtube.com/channel/UCebwuk5CfIe5kolBI9nuBTg";
|
||||
public static string ONLINE_MANUAL = "https://docs.google.com/document/d/1Wf4CDlD96c6tna1ee0fpquWkdSrGDIO-eKuQDxjJedY/edit?usp=sharing";
|
||||
public static string FORUM = "https://forum.unity.com/threads/pre-released-jupiter-procedural-sky-builtin-lwrp-urp.799635/";
|
||||
public static string DISCORD = "https://discord.gg/HXNnFpS";
|
||||
|
||||
|
||||
public const int PREVIEW_TEXTURE_SIZE = 512;
|
||||
public const int TEXTURE_SIZE_MIN = 1;
|
||||
public const int TEXTURE_SIZE_MAX = 8192;
|
||||
|
||||
public static JRenderPipelineType CurrentRenderPipeline
|
||||
{
|
||||
get
|
||||
{
|
||||
string pipelineName = Shader.globalRenderPipeline;
|
||||
if (pipelineName.Equals("UniversalPipeline,LightweightPipeline"))
|
||||
{
|
||||
return JRenderPipelineType.Universal;
|
||||
}
|
||||
else if (pipelineName.Equals("LightweightPipeline"))
|
||||
{
|
||||
return JRenderPipelineType.Lightweight;
|
||||
}
|
||||
else
|
||||
{
|
||||
return JRenderPipelineType.Builtin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector2[] fullRectUvPoints;
|
||||
public static Vector2[] FullRectUvPoints
|
||||
{
|
||||
get
|
||||
{
|
||||
if (fullRectUvPoints == null)
|
||||
{
|
||||
fullRectUvPoints = new Vector2[]
|
||||
{
|
||||
Vector2.zero,
|
||||
Vector2.up,
|
||||
Vector2.one,
|
||||
Vector2.right
|
||||
};
|
||||
}
|
||||
return fullRectUvPoints;
|
||||
}
|
||||
}
|
||||
|
||||
private static Mesh emptyMesh;
|
||||
public static Mesh EmptyMesh
|
||||
{
|
||||
get
|
||||
{
|
||||
if (emptyMesh == null)
|
||||
{
|
||||
emptyMesh = new Mesh();
|
||||
}
|
||||
return emptyMesh;
|
||||
}
|
||||
}
|
||||
|
||||
private static Material[] emptyMaterials;
|
||||
public static Material[] EmptyMaterials
|
||||
{
|
||||
get
|
||||
{
|
||||
if (emptyMaterials==null)
|
||||
{
|
||||
emptyMaterials = new Material[0];
|
||||
}
|
||||
return emptyMaterials;
|
||||
}
|
||||
}
|
||||
|
||||
public static Rect UnitRect
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Rect(0, 0, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetUniqueID()
|
||||
{
|
||||
string s = GetTimeTick().ToString();
|
||||
return Reverse(s);
|
||||
}
|
||||
|
||||
public static long GetTimeTick()
|
||||
{
|
||||
DateTime time = DateTime.Now;
|
||||
return time.Ticks;
|
||||
}
|
||||
|
||||
public static string Reverse(string s)
|
||||
{
|
||||
char[] chars = s.ToCharArray();
|
||||
System.Array.Reverse(chars);
|
||||
return new string(chars);
|
||||
}
|
||||
|
||||
public static void SetDirty(Object o)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.SetDirty(o);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void AddObjectToAsset(Object objectToAdd, Object asset)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
AssetDatabase.AddObjectToAsset(objectToAdd, asset);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static Texture2D CreateTexture(int resolution, Color fill, TextureFormat format = TextureFormat.ARGB32)
|
||||
{
|
||||
Texture2D t = new Texture2D(resolution, resolution, format, false);
|
||||
Color[] colors = new Color[resolution * resolution];
|
||||
JUtilities.Fill(colors, fill);
|
||||
t.SetPixels(colors);
|
||||
t.Apply();
|
||||
return t;
|
||||
}
|
||||
|
||||
public static void CopyToRT(Texture t, RenderTexture rt)
|
||||
{
|
||||
RenderTexture.active = rt;
|
||||
Graphics.Blit(t, rt);
|
||||
RenderTexture.active = null;
|
||||
}
|
||||
|
||||
public static void CopyFromRT(Texture2D t, RenderTexture rt)
|
||||
{
|
||||
RenderTexture.active = rt;
|
||||
t.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
|
||||
t.Apply();
|
||||
RenderTexture.active = null;
|
||||
}
|
||||
|
||||
public static void CopyTexture(Texture2D src, Texture2D des)
|
||||
{
|
||||
RenderTexture rt = new RenderTexture(des.width, des.height, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Default);
|
||||
CopyToRT(src, rt);
|
||||
CopyFromRT(des, rt);
|
||||
rt.Release();
|
||||
JUtilities.DestroyObject(rt);
|
||||
}
|
||||
|
||||
public static Texture2D CloneTexture(Texture2D t)
|
||||
{
|
||||
RenderTexture rt = new RenderTexture(t.width, t.height, 0, RenderTextureFormat.ARGB32);
|
||||
CopyToRT(t, rt);
|
||||
Texture2D result = new Texture2D(t.width, t.height, TextureFormat.ARGB32, false);
|
||||
result.filterMode = t.filterMode;
|
||||
result.wrapMode = t.wrapMode;
|
||||
CopyFromRT(result, rt);
|
||||
rt.Release();
|
||||
Object.DestroyImmediate(rt);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void FillTexture(Texture2D t, Color c)
|
||||
{
|
||||
Color[] colors = new Color[t.width * t.height];
|
||||
JUtilities.Fill(colors, c);
|
||||
t.SetPixels(colors);
|
||||
t.Apply();
|
||||
}
|
||||
|
||||
public static void FillTexture(RenderTexture rt, Color c)
|
||||
{
|
||||
Texture2D tex = new Texture2D(1, 1, TextureFormat.ARGB32, false);
|
||||
tex.SetPixel(0, 0, c);
|
||||
tex.Apply();
|
||||
CopyToRT(tex, rt);
|
||||
JUtilities.DestroyObject(tex);
|
||||
}
|
||||
|
||||
public static Texture2D CloneAndResizeTexture(Texture2D t, int width, int height)
|
||||
{
|
||||
RenderTexture rt = new RenderTexture(width, height, 0, RenderTextureFormat.ARGB32);
|
||||
CopyToRT(t, rt);
|
||||
Texture2D result = new Texture2D(width, height, TextureFormat.ARGB32, false);
|
||||
result.filterMode = t.filterMode;
|
||||
result.wrapMode = t.wrapMode;
|
||||
CopyFromRT(result, rt);
|
||||
rt.Release();
|
||||
Object.DestroyImmediate(rt);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static RenderTexture CopyToRT(Texture src, int startX, int startY, int width, int height, Color defaultColor)
|
||||
{
|
||||
int endX = startX + width - 1;
|
||||
int endY = startY + height - 1;
|
||||
Vector2 startUV = new Vector2(
|
||||
JUtilities.InverseLerpUnclamped(0, src.width - 1, startX),
|
||||
JUtilities.InverseLerpUnclamped(0, src.height - 1, startY));
|
||||
Vector2 endUV = new Vector2(
|
||||
JUtilities.InverseLerpUnclamped(0, src.width - 1, endX),
|
||||
JUtilities.InverseLerpUnclamped(0, src.height - 1, endY));
|
||||
Material mat = JInternalMaterials.CopyTextureMaterial;
|
||||
mat.SetTexture("_MainTex", src);
|
||||
mat.SetVector("_StartUV", startUV);
|
||||
mat.SetVector("_EndUV", endUV);
|
||||
mat.SetColor("_DefaultColor", defaultColor);
|
||||
mat.SetPass(0);
|
||||
RenderTexture rt = new RenderTexture(width, height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
|
||||
RenderTexture.active = rt;
|
||||
Graphics.Blit(src, mat);
|
||||
RenderTexture.active = null;
|
||||
|
||||
return rt;
|
||||
}
|
||||
|
||||
public static void DrawTexture(RenderTexture rt, Texture texture, Rect uvRect, Material mat, int pass = 0)
|
||||
{
|
||||
if (mat == null)
|
||||
mat = JInternalMaterials.UnlitTextureMaterial;
|
||||
RenderTexture.active = rt;
|
||||
GL.PushMatrix();
|
||||
mat.SetTexture("_MainTex", texture);
|
||||
mat.SetPass(pass);
|
||||
GL.LoadOrtho();
|
||||
GL.Begin(GL.QUADS);
|
||||
GL.TexCoord(new Vector3(0, 0, 0));
|
||||
GL.Vertex3(uvRect.min.x, uvRect.min.y, 0);
|
||||
GL.TexCoord(new Vector3(0, 1, 0));
|
||||
GL.Vertex3(uvRect.min.x, uvRect.max.y, 0);
|
||||
GL.TexCoord(new Vector3(1, 1, 0));
|
||||
GL.Vertex3(uvRect.max.x, uvRect.max.y, 0);
|
||||
GL.TexCoord(new Vector3(1, 0, 0));
|
||||
GL.Vertex3(uvRect.max.x, uvRect.min.y, 0);
|
||||
GL.End();
|
||||
GL.PopMatrix();
|
||||
RenderTexture.active = null;
|
||||
}
|
||||
|
||||
public static void DrawTriangle(RenderTexture rt, Vector2 v0, Vector2 v1, Vector2 v2, Color c)
|
||||
{
|
||||
Material mat = JInternalMaterials.SolidColorMaterial;
|
||||
mat.SetColor("_Color", c);
|
||||
RenderTexture.active = rt;
|
||||
GL.PushMatrix();
|
||||
mat.SetPass(0);
|
||||
GL.LoadOrtho();
|
||||
GL.Begin(GL.TRIANGLES);
|
||||
GL.Vertex3(v0.x, v0.y, 0);
|
||||
GL.Vertex3(v1.x, v1.y, 0);
|
||||
GL.Vertex3(v2.x, v2.y, 0);
|
||||
GL.End();
|
||||
GL.PopMatrix();
|
||||
RenderTexture.active = null;
|
||||
}
|
||||
|
||||
public static void DrawQuad(RenderTexture rt, Vector2[] quadCorners, Material mat, int pass)
|
||||
{
|
||||
RenderTexture.active = rt;
|
||||
GL.PushMatrix();
|
||||
mat.SetPass(pass);
|
||||
GL.LoadOrtho();
|
||||
GL.Begin(GL.QUADS);
|
||||
GL.TexCoord(new Vector3(0, 0, 0));
|
||||
GL.Vertex3(quadCorners[0].x, quadCorners[0].y, 0);
|
||||
GL.TexCoord(new Vector3(0, 1, 0));
|
||||
GL.Vertex3(quadCorners[1].x, quadCorners[1].y, 0);
|
||||
GL.TexCoord(new Vector3(1, 1, 0));
|
||||
GL.Vertex3(quadCorners[2].x, quadCorners[2].y, 0);
|
||||
GL.TexCoord(new Vector3(1, 0, 0));
|
||||
GL.Vertex3(quadCorners[3].x, quadCorners[3].y, 0);
|
||||
GL.End();
|
||||
GL.PopMatrix();
|
||||
RenderTexture.active = null;
|
||||
}
|
||||
|
||||
public static List<System.Type> GetAllLoadedTypes()
|
||||
{
|
||||
List<System.Type> loadedTypes = new List<System.Type>();
|
||||
List<string> typeName = new List<string>();
|
||||
foreach (var assembly in System.AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
foreach (var t in assembly.GetTypes())
|
||||
{
|
||||
if (t.IsVisible && !t.IsGenericType)
|
||||
{
|
||||
typeName.Add(t.Name);
|
||||
loadedTypes.Add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
return loadedTypes;
|
||||
}
|
||||
|
||||
public static IEnumerable<Rect> CompareHeightMap(int gridSize, Color[] oldValues, Color[] newValues)
|
||||
{
|
||||
if (oldValues.LongLength != newValues.LongLength)
|
||||
{
|
||||
return new Rect[1] { new Rect(0, 0, 1, 1) };
|
||||
}
|
||||
Rect[] rects = new Rect[gridSize * gridSize];
|
||||
for (int x = 0; x < gridSize; ++x)
|
||||
{
|
||||
for (int z = 0; z < gridSize; ++z)
|
||||
{
|
||||
rects[JUtilities.To1DIndex(x, z, gridSize)] = GetUvRange(gridSize, x, z);
|
||||
}
|
||||
}
|
||||
|
||||
HashSet<Rect> dirtyRects = new HashSet<Rect>();
|
||||
|
||||
int index = 0;
|
||||
int resolution = Mathf.RoundToInt(Mathf.Sqrt(newValues.LongLength));
|
||||
for (int rectIndex = 0; rectIndex < rects.Length; ++rectIndex)
|
||||
{
|
||||
Rect r = rects[rectIndex];
|
||||
int startX = (int)Mathf.Lerp(0, resolution - 1, r.min.x);
|
||||
int startY = (int)Mathf.Lerp(0, resolution - 1, r.min.y);
|
||||
int endX = (int)Mathf.Lerp(0, resolution - 1, r.max.x);
|
||||
int endY = (int)Mathf.Lerp(0, resolution - 1, r.max.y);
|
||||
for (int x = startX; x <= endX; ++x)
|
||||
{
|
||||
for (int y = startY; y <= endY; ++y)
|
||||
{
|
||||
index = JUtilities.To1DIndex(x, y, resolution);
|
||||
if (oldValues[index].r == newValues[index].r &&
|
||||
oldValues[index].g == newValues[index].g &&
|
||||
oldValues[index].b == newValues[index].b &&
|
||||
oldValues[index].a == newValues[index].a)
|
||||
continue;
|
||||
dirtyRects.Add(r);
|
||||
|
||||
Rect hRect = new Rect();
|
||||
hRect.size = new Vector2(r.width * 1.2f, r.height);
|
||||
hRect.center = r.center;
|
||||
dirtyRects.Add(hRect);
|
||||
|
||||
Rect vRect = new Rect();
|
||||
vRect.size = new Vector2(r.width, r.height * 1.2f);
|
||||
vRect.center = r.center;
|
||||
dirtyRects.Add(vRect);
|
||||
break;
|
||||
}
|
||||
if (dirtyRects.Contains(r))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return dirtyRects;
|
||||
}
|
||||
|
||||
public static Rect GetUvRange(int gridSize, int x, int z)
|
||||
{
|
||||
Vector2 position = new Vector2(x * 1.0f / gridSize, z * 1.0f / gridSize);
|
||||
Vector2 size = Vector2.one / gridSize;
|
||||
return new Rect(position, size);
|
||||
}
|
||||
|
||||
public static Texture2D CreateTextureFromCurve(AnimationCurve curve, int width, int height)
|
||||
{
|
||||
Texture2D t = new Texture2D(width, height, TextureFormat.ARGB32, false);
|
||||
t.wrapMode = TextureWrapMode.Clamp;
|
||||
Color[] colors = new Color[width * height];
|
||||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
float f = Mathf.InverseLerp(0, width - 1, x);
|
||||
float value = curve.Evaluate(f);
|
||||
Color c = new Color(value, value, value, value);
|
||||
for (int y = 0; y < height; ++y)
|
||||
{
|
||||
colors[JUtilities.To1DIndex(x, y, width)] = c;
|
||||
}
|
||||
}
|
||||
t.filterMode = FilterMode.Bilinear;
|
||||
t.SetPixels(colors);
|
||||
t.Apply();
|
||||
return t;
|
||||
}
|
||||
|
||||
public static Vector3[] GetBrushQuadCorners(Vector3 center, float radius, float rotation)
|
||||
{
|
||||
Matrix4x4 matrix = Matrix4x4.Rotate(Quaternion.Euler(0, rotation, 0));
|
||||
Vector3[] corners = new Vector3[]
|
||||
{
|
||||
center + matrix.MultiplyPoint(new Vector3(-1,0,-1)*radius),
|
||||
center + matrix.MultiplyPoint(new Vector3(-1,0,1)*radius),
|
||||
center + matrix.MultiplyPoint(new Vector3(1,0,1)*radius),
|
||||
center + matrix.MultiplyPoint(new Vector3(1,0,-1)*radius)
|
||||
};
|
||||
return corners;
|
||||
}
|
||||
|
||||
//public static void RegisterBeginRender(Camera.CameraCallback callback)
|
||||
//{
|
||||
// Camera.onPreCull += callback;
|
||||
//}
|
||||
|
||||
//public static void RegisterBeginRenderSRP(System.Action<Camera> callback)
|
||||
//{
|
||||
// RenderPipelineManager.beginCameraRendering += callback;
|
||||
//}
|
||||
|
||||
//public static void UnregisterBeginRender(Camera.CameraCallback callback)
|
||||
//{
|
||||
// Camera.onPreCull -= callback;
|
||||
//}
|
||||
|
||||
//public static void UnregisterBeginRenderSRP(System.Action<Camera> callback)
|
||||
//{
|
||||
// RenderPipeline.beginCameraRendering -= callback;
|
||||
//}
|
||||
|
||||
//public static void RegisterEndRender(Camera.CameraCallback callback)
|
||||
//{
|
||||
// Camera.onPostRender += callback;
|
||||
//}
|
||||
|
||||
public static void ClearRT(RenderTexture rt)
|
||||
{
|
||||
RenderTexture.active = rt;
|
||||
GL.Clear(true, true, Color.clear);
|
||||
RenderTexture.active = null;
|
||||
}
|
||||
|
||||
public static void SetMaterialKeywordActive(Material mat, string keyword, bool active)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
mat.EnableKeyword(keyword);
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.DisableKeyword(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Editor_ProgressBar(string title, string detail, float percent)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.DisplayProgressBar(title, detail, percent);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Editor_CancelableProgressBar(string title, string detail, float percent)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (EditorUtility.DisplayCancelableProgressBar(title, detail, percent))
|
||||
{
|
||||
throw new JProgressCancelledException();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void Editor_ClearProgressBar()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
EditorUtility.ClearProgressBar();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static Camera CreateCamera()
|
||||
{
|
||||
GameObject g = new GameObject();
|
||||
Camera cam = g.AddComponent<Camera>();
|
||||
return cam;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
public enum JDetailOverlayLayer
|
||||
{
|
||||
AfterSky,
|
||||
AfterStars,
|
||||
AfterSun,
|
||||
AfterMoon,
|
||||
AfterHorizonCloud,
|
||||
AfterOverheadCloud
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
public enum JFogSyncOption
|
||||
{
|
||||
DontSync,
|
||||
SkyColor,
|
||||
HorizonColor,
|
||||
GroundColor,
|
||||
CustomColor
|
||||
}
|
||||
}
|
@@ -0,0 +1,125 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
//[CreateAssetMenu(menuName = "Jupiter/Settings")]
|
||||
public class JJupiterSettings : ScriptableObject
|
||||
{
|
||||
private static JJupiterSettings instance;
|
||||
public static JJupiterSettings Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = Resources.Load<JJupiterSettings>("JupiterSettings");
|
||||
if (instance == null)
|
||||
{
|
||||
instance = ScriptableObject.CreateInstance<JJupiterSettings>() as JJupiterSettings;
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Material defaultSkybox;
|
||||
public Material DefaultSkybox
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultSkybox;
|
||||
}
|
||||
set
|
||||
{
|
||||
defaultSkybox = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Texture2D noiseTexture;
|
||||
public Texture2D NoiseTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return noiseTexture;
|
||||
}
|
||||
set
|
||||
{
|
||||
noiseTexture = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Texture2D cloudTexture;
|
||||
public Texture2D CloudTexture
|
||||
{
|
||||
get
|
||||
{
|
||||
return cloudTexture;
|
||||
}
|
||||
set
|
||||
{
|
||||
cloudTexture = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private JSkyProfile defaultProfileSunnyDay;
|
||||
public JSkyProfile DefaultProfileSunnyDay
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultProfileSunnyDay;
|
||||
}
|
||||
set
|
||||
{
|
||||
defaultProfileSunnyDay = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private JSkyProfile defaultProfileStarryNight;
|
||||
public JSkyProfile DefaultProfileStarryNight
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultProfileStarryNight;
|
||||
}
|
||||
set
|
||||
{
|
||||
defaultProfileStarryNight = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private JDayNightCycleProfile defaultDayNightCycleProfile;
|
||||
public JDayNightCycleProfile DefaultDayNightCycleProfile
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultDayNightCycleProfile;
|
||||
}
|
||||
set
|
||||
{
|
||||
defaultDayNightCycleProfile = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private JInternalShaderSettings internalShaders;
|
||||
public JInternalShaderSettings InternalShaders
|
||||
{
|
||||
get
|
||||
{
|
||||
return internalShaders;
|
||||
}
|
||||
set
|
||||
{
|
||||
internalShaders = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,334 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
public static class JMat
|
||||
{
|
||||
public static readonly int NOISE_TEX = Shader.PropertyToID("_NoiseTex");
|
||||
public static readonly int CLOUD_TEX = Shader.PropertyToID("_CloudTex");
|
||||
|
||||
public static readonly int SKY_COLOR = Shader.PropertyToID("_SkyColor");
|
||||
public static readonly int HORIZON_COLOR = Shader.PropertyToID("_HorizonColor");
|
||||
public static readonly int GROUND_COLOR = Shader.PropertyToID("_GroundColor");
|
||||
public static readonly int HORIZON_THICKNESS = Shader.PropertyToID("_HorizonThickness");
|
||||
public static readonly int HORIZON_EXPONENT = Shader.PropertyToID("_HorizonExponent");
|
||||
public static readonly int HORIZON_STEP = Shader.PropertyToID("_HorizonStep");
|
||||
public static readonly int FOG_COLOR = Shader.PropertyToID("_FogColor");
|
||||
|
||||
public static readonly string KW_STARS = "STARS";
|
||||
public static readonly string KW_STARS_LAYER_0 = "STARS_LAYER_0";
|
||||
public static readonly string KW_STARS_LAYER_1 = "STARS_LAYER_1";
|
||||
public static readonly string KW_STARS_LAYER_2 = "STARS_LAYER_2";
|
||||
public static readonly int STARS_START = Shader.PropertyToID("_StarsStartPosition");
|
||||
public static readonly int STARS_END = Shader.PropertyToID("_StarsEndPosition");
|
||||
public static readonly int STARS_OPACITY = Shader.PropertyToID("_StarsOpacity");
|
||||
public static readonly int STARS_COLOR_0 = Shader.PropertyToID("_StarsColor0");
|
||||
public static readonly int STARS_COLOR_1 = Shader.PropertyToID("_StarsColor1");
|
||||
public static readonly int STARS_COLOR_2 = Shader.PropertyToID("_StarsColor2");
|
||||
public static readonly int STARS_DENSITY_0 = Shader.PropertyToID("_StarsDensity0");
|
||||
public static readonly int STARS_DENSITY_1 = Shader.PropertyToID("_StarsDensity1");
|
||||
public static readonly int STARS_DENSITY_2 = Shader.PropertyToID("_StarsDensity2");
|
||||
public static readonly int STARS_SIZE_0 = Shader.PropertyToID("_StarsSize0");
|
||||
public static readonly int STARS_SIZE_1 = Shader.PropertyToID("_StarsSize1");
|
||||
public static readonly int STARS_SIZE_2 = Shader.PropertyToID("_StarsSize2");
|
||||
public static readonly int STARS_GLOW_0 = Shader.PropertyToID("_StarsGlow0");
|
||||
public static readonly int STARS_GLOW_1 = Shader.PropertyToID("_StarsGlow1");
|
||||
public static readonly int STARS_GLOW_2 = Shader.PropertyToID("_StarsGlow2");
|
||||
public static readonly int STARS_TWINKLE_0 = Shader.PropertyToID("_StarsTwinkle0");
|
||||
public static readonly int STARS_TWINKLE_1 = Shader.PropertyToID("_StarsTwinkle1");
|
||||
public static readonly int STARS_TWINKLE_2 = Shader.PropertyToID("_StarsTwinkle2");
|
||||
|
||||
public static readonly string KW_STARS_BAKED = "STARS_BAKED";
|
||||
public static readonly int STARS_CUBEMAP = Shader.PropertyToID("_StarsCubemap");
|
||||
public static readonly int STARS_TWINKLE_MAP = Shader.PropertyToID("_StarsTwinkleMap");
|
||||
|
||||
public static readonly string KW_SUN = "SUN";
|
||||
public static readonly string KW_SUN_USE_TEXTURE = "SUN_USE_TEXTURE";
|
||||
public static readonly int SUN_TEX = Shader.PropertyToID("_SunTex");
|
||||
public static readonly int SUN_COLOR = Shader.PropertyToID("_SunColor");
|
||||
public static readonly int SUN_SIZE = Shader.PropertyToID("_SunSize");
|
||||
public static readonly int SUN_SOFT_EDGE = Shader.PropertyToID("_SunSoftEdge");
|
||||
public static readonly int SUN_GLOW = Shader.PropertyToID("_SunGlow");
|
||||
public static readonly int SUN_DIRECTION = Shader.PropertyToID("_SunDirection");
|
||||
public static readonly int SUN_TRANSFORM_MATRIX = Shader.PropertyToID("_PositionToSunUV");
|
||||
public static readonly int SUN_LIGHT_COLOR = Shader.PropertyToID("_SunLightColor");
|
||||
public static readonly int SUN_LIGHT_INTENSITY = Shader.PropertyToID("_SunLightIntensity");
|
||||
|
||||
public static readonly string KW_SUN_BAKED = "SUN_BAKED";
|
||||
public static readonly int SUN_CUBEMAP = Shader.PropertyToID("_SunCubemap");
|
||||
public static readonly int SUN_ROTATION_MATRIX = Shader.PropertyToID("_SunRotationMatrix");
|
||||
|
||||
public static readonly string KW_MOON = "MOON";
|
||||
public static readonly string KW_MOON_USE_TEXTURE = "MOON_USE_TEXTURE";
|
||||
public static readonly int MOON_TEX = Shader.PropertyToID("_MoonTex");
|
||||
public static readonly int MOON_COLOR = Shader.PropertyToID("_MoonColor");
|
||||
public static readonly int MOON_SIZE = Shader.PropertyToID("_MoonSize");
|
||||
public static readonly int MOON_SOFT_EDGE = Shader.PropertyToID("_MoonSoftEdge");
|
||||
public static readonly int MOON_GLOW = Shader.PropertyToID("_MoonGlow");
|
||||
public static readonly int MOON_DIRECTION = Shader.PropertyToID("_MoonDirection");
|
||||
public static readonly int MOON_TRANSFORM_MATRIX = Shader.PropertyToID("_PositionToMoonUV");
|
||||
public static readonly int MOON_LIGHT_COLOR = Shader.PropertyToID("_MoonLightColor");
|
||||
public static readonly int MOON_LIGHT_INTENSITY = Shader.PropertyToID("_MoonLightIntensity");
|
||||
|
||||
public static readonly string KW_MOON_BAKED = "MOON_BAKED";
|
||||
public static readonly int MOON_CUBEMAP = Shader.PropertyToID("_MoonCubemap");
|
||||
public static readonly int MOON_ROTATION_MATRIX = Shader.PropertyToID("_MoonRotationMatrix");
|
||||
|
||||
public static readonly string KW_HORIZON_CLOUD = "HORIZON_CLOUD";
|
||||
public static readonly int HORIZON_CLOUD_COLOR = Shader.PropertyToID("_HorizonCloudColor");
|
||||
public static readonly int HORIZON_CLOUD_START = Shader.PropertyToID("_HorizonCloudStartPosition");
|
||||
public static readonly int HORIZON_CLOUD_END = Shader.PropertyToID("_HorizonCloudEndPosition");
|
||||
public static readonly int HORIZON_CLOUD_SIZE = Shader.PropertyToID("_HorizonCloudSize");
|
||||
public static readonly int HORIZON_CLOUD_STEP = Shader.PropertyToID("_HorizonCloudStep");
|
||||
public static readonly int HORIZON_CLOUD_ANIMATION_SPEED = Shader.PropertyToID("_HorizonCloudAnimationSpeed");
|
||||
|
||||
public static readonly string KW_OVERHEAD_CLOUD = "OVERHEAD_CLOUD";
|
||||
public static readonly int OVERHEAD_CLOUD_COLOR = Shader.PropertyToID("_OverheadCloudColor");
|
||||
public static readonly int OVERHEAD_CLOUD_ALTITUDE = Shader.PropertyToID("_OverheadCloudAltitude");
|
||||
public static readonly int OVERHEAD_CLOUD_SIZE = Shader.PropertyToID("_OverheadCloudSize");
|
||||
public static readonly int OVERHEAD_CLOUD_STEP = Shader.PropertyToID("_OverheadCloudStep");
|
||||
public static readonly int OVERHEAD_CLOUD_ANIMATION_SPEED = Shader.PropertyToID("_OverheadCloudAnimationSpeed");
|
||||
public static readonly int OVERHEAD_CLOUD_FLOW_X = Shader.PropertyToID("_OverheadCloudFlowDirectionX");
|
||||
public static readonly int OVERHEAD_CLOUD_FLOW_Z = Shader.PropertyToID("_OverheadCloudFlowDirectionZ");
|
||||
public static readonly int OVERHEAD_CLOUD_REMAP_MIN = Shader.PropertyToID("_OverheadCloudRemapMin");
|
||||
public static readonly int OVERHEAD_CLOUD_REMAP_MAX = Shader.PropertyToID("_OverheadCloudRemapMax");
|
||||
public static readonly int OVERHEAD_CLOUD_SHADOW_CLIP_MASK = Shader.PropertyToID("_OverheadCloudShadowClipMask");
|
||||
|
||||
public static readonly string KW_DETAIL_OVERLAY = "DETAIL_OVERLAY";
|
||||
public static readonly string KW_DETAIL_OVERLAY_ROTATION = "DETAIL_OVERLAY_ROTATION";
|
||||
public static readonly int DETAIL_OVERLAY_COLOR = Shader.PropertyToID("_DetailOverlayTintColor");
|
||||
public static readonly int DETAIL_OVERLAY_CUBEMAP = Shader.PropertyToID("_DetailOverlayCubemap");
|
||||
public static readonly int DETAIL_OVERLAY_LAYER = Shader.PropertyToID("_DetailOverlayLayer");
|
||||
public static readonly int DETAIL_OVERLAY_ROTATION_SPEED = Shader.PropertyToID("_DetailOverlayRotationSpeed");
|
||||
|
||||
public static readonly string KW_ALLOW_STEP_EFFECT = "ALLOW_STEP_EFFECT";
|
||||
|
||||
private static Material activeMaterial;
|
||||
|
||||
public static void SetActiveMaterial(Material mat)
|
||||
{
|
||||
activeMaterial = mat;
|
||||
}
|
||||
|
||||
public static void GetColor(int prop, ref Color value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (activeMaterial.HasProperty(prop))
|
||||
{
|
||||
value = activeMaterial.GetColor(prop);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException nullEx)
|
||||
{
|
||||
Debug.LogError(nullEx.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void GetFloat(int prop, ref float value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (activeMaterial.HasProperty(prop))
|
||||
{
|
||||
value = activeMaterial.GetFloat(prop);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException nullEx)
|
||||
{
|
||||
Debug.LogError(nullEx.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void GetVector(int prop, ref Vector4 value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (activeMaterial.HasProperty(prop))
|
||||
{
|
||||
value = activeMaterial.GetVector(prop);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException nullEx)
|
||||
{
|
||||
Debug.LogError(nullEx.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void GetTexture(int prop, ref Texture value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (activeMaterial.HasProperty(prop))
|
||||
{
|
||||
value = activeMaterial.GetTexture(prop);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException nullEx)
|
||||
{
|
||||
Debug.LogError(nullEx.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void GetKeywordEnabled(string kw, ref bool value)
|
||||
{
|
||||
try
|
||||
{
|
||||
value = activeMaterial.IsKeywordEnabled(kw);
|
||||
}
|
||||
catch (NullReferenceException nullEx)
|
||||
{
|
||||
Debug.LogError(nullEx.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void SetColor(int prop, Color value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (activeMaterial.HasProperty(prop))
|
||||
{
|
||||
activeMaterial.SetColor(prop, value);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException nullEx)
|
||||
{
|
||||
Debug.LogError(nullEx.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void SetFloat(int prop, float value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (activeMaterial.HasProperty(prop))
|
||||
{
|
||||
activeMaterial.SetFloat(prop, value);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException nullEx)
|
||||
{
|
||||
Debug.LogError(nullEx.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void SetVector(int prop, Vector4 value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (activeMaterial.HasProperty(prop))
|
||||
{
|
||||
activeMaterial.SetVector(prop, value);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException nullEx)
|
||||
{
|
||||
Debug.LogError(nullEx.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void SetTexture(int prop, Texture value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (activeMaterial.HasProperty(prop))
|
||||
{
|
||||
activeMaterial.SetTexture(prop, value);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException nullEx)
|
||||
{
|
||||
Debug.LogError(nullEx.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void SetMatrix(int prop, Matrix4x4 value)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (activeMaterial.HasProperty(prop))
|
||||
{
|
||||
activeMaterial.SetMatrix(prop, value);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException nullEx)
|
||||
{
|
||||
Debug.LogError(nullEx.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void SetKeywordEnable(string kw, bool enable)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
activeMaterial.EnableKeyword(kw);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeMaterial.DisableKeyword(kw);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException nullEx)
|
||||
{
|
||||
Debug.LogError(nullEx.ToString());
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public static void SetOverrideTag(string tag, string value)
|
||||
{
|
||||
activeMaterial.SetOverrideTag(tag, value);
|
||||
}
|
||||
|
||||
public static void SetRenderQueue(int queue)
|
||||
{
|
||||
activeMaterial.renderQueue = queue;
|
||||
}
|
||||
|
||||
public static void SetRenderQueue(RenderQueue queue)
|
||||
{
|
||||
activeMaterial.renderQueue = (int)queue;
|
||||
}
|
||||
|
||||
public static void SetSourceBlend(BlendMode mode)
|
||||
{
|
||||
activeMaterial.SetInt("_SrcBlend", (int)mode);
|
||||
}
|
||||
|
||||
public static void SetDestBlend(BlendMode mode)
|
||||
{
|
||||
activeMaterial.SetInt("_DstBlend", (int)mode);
|
||||
}
|
||||
|
||||
public static void SetZWrite(bool value)
|
||||
{
|
||||
activeMaterial.SetInt("_ZWrite", value ? 1 : 0);
|
||||
}
|
||||
|
||||
public static void SetBlend(bool value)
|
||||
{
|
||||
activeMaterial.SetInt("_Blend", value ? 1 : 0);
|
||||
}
|
||||
|
||||
public static void SetShader(Shader shader)
|
||||
{
|
||||
activeMaterial.shader = shader;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,261 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class JSky : MonoBehaviour
|
||||
{
|
||||
public static readonly Vector3 DefaultSunDirection = Vector3.forward;
|
||||
public static readonly Vector3 DefaultMoonDirection = Vector3.forward;
|
||||
|
||||
[SerializeField]
|
||||
private JSkyProfile profile;
|
||||
public JSkyProfile Profile
|
||||
{
|
||||
get
|
||||
{
|
||||
return profile;
|
||||
}
|
||||
set
|
||||
{
|
||||
profile = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Light sunLightSource;
|
||||
public Light SunLightSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return sunLightSource;
|
||||
}
|
||||
set
|
||||
{
|
||||
Light src = value;
|
||||
if (src != null && src.type == LightType.Directional)
|
||||
{
|
||||
sunLightSource = src;
|
||||
}
|
||||
else
|
||||
{
|
||||
sunLightSource = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Light moonLightSource;
|
||||
public Light MoonLightSource
|
||||
{
|
||||
get
|
||||
{
|
||||
return moonLightSource;
|
||||
}
|
||||
set
|
||||
{
|
||||
Light src = value;
|
||||
if (src != null && src.type == LightType.Directional)
|
||||
{
|
||||
moonLightSource = src;
|
||||
}
|
||||
else
|
||||
{
|
||||
moonLightSource = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JDayNightCycle DNC { get; set; }
|
||||
|
||||
private static Mesh sphereMesh;
|
||||
private static Mesh SphereMesh
|
||||
{
|
||||
get
|
||||
{
|
||||
if (sphereMesh == null)
|
||||
{
|
||||
sphereMesh = Resources.GetBuiltinResource<Mesh>("Sphere.fbx");
|
||||
}
|
||||
return sphereMesh;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
Camera.onPreCull += OnCameraPreCull;
|
||||
RenderPipelineManager.beginCameraRendering += OnBeginCameraRenderingSRP;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Camera.onPreCull -= OnCameraPreCull;
|
||||
RenderPipelineManager.beginCameraRendering -= OnBeginCameraRenderingSRP;
|
||||
RenderSettings.skybox = JJupiterSettings.Instance.DefaultSkybox;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
RenderSettings.skybox = JJupiterSettings.Instance.DefaultSkybox;
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
Light[] lights = FindObjectsOfType<Light>();
|
||||
for (int i = 0; i < lights.Length; ++i)
|
||||
{
|
||||
if (lights[i].type == LightType.Directional)
|
||||
{
|
||||
SunLightSource = lights[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCameraPreCull(Camera cam)
|
||||
{
|
||||
SetupSkyMaterial();
|
||||
SyncFog();
|
||||
RenderShadow(cam);
|
||||
}
|
||||
|
||||
private void OnBeginCameraRenderingSRP(ScriptableRenderContext context, Camera cam)
|
||||
{
|
||||
OnCameraPreCull(cam);
|
||||
}
|
||||
|
||||
private void SetupSkyMaterial()
|
||||
{
|
||||
if (Profile == null)
|
||||
{
|
||||
RenderSettings.skybox = JJupiterSettings.Instance.DefaultSkybox;
|
||||
return;
|
||||
}
|
||||
RenderSettings.skybox = Profile.Material;
|
||||
|
||||
Profile.Material.SetTexture(JMat.NOISE_TEX, JJupiterSettings.Instance.NoiseTexture);
|
||||
Profile.Material.SetTexture(JMat.CLOUD_TEX, Profile.CustomCloudTexture ? Profile.CustomCloudTexture : JJupiterSettings.Instance.CloudTexture);
|
||||
|
||||
if (Profile.EnableSun)
|
||||
{
|
||||
if (SunLightSource != null)
|
||||
{
|
||||
JDayNightCycleProfile dncProfile = DNC ? DNC.Profile : null;
|
||||
bool isSunLightColorOverridden = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.SunLightColor));
|
||||
if (!isSunLightColorOverridden)
|
||||
{
|
||||
SunLightSource.color = Profile.SunLightColor;
|
||||
}
|
||||
bool isSunLightIntensityOverridden = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.SunLightIntensity));
|
||||
if (!isSunLightIntensityOverridden)
|
||||
{
|
||||
SunLightSource.intensity = Profile.SunLightIntensity;
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 sunDirection = SunLightSource ? SunLightSource.transform.forward : DefaultSunDirection;
|
||||
if (Profile.UseBakedSun)
|
||||
{
|
||||
Matrix4x4 sunRotationMatrix = Matrix4x4.Rotate(
|
||||
Quaternion.FromToRotation(sunDirection, DefaultSunDirection));
|
||||
Profile.Material.SetMatrix(JMat.SUN_ROTATION_MATRIX, sunRotationMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
Matrix4x4 positionToSunUV = Matrix4x4.TRS(
|
||||
-sunDirection,
|
||||
Quaternion.LookRotation(sunDirection),
|
||||
Profile.SunSize * Vector3.one).inverse;
|
||||
Profile.Material.SetVector(JMat.SUN_DIRECTION, sunDirection);
|
||||
Profile.Material.SetMatrix(JMat.SUN_TRANSFORM_MATRIX, positionToSunUV);
|
||||
}
|
||||
}
|
||||
|
||||
if (Profile.EnableMoon)
|
||||
{
|
||||
if (MoonLightSource != null)
|
||||
{
|
||||
JDayNightCycleProfile dncProfile = DNC ? DNC.Profile : null;
|
||||
bool isMoonLightColorOverridden = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.MoonLightColor));
|
||||
if (!isMoonLightColorOverridden)
|
||||
{
|
||||
MoonLightSource.color = Profile.MoonLightColor;
|
||||
}
|
||||
bool isMoonLightIntensityOverridden = dncProfile != null && dncProfile.ContainProperty(nameof(Profile.MoonLightIntensity));
|
||||
if (!isMoonLightIntensityOverridden)
|
||||
{
|
||||
MoonLightSource.intensity = Profile.MoonLightIntensity;
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 moonDirection = MoonLightSource ? MoonLightSource.transform.forward : DefaultMoonDirection;
|
||||
if (Profile.UseBakedMoon)
|
||||
{
|
||||
Matrix4x4 moonRotationMatrix = Matrix4x4.Rotate(
|
||||
Quaternion.FromToRotation(moonDirection, DefaultMoonDirection));
|
||||
Profile.Material.SetMatrix(JMat.MOON_ROTATION_MATRIX, moonRotationMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
Matrix4x4 positionToMoonUV = Matrix4x4.TRS(
|
||||
-moonDirection,
|
||||
Quaternion.LookRotation(moonDirection),
|
||||
Profile.MoonSize * Vector3.one).inverse;
|
||||
Profile.Material.SetVector(JMat.MOON_DIRECTION, moonDirection);
|
||||
Profile.Material.SetMatrix(JMat.MOON_TRANSFORM_MATRIX, positionToMoonUV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SyncFog()
|
||||
{
|
||||
if (Profile == null)
|
||||
return;
|
||||
if (Profile.FogSyncOption == JFogSyncOption.DontSync)
|
||||
return;
|
||||
if (Profile.FogSyncOption == JFogSyncOption.SkyColor)
|
||||
{
|
||||
RenderSettings.fogColor = Profile.Material.GetColor(JMat.SKY_COLOR);
|
||||
}
|
||||
else if (Profile.FogSyncOption == JFogSyncOption.HorizonColor)
|
||||
{
|
||||
RenderSettings.fogColor = Profile.Material.GetColor(JMat.HORIZON_COLOR);
|
||||
}
|
||||
else if (Profile.FogSyncOption == JFogSyncOption.GroundColor)
|
||||
{
|
||||
RenderSettings.fogColor = Profile.Material.GetColor(JMat.GROUND_COLOR);
|
||||
}
|
||||
else if (Profile.FogSyncOption == JFogSyncOption.CustomColor)
|
||||
{
|
||||
RenderSettings.fogColor = Profile.Material.GetColor(JMat.FOG_COLOR);
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderShadow(Camera cam)
|
||||
{
|
||||
if (Profile == null)
|
||||
return;
|
||||
if (Profile.EnableOverheadCloud && Profile.OverheadCloudCastShadow)
|
||||
{
|
||||
Profile.ShadowMaterial.SetTexture(JMat.NOISE_TEX, JJupiterSettings.Instance.NoiseTexture);
|
||||
Profile.ShadowMaterial.SetTexture(JMat.CLOUD_TEX, Profile.CustomCloudTexture ? Profile.CustomCloudTexture : JJupiterSettings.Instance.CloudTexture);
|
||||
Graphics.DrawMesh(
|
||||
SphereMesh,
|
||||
Matrix4x4.TRS(Vector3.zero, Quaternion.identity, 2 * Vector3.one * Profile.OverheadCloudAltitude),
|
||||
Profile.ShadowMaterial,
|
||||
0,
|
||||
cam,
|
||||
0,
|
||||
null,
|
||||
ShadowCastingMode.ShadowsOnly,
|
||||
false,
|
||||
null,
|
||||
LightProbeUsage.Off,
|
||||
null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class JAnimatableAttribute : Attribute
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public JCurveOrGradient CurveOrGradient { get; set; }
|
||||
|
||||
public JAnimatableAttribute(string displayName, JCurveOrGradient curveOrGradient)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
CurveOrGradient = curveOrGradient;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
[System.Serializable]
|
||||
public class JAnimatedProperty
|
||||
{
|
||||
[SerializeField]
|
||||
private string name;
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
name = string.Empty;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private string displayName;
|
||||
public string DisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (displayName == null)
|
||||
{
|
||||
displayName = string.Empty;
|
||||
}
|
||||
return displayName;
|
||||
}
|
||||
set
|
||||
{
|
||||
displayName = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private JCurveOrGradient curveOrGradient;
|
||||
public JCurveOrGradient CurveOrGradient
|
||||
{
|
||||
get
|
||||
{
|
||||
return curveOrGradient;
|
||||
}
|
||||
set
|
||||
{
|
||||
curveOrGradient = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private AnimationCurve curve;
|
||||
public AnimationCurve Curve
|
||||
{
|
||||
get
|
||||
{
|
||||
if (curve == null)
|
||||
{
|
||||
curve = AnimationCurve.EaseInOut(0, 0, 1, 0);
|
||||
}
|
||||
return curve;
|
||||
}
|
||||
set
|
||||
{
|
||||
curve = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Gradient gradient;
|
||||
public Gradient Gradient
|
||||
{
|
||||
get
|
||||
{
|
||||
if (gradient == null)
|
||||
{
|
||||
gradient = JUtilities.CreateFullWhiteGradient();
|
||||
}
|
||||
return gradient;
|
||||
}
|
||||
set
|
||||
{
|
||||
gradient = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float EvaluateFloat(float t)
|
||||
{
|
||||
return Curve.Evaluate(t);
|
||||
}
|
||||
|
||||
public Color EvaluateColor(float t)
|
||||
{
|
||||
return Gradient.Evaluate(t);
|
||||
}
|
||||
|
||||
public static JAnimatedProperty Create(string name, string displayName, JCurveOrGradient curveOrGradient)
|
||||
{
|
||||
JAnimatedProperty props = new JAnimatedProperty();
|
||||
props.name = name;
|
||||
props.displayName = displayName;
|
||||
props.curveOrGradient = curveOrGradient;
|
||||
return props;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
public enum JCurveOrGradient
|
||||
{
|
||||
Curve, Gradient
|
||||
}
|
||||
}
|
@@ -0,0 +1,372 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Rendering;
|
||||
using System;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
public class JDayNightCycle : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private JDayNightCycleProfile profile;
|
||||
public JDayNightCycleProfile Profile
|
||||
{
|
||||
get
|
||||
{
|
||||
return profile;
|
||||
}
|
||||
set
|
||||
{
|
||||
profile = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private JSky sky;
|
||||
public JSky Sky
|
||||
{
|
||||
get
|
||||
{
|
||||
return sky;
|
||||
}
|
||||
set
|
||||
{
|
||||
sky = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private bool useSunPivot;
|
||||
public bool UseSunPivot
|
||||
{
|
||||
get
|
||||
{
|
||||
return useSunPivot;
|
||||
}
|
||||
set
|
||||
{
|
||||
useSunPivot = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Transform sunOrbitPivot;
|
||||
public Transform SunOrbitPivot
|
||||
{
|
||||
get
|
||||
{
|
||||
return sunOrbitPivot;
|
||||
}
|
||||
set
|
||||
{
|
||||
sunOrbitPivot = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private bool useMoonPivot;
|
||||
public bool UseMoonPivot
|
||||
{
|
||||
get
|
||||
{
|
||||
return useMoonPivot;
|
||||
}
|
||||
set
|
||||
{
|
||||
useMoonPivot = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Transform moonOrbitPivot;
|
||||
public Transform MoonOrbitPivot
|
||||
{
|
||||
get
|
||||
{
|
||||
return moonOrbitPivot;
|
||||
}
|
||||
set
|
||||
{
|
||||
moonOrbitPivot = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private float startTime;
|
||||
public float StartTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
startTime = Mathf.Clamp(value, 0f, 24f);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private float timeIncrement;
|
||||
public float TimeIncrement
|
||||
{
|
||||
get
|
||||
{
|
||||
return timeIncrement;
|
||||
}
|
||||
set
|
||||
{
|
||||
timeIncrement = Mathf.Max(0, value);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private bool autoTimeIncrement;
|
||||
public bool AutoTimeIncrement
|
||||
{
|
||||
get
|
||||
{
|
||||
return autoTimeIncrement;
|
||||
}
|
||||
set
|
||||
{
|
||||
autoTimeIncrement = value;
|
||||
}
|
||||
}
|
||||
|
||||
private float time;
|
||||
public float Time
|
||||
{
|
||||
get
|
||||
{
|
||||
return time % 24f;
|
||||
}
|
||||
set
|
||||
{
|
||||
time = value % 24f;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private bool shouldUpdateEnvironmentReflection;
|
||||
public bool ShouldUpdateEnvironmentReflection
|
||||
{
|
||||
get
|
||||
{
|
||||
return shouldUpdateEnvironmentReflection;
|
||||
}
|
||||
set
|
||||
{
|
||||
shouldUpdateEnvironmentReflection = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private int environmentReflectionResolution;
|
||||
public int EnvironmentReflectionResolution
|
||||
{
|
||||
get
|
||||
{
|
||||
return environmentReflectionResolution;
|
||||
}
|
||||
set
|
||||
{
|
||||
int oldValue = environmentReflectionResolution;
|
||||
int newValue = Mathf.Clamp(value, 16, 2048);
|
||||
environmentReflectionResolution = newValue;
|
||||
if (oldValue != newValue)
|
||||
{
|
||||
if (environmentReflection != null)
|
||||
{
|
||||
JUtilities.DestroyObject(environmentReflection);
|
||||
}
|
||||
if (environmentProbe != null)
|
||||
{
|
||||
JUtilities.DestroyGameobject(environmentProbe.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private ReflectionProbeTimeSlicingMode environmentReflectionTimeSlicingMode;
|
||||
public ReflectionProbeTimeSlicingMode EnvironmentReflectionTimeSlicingMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return environmentReflectionTimeSlicingMode;
|
||||
}
|
||||
set
|
||||
{
|
||||
environmentReflectionTimeSlicingMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private ReflectionProbe environmentProbe;
|
||||
private ReflectionProbe EnvironmentProbe
|
||||
{
|
||||
get
|
||||
{
|
||||
if (environmentProbe == null)
|
||||
{
|
||||
GameObject probeGO = new GameObject("~EnvironmentReflectionRenderer");
|
||||
probeGO.transform.parent = transform;
|
||||
probeGO.transform.position = new Vector3(0, -1000, 0);
|
||||
probeGO.transform.rotation = Quaternion.identity;
|
||||
probeGO.transform.localScale = Vector3.one;
|
||||
probeGO.hideFlags = HideFlags.DontSave;
|
||||
|
||||
environmentProbe = probeGO.AddComponent<ReflectionProbe>();
|
||||
environmentProbe.resolution = EnvironmentReflectionResolution;
|
||||
environmentProbe.size = new Vector3(1, 1, 1);
|
||||
environmentProbe.cullingMask = 0;
|
||||
}
|
||||
environmentProbe.clearFlags = ReflectionProbeClearFlags.Skybox;
|
||||
environmentProbe.mode = ReflectionProbeMode.Realtime;
|
||||
environmentProbe.refreshMode = ReflectionProbeRefreshMode.ViaScripting;
|
||||
environmentProbe.timeSlicingMode = EnvironmentReflectionTimeSlicingMode;
|
||||
environmentProbe.hdr = false;
|
||||
|
||||
return environmentProbe;
|
||||
}
|
||||
}
|
||||
|
||||
private Cubemap environmentReflection;
|
||||
private Cubemap EnvironmentReflection
|
||||
{
|
||||
get
|
||||
{
|
||||
if (environmentReflection == null)
|
||||
{
|
||||
environmentReflection = new Cubemap(EnvironmentProbe.resolution, TextureFormat.RGBA32, true);
|
||||
}
|
||||
return environmentReflection;
|
||||
}
|
||||
}
|
||||
|
||||
private int probeRenderId = -1;
|
||||
|
||||
private float DeltaTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
return UnityEngine.Time.deltaTime;
|
||||
else
|
||||
return 1.0f / 60f;
|
||||
}
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
Sky = GetComponent<JSky>();
|
||||
StartTime = 0;
|
||||
TimeIncrement = 1;
|
||||
AutoTimeIncrement = true;
|
||||
Time = 0;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
time = StartTime;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
CleanUp();
|
||||
}
|
||||
private void CleanUp()
|
||||
{
|
||||
if (environmentProbe != null)
|
||||
{
|
||||
JUtilities.DestroyGameobject(environmentProbe.gameObject);
|
||||
}
|
||||
if (environmentReflection != null)
|
||||
{
|
||||
JUtilities.DestroyObject(environmentReflection);
|
||||
}
|
||||
if (Sky != null)
|
||||
{
|
||||
Sky.DNC = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
AnimateSky();
|
||||
if (ShouldUpdateEnvironmentReflection)
|
||||
{
|
||||
UpdateEnvironmentReflection();
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderSettings.defaultReflectionMode = DefaultReflectionMode.Skybox;
|
||||
}
|
||||
}
|
||||
|
||||
private void AnimateSky()
|
||||
{
|
||||
if (Profile == null)
|
||||
return;
|
||||
if (Sky == null)
|
||||
return;
|
||||
if (Sky.Profile == null)
|
||||
return;
|
||||
Sky.DNC = this;
|
||||
if (AutoTimeIncrement)
|
||||
{
|
||||
Time += TimeIncrement * DeltaTime;
|
||||
}
|
||||
float evalTime = Mathf.InverseLerp(0f, 24f, Time);
|
||||
Profile.Animate(Sky, evalTime);
|
||||
|
||||
if (Sky.Profile.EnableSun && Sky.SunLightSource != null)
|
||||
{
|
||||
float angle = evalTime * 360f;
|
||||
Matrix4x4 localRotationMatrix = Matrix4x4.Rotate(Quaternion.Euler(angle, 0, 0));
|
||||
Vector3 localDirection = localRotationMatrix.MultiplyVector(Vector3.up);
|
||||
|
||||
Transform pivot = (UseSunPivot && SunOrbitPivot != null) ? SunOrbitPivot : transform;
|
||||
Matrix4x4 localToWorld = pivot.localToWorldMatrix;
|
||||
Vector3 worldDirection = localToWorld.MultiplyVector(localDirection);
|
||||
Sky.SunLightSource.transform.forward = worldDirection;
|
||||
Sky.SunLightSource.color = Sky.Profile.Material.GetColor(JMat.SUN_LIGHT_COLOR);
|
||||
Sky.SunLightSource.intensity = Sky.Profile.Material.GetFloat(JMat.SUN_LIGHT_INTENSITY);
|
||||
}
|
||||
|
||||
if (Sky.Profile.EnableMoon && Sky.MoonLightSource != null)
|
||||
{
|
||||
float angle = evalTime * 360f;
|
||||
Matrix4x4 localRotationMatrix = Matrix4x4.Rotate(Quaternion.Euler(angle, 0, 0));
|
||||
Vector3 localDirection = localRotationMatrix.MultiplyVector(Vector3.down);
|
||||
|
||||
Transform pivot = (UseMoonPivot && MoonOrbitPivot != null) ? MoonOrbitPivot : transform;
|
||||
Matrix4x4 localToWorld = pivot.localToWorldMatrix;
|
||||
Vector3 worldDirection = localToWorld.MultiplyVector(localDirection);
|
||||
Sky.MoonLightSource.transform.forward = worldDirection;
|
||||
Sky.MoonLightSource.color = Sky.Profile.Material.GetColor(JMat.MOON_LIGHT_COLOR);
|
||||
Sky.MoonLightSource.intensity = Sky.Profile.Material.GetFloat(JMat.MOON_LIGHT_INTENSITY);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEnvironmentReflection()
|
||||
{
|
||||
if ((SystemInfo.copyTextureSupport & CopyTextureSupport.RTToTexture) != 0)
|
||||
{
|
||||
if (EnvironmentProbe.texture == null)
|
||||
{
|
||||
probeRenderId = EnvironmentProbe.RenderProbe();
|
||||
}
|
||||
else if (EnvironmentProbe.texture != null || EnvironmentProbe.IsFinishedRendering(probeRenderId))
|
||||
{
|
||||
Graphics.CopyTexture(EnvironmentProbe.texture, EnvironmentReflection as Texture);
|
||||
RenderSettings.customReflection = EnvironmentReflection;
|
||||
RenderSettings.defaultReflectionMode = DefaultReflectionMode.Custom;
|
||||
probeRenderId = EnvironmentProbe.RenderProbe();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,130 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.InitializeOnLoad]
|
||||
#endif
|
||||
[CreateAssetMenu(menuName = "Jupiter/Day Night Cycle Profile")]
|
||||
public class JDayNightCycleProfile : ScriptableObject
|
||||
{
|
||||
private static Dictionary<string, int> propertyRemap;
|
||||
private static Dictionary<string, int> PropertyRemap
|
||||
{
|
||||
get
|
||||
{
|
||||
if (propertyRemap == null)
|
||||
{
|
||||
propertyRemap = new Dictionary<string, int>();
|
||||
}
|
||||
return propertyRemap;
|
||||
}
|
||||
set
|
||||
{
|
||||
propertyRemap = value;
|
||||
}
|
||||
}
|
||||
|
||||
static JDayNightCycleProfile()
|
||||
{
|
||||
InitPropertyRemap();
|
||||
}
|
||||
|
||||
private static void InitPropertyRemap()
|
||||
{
|
||||
PropertyRemap.Clear();
|
||||
Type type = typeof(JSkyProfile);
|
||||
PropertyInfo[] props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
||||
foreach (PropertyInfo p in props)
|
||||
{
|
||||
JAnimatableAttribute animatable = p.GetCustomAttribute(typeof(JAnimatableAttribute), false) as JAnimatableAttribute;
|
||||
if (animatable == null)
|
||||
continue;
|
||||
string name = p.Name;
|
||||
int id = Shader.PropertyToID("_" + name);
|
||||
PropertyRemap.Add(name, id);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private List<JAnimatedProperty> animatedProperties;
|
||||
public List<JAnimatedProperty> AnimatedProperties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (animatedProperties == null)
|
||||
{
|
||||
animatedProperties = new List<JAnimatedProperty>();
|
||||
}
|
||||
return animatedProperties;
|
||||
}
|
||||
set
|
||||
{
|
||||
animatedProperties = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddProperty(JAnimatedProperty p, bool setDefaultValue = true)
|
||||
{
|
||||
if (setDefaultValue)
|
||||
{
|
||||
JDayNightCycleProfile defaultProfile = JJupiterSettings.Instance.DefaultDayNightCycleProfile;
|
||||
if (defaultProfile != null)
|
||||
{
|
||||
JAnimatedProperty defaultProp = defaultProfile.AnimatedProperties.Find(p0 => p0.Name != null && p0.Name.Equals(p.Name));
|
||||
if (defaultProp != null)
|
||||
{
|
||||
p.Curve = defaultProp.Curve;
|
||||
p.Gradient = defaultProp.Gradient;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AnimatedProperties.Add(p);
|
||||
}
|
||||
|
||||
public void Animate(JSky sky, float t)
|
||||
{
|
||||
CheckDefaultProfileAndThrow(sky.Profile);
|
||||
|
||||
for (int i = 0; i < AnimatedProperties.Count; ++i)
|
||||
{
|
||||
JAnimatedProperty aProp = AnimatedProperties[i];
|
||||
int id = 0;
|
||||
if (!PropertyRemap.TryGetValue(aProp.Name, out id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aProp.CurveOrGradient == JCurveOrGradient.Curve)
|
||||
{
|
||||
sky.Profile.Material.SetFloat(id, aProp.EvaluateFloat(t));
|
||||
}
|
||||
else
|
||||
{
|
||||
sky.Profile.Material.SetColor(id, aProp.EvaluateColor(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckDefaultProfileAndThrow(JSkyProfile p)
|
||||
{
|
||||
if (p == null)
|
||||
return;
|
||||
if (p == JJupiterSettings.Instance.DefaultProfileSunnyDay ||
|
||||
p == JJupiterSettings.Instance.DefaultProfileStarryNight)
|
||||
{
|
||||
throw new ArgumentException("Animating default sky profile is prohibited. You must create a new profile for your sky to animate it.");
|
||||
}
|
||||
}
|
||||
|
||||
public bool ContainProperty(string propertyName)
|
||||
{
|
||||
return AnimatedProperties.Exists((p) => p.Name.Equals(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
public static class JCubemapRenderer
|
||||
{
|
||||
public static bool Render(JCubemapRendererArgs args)
|
||||
{
|
||||
GameObject go = new GameObject("~CubemapRendererCamera");
|
||||
go.transform.position = args.CameraPosition;
|
||||
|
||||
Camera cam = go.AddComponent<Camera>();
|
||||
cam.clearFlags = args.CameraClearFlag;
|
||||
cam.nearClipPlane = args.CameraNearPlane;
|
||||
cam.farClipPlane = args.CameraFarPlane;
|
||||
cam.backgroundColor = args.CameraBackgroundColor;
|
||||
|
||||
bool result = cam.RenderToCubemap(args.Cubemap, (int)args.Face);
|
||||
JUtilities.DestroyGameobject(go);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
public struct JCubemapRendererArgs
|
||||
{
|
||||
public Cubemap Cubemap { get; set; }
|
||||
|
||||
public Vector3 CameraPosition { get; set; }
|
||||
public float CameraNearPlane { get; set; }
|
||||
public float CameraFarPlane { get; set; }
|
||||
public CameraClearFlags CameraClearFlag { get; set; }
|
||||
public Color CameraBackgroundColor { get; set; }
|
||||
public int Resolution { get; set; }
|
||||
public CubemapFace Face { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false)]
|
||||
public class JDisplayName : Attribute
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public JDisplayName(string name)
|
||||
{
|
||||
DisplayName = name;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
public static class JInternalMaterials
|
||||
{
|
||||
private static Material copyTextureMaterial;
|
||||
public static Material CopyTextureMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (copyTextureMaterial == null)
|
||||
{
|
||||
copyTextureMaterial = new Material(JJupiterSettings.Instance.InternalShaders.CopyTextureShader);
|
||||
}
|
||||
return copyTextureMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
private static Material solidColorMaterial;
|
||||
public static Material SolidColorMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (solidColorMaterial == null)
|
||||
{
|
||||
solidColorMaterial = new Material(JJupiterSettings.Instance.InternalShaders.SolidColorShader);
|
||||
}
|
||||
return solidColorMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
private static Material unlitTextureMaterial;
|
||||
public static Material UnlitTextureMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (unlitTextureMaterial == null)
|
||||
{
|
||||
unlitTextureMaterial = new Material(Shader.Find("Unlit/Texture"));
|
||||
}
|
||||
return unlitTextureMaterial;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
[System.Serializable]
|
||||
public struct JInternalShaderSettings
|
||||
{
|
||||
[SerializeField]
|
||||
private Shader skyShader;
|
||||
public Shader SkyShader
|
||||
{
|
||||
get
|
||||
{
|
||||
return skyShader;
|
||||
}
|
||||
set
|
||||
{
|
||||
skyShader = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Shader skyShadowShader;
|
||||
public Shader SkyShadowShader
|
||||
{
|
||||
get
|
||||
{
|
||||
return skyShadowShader;
|
||||
}
|
||||
set
|
||||
{
|
||||
skyShadowShader = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Shader copyTextureShader;
|
||||
public Shader CopyTextureShader
|
||||
{
|
||||
get
|
||||
{
|
||||
return copyTextureShader;
|
||||
}
|
||||
set
|
||||
{
|
||||
copyTextureShader = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Shader solidColorShader;
|
||||
public Shader SolidColorShader
|
||||
{
|
||||
get
|
||||
{
|
||||
return solidColorShader;
|
||||
}
|
||||
set
|
||||
{
|
||||
solidColorShader = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
public class JProgressCancelledException : Exception
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
public enum JRenderPipelineType
|
||||
{
|
||||
Builtin, Lightweight, Universal
|
||||
}
|
||||
}
|
@@ -0,0 +1,757 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class for helper function
|
||||
/// </summary>
|
||||
public static class JUtilities
|
||||
{
|
||||
public static float DELTA_TIME = 0.0167f;
|
||||
|
||||
private static Mesh quadMesh;
|
||||
public static Mesh QuadMesh
|
||||
{
|
||||
get
|
||||
{
|
||||
if (quadMesh == null)
|
||||
{
|
||||
quadMesh = JUtilities.GetPrimitiveMesh(PrimitiveType.Quad);
|
||||
}
|
||||
return quadMesh;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ListElementsToString<T>(this IEnumerable<T> list, string separator)
|
||||
{
|
||||
IEnumerator<T> i = list.GetEnumerator();
|
||||
System.Text.StringBuilder s = new System.Text.StringBuilder();
|
||||
if (i.MoveNext())
|
||||
s.Append(i.Current.ToString());
|
||||
while (i.MoveNext())
|
||||
s.Append(separator).Append(i.Current.ToString());
|
||||
return s.ToString();
|
||||
}
|
||||
|
||||
public static T[][] CreateJaggedArray<T>(int dimension1, int dimension2)
|
||||
{
|
||||
T[][] jaggedArray = new T[dimension1][];
|
||||
for (int i = 0; i < dimension1; ++i)
|
||||
{
|
||||
jaggedArray[i] = new T[dimension2];
|
||||
}
|
||||
return jaggedArray;
|
||||
}
|
||||
|
||||
public static T[] To1dArray<T>(T[][] jaggedArray)
|
||||
{
|
||||
List<T> result = new List<T>();
|
||||
for (int z = 0; z < jaggedArray.Length; ++z)
|
||||
{
|
||||
for (int x = 0; x < jaggedArray[z].Length; ++x)
|
||||
{
|
||||
result.Add(jaggedArray[z][x]);
|
||||
}
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
public static T[] To1dArray<T>(T[,] grid)
|
||||
{
|
||||
int height = grid.GetLength(0);
|
||||
int width = grid.GetLength(1);
|
||||
T[] result = new T[height * width];
|
||||
for (int z = 0; z < height; ++z)
|
||||
{
|
||||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
result[To1DIndex(x, z, width)] = grid[z, x];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void Fill<T>(T[] array, T value)
|
||||
{
|
||||
for (int i = 0; i < array.Length; ++i)
|
||||
{
|
||||
array[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CopyTo<T>(T[] src, T[] des)
|
||||
{
|
||||
int limit = Mathf.Min(src.Length, des.Length);
|
||||
for (int i = 0; i < limit; ++i)
|
||||
{
|
||||
des[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
public static int Sum(int[,] array)
|
||||
{
|
||||
int sum = 0;
|
||||
int length = array.GetLength(0);
|
||||
int width = array.GetLength(1);
|
||||
for (int z = 0; z < length; ++z)
|
||||
{
|
||||
for (int x = 0; x < width; ++x)
|
||||
{
|
||||
sum += array[z, x];
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
public static int To1DIndex(int x, int z, int width)
|
||||
{
|
||||
return z * width + x;
|
||||
}
|
||||
|
||||
public static bool IsInRange(float number, float minValue, float maxValue)
|
||||
{
|
||||
return number >= minValue && number <= maxValue;
|
||||
}
|
||||
|
||||
public static bool IsInRangeExclusive(float number, float minValue, float maxValue)
|
||||
{
|
||||
return number > minValue && number < maxValue;
|
||||
}
|
||||
|
||||
public static float GetFraction(float value, float floor, float ceil)
|
||||
{
|
||||
return (value - floor) / (ceil - floor);
|
||||
}
|
||||
|
||||
public static void ClearChildren(Transform t)
|
||||
{
|
||||
int childCount = t.childCount;
|
||||
for (int i = childCount - 1; i >= 0; --i)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!UnityEditor.EditorApplication.isPlaying)
|
||||
{
|
||||
GameObject.DestroyImmediate(t.GetChild(i).gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject.Destroy(t.GetChild(i).gameObject);
|
||||
}
|
||||
#else
|
||||
GameObject.Destroy(t.GetChild(i).gameObject);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public static Gradient CreateFullWhiteGradient()
|
||||
{
|
||||
Gradient g = new Gradient();
|
||||
GradientColorKey color = new GradientColorKey(Color.white, 1);
|
||||
GradientAlphaKey alpha = new GradientAlphaKey(1, 1);
|
||||
g.SetKeys(new GradientColorKey[] { color }, new GradientAlphaKey[] { alpha });
|
||||
return g;
|
||||
}
|
||||
|
||||
public static Gradient CreateFullTransparentGradient()
|
||||
{
|
||||
Gradient g = new Gradient();
|
||||
GradientColorKey color = new GradientColorKey(Color.white, 1);
|
||||
GradientAlphaKey alpha = new GradientAlphaKey(0, 1);
|
||||
g.SetKeys(new GradientColorKey[] { color }, new GradientAlphaKey[] { alpha });
|
||||
return g;
|
||||
}
|
||||
|
||||
public static void CalculateBarycentricCoord(Vector2 p, Vector2 p1, Vector2 p2, Vector2 p3, ref Vector3 bary)
|
||||
{
|
||||
Vector2 v0 = p2 - p1;
|
||||
Vector2 v1 = p3 - p1;
|
||||
Vector2 v2 = p - p1;
|
||||
float d00 = Vector2.Dot(v0, v0);
|
||||
float d01 = Vector2.Dot(v0, v1);
|
||||
float d11 = Vector2.Dot(v1, v1);
|
||||
float d20 = Vector2.Dot(v2, v0);
|
||||
float d21 = Vector2.Dot(v2, v1);
|
||||
float inverseDenom = 1 / (d00 * d11 - d01 * d01);
|
||||
bary.y = (d11 * d20 - d01 * d21) * inverseDenom;
|
||||
bary.z = (d00 * d21 - d01 * d20) * inverseDenom;
|
||||
bary.x = 1.0f - bary.y - bary.z;
|
||||
}
|
||||
|
||||
public static void ExpandTrisUvCoord(Texture2D tex, Vector2[] trisUv)
|
||||
{
|
||||
Vector2 texelSize = tex.texelSize;
|
||||
Vector2 center = (trisUv[0] + trisUv[1] + trisUv[2]) / 3;
|
||||
trisUv[0] += (trisUv[0] - center).normalized * texelSize.magnitude;
|
||||
trisUv[0].x = Mathf.Clamp01(trisUv[0].x);
|
||||
trisUv[0].y = Mathf.Clamp01(trisUv[0].y);
|
||||
|
||||
trisUv[1] += (trisUv[1] - center).normalized * texelSize.magnitude;
|
||||
trisUv[1].x = Mathf.Clamp01(trisUv[1].x);
|
||||
trisUv[1].y = Mathf.Clamp01(trisUv[1].y);
|
||||
|
||||
trisUv[2] += (trisUv[2] - center).normalized * texelSize.magnitude;
|
||||
trisUv[2].x = Mathf.Clamp01(trisUv[2].x);
|
||||
trisUv[2].y = Mathf.Clamp01(trisUv[2].y);
|
||||
}
|
||||
|
||||
public static bool ContainIdenticalElements<T>(T[] arr1, T[] arr2)
|
||||
{
|
||||
if (arr1 == null && arr2 == null)
|
||||
return true;
|
||||
if (arr1 == null && arr2 != null)
|
||||
return false;
|
||||
if (arr1 != null && arr2 == null)
|
||||
return false;
|
||||
if (arr1.Length != arr2.Length)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < arr1.Length; ++i)
|
||||
{
|
||||
if (!arr1[i].Equals(arr2[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static float GetNearestMultiple(float number, float multipleOf)
|
||||
{
|
||||
int multiplier = 0;
|
||||
while (multipleOf * multiplier < number)
|
||||
{
|
||||
multiplier += 1;
|
||||
}
|
||||
|
||||
float floor = multipleOf * (multiplier - 1);
|
||||
float ceil = multipleOf * multiplier;
|
||||
float f0 = number - floor;
|
||||
float f1 = ceil - number;
|
||||
|
||||
if (f0 < f1)
|
||||
return floor;
|
||||
else
|
||||
return ceil;
|
||||
}
|
||||
|
||||
public static Transform GetChildrenWithName(Transform parent, string name)
|
||||
{
|
||||
Transform t = parent.Find(name);
|
||||
if (t == null)
|
||||
{
|
||||
GameObject g = new GameObject(name);
|
||||
g.transform.parent = parent;
|
||||
ResetTransform(g.transform, parent);
|
||||
t = g.transform;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
public static void ResetTransform(Transform t, Transform parent)
|
||||
{
|
||||
t.parent = parent;
|
||||
t.localPosition = Vector3.zero;
|
||||
t.localRotation = Quaternion.identity;
|
||||
t.localScale = Vector3.one;
|
||||
}
|
||||
|
||||
public static void DestroyGameobject(GameObject g)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (UnityEditor.EditorApplication.isPlaying)
|
||||
GameObject.Destroy(g);
|
||||
else
|
||||
GameObject.DestroyImmediate(g);
|
||||
#else
|
||||
GameObject.Destroy(g);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void DestroyGameObjectWithUndo(GameObject g)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Undo.DestroyObjectImmediate(g);
|
||||
#else
|
||||
DestroyGameobject(g);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void DestroyObject(Object o)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (UnityEditor.EditorApplication.isPlaying)
|
||||
Object.Destroy(o);
|
||||
else
|
||||
Object.DestroyImmediate(o, true);
|
||||
#else
|
||||
GameObject.Destroy(o);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string Repeat(char src, int count)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
sb.Append(src, count);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static void MarkCurrentSceneDirty()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!UnityEditor.EditorApplication.isPlaying)
|
||||
UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene());
|
||||
#endif
|
||||
}
|
||||
|
||||
public static GameObject[] GetChildrenGameObjects(Transform parent)
|
||||
{
|
||||
GameObject[] children = new GameObject[parent.childCount];
|
||||
for (int i = 0; i < parent.childCount; ++i)
|
||||
{
|
||||
children[i] = parent.GetChild(i).gameObject;
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
public static Transform[] GetChildrenTransforms(Transform parent)
|
||||
{
|
||||
Transform[] children = new Transform[parent.childCount];
|
||||
for (int i = 0; i < parent.childCount; ++i)
|
||||
{
|
||||
children[i] = parent.GetChild(i);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula
|
||||
/// </summary>
|
||||
/// <param name="vector"></param>
|
||||
/// <param name="normal"></param>
|
||||
/// <param name="angleDegree"></param>
|
||||
/// <returns></returns>
|
||||
public static Vector3 RotateVectorAroundNormal(Vector3 vector, Vector3 normal, float angleDegree)
|
||||
{
|
||||
float sin = Mathf.Sin(angleDegree * Mathf.Deg2Rad);
|
||||
float cos = Mathf.Cos(angleDegree * Mathf.Deg2Rad);
|
||||
Vector3 rotatedVector =
|
||||
vector * cos +
|
||||
Vector3.Cross(normal, vector) * sin +
|
||||
normal * Vector3.Dot(normal, vector) * (1 - cos);
|
||||
return rotatedVector;
|
||||
}
|
||||
|
||||
public static Mesh GetPrimitiveMesh(PrimitiveType type)
|
||||
{
|
||||
GameObject g = GameObject.CreatePrimitive(type);
|
||||
Mesh m = g.GetComponent<MeshFilter>().sharedMesh;
|
||||
DestroyGameobject(g);
|
||||
return m;
|
||||
}
|
||||
|
||||
public static void ShuffleList<T>(List<T> list)
|
||||
{
|
||||
int length = list.Count;
|
||||
for (int i = 0; i < length - 1; ++i)
|
||||
{
|
||||
int j = UnityEngine.Random.Range(0, length);
|
||||
T tmp = list[i];
|
||||
list[i] = list[j];
|
||||
list[j] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
public static int[] GetShuffleIndicesArray(int length)
|
||||
{
|
||||
int[] indices = GetIndicesArray(length);
|
||||
for (int i = 0; i < length - 1; ++i)
|
||||
{
|
||||
int j = UnityEngine.Random.Range(0, length);
|
||||
int tmp = indices[i];
|
||||
indices[i] = indices[j];
|
||||
indices[j] = tmp;
|
||||
}
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
||||
public static int[] GetIndicesArray(int length)
|
||||
{
|
||||
int[] indices = new int[length];
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
indices[i] = i;
|
||||
}
|
||||
return indices;
|
||||
}
|
||||
|
||||
public static void ResetArray<T>(ref T[] array, int count, T defaultValue)
|
||||
{
|
||||
if (array != null && array.Length == count)
|
||||
{
|
||||
JUtilities.Fill(array, defaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
array = new T[count];
|
||||
}
|
||||
}
|
||||
|
||||
public static bool EnsureArrayLength<T>(ref T[] array, int count)
|
||||
{
|
||||
if (array == null || array.Length != count)
|
||||
{
|
||||
array = new T[count];
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static float GetValueBilinear(float[] data, int width, int height, Vector2 uv)
|
||||
{
|
||||
float value = 0;
|
||||
Vector2 pixelCoord = new Vector2(
|
||||
Mathf.Lerp(0, width - 1, uv.x),
|
||||
Mathf.Lerp(0, height - 1, uv.y));
|
||||
//apply a bilinear filter
|
||||
int xFloor = Mathf.FloorToInt(pixelCoord.x);
|
||||
int xCeil = Mathf.CeilToInt(pixelCoord.x);
|
||||
int yFloor = Mathf.FloorToInt(pixelCoord.y);
|
||||
int yCeil = Mathf.CeilToInt(pixelCoord.y);
|
||||
|
||||
float f00 = data[JUtilities.To1DIndex(xFloor, yFloor, width)];
|
||||
float f01 = data[JUtilities.To1DIndex(xFloor, yCeil, width)];
|
||||
float f10 = data[JUtilities.To1DIndex(xCeil, yFloor, width)];
|
||||
float f11 = data[JUtilities.To1DIndex(xCeil, yCeil, width)];
|
||||
|
||||
Vector2 unitCoord = new Vector2(
|
||||
pixelCoord.x - xFloor,
|
||||
pixelCoord.y - yFloor);
|
||||
|
||||
value =
|
||||
f00 * (1 - unitCoord.x) * (1 - unitCoord.y) +
|
||||
f01 * (1 - unitCoord.x) * unitCoord.y +
|
||||
f10 * unitCoord.x * (1 - unitCoord.y) +
|
||||
f11 * unitCoord.x * unitCoord.y;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Color GetColorBilinear(Color[] textureData, int width, int height, Vector2 uv)
|
||||
{
|
||||
Color color = Color.clear;
|
||||
Vector2 pixelCoord = new Vector2(
|
||||
Mathf.Lerp(0, width - 1, uv.x),
|
||||
Mathf.Lerp(0, height - 1, uv.y));
|
||||
//apply a bilinear filter
|
||||
int xFloor = Mathf.FloorToInt(pixelCoord.x);
|
||||
int xCeil = Mathf.CeilToInt(pixelCoord.x);
|
||||
int yFloor = Mathf.FloorToInt(pixelCoord.y);
|
||||
int yCeil = Mathf.CeilToInt(pixelCoord.y);
|
||||
|
||||
Color f00 = textureData[JUtilities.To1DIndex(xFloor, yFloor, width)];
|
||||
Color f01 = textureData[JUtilities.To1DIndex(xFloor, yCeil, width)];
|
||||
Color f10 = textureData[JUtilities.To1DIndex(xCeil, yFloor, width)];
|
||||
Color f11 = textureData[JUtilities.To1DIndex(xCeil, yCeil, width)];
|
||||
|
||||
Vector2 unitCoord = new Vector2(
|
||||
pixelCoord.x - xFloor,
|
||||
pixelCoord.y - yFloor);
|
||||
|
||||
color =
|
||||
f00 * (1 - unitCoord.x) * (1 - unitCoord.y) +
|
||||
f01 * (1 - unitCoord.x) * unitCoord.y +
|
||||
f10 * unitCoord.x * (1 - unitCoord.y) +
|
||||
f11 * unitCoord.x * unitCoord.y;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
public static GameObject CreatePreviewGameObject(Mesh m, Material mat, Vector3 position)
|
||||
{
|
||||
GameObject g = new GameObject("GO");
|
||||
g.transform.position = position;
|
||||
g.transform.rotation = Quaternion.identity;
|
||||
g.transform.localScale = Vector3.one;
|
||||
|
||||
MeshFilter mf = g.AddComponent<MeshFilter>();
|
||||
mf.sharedMesh = m;
|
||||
|
||||
MeshRenderer mr = g.AddComponent<MeshRenderer>();
|
||||
mr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
|
||||
mr.receiveShadows = false;
|
||||
mr.sharedMaterial = mat;
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
public static Camera CreatePreviewCamera(GameObject target, float distance, float padding)
|
||||
{
|
||||
GameObject g = new GameObject("CAM");
|
||||
g.transform.rotation = Quaternion.identity;
|
||||
g.transform.localScale = Vector3.one;
|
||||
|
||||
Camera cam = g.AddComponent<Camera>();
|
||||
cam.orthographic = true;
|
||||
cam.clearFlags = CameraClearFlags.Nothing;
|
||||
cam.aspect = 1;
|
||||
|
||||
MeshRenderer mr = target.GetComponent<MeshRenderer>();
|
||||
Bounds bounds = mr.bounds;
|
||||
cam.transform.position = bounds.center + new Vector3(-1, 0.5f, -1) * distance;
|
||||
cam.transform.LookAt(bounds.center);
|
||||
cam.orthographicSize = Mathf.Max(bounds.size.x, bounds.size.y, bounds.size.z) / 2 + padding;
|
||||
|
||||
return cam;
|
||||
}
|
||||
|
||||
public static void EnsureDirectoryExists(string dir)
|
||||
{
|
||||
if (!System.IO.Directory.Exists(dir))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(dir);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetStaticRecursively(GameObject g, bool isStatic)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
g.isStatic = isStatic;
|
||||
GameObject[] children = GetChildrenGameObjects(g.transform);
|
||||
for (int i = 0; i < children.Length; ++i)
|
||||
{
|
||||
SetStaticRecursively(children[i], isStatic);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void EnsureLengthSufficient<T>(List<T> list, int preferredLength) where T : Object
|
||||
{
|
||||
if (list == null)
|
||||
list = new List<T>();
|
||||
while (list.Count < preferredLength)
|
||||
{
|
||||
list.Add(null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnsureLengthSufficient(List<string> list, int preferredLength)
|
||||
{
|
||||
if (list == null)
|
||||
list = new List<string>();
|
||||
while (list.Count < preferredLength)
|
||||
{
|
||||
list.Add(string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnsureLengthSufficient(List<bool> list, int preferredLength)
|
||||
{
|
||||
if (list == null)
|
||||
list = new List<bool>();
|
||||
while (list.Count < preferredLength)
|
||||
{
|
||||
list.Add(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static string Ellipsis(string s, int length)
|
||||
{
|
||||
if (s.Length < length)
|
||||
return s;
|
||||
string s0 = s.Substring(0, length);
|
||||
return s0 + "...";
|
||||
}
|
||||
|
||||
public static bool IsRectContainPointExclusive(Rect r, Vector2 p)
|
||||
{
|
||||
return
|
||||
p.x > r.min.x &&
|
||||
p.x < r.max.x &&
|
||||
p.y > r.min.y &&
|
||||
p.y < r.max.y;
|
||||
}
|
||||
|
||||
public static Color GetColor(Color baseColor, float alpha)
|
||||
{
|
||||
return new Color(baseColor.r, baseColor.g, baseColor.b, alpha);
|
||||
}
|
||||
|
||||
public static Rect GetRectContainsPoints(params Vector2[] points)
|
||||
{
|
||||
float xMin = float.MaxValue;
|
||||
float xMax = float.MinValue;
|
||||
float yMin = float.MaxValue;
|
||||
float yMax = float.MinValue;
|
||||
for (int i = 0; i < points.Length; ++i)
|
||||
{
|
||||
xMin = points[i].x < xMin ? points[i].x : xMin;
|
||||
xMax = points[i].x > xMax ? points[i].x : xMax;
|
||||
yMin = points[i].y < yMin ? points[i].y : yMin;
|
||||
yMax = points[i].y > yMax ? points[i].y : yMax;
|
||||
}
|
||||
return Rect.MinMaxRect(xMin, yMin, xMax, yMax);
|
||||
}
|
||||
|
||||
public static float InverseLerpUnclamped(float a, float b, float value)
|
||||
{
|
||||
if (a != b)
|
||||
{
|
||||
return (value - a) / (b - a);
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public static Vector2 PointToNormalizedUnclampled(Rect r, Vector2 point)
|
||||
{
|
||||
return new Vector2(InverseLerpUnclamped(r.x, r.xMax, point.x), InverseLerpUnclamped(r.y, r.yMax, point.y));
|
||||
}
|
||||
|
||||
public static Rect GetUvRect(Vector2 v0, Vector2 v1, Vector2 v2)
|
||||
{
|
||||
return Rect.MinMaxRect(
|
||||
Mathf.Min(v0.x, v1.x, v2.x),
|
||||
Mathf.Min(v0.y, v1.y, v2.y),
|
||||
Mathf.Max(v0.x, v1.x, v2.x),
|
||||
Mathf.Max(v0.y, v1.y, v2.y));
|
||||
}
|
||||
|
||||
public static Gradient Clone(Gradient src)
|
||||
{
|
||||
if (src == null)
|
||||
return null;
|
||||
Gradient des = new Gradient();
|
||||
des.SetKeys(src.colorKeys, src.alphaKeys);
|
||||
return des;
|
||||
}
|
||||
|
||||
public static AnimationCurve Clone(AnimationCurve src)
|
||||
{
|
||||
if (src == null)
|
||||
return null;
|
||||
AnimationCurve des = new AnimationCurve();
|
||||
Keyframe[] keys = src.keys;
|
||||
for (int i = 0; i < keys.Length; ++i)
|
||||
{
|
||||
des.AddKey(keys[i]);
|
||||
}
|
||||
|
||||
des.preWrapMode = src.preWrapMode;
|
||||
des.postWrapMode = src.postWrapMode;
|
||||
return des;
|
||||
}
|
||||
|
||||
public static bool IsPointInsideQuadXZ(Vector3 point, Vector3[] quad)
|
||||
{
|
||||
Vector3 bary = Vector3.zero;
|
||||
CalculateBarycentricCoord(
|
||||
new Vector2(point.x, point.z),
|
||||
new Vector2(quad[0].x, quad[0].z),
|
||||
new Vector2(quad[1].x, quad[1].z),
|
||||
new Vector2(quad[2].x, quad[2].z),
|
||||
ref bary);
|
||||
if (bary.x >= 0 && bary.y >= 0 && bary.z >= 0)
|
||||
return true;
|
||||
|
||||
CalculateBarycentricCoord(
|
||||
new Vector2(point.x, point.z),
|
||||
new Vector2(quad[0].x, quad[0].z),
|
||||
new Vector2(quad[2].x, quad[2].z),
|
||||
new Vector2(quad[3].x, quad[3].z),
|
||||
ref bary);
|
||||
if (bary.x >= 0 && bary.y >= 0 && bary.z >= 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void DestroyMeshArray(Mesh[] meshes)
|
||||
{
|
||||
for (int i = 0; i < meshes.Length; ++i)
|
||||
{
|
||||
if (meshes[i] != null)
|
||||
{
|
||||
Object.DestroyImmediate(meshes[i], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector2 FlipY(Vector2 v)
|
||||
{
|
||||
return new Vector2(v.x, 1 - v.y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// https://en.wikipedia.org/wiki/Delaunay_triangulation#Algorithms
|
||||
/// </summary>
|
||||
/// <param name="v0"></param>
|
||||
/// <param name="v1"></param>
|
||||
/// <param name="v2"></param>
|
||||
/// <param name="p"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsPointInCircumcircle(Vector2 v0, Vector2 v1, Vector2 v2, Vector2 p)
|
||||
{
|
||||
Matrix4x4 mat = new Matrix4x4();
|
||||
mat.SetRow(0, new Vector4(v0.x, v0.y, v0.x * v0.x + v0.y * v0.y, 1));
|
||||
mat.SetRow(1, new Vector4(v2.x, v2.y, v2.x * v2.x + v2.y * v2.y, 1)); //a,b,c counterclockwise
|
||||
mat.SetRow(2, new Vector4(v1.x, v1.y, v1.x * v1.x + v1.y * v1.y, 1));
|
||||
mat.SetRow(3, new Vector4(p.x, p.y, p.x * p.x + p.y * p.y, 1));
|
||||
|
||||
return mat.determinant > 0;
|
||||
}
|
||||
|
||||
public static bool IsPointInCircumcircleXZ(Vector3 v0, Vector3 v1, Vector3 v2, Vector3 p)
|
||||
{
|
||||
Matrix4x4 mat = new Matrix4x4();
|
||||
mat.SetRow(0, new Vector4(v0.x, v0.z, v0.x * v0.x + v0.z * v0.z, 1));
|
||||
mat.SetRow(1, new Vector4(v2.x, v2.z, v2.x * v2.x + v2.z * v2.z, 1)); //a,b,c counterclockwise
|
||||
mat.SetRow(2, new Vector4(v1.x, v1.z, v1.x * v1.x + v1.z * v1.z, 1));
|
||||
mat.SetRow(3, new Vector4(p.x, p.z, p.x * p.x + p.z * p.z, 1));
|
||||
|
||||
return mat.determinant > 0;
|
||||
}
|
||||
|
||||
public static bool AreSetEqual(ushort[] setA, ushort[] setB)
|
||||
{
|
||||
HashSet<ushort> a = new HashSet<ushort>(setA);
|
||||
HashSet<ushort> b = new HashSet<ushort>(setB);
|
||||
return a.SetEquals(b);
|
||||
}
|
||||
|
||||
public static void Distinct<T>(this List<T> list)
|
||||
{
|
||||
list.Distinct();
|
||||
}
|
||||
|
||||
public static void AddIfNotContains<T>(this IList<T> list, IEnumerable<T> items)
|
||||
{
|
||||
IEnumerator<T> iter = items.GetEnumerator();
|
||||
while (iter.MoveNext())
|
||||
{
|
||||
T current = iter.Current;
|
||||
if (!list.Contains(current))
|
||||
{
|
||||
list.Add(current);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddIfNotContains<T>(this IList<T> list, T item)
|
||||
{
|
||||
if (!list.Contains(item))
|
||||
{
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3 ToX0Y(this Vector2 v)
|
||||
{
|
||||
return new Vector3(v.x, 0, v.y);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Pinwheel.Jupiter
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class contains product info
|
||||
/// </summary>
|
||||
public static class JVersionInfo
|
||||
{
|
||||
public static string Code
|
||||
{
|
||||
get
|
||||
{
|
||||
return "1.2.14";
|
||||
}
|
||||
}
|
||||
|
||||
public static string ProductName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Jupiter - Procedural Sky";
|
||||
}
|
||||
}
|
||||
|
||||
public static string ProductNameAndVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format("{0} v{1}", ProductName, Code);
|
||||
}
|
||||
}
|
||||
|
||||
public static string ProductNameShort
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Jupiter";
|
||||
}
|
||||
}
|
||||
|
||||
public static string ProductNameAndVersionShort
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format("{0} v{1}", ProductNameShort, Code);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
#ifndef FILE_INCLUDED
|
||||
#define FILE_INCLUDED
|
||||
|
||||
|
||||
|
||||
#endif
|
@@ -0,0 +1,162 @@
|
||||
#ifndef COMMON_INCLUDED
|
||||
#define COMMON_INCLUDED
|
||||
|
||||
sampler2D _NoiseTex;
|
||||
sampler2D _CloudTex;
|
||||
|
||||
float NoiseTexFrag(float2 uv)
|
||||
{
|
||||
return tex2D(_NoiseTex, uv).r*2 - 1;
|
||||
}
|
||||
|
||||
float NoiseTexVert(float2 uv)
|
||||
{
|
||||
return tex2Dlod(_NoiseTex, float4(uv.xy, 0, 0)).r*2 - 1;
|
||||
}
|
||||
|
||||
float CloudTexFrag(float2 uv)
|
||||
{
|
||||
return tex2D(_CloudTex, uv).r*2 - 1;
|
||||
}
|
||||
|
||||
float CloudTexLod0(float2 uv)
|
||||
{
|
||||
return tex2Dlod(_CloudTex, float4(uv.xy, 0, 0)).r*2 - 1;
|
||||
}
|
||||
|
||||
float CloudTexVert(float2 uv)
|
||||
{
|
||||
return CloudTexLod0(uv);
|
||||
}
|
||||
|
||||
float2 GradientNoise_dir(float2 p)
|
||||
{
|
||||
p = p % 289;
|
||||
float x = (34 * p.x + 1) * p.x % 289 + p.y;
|
||||
x = (34 * x + 1) * x % 289;
|
||||
x = frac(x / 41) * 2 - 1;
|
||||
return normalize(float2(x - floor(x + 0.5), abs(x) - 0.5));
|
||||
}
|
||||
|
||||
float GradientNoise(float2 p)
|
||||
{
|
||||
float2 ip = floor(p);
|
||||
float2 fp = frac(p);
|
||||
float d00 = dot(GradientNoise_dir(ip), fp);
|
||||
float d01 = dot(GradientNoise_dir(ip + float2(0, 1)), fp - float2(0, 1));
|
||||
float d10 = dot(GradientNoise_dir(ip + float2(1, 0)), fp - float2(1, 0));
|
||||
float d11 = dot(GradientNoise_dir(ip + float2(1, 1)), fp - float2(1, 1));
|
||||
fp = fp * fp * fp * (fp * (fp * 6 - 15) + 10);
|
||||
return lerp(lerp(d00, d01, fp.y), lerp(d10, d11, fp.y), fp.x);
|
||||
}
|
||||
|
||||
float InverseLerpUnclamped(float a, float b, float value)
|
||||
{
|
||||
//adding a==b check if needed
|
||||
return (value - a) / (b - a + 0.00000001);
|
||||
}
|
||||
|
||||
float RandomValue(float seed)
|
||||
{
|
||||
return frac(seed*23.456*(1+ceil(seed)*12.345));
|
||||
}
|
||||
|
||||
float RandomValue(float3 seed)
|
||||
{
|
||||
float3 value = frac(seed*23.456*(1+ceil(seed)*12.345));
|
||||
return max(value.x, min(value.y, value.z));
|
||||
}
|
||||
|
||||
float2 VoronoiRandomVector (float2 UV, float offset)
|
||||
{
|
||||
float2x2 m = float2x2(15.27, 47.63, 99.41, 89.98);
|
||||
UV = frac(sin(mul(UV, m)) * 46839.32);
|
||||
return float2(sin(UV.y*+offset)*0.5+0.5, cos(UV.x*offset)*0.5+0.5);
|
||||
}
|
||||
|
||||
float Voronoi(float2 UV, float AngleOffset, float CellDensity)
|
||||
{
|
||||
float2 g = floor(UV * CellDensity);
|
||||
float2 f = frac(UV * CellDensity);
|
||||
float t = 8.0;
|
||||
float3 res = float3(8.0, 0.0, 0.0);
|
||||
float noiseValue = 0;
|
||||
|
||||
for(int y=-1; y<=1; y++)
|
||||
{
|
||||
for(int x=-1; x<=1; x++)
|
||||
{
|
||||
float2 lattice = float2(x,y);
|
||||
float2 offset = VoronoiRandomVector(lattice + g, AngleOffset);
|
||||
float d = distance(lattice + offset, f);
|
||||
if(d < res.x)
|
||||
{
|
||||
res = float3(d, offset.x, offset.y);
|
||||
noiseValue = res.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return noiseValue;
|
||||
}
|
||||
|
||||
float2 PanUV(float2 uv, float2 speed)
|
||||
{
|
||||
return uv + _Time.y*speed;
|
||||
}
|
||||
|
||||
half IsOrtho()
|
||||
{
|
||||
return unity_OrthoParams.w;
|
||||
}
|
||||
|
||||
half GetNearPlane()
|
||||
{
|
||||
return _ProjectionParams.y;
|
||||
}
|
||||
|
||||
half GetFarPlane()
|
||||
{
|
||||
return _ProjectionParams.z;
|
||||
}
|
||||
|
||||
float SqrDistance(float3 pt1, float3 pt2)
|
||||
{
|
||||
float3 v = pt2 - pt1;
|
||||
return dot(v,v);
|
||||
}
|
||||
|
||||
fixed SqrDistance(fixed pt1, fixed pt2)
|
||||
{
|
||||
fixed v = pt2 - pt1;
|
||||
return dot(v,v);
|
||||
}
|
||||
|
||||
float SqrMagnitude(float2 p)
|
||||
{
|
||||
return p.x*p.x + p.y*p.y;
|
||||
}
|
||||
|
||||
float SqrMagnitude(float3 p)
|
||||
{
|
||||
return p.x*p.x + p.y*p.y + p.z*p.z;
|
||||
}
|
||||
|
||||
float StepValue(float v, float count)
|
||||
{
|
||||
float step = 1.0/count;
|
||||
return v-v%step;
|
||||
}
|
||||
|
||||
float TriangleWave(float t)
|
||||
{
|
||||
return 2.0 * abs( 2 * (t - floor(0.5 + t)) ) - 1.0;
|
||||
}
|
||||
|
||||
fixed4 BlendOverlay(fixed4 src, fixed4 des)
|
||||
{
|
||||
fixed4 result = src*src.a + des*(1-src.a);
|
||||
result.a = 1 - (1-src.a)*(1-des.a);
|
||||
return result;
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,33 @@
|
||||
#ifndef DETAIL_OVERLAY_INCLUDED
|
||||
#define DETAIL_OVERLAY_INCLUDED
|
||||
|
||||
void CalculateDetailOverlayColor(
|
||||
float4 localPos,
|
||||
samplerCUBE cubemap,
|
||||
fixed4 tint,
|
||||
out fixed4 color)
|
||||
{
|
||||
color = texCUBE(cubemap, localPos.xyz);
|
||||
color *= tint;
|
||||
}
|
||||
|
||||
void CalculateDetailOverlayColor(
|
||||
float4 localPos,
|
||||
samplerCUBE cubemap,
|
||||
fixed4 tint,
|
||||
float rotationSpeed,
|
||||
out fixed4 color)
|
||||
{
|
||||
float angle = rotationSpeed*_Time.y;
|
||||
float sinY = sin(radians(angle));
|
||||
float cosY = cos(radians(angle));
|
||||
float3x3 ry = float3x3(cosY, 0, sinY,
|
||||
0, 1, 0,
|
||||
-sinY, 0, cosY);
|
||||
localPos.xyz = mul(ry, localPos.xyz);
|
||||
|
||||
color = texCUBE(cubemap, localPos.xyz);
|
||||
color *= tint;
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,52 @@
|
||||
#ifndef HORIZON_CLOUD_INCLUDED
|
||||
#define HORIZON_CLOUD_INCLUDED
|
||||
|
||||
#include "JCommon.cginc"
|
||||
|
||||
void CalculateHorizonCloudColor(
|
||||
float4 localPos,
|
||||
fixed4 cloudColor,
|
||||
fixed cloudStart, fixed cloudEnd,
|
||||
fixed cloudSize, fixed cloudStep,
|
||||
fixed animationSpeed,
|
||||
out fixed4 color)
|
||||
{
|
||||
fixed fadeBottom = saturate(InverseLerpUnclamped(cloudStart, 0, localPos.y));
|
||||
fixed fadeTop = saturate(InverseLerpUnclamped(cloudEnd, 0, localPos.y));
|
||||
fixed fade = saturate(lerp(fadeBottom, fadeTop, localPos.y >= 0));
|
||||
fade = fade*fade;
|
||||
|
||||
fixed loop;
|
||||
#if SHADER_API_MOBILE
|
||||
loop = 1;
|
||||
#else
|
||||
loop = 2;
|
||||
#endif
|
||||
|
||||
fixed noise = 0;
|
||||
fixed sample0 = 0;
|
||||
fixed sample1 = 0;
|
||||
fixed noiseSize = cloudSize + 0.0001;
|
||||
fixed noiseAmp = 1;
|
||||
fixed sign = -1;
|
||||
fixed2 span = animationSpeed*_Time.y*0.0001;
|
||||
for (fixed i=0; i<loop; ++i)
|
||||
{
|
||||
sample0 = CloudTexLod0((localPos.xy)/noiseSize + sign*span)*noiseAmp;
|
||||
sample1 = CloudTexLod0((localPos.yz)/noiseSize + sign*span)*noiseAmp;
|
||||
noise += (sample0 + sample1)*0.5;
|
||||
noiseSize *= 0.5;
|
||||
noiseAmp *= 0.5;
|
||||
sign *= -1;
|
||||
}
|
||||
|
||||
noise = noise*0.5 + 0.5;
|
||||
|
||||
#if ALLOW_STEP_EFFECT
|
||||
noise = StepValue(noise, cloudStep);
|
||||
#endif
|
||||
|
||||
color = fixed4(1, 1, 1, fade*noise*2)*cloudColor;
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,65 @@
|
||||
#ifndef OVERHEAD_CLOUD_INCLUDED
|
||||
#define OVERHEAD_CLOUD_INCLUDED
|
||||
|
||||
#include "JCommon.cginc"
|
||||
|
||||
void CalculateOverheadCloudColor(
|
||||
float4 localPos,
|
||||
fixed4 cloudColor,
|
||||
fixed cloudAltitude,
|
||||
fixed cloudSize, fixed cloudStep,
|
||||
fixed animationSpeed,
|
||||
fixed flowX, fixed flowZ,
|
||||
fixed remapMin, fixed remapMax,
|
||||
out fixed4 color)
|
||||
{
|
||||
fixed3 rayDir = localPos.xyz;
|
||||
float3 cloudPlaneOrigin = float3(0, cloudAltitude, 0);
|
||||
float3 cloudPlaneNormal = float3(0, 1, 0);
|
||||
|
||||
float rayLength = dot(cloudPlaneOrigin, cloudPlaneNormal) / (dot(rayDir, cloudPlaneNormal) + 0.000001);
|
||||
float3 intersectionPoint = rayDir * rayLength;
|
||||
|
||||
fixed loop;
|
||||
#if SHADER_API_MOBILE
|
||||
loop = 1;
|
||||
#else
|
||||
loop = 2;
|
||||
#endif
|
||||
|
||||
fixed noise = 0;
|
||||
fixed sample = 0;
|
||||
fixed noiseSize = cloudSize * 1000 + 0.0001;
|
||||
fixed noiseAmp = 1;
|
||||
fixed sign = -1;
|
||||
fixed2 span = fixed2(flowX, flowZ) * animationSpeed * _Time.y * 0.0001;
|
||||
for (fixed i = 0; i < loop; ++i)
|
||||
{
|
||||
sample = CloudTexLod0((intersectionPoint.xz) / noiseSize + sign * span) * noiseAmp;
|
||||
noise += sample;
|
||||
noiseSize *= 0.5;
|
||||
noiseAmp *= 0.5;
|
||||
sign *= -1;
|
||||
}
|
||||
noise = noise * 0.5 + 0.5;
|
||||
noise = noise * cloudColor.a;
|
||||
noise = lerp(remapMin, remapMax, noise);
|
||||
noise = saturate(noise);
|
||||
|
||||
#if ALLOW_STEP_EFFECT
|
||||
noise = StepValue(noise, cloudStep);
|
||||
#endif
|
||||
|
||||
color = fixed4(cloudColor.rgb, noise);
|
||||
|
||||
float sqrCloudDiscRadius = 100000000;
|
||||
float sqrDistanceToCloudPlaneOrigin = SqrDistance(intersectionPoint, cloudPlaneOrigin);
|
||||
|
||||
fixed fDistance = saturate(1 - InverseLerpUnclamped(0, sqrCloudDiscRadius, sqrDistanceToCloudPlaneOrigin));
|
||||
color.a *= fDistance * fDistance;
|
||||
|
||||
fixed4 clear = fixed4(0, 0, 0, 0);
|
||||
color = lerp(clear, color, localPos.y > 0);
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,25 @@
|
||||
#ifndef SKY_GRADIENT_INCLUDED
|
||||
#define SKY_GRADIENT_INCLUDED
|
||||
|
||||
#include "JCommon.cginc"
|
||||
|
||||
void CalculateSkyGradientColor(
|
||||
float4 localPos,
|
||||
fixed4 skyColor, fixed4 horizonColor, fixed4 groundColor,
|
||||
fixed horizonThickness, fixed horizonExponent, fixed horizonStep,
|
||||
out fixed4 skyBlendColor, out fixed4 horizonBlendColor)
|
||||
{
|
||||
skyBlendColor = lerp(groundColor, skyColor, localPos.y > 0);
|
||||
horizonThickness *= lerp(0.25, 1, localPos.y > 0);
|
||||
|
||||
#if ALLOW_STEP_EFFECT
|
||||
localPos.y = StepValue(localPos.y, horizonStep);
|
||||
#endif
|
||||
|
||||
fixed horizonBlendFactor = saturate(1 - InverseLerpUnclamped(0, horizonThickness, abs(localPos.y)));
|
||||
horizonBlendFactor = pow(horizonBlendFactor, horizonExponent);
|
||||
//horizon = lerp(color, horizonColor, horizonBlendFactor);
|
||||
horizonBlendColor = fixed4(horizonColor.xyz, horizonBlendFactor*horizonColor.a);
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,55 @@
|
||||
#ifndef STARS_INCLUDED
|
||||
#define STARS_INCLUDED
|
||||
|
||||
#include "JCommon.cginc"
|
||||
|
||||
void CalculateStarsColor(
|
||||
float4 localPos,
|
||||
float starsStartPosition, float starsEndPosition,
|
||||
fixed4 starsColor, fixed starsOpacity,
|
||||
float starsDensity,
|
||||
float starsSize,
|
||||
fixed starsGlow,
|
||||
fixed starsTwinkle,
|
||||
out fixed4 color)
|
||||
{
|
||||
float cellCount = starsDensity*50;
|
||||
float cellSize = 1/cellCount;
|
||||
|
||||
float3 cellCenter = floor(localPos.xyz/cellSize)*cellSize + 0.5*cellSize*float3(1,1,1);
|
||||
float rand = RandomValue(cellCenter.xyz) - 0.5;
|
||||
float3 starPos = cellCenter + float3(1,1,1)*cellSize*rand;
|
||||
float sqrDistance = SqrDistance(localPos.xyz, starPos);
|
||||
float sqrDistanceThreshold = 0.00001*starsSize*starsSize;
|
||||
|
||||
fixed4 clear = fixed4(0,0,0,0);
|
||||
fixed4 white = fixed4(1,1,1,1);
|
||||
|
||||
color = lerp(clear, white, sqrDistance <= sqrDistanceThreshold);
|
||||
color *= starsColor;
|
||||
color.a *= 2*(1 + starsGlow)*(rand + 0.5);
|
||||
float wave = TriangleWave(rand*_Time.y*starsTwinkle)*0.5 + 0.5;
|
||||
color.a *= lerp(0.5, 1, (1-wave));
|
||||
color.a *= starsOpacity;
|
||||
|
||||
color = lerp(clear, color, cellCenter.y >= starsStartPosition);
|
||||
color = lerp(clear, color, cellCenter.y <= starsEndPosition);
|
||||
color = lerp(clear, color, rand <= starsDensity);
|
||||
}
|
||||
|
||||
void CalculateStarsColorBaked(
|
||||
float4 localPos,
|
||||
samplerCUBE starsCubemap,
|
||||
sampler2D starsTwinkleMap,
|
||||
fixed starsOpacity,
|
||||
out fixed4 color)
|
||||
{
|
||||
float2 span = float2(1,1)*_Time.y*0.1;
|
||||
fixed twinkle = tex2D(starsTwinkleMap, localPos.xy + span).r;
|
||||
|
||||
color = texCUBE(starsCubemap, localPos.xyz);
|
||||
color.a *= twinkle;
|
||||
color.a *= starsOpacity;
|
||||
}
|
||||
|
||||
#endif
|
@@ -0,0 +1,90 @@
|
||||
#ifndef SUN_MOON_INCLUDED
|
||||
#define SUN_MOON_INCLUDED
|
||||
|
||||
#include "JCommon.cginc"
|
||||
|
||||
void CalculateSunMoonColorTextured(
|
||||
float4 localPos,
|
||||
sampler2D tex, float4x4 posToUvMatrix,
|
||||
fixed4 tintColor,
|
||||
float size, fixed softEdge, fixed glow,
|
||||
float4 direction,
|
||||
out fixed4 color)
|
||||
{
|
||||
fixed3 sunPos = -direction;
|
||||
fixed3 rayDir = localPos.xyz;
|
||||
fixed3 sunPlaneOrigin = sunPos;
|
||||
fixed3 sunPlaneNormal = sunPos;
|
||||
|
||||
fixed rayLength = dot(sunPlaneOrigin, sunPlaneNormal)/(dot(rayDir, sunPlaneNormal)+0.000001);
|
||||
fixed3 intersectionPoint = rayDir*rayLength;
|
||||
fixed sqrDistanceToSun = SqrDistance(intersectionPoint, sunPos);
|
||||
fixed fSize = 1 - InverseLerpUnclamped(0, size*size*0.25, sqrDistanceToSun);
|
||||
fixed fGlow = 1 - InverseLerpUnclamped(0, size*size*400*glow*glow, sqrDistanceToSun);
|
||||
fGlow = saturate(fGlow);
|
||||
|
||||
fixed4 clear = fixed4(0,0,0,0);
|
||||
fixed4 white = fixed4(1,1,1,1);
|
||||
|
||||
fixed4 glowColor = fixed4(tintColor.xyz, fGlow*fGlow*fGlow*fGlow*fGlow*fGlow*glow);
|
||||
float4 uvSpacePos = mul(posToUvMatrix, localPos);
|
||||
fixed4 texColor = tex2D(tex, uvSpacePos.xy - float2(0.5, 0.5));
|
||||
texColor.a = lerp(0, texColor.a, SqrMagnitude(uvSpacePos.xy) <= 0.25);
|
||||
float texAlpha = texColor.a;
|
||||
|
||||
float fSoftEdge = saturate(lerp(0, 1/(softEdge+0.0000001), fSize));
|
||||
texColor = lerp(glowColor, texColor, fSoftEdge*texAlpha);
|
||||
texColor.a = texAlpha*fSoftEdge;
|
||||
|
||||
color = texColor + glowColor*glowColor.a;
|
||||
color *= tintColor;
|
||||
color.a = saturate(color.a);
|
||||
|
||||
float dotProduct = dot(localPos.xyz, sunPos);
|
||||
color = lerp(clear, color, dotProduct >= 0);
|
||||
}
|
||||
|
||||
void CalculateSunMoonColor(
|
||||
float4 localPos,
|
||||
fixed4 tintColor,
|
||||
float size, fixed softEdge, fixed glow,
|
||||
float4 direction,
|
||||
out fixed4 color)
|
||||
{
|
||||
fixed3 sunPos = -direction;
|
||||
fixed3 rayDir = localPos.xyz;
|
||||
fixed3 sunPlaneOrigin = sunPos;
|
||||
fixed3 sunPlaneNormal = sunPos;
|
||||
|
||||
fixed rayLength = dot(sunPlaneOrigin, sunPlaneNormal)/(dot(rayDir, sunPlaneNormal)+0.000001);
|
||||
fixed3 intersectionPoint = rayDir*rayLength;
|
||||
fixed sqrDistanceToSun = SqrDistance(intersectionPoint, sunPos);
|
||||
fixed fSize = 1 - InverseLerpUnclamped(0, size*size*0.25, sqrDistanceToSun);
|
||||
fixed fGlow = 1 - InverseLerpUnclamped(0, size*size*400*glow*glow, sqrDistanceToSun);
|
||||
fGlow = saturate(fGlow);
|
||||
|
||||
fixed4 clear = fixed4(0,0,0,0);
|
||||
fixed4 white = fixed4(1,1,1,1);
|
||||
|
||||
fixed4 texColor = white;
|
||||
fixed4 glowColor = fixed4(tintColor.xyz, fGlow*fGlow*fGlow*fGlow*fGlow*fGlow*glow);
|
||||
fixed fSoftEdge = saturate(lerp(0, 1/(softEdge+0.0000001), fSize));
|
||||
texColor = lerp(glowColor, texColor, fSoftEdge);
|
||||
|
||||
color = texColor + glowColor*glowColor.a*glowColor.a;
|
||||
color *= tintColor;
|
||||
color.a = saturate(color.a);
|
||||
|
||||
fixed dotProduct = dot(localPos.xyz, sunPos);
|
||||
color = lerp(clear, color, dotProduct >= 0);
|
||||
}
|
||||
|
||||
void CalculateSunMoonColorBaked(
|
||||
float4 localPos, float4x4 rotationMatrix,
|
||||
samplerCUBE sunCubemap,
|
||||
out fixed4 color)
|
||||
{
|
||||
localPos = mul(rotationMatrix, float4(localPos.xyz,0));
|
||||
color = texCUBE(sunCubemap, localPos.xyz);
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,69 @@
|
||||
Shader "Hidden/Griffin/CopyTexture"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_StartUV ("Start UV", Vector) = (0,0,0,0)
|
||||
_EndUV ("End UV", Vector) = (1,1,1,1)
|
||||
_DefaultColor ("Default Color", Color) = (0,0,0,0)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
float4 _StartUV;
|
||||
float4 _EndUV;
|
||||
float4 _DefaultColor;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
float2 TransformUV(float2 uv)
|
||||
{
|
||||
return lerp(_StartUV, _EndUV, uv);
|
||||
}
|
||||
|
||||
float IsInRange01(float2 uv)
|
||||
{
|
||||
return uv.x>=0 && uv.x<=1 && uv.y>=0 && uv.y<=1;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float2 transformedUV = TransformUV(i.uv);
|
||||
float4 texColor = tex2D(_MainTex, transformedUV);
|
||||
float inRange = IsInRange01(transformedUV);
|
||||
float4 result = texColor*inRange + _DefaultColor*(1-inRange);
|
||||
return result;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
Shader "Hidden/Griffin/SolidColor"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" }
|
||||
Blend One Zero
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
float4 _Color;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
return _Color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,483 @@
|
||||
Shader "Jupiter/Sky"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _SkyColor("Sky Color", Color) = (0.15, 0.4, 0.65, 1)
|
||||
[HideInInspector] _HorizonColor("Horizon Color", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _GroundColor("Ground Color", Color) = (0.4, 0.4, 0.4, 1)
|
||||
[HideInInspector] _HorizonThickness("Horizon Thickness", Range(0.0, 1.0)) = 0.3
|
||||
[HideInInspector] _HorizonExponent("Horizon Exponent", Float) = 1.0
|
||||
[HideInInspector] _HorizonStep("Horizon Step", Float) = 25
|
||||
[HideInInspector] _FogColor("Custom Fog Color", Color) = (0, 0, 0, 1)
|
||||
|
||||
[HideInInspector] _StarsStartPosition("Stars Start", Float) = 0.3
|
||||
[HideInInspector] _StarsEndPosition("Stars End", Float) = 1
|
||||
[HideInInspector] _StarsOpacity("Stars Opacity", Float) = 1
|
||||
|
||||
[HideInInspector] _StarsColor0("Stars Color 0", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _StarsColor1("Stars Color 1", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _StarsColor2("Stars Color 2", Color) = (1, 1, 1, 1)
|
||||
|
||||
[HideInInspector] _StarsDensity0("Stars Density 0", Float) = 1
|
||||
[HideInInspector] _StarsDensity1("Stars Density 1", Float) = 1
|
||||
[HideInInspector] _StarsDensity2("Stars Density 2", Float) = 1
|
||||
|
||||
[HideInInspector] _StarsSize0("Stars Size 0", Float) = 1
|
||||
[HideInInspector] _StarsSize1("Stars Size 1", Float) = 1
|
||||
[HideInInspector] _StarsSize2("Stars Size 2", Float) = 1
|
||||
|
||||
[HideInInspector] _StarsGlow0("Stars Glow 0", Float) = 0
|
||||
[HideInInspector] _StarsGlow1("Stars Glow 1", Float) = 0
|
||||
[HideInInspector] _StarsGlow2("Stars Glow 2", Float) = 0
|
||||
|
||||
[HideInInspector] _StarsTwinkle0("Stars Twinkle 0", Float) = 1
|
||||
[HideInInspector] _StarsTwinkle1("Stars Twinkle 1", Float) = 1
|
||||
[HideInInspector] _StarsTwinkle2("Stars Twinkle 2", Float) = 1
|
||||
|
||||
[HideInInspector] _StarsCubemap("Stars Cubemap", CUBE) = "any" {}
|
||||
[HideInInspector] _StarsTwinkleMap("Stars Twinkle Map", 2D) = "white" {}
|
||||
|
||||
[HideInInspector] _SunTex("Sun Texture", 2D) = "white" {}
|
||||
[HideInInspector] _SunColor("Sun Color", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _SunSize("Sun Size", Float) = 0.1
|
||||
[HideInInspector] _SunSoftEdge("Sun Soft Edge", Float) = 0
|
||||
[HideInInspector] _SunGlow("Sun Glow", Float) = 0
|
||||
[HideInInspector] _SunDirection("Sun Direction", Vector) = (-1, -1, -1, 0)
|
||||
[HideInInspector] _SunCubemap("Sun Cubemap", CUBE) = "any" {}
|
||||
[HideInInspector] _SunLightColor("Sun Light Color", Color) = (1,1,1,1)
|
||||
[HideInInspector] _SunLightIntensity("Sun Light Intensity", Float) = 1
|
||||
|
||||
[HideInInspector] _MoonTex("Moon Texture", 2D) = "white" {}
|
||||
[HideInInspector] _MoonColor("Moon Color", Color) = (1, 1, 1, 1)
|
||||
[HideInInspector] _MoonSize("Moon Size", Float) = 0.1
|
||||
[HideInInspector] _MoonSoftEdge("Moon Soft Edge", Float) = 0
|
||||
[HideInInspector] _MoonGlow("Moon Glow", Float) = 0
|
||||
[HideInInspector] _MoonDirection("Moon Direction", Vector) = (1, 1, 1, 0)
|
||||
[HideInInspector] _MoonCubemap("Moon Cubemap", CUBE) = "any" {}
|
||||
[HideInInspector] _MoonLightColor("Moon Light Color", Color) = (1,1,1,1)
|
||||
[HideInInspector] _MoonLightIntensity("Moon Light Intensity", Float) = 1
|
||||
|
||||
[HideInInspector] _HorizonCloudColor("Horizon Cloud Color", Color) = (1, 1, 1, 0.5)
|
||||
[HideInInspector] _HorizonCloudStartPosition("Horizon Cloud Start", Float) = -0.1
|
||||
[HideInInspector] _HorizonCloudEndPosition("Horizon Cloud End", Float) = 0.5
|
||||
[HideInInspector] _HorizonCloudSize("Horizon Cloud Size", Float) = 10
|
||||
[HideInInspector] _HorizonCloudStep("Horizon Cloud Step", Float) = 25
|
||||
[HideInInspector] _HorizonCloudAnimationSpeed("Horizon Cloud Animation Speed", Float) = 1
|
||||
|
||||
[HideInInspector] _OverheadCloudColor("Overhead Cloud Color", Color) = (1, 1, 1, 0.5)
|
||||
[HideInInspector] _OverheadCloudAltitude("Overhead Cloud Altitude", Float) = 1000
|
||||
[HideInInspector] _OverheadCloudSize("Overhead Cloud Size", Float) = 100
|
||||
[HideInInspector] _OverheadCloudStep("Overhead Cloud Step", Float) = 25
|
||||
[HideInInspector] _OverheadCloudAnimationSpeed("Overhead Cloud Animation Speed", Float) = 1
|
||||
[HideInInspector] _OverheadCloudFlowDirectionX("Overhead Cloud Flow X", Float) = 1
|
||||
[HideInInspector] _OverheadCloudFlowDirectionZ("Overhead Cloud Flow X", Float) = 1
|
||||
[HideInInspector] _OverheadCloudRemapMin("Overhead Cloud Remap Min", Float) = 0
|
||||
[HideInInspector] _OverheadCloudRemapMax("Overhead Cloud Remap Max", Float) = 1
|
||||
|
||||
[HideInInspector] _DetailOverlayTintColor("Detail Overlay Color", COLOR) = (1, 1, 1, 0.5)
|
||||
[HideInInspector] _DetailOverlayCubemap("Detail Overlay Cubemap", CUBE) = "any" {}
|
||||
[HideInInspector] _DetailOverlayLayer("Detail Overlay Layer", Float) = 0
|
||||
[HideInInspector] _DetailOverlayRotationSpeed("Detail Overlay Rotation Speed", Float) = 0
|
||||
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue" = "Background" "RenderType" = "Background" "PreviewType" = "Skybox" }
|
||||
Cull Off ZWrite Off
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#pragma shader_feature_local STARS
|
||||
#pragma shader_feature_local STARS_LAYER_0
|
||||
#pragma shader_feature_local STARS_LAYER_1
|
||||
#pragma shader_feature_local STARS_LAYER_2
|
||||
#pragma shader_feature_local STARS_BAKED
|
||||
|
||||
#pragma shader_feature_local SUN
|
||||
#pragma shader_feature_local SUN_USE_TEXTURE
|
||||
#pragma shader_feature_local SUN_BAKED
|
||||
|
||||
#pragma shader_feature_local MOON
|
||||
#pragma shader_feature_local MOON_USE_TEXTURE
|
||||
#pragma shader_feature_local MOON_BAKED
|
||||
|
||||
#pragma shader_feature_local HORIZON_CLOUD
|
||||
#pragma shader_feature_local OVERHEAD_CLOUD
|
||||
#pragma shader_feature_local DETAIL_OVERLAY
|
||||
#pragma shader_feature_local DETAIL_OVERLAY_ROTATION
|
||||
#pragma shader_feature_local ALLOW_STEP_EFFECT
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "./CGIncludes/JCommon.cginc"
|
||||
#include "./CGIncludes/JSkyGradient.cginc"
|
||||
#include "./CGIncludes/JStars.cginc"
|
||||
#include "./CGIncludes/JSunMoon.cginc"
|
||||
#include "./CGIncludes/JHorizonCloud.cginc"
|
||||
#include "./CGIncludes/JOverheadCloud.cginc"
|
||||
#include "./CGIncludes/JDetailOverlay.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
float4 localPos : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
uniform fixed4 _SkyColor;
|
||||
uniform fixed4 _HorizonColor;
|
||||
uniform fixed4 _GroundColor;
|
||||
uniform fixed _HorizonThickness;
|
||||
uniform fixed _HorizonExponent;
|
||||
uniform fixed _HorizonStep;
|
||||
uniform fixed4 _FogColor;
|
||||
|
||||
#if STARS
|
||||
uniform fixed _StarsOpacity;
|
||||
#if STARS_BAKED
|
||||
uniform samplerCUBE _StarsCubemap;
|
||||
uniform sampler2D _StarsTwinkleMap;
|
||||
#else
|
||||
uniform float _StarsStartPosition;
|
||||
uniform float _StarsEndPosition;
|
||||
|
||||
uniform fixed4 _StarsColor0;
|
||||
uniform fixed4 _StarsColor1;
|
||||
uniform fixed4 _StarsColor2;
|
||||
|
||||
uniform float _StarsDensity0;
|
||||
uniform float _StarsDensity1;
|
||||
uniform float _StarsDensity2;
|
||||
|
||||
uniform float _StarsSize0;
|
||||
uniform float _StarsSize1;
|
||||
uniform float _StarsSize2;
|
||||
|
||||
uniform fixed _StarsGlow0;
|
||||
uniform fixed _StarsGlow1;
|
||||
uniform fixed _StarsGlow2;
|
||||
|
||||
uniform fixed _StarsTwinkle0;
|
||||
uniform fixed _StarsTwinkle1;
|
||||
uniform fixed _StarsTwinkle2;
|
||||
#endif //STARS_BAKED
|
||||
#endif //STARS
|
||||
|
||||
#if SUN
|
||||
#if SUN_BAKED
|
||||
uniform samplerCUBE _SunCubemap;
|
||||
uniform float4x4 _SunRotationMatrix;
|
||||
#else
|
||||
#if SUN_USE_TEXTURE
|
||||
uniform sampler2D _SunTex;
|
||||
uniform float4x4 _PositionToSunUV;
|
||||
#endif //SUN_USE_TEXTURE
|
||||
uniform fixed4 _SunColor;
|
||||
uniform float _SunSize;
|
||||
uniform fixed _SunSoftEdge;
|
||||
uniform fixed _SunGlow;
|
||||
uniform float4 _SunDirection;
|
||||
uniform float4 _SunLightColor;
|
||||
uniform float4 _SunLightIntensity;
|
||||
#endif //SUN_BAKED
|
||||
#endif //SUN
|
||||
|
||||
#if MOON
|
||||
#if MOON_BAKED
|
||||
uniform samplerCUBE _MoonCubemap;
|
||||
uniform float4x4 _MoonRotationMatrix;
|
||||
#else
|
||||
#if MOON_USE_TEXTURE
|
||||
uniform sampler2D _MoonTex;
|
||||
uniform float4x4 _PositionToMoonUV;
|
||||
#endif //MOON_USE_TEXTURE
|
||||
uniform fixed4 _MoonColor;
|
||||
uniform float _MoonSize;
|
||||
uniform fixed _MoonSoftEdge;
|
||||
uniform fixed _MoonGlow;
|
||||
uniform float4 _MoonDirection;
|
||||
uniform float4 _MoonLightColor;
|
||||
uniform float4 _MoonLightIntensity;
|
||||
#endif //MOON_BAKED
|
||||
#endif //MOON
|
||||
|
||||
#if HORIZON_CLOUD
|
||||
uniform fixed4 _HorizonCloudColor;
|
||||
uniform fixed _HorizonCloudStartPosition;
|
||||
uniform fixed _HorizonCloudEndPosition;
|
||||
uniform fixed _HorizonCloudSize;
|
||||
uniform fixed _HorizonCloudStep;
|
||||
uniform fixed _HorizonCloudAnimationSpeed;
|
||||
#endif //HORIZON_CLOUD
|
||||
|
||||
#if OVERHEAD_CLOUD
|
||||
uniform fixed4 _OverheadCloudColor;
|
||||
uniform fixed _OverheadCloudAltitude;
|
||||
uniform fixed _OverheadCloudSize;
|
||||
uniform fixed _OverheadCloudStep;
|
||||
uniform fixed _OverheadCloudAnimationSpeed;
|
||||
uniform fixed _OverheadCloudFlowDirectionX;
|
||||
uniform fixed _OverheadCloudFlowDirectionZ;
|
||||
uniform fixed _OverheadCloudRemapMin;
|
||||
uniform fixed _OverheadCloudRemapMax;
|
||||
#endif //OVERHEAD_CLOUD
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
uniform fixed4 _DetailOverlayTintColor;
|
||||
uniform samplerCUBE _DetailOverlayCubemap;
|
||||
uniform fixed _DetailOverlayLayer;
|
||||
uniform fixed _DetailOverlayRotationSpeed;
|
||||
#endif
|
||||
|
||||
//uniform float4x4 _SkyTransform;
|
||||
|
||||
v2f vert(appdata v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.localPos = v.vertex;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float4 localPos = float4(i.localPos.xyz, 1);
|
||||
//localPos = mul(_SkyTransform, localPos);
|
||||
float4 normalizedLocalPos = float4(normalize(localPos.xyz), 1);
|
||||
fixed4 color = fixed4(0,0,0,0);
|
||||
|
||||
fixed4 skyBlendColor;
|
||||
fixed4 horizonBlendColor;
|
||||
CalculateSkyGradientColor(
|
||||
normalizedLocalPos,
|
||||
_SkyColor, _HorizonColor, _GroundColor,
|
||||
_HorizonThickness, _HorizonExponent, _HorizonStep,
|
||||
skyBlendColor, horizonBlendColor);
|
||||
color = BlendOverlay(skyBlendColor, color);
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
fixed4 detailOverlayColor;
|
||||
#if DETAIL_OVERLAY_ROTATION
|
||||
CalculateDetailOverlayColor(
|
||||
i.localPos,
|
||||
_DetailOverlayCubemap,
|
||||
_DetailOverlayTintColor,
|
||||
_DetailOverlayRotationSpeed,
|
||||
detailOverlayColor);
|
||||
#else
|
||||
CalculateDetailOverlayColor(
|
||||
i.localPos,
|
||||
_DetailOverlayCubemap,
|
||||
_DetailOverlayTintColor,
|
||||
detailOverlayColor);
|
||||
#endif //DETAIL_OVERLAY_ROTATION
|
||||
|
||||
fixed isLayerEqual = _DetailOverlayLayer == 0;
|
||||
fixed4 overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif //DETAIL_OVERLAY
|
||||
|
||||
#if STARS
|
||||
fixed4 starsColor;
|
||||
#if STARS_BAKED
|
||||
CalculateStarsColorBaked(
|
||||
normalizedLocalPos,
|
||||
_StarsCubemap,
|
||||
_StarsTwinkleMap,
|
||||
_StarsOpacity,
|
||||
starsColor);
|
||||
#else
|
||||
#if STARS_LAYER_0
|
||||
fixed4 starsColor0;
|
||||
CalculateStarsColor(
|
||||
normalizedLocalPos,
|
||||
_StarsStartPosition, _StarsEndPosition,
|
||||
_StarsColor0, _StarsOpacity,
|
||||
_StarsDensity0,
|
||||
_StarsSize0,
|
||||
_StarsGlow0,
|
||||
_StarsTwinkle0,
|
||||
starsColor0);
|
||||
starsColor = starsColor0;
|
||||
#endif //STARS_LAYER_0
|
||||
|
||||
#if STARS_LAYER_1
|
||||
fixed4 starsColor1;
|
||||
CalculateStarsColor(
|
||||
normalizedLocalPos,
|
||||
_StarsStartPosition, _StarsEndPosition,
|
||||
_StarsColor1, _StarsOpacity,
|
||||
_StarsDensity1,
|
||||
_StarsSize1,
|
||||
_StarsGlow1,
|
||||
_StarsTwinkle1,
|
||||
starsColor1);
|
||||
starsColor = lerp(starsColor, starsColor1, starsColor1.a);
|
||||
#endif //STARS_LAYER_1
|
||||
|
||||
#if STARS_LAYER_2
|
||||
fixed4 starsColor2;
|
||||
CalculateStarsColor(
|
||||
normalizedLocalPos,
|
||||
_StarsStartPosition, _StarsEndPosition,
|
||||
_StarsColor2, _StarsOpacity,
|
||||
_StarsDensity2,
|
||||
_StarsSize2,
|
||||
_StarsGlow2,
|
||||
_StarsTwinkle2,
|
||||
starsColor2);
|
||||
starsColor = lerp(starsColor, starsColor2, starsColor2.a);
|
||||
#endif //STARS_LAYER_2
|
||||
#endif //STARS_BAKED
|
||||
|
||||
color = BlendOverlay(starsColor, color);
|
||||
#endif //STARS
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
isLayerEqual = _DetailOverlayLayer == 1;
|
||||
overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif //DETAIL_OVERLAY
|
||||
|
||||
#if SUN
|
||||
fixed4 sunColor;
|
||||
#if SUN_BAKED
|
||||
CalculateSunMoonColorBaked(
|
||||
normalizedLocalPos, _SunRotationMatrix,
|
||||
_SunCubemap,
|
||||
sunColor);
|
||||
#else
|
||||
#if SUN_USE_TEXTURE
|
||||
CalculateSunMoonColorTextured(
|
||||
normalizedLocalPos,
|
||||
_SunTex, _PositionToSunUV,
|
||||
_SunColor,
|
||||
_SunSize, _SunSoftEdge, _SunGlow,
|
||||
_SunDirection,
|
||||
sunColor);
|
||||
#else
|
||||
CalculateSunMoonColor(
|
||||
normalizedLocalPos,
|
||||
_SunColor,
|
||||
_SunSize, _SunSoftEdge, _SunGlow,
|
||||
_SunDirection,
|
||||
sunColor);
|
||||
#endif //SUN_USE_TEXTURE
|
||||
#endif //SUN_BAKED
|
||||
color = BlendOverlay(sunColor, color);
|
||||
#endif //SUN
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
isLayerEqual = _DetailOverlayLayer == 2;
|
||||
overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif //DETAIL_OVERLAY
|
||||
|
||||
#if MOON
|
||||
fixed4 moonColor;
|
||||
#if MOON_BAKED
|
||||
CalculateSunMoonColorBaked(
|
||||
normalizedLocalPos, _MoonRotationMatrix,
|
||||
_MoonCubemap,
|
||||
moonColor);
|
||||
#else
|
||||
#if MOON_USE_TEXTURE
|
||||
CalculateSunMoonColorTextured(
|
||||
normalizedLocalPos,
|
||||
_MoonTex, _PositionToMoonUV,
|
||||
_MoonColor,
|
||||
_MoonSize, _MoonSoftEdge, _MoonGlow,
|
||||
_MoonDirection,
|
||||
moonColor);
|
||||
#else
|
||||
CalculateSunMoonColor(
|
||||
normalizedLocalPos,
|
||||
_MoonColor,
|
||||
_MoonSize, _MoonSoftEdge, _MoonGlow,
|
||||
_MoonDirection,
|
||||
moonColor);
|
||||
#endif //MOON_USE_TEXTURE
|
||||
#endif //MOON_BAKED
|
||||
color = BlendOverlay(moonColor, color);
|
||||
#endif //MOON
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
isLayerEqual = _DetailOverlayLayer == 3;
|
||||
overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif
|
||||
|
||||
#if HORIZON_CLOUD
|
||||
fixed4 horizonCloudColor;
|
||||
CalculateHorizonCloudColor(
|
||||
normalizedLocalPos,
|
||||
_HorizonCloudColor,
|
||||
_HorizonCloudStartPosition, _HorizonCloudEndPosition,
|
||||
_HorizonCloudSize, _HorizonCloudStep,
|
||||
_HorizonCloudAnimationSpeed,
|
||||
horizonCloudColor);
|
||||
color = BlendOverlay(horizonCloudColor, color);
|
||||
#endif
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
isLayerEqual = _DetailOverlayLayer == 4;
|
||||
overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif
|
||||
|
||||
#if OVERHEAD_CLOUD
|
||||
fixed4 overheadCloudColor;
|
||||
CalculateOverheadCloudColor(
|
||||
normalizedLocalPos,
|
||||
_OverheadCloudColor,
|
||||
_OverheadCloudAltitude,
|
||||
_OverheadCloudSize,
|
||||
_OverheadCloudStep,
|
||||
_OverheadCloudAnimationSpeed,
|
||||
_OverheadCloudFlowDirectionX,
|
||||
_OverheadCloudFlowDirectionZ,
|
||||
_OverheadCloudRemapMin,
|
||||
_OverheadCloudRemapMax,
|
||||
overheadCloudColor);
|
||||
color = BlendOverlay(overheadCloudColor, color);
|
||||
#endif
|
||||
|
||||
#if DETAIL_OVERLAY
|
||||
isLayerEqual = _DetailOverlayLayer == 5;
|
||||
overlay = detailOverlayColor;
|
||||
overlay.a *= isLayerEqual;
|
||||
color = BlendOverlay(overlay, color);
|
||||
#endif
|
||||
|
||||
color = BlendOverlay(horizonBlendColor, color);
|
||||
|
||||
//color = float4(localPos.xyz, 1);
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
Fallback "Unlit/Color"
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
Shader "Jupiter/SkyShadow"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[HideInInspector] _OverheadCloudColor("Overhead Cloud Color", Color) = (1, 1, 1, 0.5)
|
||||
[HideInInspector] _OverheadCloudAltitude("Overhead Cloud Altitude", Float) = 1000
|
||||
[HideInInspector] _OverheadCloudSize("Overhead Cloud Size", Float) = 100
|
||||
[HideInInspector] _OverheadCloudStep("Overhead Cloud Step", Float) = 25
|
||||
[HideInInspector] _OverheadCloudAnimationSpeed("Overhead Cloud Animation Speed", Float) = 1
|
||||
[HideInInspector] _OverheadCloudFlowDirectionX("Overhead Cloud Flow X", Float) = 1
|
||||
[HideInInspector] _OverheadCloudFlowDirectionZ("Overhead Cloud Flow X", Float) = 1
|
||||
[HideInInspector] _OverheadCloudRemapMin("Overhead Cloud Remap Min", Float) = 0
|
||||
[HideInInspector] _OverheadCloudRemapMax("Overhead Cloud Remap Max", Float) = 1
|
||||
[HideInInspector] _OverheadCloudShadowClipMask("Overhead Cloud Shadow Clip Mask", Float) = 0.1
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode" = "ShadowCaster" }
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile_instancing // allow instanced shadow pass for most of the shaders
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#pragma shader_feature_local ALLOW_STEP_EFFECT
|
||||
|
||||
#include "./CGIncludes/JCommon.cginc"
|
||||
#include "./CGIncludes/JOverheadCloud.cginc"
|
||||
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
float3 localPos : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform fixed4 _OverheadCloudColor;
|
||||
uniform fixed _OverheadCloudAltitude;
|
||||
uniform fixed _OverheadCloudSize;
|
||||
uniform fixed _OverheadCloudStep;
|
||||
uniform fixed _OverheadCloudAnimationSpeed;
|
||||
uniform fixed _OverheadCloudFlowDirectionX;
|
||||
uniform fixed _OverheadCloudFlowDirectionZ;
|
||||
uniform fixed _OverheadCloudRemapMin;
|
||||
uniform fixed _OverheadCloudRemapMax;
|
||||
uniform fixed _OverheadCloudShadowClipMask;
|
||||
|
||||
v2f vert(appdata_base v)
|
||||
{
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
|
||||
o.localPos = v.vertex;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag(v2f i) : SV_Target
|
||||
{
|
||||
float4 localPos = float4(i.localPos.xyz, 1);
|
||||
float4 normalizedLocalPos = float4(normalize(localPos.xyz), 1);
|
||||
fixed4 overheadCloudColor;
|
||||
CalculateOverheadCloudColor(
|
||||
normalizedLocalPos,
|
||||
_OverheadCloudColor,
|
||||
_OverheadCloudAltitude,
|
||||
_OverheadCloudSize, _OverheadCloudStep,
|
||||
_OverheadCloudAnimationSpeed,
|
||||
_OverheadCloudFlowDirectionX, _OverheadCloudFlowDirectionZ,
|
||||
_OverheadCloudRemapMin, _OverheadCloudRemapMax,
|
||||
overheadCloudColor);
|
||||
clip(overheadCloudColor.a - _OverheadCloudShadowClipMask);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 111 KiB |
Binary file not shown.
After Width: | Height: | Size: 117 KiB |
Reference in New Issue
Block a user