Skip to content

Commit

Permalink
Workaround for #316 and fix for Viewport resizing
Browse files Browse the repository at this point in the history
This makes the screenshot tool functional again, but doesn't close the issue since it's a workaround that seems like it might not be 100% stable
  • Loading branch information
LandscapeLab Office committed Apr 19, 2023
1 parent 50b1867 commit f383e71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Global/Screencapture.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ func screenshot(
pos_manager.get_viewport().set_use_taa(false)
pos_manager.get_viewport().set_msaa_3d(Viewport.MSAA_MAX)

pos_manager.get_viewport().get_parent().stretch = false
pos_manager.get_viewport().size = previous_viewport_size * upscale_viewport
Vegetation.plant_extent_factor = plant_extent

#await get_tree().create_timer(1).timeout

RenderingServer.force_sync()
RenderingServer.force_draw()
await get_tree().process_frame
await get_tree().process_frame
await get_tree().process_frame

# get data of the viewport
var image = pos_manager.get_viewport().get_texture().get_image()
Expand All @@ -53,12 +57,15 @@ func screenshot(
image.save_png(image_name)

# Reset to prior configuration
pos_manager.get_viewport().size = previous_viewport_size
pos_manager.get_viewport().get_parent().stretch = true
Vegetation.plant_extent_factor = previous_plant_extent_factor
pos_manager.get_viewport().set_use_taa(taa_before)
pos_manager.get_viewport().set_msaa_3d(msaa_before)

RenderingServer.force_sync()
RenderingServer.force_draw()
await get_tree().process_frame
await get_tree().process_frame
await get_tree().process_frame

screenshot_finished.emit()
2 changes: 1 addition & 1 deletion Layers/Renderers/RasterVegetation/VegetationParticles.gd
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func apply_data():
# Row crops
if density_class.id == 6:
process_material.set_shader_parameter("row_spacing", 3.0)


func apply_wind_speed(wind_speed):
material_override.set_shader_parameter("speed", Vector2(wind_speed, wind_speed) / 160.0)
Expand Down
3 changes: 1 addition & 2 deletions Layers/Renderers/RasterVegetation/VegetationParticles.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ shader_parameter/uv_offset = null
[node name="VegetationParticles" type="GPUParticles3D"]
layers = 2
material_override = SubResource("ShaderMaterial_oyqth")
cast_shadow = 0
amount = 1
explosiveness = 1.0
fixed_fps = 0
fixed_fps = 1
interpolate = false
fract_delta = false
visibility_aabb = AABB(-150, -150, -150, 300, 300, 300)
Expand Down

0 comments on commit f383e71

Please sign in to comment.