CodeChickenCore

CodeChickenCore

31M Downloads

Rendering model with a rotation op yields incorrect results.

MrTJP opened this issue · 3 comments

commented

Unless I am mistaken, applying a transformation to a model should be the same as rendering it with the transformation in-line. If you apply a rotation and then render the model with the light matrix, it works correctly. The model is properly shaded on the correct sides. However, if you render the model without the transformation pre-applied, it seems that the rotation will actually rotate the light matrix's shading.

This is for static rendering, by the way.

Correct results:

  1. Reset renderstate
  2. Locate renderstate lightmatrix
  3. Apply rotation to model
  4. Render model with (uv transformation, light matrix)

Incorrect results:

  1. Reset renderstate
  2. Locate renderstate lightmatrix
  3. Render model with (rotation, uv transformation, light matrix)

I don't have a complete understanding of how the lighting works, but I think its because the light matrix applies colour shading based on vertex order, so when you rotate a model, the first four vertexes are thought to be the first side while in actuality they could be any side.

commented

Do you have some code I can run to verify this?

On Wed, Jun 24, 2015 at 7:32 AM, MrTJP [email protected] wrote:

Unless I am mistaken, applying a transformation to a model should be the
same as rendering it with the transformation in-line. If you apply a
rotation and then render the model with the light matrix, it works
correctly. The model is properly shaded on the correct sides. However, if
you render the model without the transformation pre-applied, it seems that
the rotation will actually rotate the light matrix's shading.

Correct results:

  1. Locate renderstate lightmatrix
  2. Apply rotation to model
  3. Render model with (uv transformation, light matrix)

Incorrect results:

  1. Locate renderstate lightmatrix
  2. Render model with (rotation, uv transformation, light matrix)


Reply to this email directly or view it on GitHub
#45.

commented

Not in production, at the moment. I will leave a comment in my code and link you to it when I push the commit.