Tooltip
This commit is contained in:
parent
d4b50bdda0
commit
21a4adf229
16 changed files with 136 additions and 24 deletions
|
|
@ -12,7 +12,48 @@ enum DisplayType{
|
|||
material_override.set_shader_parameter("wave_intensity",1.)
|
||||
tween.tween_property(material_override,"shader_parameter/wave_intensity",0.0,2.0)
|
||||
|
||||
func update_material(substances: Array[RuntimeSubstanceData]) -> void:
|
||||
func update_fluid_material(substances: Array[RuntimeSubstanceData]) -> void:
|
||||
var mat: ShaderMaterial = material_override
|
||||
if len(substances) == 0:
|
||||
visible = false
|
||||
return
|
||||
else:
|
||||
visible = true
|
||||
|
||||
var total_weight = 0
|
||||
var total_color = 0
|
||||
|
||||
for sub in substances:
|
||||
total_weight += sub.amount
|
||||
total_color += sub.substance.color_influence
|
||||
|
||||
var pH: float = 0
|
||||
var color: Color = Color(0,0,0,0)
|
||||
|
||||
for sub: RuntimeSubstanceData in substances:
|
||||
var weight: float = sub.amount/total_weight
|
||||
pH += sub.substance.get_ph_runtime(substances) * weight
|
||||
|
||||
for sub: RuntimeSubstanceData in substances:
|
||||
var color_to_add: Color
|
||||
if sub.substance.pHColor != null:
|
||||
color_to_add = sub.substance.pHColor.sample(pH/14.0)
|
||||
else:
|
||||
color_to_add = sub.substance.color
|
||||
|
||||
if display_type == DisplayType.Fluid and sub.is_solution:
|
||||
color_to_add.a = 0.5
|
||||
|
||||
#if color == Color(0,0,0,0):
|
||||
# color = color_to_add
|
||||
#else:
|
||||
# color = color.lerp(color_to_add,sub.substance.color_influence)
|
||||
color += color_to_add * sub.substance.color_influence
|
||||
|
||||
|
||||
mat.set_shader_parameter("albedo_color", color / total_color)
|
||||
|
||||
func update_solid_material(substances: Array[RuntimeSubstanceData]) -> void:
|
||||
var mat: StandardMaterial3D = material_override
|
||||
if len(substances) == 0:
|
||||
visible = false
|
||||
|
|
@ -57,10 +98,10 @@ func update_material_unfiltered(substances: Array[RuntimeSubstanceData]):
|
|||
match display_type:
|
||||
DisplayType.Fluid:
|
||||
var fluids = substances.filter(filter_liquids)
|
||||
update_material(fluids)
|
||||
update_fluid_material(fluids)
|
||||
DisplayType.Solid:
|
||||
var solids = substances.filter(filter_solids)
|
||||
update_material(solids)
|
||||
update_solid_material(solids)
|
||||
|
||||
func filter_liquids(sub: RuntimeSubstanceData): return sub.substance.melting_point < sub.temperature or sub.is_solution
|
||||
func filter_solids(sub: RuntimeSubstanceData): return sub.substance.melting_point > sub.temperature and not sub.is_solution
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue