Improve tree gathering and rain occlusion
This commit is contained in:
parent
a7c71213cc
commit
3608be41ab
8 changed files with 165 additions and 2 deletions
|
|
@ -17,6 +17,8 @@ const LIGHT_RAIN_FIXED_FPS: int = 8
|
|||
const RAIN_VELOCITY_MIN: float = 16.0
|
||||
const RAIN_VELOCITY_MAX: float = 20.0
|
||||
const RAIN_DROP_SIZE := Vector3(0.014, 0.34, 0.014)
|
||||
const RAIN_COLLISION_BASE_SIZE: float = 0.08
|
||||
const RAIN_COLLISION_SIZE := Vector3(28.0, 24.0, 28.0)
|
||||
const FOG_DAYLIGHT_SCENE_BRIGHTNESS: float = 0.42
|
||||
const FOG_DAYLIGHT_FOG_LIGHT_BRIGHTNESS: float = 0.42
|
||||
const FOG_DAYLIGHT_WATER_BRIGHTNESS: float = 0.42
|
||||
|
|
@ -37,6 +39,9 @@ const FRESH_WATER_MATERIAL: ShaderMaterial = preload(
|
|||
const LocalStormCloudLayerType = preload(
|
||||
"res://world/environment/local_storm_cloud_layer.gd"
|
||||
)
|
||||
const PrecipitationOcclusionType = preload(
|
||||
"res://world/environment/precipitation_occlusion.gd"
|
||||
)
|
||||
|
||||
const DAY_SKY_TOP := Color(0.204, 0.498, 0.643)
|
||||
const DAY_SKY_HORIZON := Color(0.663, 0.843, 0.847)
|
||||
|
|
@ -88,6 +93,7 @@ var _rain_camera_provider: Callable
|
|||
var _environment: Environment
|
||||
var _sky_material: ShaderMaterial
|
||||
var _rain: GPUParticles3D
|
||||
var _rain_collision: GPUParticlesCollisionHeightField3D
|
||||
var _storm_clouds: LocalStormCloudLayer
|
||||
var _elapsed: float = 0.0
|
||||
var _weather_from: WorldWeatherService.Weather = (
|
||||
|
|
@ -211,6 +217,7 @@ func _prepare_rain() -> void:
|
|||
LIGHT_RAIN_FIXED_FPS if _light_performance_profile else 30
|
||||
)
|
||||
_rain.local_coords = false
|
||||
_rain.collision_base_size = RAIN_COLLISION_BASE_SIZE
|
||||
_rain.visibility_aabb = RAIN_VISIBILITY_AABB
|
||||
var process_material := ParticleProcessMaterial.new()
|
||||
process_material.emission_shape = (
|
||||
|
|
@ -222,6 +229,9 @@ func _prepare_rain() -> void:
|
|||
process_material.initial_velocity_min = RAIN_VELOCITY_MIN
|
||||
process_material.initial_velocity_max = RAIN_VELOCITY_MAX
|
||||
process_material.gravity = Vector3(0.0, -2.0, 0.0)
|
||||
process_material.collision_mode = (
|
||||
ParticleProcessMaterial.COLLISION_HIDE_ON_CONTACT
|
||||
)
|
||||
_rain.process_material = process_material
|
||||
var drop_mesh := BoxMesh.new()
|
||||
drop_mesh.size = RAIN_DROP_SIZE
|
||||
|
|
@ -232,9 +242,30 @@ func _prepare_rain() -> void:
|
|||
drop_mesh.material = drop_material
|
||||
_rain.draw_pass_1 = drop_mesh
|
||||
add_child(_rain)
|
||||
_prepare_rain_collision()
|
||||
_update_rain_position()
|
||||
|
||||
|
||||
func _prepare_rain_collision() -> void:
|
||||
_rain_collision = GPUParticlesCollisionHeightField3D.new()
|
||||
_rain_collision.name = "LocalRainCanopyCollision"
|
||||
_rain_collision.size = RAIN_COLLISION_SIZE
|
||||
_rain_collision.resolution = (
|
||||
GPUParticlesCollisionHeightField3D.RESOLUTION_256
|
||||
)
|
||||
_rain_collision.update_mode = (
|
||||
GPUParticlesCollisionHeightField3D.UPDATE_MODE_WHEN_MOVED
|
||||
)
|
||||
_rain_collision.follow_camera_enabled = true
|
||||
_rain_collision.heightfield_mask = (
|
||||
PrecipitationOcclusionType.RENDER_LAYER_MASK
|
||||
)
|
||||
# Local rain remains on its normal layer; unrelated particle systems do not
|
||||
# need to query this weather-specific collision field.
|
||||
_rain_collision.cull_mask = 1
|
||||
add_child(_rain_collision)
|
||||
|
||||
|
||||
func _prepare_storm_clouds() -> void:
|
||||
_storm_clouds = LocalStormCloudLayerType.new()
|
||||
_storm_clouds.name = "LocalStormClouds"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue