Better texture node.

This commit is contained in:
Roz K 2022-12-31 21:45:29 +01:00
parent acc2e4cd28
commit dd786ef2b4
Signed by: roz
GPG Key ID: 51FBF4E483E1C822
2 changed files with 20 additions and 17 deletions

View File

@ -158,24 +158,26 @@ def create_scene(keyboard, mouse):
sea_triangles = sea.sea_triangles(64, proj_far_z - 0.1, proj_ratio) sea_triangles = sea.sea_triangles(64, proj_far_z - 0.1, proj_ratio)
return SceneNode( return SceneNode(
FuncNode(update_camera, (mouse, camera, environment)), TextureNode({1: heightmap, 2: normalmap},
TextureNode((tiles_texture, heightmap, normalmap), FuncNode(update_camera, (mouse, camera, environment)),
ShaderNode(tiles_shader, TextureNode({0: tiles_texture},
InputNode(tiles_shader, camera), ShaderNode(tiles_shader,
InputNode(tiles_shader, environment), InputNode(tiles_shader, camera),
DrawNode(tiles_batch) InputNode(tiles_shader, environment),
) DrawNode(tiles_batch)
), )
FuncNode(update_tests, (blob, cube, clouds)), ),
TextureNode((tests_texture, heightmap, normalmap), FuncNode(update_tests, (blob, cube, clouds)),
ShaderNode(tests_shader, TextureNode({0: tests_texture},
InputNode(tests_shader, camera), ShaderNode(tests_shader,
InputNode(tests_shader, environment), InputNode(tests_shader, camera),
DrawNode(tests_batch) InputNode(tests_shader, environment),
DrawNode(tests_batch)
)
) )
), ),
FuncNode(update_sea, (camera, sea_phase)), FuncNode(update_sea, (camera, sea_phase)),
TextureNode((sea_polar_textures, sea_detail_texture), TextureNode({0: sea_polar_textures, 1: sea_detail_texture},
ShaderNode(sea_shader, ShaderNode(sea_shader,
InputNode(sea_shader, camera), InputNode(sea_shader, camera),
InputNode(sea_shader, environment), InputNode(sea_shader, environment),

View File

@ -34,10 +34,11 @@ class TextureNode(Node):
self._textures = textures self._textures = textures
def draw(self, time): def draw(self, time):
for slot, texture in enumerate(self._textures): items = self._textures.items()
for slot, texture in items:
texture.select(slot) texture.select(slot)
Node.draw(self, time) Node.draw(self, time)
for slot, texture in enumerate(self._textures): for slot, texture in items:
texture.unselect(slot) texture.unselect(slot)
class ShaderNode(Node): class ShaderNode(Node):