Skip to content

Commit

Permalink
temp: correct lyered UV texture over shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
akorzunin committed Aug 23, 2024
1 parent 2f4e69a commit 8961bfd
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/globals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var D = {
var data := {}
var settings := {
SCALE_FACTOR = DafaultConfig.settings.game_settings.SCALE_FACTOR,
ROTATION_SPEED = DafaultConfig.settings.game_settings.ROTATION_SPEED,
}

# global signals
Expand Down
1 change: 1 addition & 0 deletions src/models/icosahedron/Icosahedron.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ shader_parameter/color = Vector3(0, 1, 0)

[node name="Icosahedron" type="Node3D"]
script = ExtResource("1_w7qn7")
shader_type = -1

[node name="CutPlane" type="MeshInstance3D" parent="."]
transform = Transform3D(-0.761007, -0.570635, -0.308616, -0.107281, 0.579858, -0.807623, 0.639811, -0.581498, -0.502495, -0.843964, 0.0584427, -0.468957)
Expand Down
5 changes: 1 addition & 4 deletions src/models/icosahedron/components/Icosahedron.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ const EDGE_NOISE = preload('res://src/models/icosahedron/resources/edge_noise.re
@export var DEBUG_VISUAL: bool
@export var scaling_enabled = false
@export var scale_factor: float
@export var shader_type: int = 0:
set(val):
shader_type = val
#set_shader_type(val)
@export var shader_type: int
var show_face_numbers: bool
@export var inital_transfrm := Quaternion()
@onready var cut_plane: CutPlane = $CutPlane
Expand Down
28 changes: 21 additions & 7 deletions src/models/icosahedron/components/MeshIcosahedron.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,27 @@ const MATERIAL_002 = preload('res://src/models/icosahedron/test/Material.face_in
EDGE_HIGHLIGHT_V_1,
]

@export var default_shaders := [
ICOSAHEDRON_SHADER_V_1,
OUTLINE_V_1,
]

@onready var icosahedron: Icosahedron = $".."
@onready var collider: Collider = $'../Collider'

var angle_good := false
var is_alt := false
var is_rotating := false
@export var currnt_type := -1
var currnt_type : int
var show_face_numbers := false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
currnt_type = icosahedron.shader_type
show_face_numbers = icosahedron.show_face_numbers
set_type(currnt_type)
if currnt_type >= 0:
set_type(currnt_type)
else:
set_default_type()
if Utils.main_scene(self) in ['MainScene', 'LoopScene', 'MenuScene']:
# wierd trick to not get errors when scaling and rotating mesh when its mounted in runtime
transform.basis = Basis(icosahedron.transform.basis.get_rotation_quaternion())
Expand All @@ -48,13 +56,19 @@ func set_color(c: Vector3):
ShaderUtils.set_shader_param(self, "color", c, i)

func set_type(type: int):
currnt_type = type
var variant: Vector4 = IcosahedronVarints.figure_variants_v2[type]
if show_face_numbers:
self.material_override = MATERIAL_002
else:
ShaderUtils.apply_shaders(applied_shaders, self)

self.material_overlay = MATERIAL_002
ShaderUtils.apply_shaders(applied_shaders, self)
ShaderUtils.set_shader_param(self, "cutplane_visible", 0, 0)
set_cutplane(variant)
var variant_color: Array = TwTheme.figure_variants_v2[type]
set_color(Op.v3(variant_color))

func set_default_type():
if show_face_numbers:
self.material_overlay = MATERIAL_002
ShaderUtils.apply_shaders(default_shaders, self)

var variant_color: Array = TwTheme.T.figure_variants.default
set_color(Op.v3(variant_color))
18 changes: 15 additions & 3 deletions src/models/icosahedron/test/variant_test.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@ extends Node3D

const IcosahedronScene = preload('res://src/models/icosahedron/Icosahedron.tscn')
var controlledNode
# TODO get from defaults

@export var ROTATION_SPEED: float = G.settings.ROTATION_SPEED
@export var show_face_numbers: bool = false

@export_category("variant settings")
@export var show_face_numbers: bool = true
@export_range(0, 19) var variant_type: int = 0
@export var use_default := false

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var new_figure = IcosahedronScene.instantiate().with_type(1).with_face_numbers(show_face_numbers)
var new_figure
if use_default:
new_figure = IcosahedronScene.instantiate()
else:
new_figure = IcosahedronScene.instantiate()\
.with_type(variant_type)\
.with_face_numbers(show_face_numbers)

add_child(new_figure)
controlledNode = new_figure.mesh_icosahedron

Expand Down
2 changes: 1 addition & 1 deletion src/models/icosahedron/test/variant_test.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ shader_parameter/bg_color = Color(0.729, 0.902, 0.992, 1)

[node name="VariantTest" type="Node3D"]
script = ExtResource("1_4av47")
show_face_numbers = true
use_default = true

[node name="Environment" type="Node3D" parent="."]

Expand Down

0 comments on commit 8961bfd

Please sign in to comment.