McJtyMods / ModTutorials

Companion code for the modding tutorials at https://www.mcjty.eu/
MIT License
136 stars 31 forks source link

2 issues with the SmarkBakedModel #11

Open Da-Technomancer opened 7 years ago

Da-Technomancer commented 7 years ago

Both of these are lighting related. Firstly, because the model is not a full block, it can cause intermittent rendering issues in certain chunks where the conduit is very dark unless builder.setApplyDiffuseLighting(false); is called from within the createQuad method. In the tutorial, it isn't.

Secondly, there is a small error in the calculation of the normal vector. This error isn't noticeable with the example model because the example is not opaque. However, the calculation produces a vector pointing in the exact opposite direction. The normal vector is used by the lighting engine to darken certain block faces, and because it is the opposite direction, the light level adjacent to the top face affects only the bottom face, and so on. However, this isn't noticeable in this case because it isn't opaque and light can pass though. The fix is simple, instead of using Vec3d normal = v1.subtract(v2).crossProduct(v3.subtract(v2)); use Vec3d normal = v3.subtract(v2).crossProduct(v1.subtract(v2)); (the difference is swapping v3 and v1). Other than these 2 subtle things, the tutorial seems to be correct.