feat(textures): atlas blocs tileable + UV mapping Chunk.gd (supprime vertex colors)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,72 +10,120 @@ enum BlockType {
|
||||
KELP = 6,
|
||||
WRECK_WOOD = 7,
|
||||
ICE = 8,
|
||||
BEDROCK = 9
|
||||
BEDROCK = 9,
|
||||
GLOW_CORAL_CYAN = 10,
|
||||
GLOW_CORAL_VIOLET = 11,
|
||||
LAVA_VENT = 12
|
||||
}
|
||||
|
||||
# Atlas is 4x4 tiles, each tile = 0.25 of atlas width/height
|
||||
const ATLAS_TILE_SIZE: Vector2 = Vector2(0.25, 0.25)
|
||||
|
||||
const _BLOCKS: Dictionary = {
|
||||
BlockType.AIR: {
|
||||
"name": "Air",
|
||||
"color": Color(0.0, 0.0, 0.0, 0.0),
|
||||
"hardness": 0.0,
|
||||
"drops": []
|
||||
"drops": [],
|
||||
"atlas_uv": Vector2(0.0, 0.0) # unused, AIR not rendered
|
||||
},
|
||||
BlockType.WATER: {
|
||||
"name": "Eau",
|
||||
"color": Color(0.1, 0.4, 0.8, 0.6),
|
||||
"hardness": 0.0,
|
||||
"drops": []
|
||||
"drops": [],
|
||||
"atlas_uv": Vector2(0.0, 0.0) # unused, WATER not solid
|
||||
},
|
||||
BlockType.SAND: {
|
||||
"name": "Sable",
|
||||
"color": Color(0.76, 0.70, 0.50, 1.0),
|
||||
"hardness": 0.5,
|
||||
"drops": [BlockType.SAND]
|
||||
"drops": [BlockType.SAND],
|
||||
"atlas_uv": Vector2(0.0, 0.0) # row 0, col 0
|
||||
},
|
||||
BlockType.ROCK: {
|
||||
"name": "Roche",
|
||||
"color": Color(0.45, 0.45, 0.45, 1.0),
|
||||
"hardness": 2.0,
|
||||
"drops": [BlockType.ROCK]
|
||||
"drops": [BlockType.ROCK],
|
||||
"atlas_uv": Vector2(0.25, 0.0) # row 0, col 1
|
||||
},
|
||||
BlockType.CORAL_RED: {
|
||||
"name": "Corail Rouge",
|
||||
"color": Color(0.90, 0.25, 0.20, 1.0),
|
||||
"hardness": 0.3,
|
||||
"drops": [BlockType.CORAL_RED]
|
||||
"drops": [BlockType.CORAL_RED],
|
||||
"atlas_uv": Vector2(0.5, 0.0) # row 0, col 2
|
||||
},
|
||||
BlockType.CORAL_BLUE: {
|
||||
"name": "Corail Bleu",
|
||||
"color": Color(0.20, 0.50, 0.95, 1.0),
|
||||
"hardness": 0.3,
|
||||
"drops": [BlockType.CORAL_BLUE]
|
||||
"drops": [BlockType.CORAL_BLUE],
|
||||
"atlas_uv": Vector2(0.75, 0.0) # row 0, col 3
|
||||
},
|
||||
BlockType.KELP: {
|
||||
"name": "Algue",
|
||||
"color": Color(0.15, 0.60, 0.20, 1.0),
|
||||
"hardness": 0.1,
|
||||
"drops": [BlockType.KELP]
|
||||
"drops": [BlockType.KELP],
|
||||
"atlas_uv": Vector2(0.0, 0.25) # row 1, col 0
|
||||
},
|
||||
BlockType.WRECK_WOOD: {
|
||||
"name": "Bois d'Épave",
|
||||
"color": Color(0.35, 0.22, 0.12, 1.0),
|
||||
"hardness": 1.0,
|
||||
"drops": [BlockType.WRECK_WOOD]
|
||||
"drops": [BlockType.WRECK_WOOD],
|
||||
"atlas_uv": Vector2(0.25, 0.25) # row 1, col 1
|
||||
},
|
||||
BlockType.ICE: {
|
||||
"name": "Glace",
|
||||
"color": Color(0.75, 0.90, 1.0, 0.85),
|
||||
"hardness": 0.8,
|
||||
"drops": []
|
||||
"drops": [],
|
||||
"atlas_uv": Vector2(0.5, 0.25) # row 1, col 2
|
||||
},
|
||||
BlockType.BEDROCK: {
|
||||
"name": "Bedrock",
|
||||
"color": Color(0.15, 0.15, 0.15, 1.0),
|
||||
"hardness": -1.0,
|
||||
"drops": []
|
||||
"drops": [],
|
||||
"atlas_uv": Vector2(0.75, 0.25) # row 1, col 3
|
||||
},
|
||||
BlockType.GLOW_CORAL_CYAN: {
|
||||
"name": "Corail Bio Cyan",
|
||||
"color": Color(0.2, 0.8, 1.0, 1.0),
|
||||
"hardness": 0.3,
|
||||
"drops": [BlockType.GLOW_CORAL_CYAN],
|
||||
"atlas_uv": Vector2(0.0, 0.5), # row 2, col 0
|
||||
"emission": Color(0.2, 0.8, 1.0),
|
||||
"emission_energy": 3.0
|
||||
},
|
||||
BlockType.GLOW_CORAL_VIOLET: {
|
||||
"name": "Corail Bio Violet",
|
||||
"color": Color(0.7, 0.3, 0.9, 1.0),
|
||||
"hardness": 0.3,
|
||||
"drops": [BlockType.GLOW_CORAL_VIOLET],
|
||||
"atlas_uv": Vector2(0.25, 0.5), # row 2, col 1
|
||||
"emission": Color(0.7, 0.3, 0.9),
|
||||
"emission_energy": 3.0
|
||||
},
|
||||
BlockType.LAVA_VENT: {
|
||||
"name": "Cheminée Hydrothermale",
|
||||
"color": Color(1.0, 0.5, 0.1, 1.0),
|
||||
"hardness": 3.0,
|
||||
"drops": [BlockType.LAVA_VENT],
|
||||
"atlas_uv": Vector2(0.5, 0.5), # row 2, col 2
|
||||
"emission": Color(1.0, 0.5, 0.1),
|
||||
"emission_energy": 3.0
|
||||
}
|
||||
}
|
||||
|
||||
func get_atlas_uv(id: int) -> Vector2:
|
||||
if _BLOCKS.has(id):
|
||||
return _BLOCKS[id]["atlas_uv"]
|
||||
return Vector2(0.0, 0.0)
|
||||
|
||||
func is_solid(id: int) -> bool:
|
||||
if id == BlockType.AIR or id == BlockType.WATER or id == BlockType.KELP:
|
||||
return false
|
||||
@@ -100,3 +148,18 @@ func get_drops(id: int) -> Array:
|
||||
if _BLOCKS.has(id):
|
||||
return _BLOCKS[id]["drops"]
|
||||
return []
|
||||
|
||||
func is_emissive(id: int) -> bool:
|
||||
if _BLOCKS.has(id):
|
||||
return _BLOCKS[id].has("emission")
|
||||
return false
|
||||
|
||||
func get_emission_color(id: int) -> Color:
|
||||
if _BLOCKS.has(id) and _BLOCKS[id].has("emission"):
|
||||
return _BLOCKS[id]["emission"]
|
||||
return Color(0.0, 0.0, 0.0)
|
||||
|
||||
func get_emission_energy(id: int) -> float:
|
||||
if _BLOCKS.has(id) and _BLOCKS[id].has("emission_energy"):
|
||||
return _BLOCKS[id]["emission_energy"]
|
||||
return 1.0
|
||||
|
||||
Reference in New Issue
Block a user