CodeChickenLib icon indicating copy to clipboard operation
CodeChickenLib copied to clipboard

Rendering model with a rotation op yields incorrect results.

Open MrTJP opened this issue 10 years ago • 3 comments

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.

MrTJP avatar Jun 23 '15 21:06 MrTJP

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 https://github.com/Chicken-Bones/CodeChickenLib/issues/45.

Chicken-Bones avatar Jun 24 '15 00:06 Chicken-Bones

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

MrTJP avatar Jun 28 '15 00:06 MrTJP

Here is a link to a piece of code that can produce the problem.

https://github.com/MrTJP/ProjectRed/blob/57cded5ca6f448727f635256e81bc20a1429b4ba/src/mrtjp/projectred/fabrication/tileicprinter.scala#L677

MrTJP avatar Jul 09 '15 01:07 MrTJP