comparison examples/E03_hello_cube.nim @ 1141:d3e014c3551c

fix: cude example perspective matrix
author sam <sam@basx.dev>
date Sat, 08 Jun 2024 15:19:58 +0700
parents 5934c5615f13
children
comparison
equal deleted inserted replaced
1140:5934c5615f13 1141:d3e014c3551c
54 Attr[Mat4]("projection"), 54 Attr[Mat4]("projection"),
55 Attr[Mat4]("view"), 55 Attr[Mat4]("view"),
56 Attr[Mat4]("model"), 56 Attr[Mat4]("model"),
57 ], 57 ],
58 outputs = [Attr[Vec4f]("color")], 58 outputs = [Attr[Vec4f]("color")],
59 vertexCode = """outcolor = color; gl_Position = (Uniforms.projection * Uniforms.view * Uniforms.model) * vec4(position, 1);""", 59 vertexCode = """
60 outcolor = color;
61 // gl_Position = vec4(position, 1) * (Uniforms.model * Uniforms.projection * Uniforms.view);
62 gl_Position = vec4(position, 1) * (Uniforms.model * Uniforms.projection * Uniforms.view);
63 """,
60 fragmentCode = "color = outcolor;", 64 fragmentCode = "color = outcolor;",
61 ) 65 )
62 var matDef = MaterialType(name: "default material", vertexAttributes: {"position": Vec3F32, "color": Vec4F32}.toTable) 66 var matDef = MaterialType(name: "default material", vertexAttributes: {"position": Vec3F32, "color": Vec4F32}.toTable)
63 var cube = Scene(name: "scene", meshes: @[NewMesh(positions = cube_pos, indices = tris, colors = cube_color, material = matDef.InitMaterialData(name = "default"))]) 67 var cube = Scene(name: "scene", meshes: @[NewMesh(positions = cube_pos, indices = tris, colors = cube_color, material = matDef.InitMaterialData(name = "default"))])
64 cube.AddShaderGlobal("projection", Unit4f32) 68 cube.AddShaderGlobal("projection", Unit4f32)