DAE Export (SOLVED)

Hi guys, I’m looking for suggestions about exporting Collada models from Blender.
I’m trying to create a vertex shader that modifies vertex position and I see errors with interpolation.
It looks like something wrong with the model because using builtin model from Defold works fine.
My models:
12 15
Builtin model:
45

Perhaps @JCash, @dlannan or @Pkeod has some idea what is wrong?

This looks like something @roccosaienz helped me with on the Discord server #shaders room. If you go there and scroll up you can see some of the discussion.

I think the problem/solution was the difference between smooth shaded and flat shaded models.

https://docs.blender.org/manual/en/2.80/modeling/meshes/editing/normals.html

1 Like

I think this is what Pkeod is referring to. Looks very similar problem:

When modifying vert position make sure you take note of the shader docs. Some verts may come in as world verts and thus applying worldmatrix again will produce incorrect results:

In most of my vp shaders position is simply:
gl_Position = mtx_proj * mtx_view * mtx_world * position.xyz
However you can mix this up a bit for example:
gl_Position = mtx_proj * mtx_worldview * position.xyz
Make sure the settings in the material match what you want, you can set mtx_world to MatrixWorldView which will make a mess of things.

Hope that helps.

2 Likes

Hi @ghpxi.

Are you using our model component or mesh component?
(only our model component support index buffers currently)

How are you modifying the vertex?
Are you using the vertex normal?

My guess in your scenario is that you have unique vertices.
As such, those vertices may have different normals, and will then be projected to different places.

Two possible solutions to that:

  • Smooth the normals, and make sure they point in the same direction.
  • Weld the vertices, making sure each vertex connecting the triangles, is actually unique.

I would go for the second option, of welding the vertices.

2 Likes

Sorry for the late response.

Yes, I’m using normals and model component, something like this:

gl_Position = position + normal * sin(time)

Smoothing normals in the blender fix the issue, but it looks strange, e.g. if I try to create a simple box, in the Blender, it looks incorrectly, but in Defold, everything is fine.

I use a sphere from the default preset, and it should be already welded.

Smooth shading looks strange with a geometric object as a cube, sure. But is the shading that is wrong, since the fragment shader is interpolating the different normals among the vertices when it computes the “illumination” of the fragments.

I would say that with the original models you posted here the smooth shading should looks fine.

1 Like