* Add cull check and item transformation mode getter to FRAPI
* Terminally deprecate `fallbackConsumer` and `bakedModelConsumer`
* Fix uvs in octagonal column test mod
* Review comments
(cherry picked from commit 39a511ba53)
* Improve flat shade
- Use AO mode to make flat shade calculation consistent with shade applied by smooth lighting
- Use face normal to calculate shade if necessary
- Use normal shade even if no custom normals are set
* Improve FRAPI test mod
- Add octagonal column to test irregular face lighting
- Use obsidian sprite instead of missing sprite for frame mesh
- Simplify and organize registration
- Inline `simple` package
* Fix crumbling on 45 degree faces
- Fix checkstyle
- Give octagonal column a non-zero hardness
* Fix checkstyle
* Improve PillarBakedModel to fully support custom block appearance
* Explain OverlayVertexConsumer fix
* Update to loom 1.3
* Fix more 1.3 deprecations
* Opps
* Move to mod publish plugin
* Revert some changes
* Fix some more Gradle deprecations
* Fix names
* Remove extra stuff
* Cleanup
### API Changes
- Interface inject `FabricBakedModel`
This change was done to eliminate the constant need to cast `BakedModel` to `FabricBakedModel`, especially when rendering sub-models. The implementations for the methods of `FabricBakedModel` were moved from `BakedModelMixin` to `FabricBakedModel` as default implementations. Some javadoc was updated to reflect this change.
- Deprecate the mesh consumer (`Consumer<Mesh>` retrieved from `RenderContext`)
This change was done to ensure consistency across all current and future contexts in which a mesh may need to be output to a quad emitter. The preferred direct replacement is the new method `Mesh#outputTo(QuadEmitter)`. Some javadoc was updated to reflect this change.
- Deprecate the baked model consumer (`BakedModelConsumer` retrieved from `RenderContext`)
This change was done to ensure consistent rendering of sub-models and to eliminate assumptions about what features a model uses. The preferred direct replacement is to use the appropriate `emit` method in `FabricBakedModel`. Some javadoc was updated to reflect this change.
Even though the consumer is now deprecated, the default `FabricBakedModel` method implementations still use it and renderers must still implement the getter. This is because Indigo and Indium sometimes apply smooth lighting differently based on if the quad came from a vanilla model or not. The eventual solution to allow all baked model consumer usage to be removed is to allow renderers to override the default `BakedModelMixin` and handle default vanilla models directly.
- Fix `QuadView#toVanilla`'s javadoc reporting the wrong minimum array size
### Implementation Changes
- Restructure `RenderContext` implementations
This change was done to reduce code duplication, improve standardization, and improve readability. Most code of `AbstractQuadRenderer` was moved into a new class called `AbstractBlockRenderContext` (which `BlockRenderContext` and `TerrainRenderContext` now extend), with the main buffering method being moved to `AbstractRenderContext`.
- Remove red blue color swap
It is unclear why this code was necessary in the first place. Indigo stores vertex color in ARGB format, then converts it to ABGR format only if the native byte order is little endian, and then reads the vertex color in ABGR format when buffering vertex data. This would mean that on big endian systems, all red and blue color components would be swapped.
Now, color is read in ARGB format when buffering and no color format conversion or swapping is done.
- Encode face normal
This change was done to improve the performance of meshes. Meshes already encoded all other geometry data, but the face normal would still have to be recomputed every time a mesh quad was rendered. Now, it is stored in the quad data header, so it is simply decoded, which is significantly faster.
- Fix some bugs
- Outputting a mesh via the mesh consumer would result in the emitter retaining the data of the last quad in the mesh.
- In non-terrain block rendering, the baked model consumer would incorrectly use the random seed provided by the block state instead of the passed random seed argument.
- When converting to or from vanilla quad data, the color would not be converted. Indigo uses ARGB format to store color, while vanilla quads use ABGR or RGBA. See the comment near the bottom of `ColorHelper` for more information.
- Fix TerrainRenderContext using incorrect overlay value of `0` instead of `OverlayTexture.DEFAULT_UV`.
- Improve performance of some code
- `QuadViewImpl#computeGeometry()` was being called before transforms and the cull test were applied. These operations can change the geometry and invalidate computed geometry data or cancel the quad outright. Calling the method explicitly in those contexts was also not necessary in the first place.
- A single `Vector4f` instance is now reused to transform the vertex position instead of allocating a new `Vector4f` for each vertex.
- The random seed lazy computation now uses a separate boolean instead of checking if the seed is `-1`.
* Material inspection
- Add MaterialView to get material properties from RenderMaterial and MaterialFinder
- Add MaterialFinder#copyFrom to copy properties from another MaterialView
- Finish todo in QuadView#toBakedQuad
- Move material impl classes to material package
* Add glint material property
- Allow force enabling or force disabling glint on items
- Force enable glint on horizontal sides of pillar item model in test mod
* Fix imports
* Add documentation
* Do not create invalid materials
- Ensure material bits are valid before creating material
- Assert that default MaterialFinder bits are valid
- Remove ordinal checks in MaterialViewImpl since bits are now guaranteed to be valid
- Set default glint mode to default instead of false
- Remove getter overrides in RenderMaterialImpl
* Add MutableQuadView#copyFrom
- Deprecate QuadView#copyTo
* Add missing nullability annotations
* Apply disabled shade from vanilla quads directly to material
- Remove QuadViewImpl.shade
* Fix enhanced AO calculation and respect non-terrain culling state
- Fix AoCalculator using AO face data computed with a potentially different shade state
- Move non-cached computation code to separate method in AoCalculator
- Turn AoCalculator's brightnessFunc and aoFunc into abstract methods
- Do not check null check world in non-terrain AO calculation since it cannot be null
- Pass through lightFace and shade state as method arguments in AoCalculator methods to prevent additional lookups
- Do not check for the axis aligned flag in AbstractQuadRenderer.shadeFlatQuad
- Respect cull parameter passed to non-terrain rendering by merging TerrainBlockRenderInfo into BlockRenderInfo
- Use reusable search pos when calling Block.shouldDrawSide to prevent additional BlockPos allocation
- Change BlockRenderContext.render and TerrainRenderContext.tessellateBlock to return void since return value is no longer used
- Remove QuadViewImpl.vertexStart since it is unused
* Add suggestions
- Mark Direction parameter to BlockRenderInfo.shouldDrawFace as Nullable
- Reuse MaterialFinder in FrameBakedModel
(cherry picked from commit 3a95925af4)
* Fix#2639: Indigo fallback consumer does not respect BlendMode or emissivity
* Change renderer testmod to test material change
* Remove presumably unneeded `quad.geometryFlags()` call
* Also test emissivity
* Call emitBlockQuads in the testmod
* Allow passing the block state explicitly to the fallback consumer. Fixes#1871
* Expand testmod to also test item models
* Also fix fallback consumer ignoring material for items
* Slight changes
* Introduce new interface for the expanded fallback consumer
* Add javadoc to ModelHelper
* Fix AO calculation
- Ensure calcFastVanilla and computeFace have parity with vanilla
- Ensure BlockStates are not queried more than once for the same position
- Replace deprecated FabricLoader#getConfigDirectory call with FabricLoader#getConfigDir
* Revert opaque sides fix
* More AO fixes and optimizations
The bitwise comparison is doing the opposite of what we want. It's currently checking for the *absence* of the BAKE_NORMALIZED flag. And if the flag is absent, it is normalizing. This should do the opposite.
A common source of crashes on modded Minecraft servers comes from modders accidently calling client only code from the client, this PR is another large step towards elimitating that.
This PR has been months in the making and years in the planning, requiring major changes to Loom & Loader. In recent Minecraft versions Mojang has made it easier than ever to cleanly split the jar, going against the status-quo of merging the client and server into one jar.
From the start we have designed Fabric to have a very clear split between client and common (client & server) code. Fabric has always encoraged keeping client only code seprate from the server, this can be seen at a fundamental level with the entrypoints in Loader. Fabric API's have all been designed with this mind.
This PR provides a compile safety net around Fabric API using client only code on the server. Even though there are almost 400 changed files, minimal changes beyond moving the files were required to achieve this in Fabric API, thanks to the effort of all contributors in the past.
These changes should not affect modders or players in anyway, a single "universal" jar is still produced. Im happy to awnswer any questions.
* Modernize Indigo
- Restructure ItemRenderContext to be more efficient and consistent with block rendering
- Remove unnecessary code including CompatibilityHelper
- Add Unique annotations to fields added by Indigo
- Fix typos
- Organize imports
* Remove unused import
* Fix bugs
- Fix enchantment glint not rendering on item models
- Fix QuadView#copyTo not copying enough data
- Make ItemRenderContext vertex consumer calculation mirror vanilla and be more efficient
* Clear the target quad's material
* Tweaks
- Retain material during copyTo instead of clearing it
- Standardize mixins
* Direct return
- Return from ItemRenderContext#quadVertexConsumer instead of assigning value to variable
* Add custom value denoting module lifecycles.
* Make the module validation work.
My hand has been forced - we must use buildSrc since JsonSlurper is not available in main buildscript.
* Apply task to each project and dont cross projects
* A horrible hack
* Wait what
* It works now.
* Not needed
* Drop unneeded maven repo, cache map lookup
(cherry picked from commit daa38b3d82)