Hi everyone, complete newbie here. I’m trying to render a simple mesh (triangle) on the screen with default renderer but only get a black screen. I’m able to successfully render a debug message (using msg.post
) though. I can see the triangle properly rendered in Defold (see bottom of my post). Would appreciate your insights on how I could get this thing working.
Relevant code
triangle.buffer:
[
{
"name": "position",
"type": "float32",
"count": 3,
"data": [-0.5, -0.5, 0,
0.5, -0.5, 0,
0.0, 0.5, 0]
},
{
"name": "color0",
"type": "float32",
"count": 4,
"data": [0, 1, 0, 1,
0, 1, 0, 1,
0, 1, 0, 1]
}
]
triangle.mesh
:
material: "/main/triangle.material"
vertices: "/main/triangle.buffer"
position_stream: "position"
normal_stream: "position"
triangle.material
name: "triangle"
tags: "triangle"
vertex_program: "/main/triangle.vp"
fragment_program: "/main/triangle.fp"
vertex_constants {
name: "mtx_proj"
type: CONSTANT_TYPE_PROJECTION
}
vertex_constants {
name: "mtx_worldview"
type: CONSTANT_TYPE_WORLDVIEW
}
VP
uniform mediump mat4 mtx_worldview;
uniform mediump mat4 mtx_proj;
attribute mediump vec4 position;
attribute mediump vec4 color0;
varying mediump vec4 var_color;
void main()
{
gl_Position = mtx_proj * mtx_worldview * vec4(position.xyz, 1.0);
var_color = color0;
}
FP
varying mediump vec4 var_color;
void main()
{
gl_FragColor = var_color;
}
main.collection
name: "main"
scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"script\"\n"
" component: \"/main/triangle.script\"\n"
"}\n"
"components {\n"
" id: \"mesh\"\n"
" component: \"/main/triangle.mesh\"\n"
"}\n"
""
}