├── gradlew ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── common ├── src │ └── main │ │ ├── resources │ │ ├── META-INF │ │ │ └── services │ │ │ │ └── io.vram.frex.api.renderer.RendererProvider │ │ └── assets │ │ │ └── frex │ │ │ ├── materials │ │ │ ├── emissive.json │ │ │ ├── emissive_no_shadow.json │ │ │ ├── emissive_no_diffuse.json │ │ │ ├── emissive_no_ao.json │ │ │ ├── emissive_transform.json │ │ │ ├── emissive_no_diffuse_no_shadow.json │ │ │ └── emissive_transform_no_shadow.json │ │ │ ├── frex_icon.png │ │ │ └── shaders │ │ │ ├── material │ │ │ ├── default.vert │ │ │ └── default.frag │ │ │ ├── lib │ │ │ ├── bitwise.glsl │ │ │ ├── noise │ │ │ │ ├── README │ │ │ │ ├── noisecommon.glsl │ │ │ │ └── LICENSE │ │ │ └── color.glsl │ │ │ └── api │ │ │ ├── fog.h │ │ │ ├── accessibility.h │ │ │ ├── sampler.h │ │ │ └── header.h │ │ └── java │ │ └── io │ │ └── vram │ │ └── frex │ │ ├── api │ │ ├── texture │ │ │ ├── PhysicalSpriteAtlas.java │ │ │ ├── PhysicalSprite.java │ │ │ └── SpriteIndex.java │ │ ├── buffer │ │ │ ├── PooledQuadEmitter.java │ │ │ ├── PooledVertexEmitter.java │ │ │ └── QuadTransform.java │ │ ├── renderer │ │ │ ├── RendererProvider.java │ │ │ ├── MaterialTextureManager.java │ │ │ ├── Renderer.java │ │ │ ├── MaterialShaderManager.java │ │ │ └── ConditionManager.java │ │ ├── material │ │ │ └── MaterialTransform.java │ │ ├── model │ │ │ ├── DynamicModel.java │ │ │ ├── InputContext.java │ │ │ ├── BlockItemModel.java │ │ │ ├── provider │ │ │ │ └── SubModelLoader.java │ │ │ └── EntityModel.java │ │ ├── light │ │ │ └── ItemLightProvider.java │ │ ├── config │ │ │ └── FrexConfig.java │ │ ├── math │ │ │ ├── MatrixStack.java │ │ │ └── FixedMath255.java │ │ ├── rendertype │ │ │ ├── RenderTypeExclusion.java │ │ │ └── BlockPresets.java │ │ ├── renderloop │ │ │ ├── FrustumSetupListener.java │ │ │ ├── WorldRenderPostListener.java │ │ │ ├── RenderReloadListener.java │ │ │ ├── WorldRenderStartListener.java │ │ │ ├── WorldRenderLastListener.java │ │ │ └── EntityRenderPostListener.java │ │ └── world │ │ │ ├── ItemColorRegistry.java │ │ │ └── BlockColorRegistry.java │ │ ├── mixinterface │ │ ├── PoseStackExt.java │ │ └── ModelBakeryExt.java │ │ ├── impl │ │ ├── texture │ │ │ ├── IndexedSprite.java │ │ │ ├── TextureAtlasPreparationExt.java │ │ │ └── SpriteFinderHolder.java │ │ ├── world │ │ │ ├── BlockEntityRenderDataProviderAccess.java │ │ │ └── BlockEntityRenderDataImpl.java │ │ ├── config │ │ │ └── FrexFeatureImpl.java │ │ ├── material │ │ │ ├── MaterialFinderPool.java │ │ │ ├── predicate │ │ │ │ ├── MaterialPredicate.java │ │ │ │ ├── EntityBiPredicate.java │ │ │ │ ├── MaterialPredicateDeserializer.java │ │ │ │ ├── StateBiPredicate.java │ │ │ │ ├── EntityMaterialOnly.java │ │ │ │ ├── StateMaterialOnly.java │ │ │ │ ├── StateOnly.java │ │ │ │ ├── EntityMaterialBoth.java │ │ │ │ └── StateMaterialBoth.java │ │ │ └── map │ │ │ │ ├── SingleInvariantMaterialMap.java │ │ │ │ ├── SpriteMaterialMap.java │ │ │ │ ├── SingleMaterialMap.java │ │ │ │ └── DefaultedSpriteMaterialMap.java │ │ ├── model │ │ │ └── ModelLookups.java │ │ ├── FrexLog.java │ │ ├── RendererHolder.java │ │ ├── math │ │ │ └── MatrixStackEntryHelper.java │ │ └── renderloop │ │ │ ├── RenderReloadListenerImpl.java │ │ │ ├── DebugRenderListenerImpl.java │ │ │ ├── FrustumSetupListenerImpl.java │ │ │ ├── WorldRenderLastListenerImpl.java │ │ │ ├── WorldRenderPostListenerImpl.java │ │ │ ├── EntityRenderPostListenerImpl.java │ │ │ ├── EntityRenderPreListenerImpl.java │ │ │ ├── TranslucentPostListenerImpl.java │ │ │ └── WorldRenderStartListenerImpl.java │ │ ├── pastel │ │ ├── PastelRenderer.java │ │ ├── PastelProvider.java │ │ └── PastelRenderMaterial.java │ │ ├── mixin │ │ ├── MixinTextureAtlasSprite.java │ │ ├── MixinLevelRenderer.java │ │ ├── MixinItemColors.java │ │ ├── MixinBlockColors.java │ │ ├── MixinBlockEntityType.java │ │ ├── MixinTextureAtlasPreparation.java │ │ └── MixinItemBlockRenderTypes.java │ │ └── base │ │ ├── renderer │ │ ├── mesh │ │ │ ├── TransformStack.java │ │ │ └── RootQuadEmitter.java │ │ ├── context │ │ │ └── input │ │ │ │ ├── AbsentInputContext.java │ │ │ │ └── BaseBakedInputContext.java │ │ ├── ao │ │ │ └── AoFaceData.java │ │ └── util │ │ │ └── ResourceCache.java │ │ └── client │ │ └── model │ │ ├── SpriteProvider.java │ │ ├── ItemOverrideProxy.java │ │ └── MeshFactory.java └── .checkstyle ├── forge ├── src │ └── main │ │ └── resources │ │ ├── frex_icon.png │ │ ├── pack.mcmeta │ │ ├── frex.pastel.json │ │ └── frex.common.json ├── gradle.properties └── settings.gradle ├── fabric ├── gradle.properties ├── settings.gradle ├── src │ └── main │ │ ├── resources │ │ ├── frex.fabricevents.json │ │ ├── frex.fabric.json │ │ ├── frex.pastel.json │ │ ├── frex.common.json │ │ └── fabric.mod.json │ │ └── java │ │ └── io │ │ └── vram │ │ └── frex │ │ ├── fabric │ │ ├── mixin │ │ │ ├── MixinFabricSpriteFinder.java │ │ │ ├── MixinFluidRenderHandler.java │ │ │ ├── events │ │ │ │ ├── MixinWorldRenderContext.java │ │ │ │ ├── FabricEventsMixinPlugin.java │ │ │ │ └── MixinFabricWorldRenderContext.java │ │ │ ├── MixinFrex.java │ │ │ ├── MixinSpriteFinderHolder.java │ │ │ ├── MixinBlockEntityRenderDataImpl.java │ │ │ ├── MixinFabricBakedModel.java │ │ │ └── FabricMixinPlugin.java │ │ └── compat │ │ │ ├── FabricMaterial.java │ │ │ ├── FabricMesh.java │ │ │ └── FabricMeshBuilder.java │ │ └── mixin │ │ └── FrexMixinPlugin.java └── project.gradle ├── .gitignore ├── upload.sh ├── project_common.gradle ├── NOTICE ├── HEADER ├── README.md ├── gruntle.sh └── fabriquilt └── src └── main └── java └── io └── vram └── frex ├── pastel ├── mixinterface │ ├── ModelBlockRendererExt.java │ └── RenderChunkRegionExt.java └── mixin │ └── MixinEntityRenderDispatcher.java └── mixin └── MixinBakedModel.java /gradlew: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vram-guild/frex/HEAD/gradlew -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vram-guild/frex/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /common/src/main/resources/META-INF/services/io.vram.frex.api.renderer.RendererProvider: -------------------------------------------------------------------------------- 1 | io.vram.frex.pastel.PastelProvider -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/materials/emissive.json: -------------------------------------------------------------------------------- 1 | { 2 | "transform": true, 3 | "emissive": true 4 | } 5 | -------------------------------------------------------------------------------- /forge/src/main/resources/frex_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vram-guild/frex/HEAD/forge/src/main/resources/frex_icon.png -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/frex_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vram-guild/frex/HEAD/common/src/main/resources/assets/frex/frex_icon.png -------------------------------------------------------------------------------- /forge/src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "frex resources", 4 | "pack_format": 7 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/materials/emissive_no_shadow.json: -------------------------------------------------------------------------------- 1 | { 2 | "transform": true, 3 | "emissive": true, 4 | "castShadows": false 5 | } 6 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/materials/emissive_no_diffuse.json: -------------------------------------------------------------------------------- 1 | { 2 | "transform": true, 3 | "disableDiffuse": true, 4 | "emissive": true 5 | } 6 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/materials/emissive_no_ao.json: -------------------------------------------------------------------------------- 1 | { 2 | "transform": true, 3 | "emissive": true, 4 | "disableAo": true, 5 | "disableDiffuse": false 6 | } 7 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/materials/emissive_transform.json: -------------------------------------------------------------------------------- 1 | { 2 | "_DEPRECATED_": "use emissive.json instead", 3 | "transform": true, 4 | "emissive": true 5 | } 6 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/materials/emissive_no_diffuse_no_shadow.json: -------------------------------------------------------------------------------- 1 | { 2 | "transform": true, 3 | "disableDiffuse": true, 4 | "emissive": true, 5 | "castShadows": false 6 | } 7 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/materials/emissive_transform_no_shadow.json: -------------------------------------------------------------------------------- 1 | { 2 | "_DEPRECATED_": "use emissive_no_shadow.json instead", 3 | "transform": true, 4 | "emissive": true, 5 | "castShadows": false 6 | } 7 | -------------------------------------------------------------------------------- /fabric/gradle.properties: -------------------------------------------------------------------------------- 1 | #### STANDARD VRAM PROPERTIES FOR FABRIC 2 | #### MAKE CHANGES IN ..\project_common.gradle 3 | #### CHANGES MADE HERE WILL BE OVERWRITTEN! 4 | 5 | org.gradle.jvmargs=-Xmx2G 6 | org.gradle.daemon=false 7 | -------------------------------------------------------------------------------- /forge/gradle.properties: -------------------------------------------------------------------------------- 1 | #### STANDARD VRAM PROPERTIES FOR FORGE 1.18 2 | #### MAKE CHANGES IN ..\project_common.gradle 3 | #### CHANGES MADE HERE WILL BE OVERWRITTEN! 4 | 5 | org.gradle.jvmargs=-Xmx2G 6 | org.gradle.daemon=false 7 | 8 | loom.platform=forge 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/shaders/material/default.vert: -------------------------------------------------------------------------------- 1 | #include frex:shaders/api/vertex.glsl 2 | 3 | /****************************************************** 4 | frex:shaders/material/default.vert 5 | ******************************************************/ 6 | 7 | void frx_materialVertex() { 8 | // NOOP 9 | } 10 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/shaders/material/default.frag: -------------------------------------------------------------------------------- 1 | #include frex:shaders/api/fragment.glsl 2 | 3 | /****************************************************** 4 | frex:shaders/material/default.frag 5 | ******************************************************/ 6 | 7 | void frx_materialFragment() { 8 | // NOOP 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | *.launch 3 | .settings 4 | .metadata 5 | .classpath 6 | .project 7 | eclipse 8 | gruntle 9 | 10 | ##idea 11 | .idea/ 12 | *.iml 13 | *.ipr 14 | *.iws 15 | 16 | ## gradle 17 | build 18 | run 19 | .gradle 20 | 21 | ## MacOS 22 | .DS_Store 23 | .AppleDouble 24 | .LSOverride 25 | 26 | ## Windows 27 | Thumbs.db 28 | 29 | .vscode 30 | .checkstyle 31 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/shaders/lib/bitwise.glsl: -------------------------------------------------------------------------------- 1 | /****************************************************** 2 | frex:shaders/lib/bitwise.glsl 3 | DEPRECATED - No longer useful now that we have 4 | reliable bitwide operations in GLSL. 5 | ******************************************************/ 6 | 7 | #define frx_bitValue(byteValue, bitIndex) float((byteValue >> bitIndex) & 1u) 8 | -------------------------------------------------------------------------------- /upload.sh: -------------------------------------------------------------------------------- 1 | if output=$(git status --porcelain) && [ -z "$output" ]; then 2 | echo "Uploading to mod distribution sites" 3 | cd fabric 4 | ../gradlew curseforge modrinth --rerun-tasks 5 | cd .. 6 | 7 | cd forge 8 | ../gradlew curseforge modrinth --rerun-tasks 9 | cd .. 10 | else 11 | echo "Git has uncommitted changes - upload to mod distribution sites cancelled." 12 | fi 13 | -------------------------------------------------------------------------------- /fabric/settings.gradle: -------------------------------------------------------------------------------- 1 | // VRAM STANDARD GRADLE SETTINGS FOR FABRIC 2 | // DO NOT MAKE CHANGES HERE - THEY WILL BE OVERWRITTEN BY AUTOMATED UPDATE 3 | 4 | pluginManagement { 5 | repositories { 6 | mavenCentral() 7 | maven { 8 | name = 'Fabric' 9 | url = 'https://maven.fabricmc.net/' 10 | } 11 | gradlePluginPortal() 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /forge/settings.gradle: -------------------------------------------------------------------------------- 1 | // VRAM STANDARD GRADLE SETTINGS FOR FORGE 1.18 2 | // DO NOT MAKE CHANGES HERE - THEY WILL BE OVERWRITTEN BY AUTOMATED UPDATE 3 | 4 | pluginManagement { 5 | repositories { 6 | maven { url "https://maven.fabricmc.net/" } 7 | maven { url "https://maven.architectury.dev/" } 8 | maven { url "https://files.minecraftforge.net/maven/" } 9 | gradlePluginPortal() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /project_common.gradle: -------------------------------------------------------------------------------- 1 | 2 | project.group = 'io.vram' 3 | ext.author = 'Grondag' 4 | ext.title = 'FREX' 5 | ext.mod_name = 'frex' 6 | ext.mod_version = '19.2' 7 | 8 | ext.github_repository_owner = 'vram-guild' 9 | ext.github_repository = 'frex' 10 | 11 | ext.curseforge_id = '318827' 12 | ext.modrinth_id = 'cFvMB8zZ' 13 | ext.release_type = 'release' 14 | 15 | ext.build_fat_jar = true 16 | ext.build_forge = false 17 | ext.accesswidener = 'src/main/resources/frex.accesswidener' 18 | -------------------------------------------------------------------------------- /fabric/src/main/resources/frex.fabricevents.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "io.vram.frex.fabric.mixin.events", 5 | "compatibilityLevel": "JAVA_17", 6 | "plugin": "io.vram.frex.fabric.mixin.events.FabricEventsMixinPlugin", 7 | "mixins": [ 8 | "MixinFabricWorldRenderContext", 9 | "MixinFabricWorldRenderEvents", 10 | "MixinLevelRendererEvents", 11 | "MixinWorldRenderContext" 12 | ], 13 | "injectors": { 14 | "defaultRequire": 1 15 | }, 16 | "overwrites": { 17 | "conformVisibility": true 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /common/.checkstyle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /fabric/src/main/resources/frex.fabric.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "io.vram.frex.fabric.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "plugin": "io.vram.frex.fabric.mixin.FabricMixinPlugin", 7 | "mixins": [ 8 | "MixinBlockEntityRenderDataImpl", 9 | "MixinFabricBakedModel", 10 | "MixinFabricSpriteFinder", 11 | "MixinFluidAppearanceImpl", 12 | "MixinFluidRenderHandler", 13 | "MixinFrex", 14 | "MixinSpriteFinderHolder" 15 | ], 16 | "injectors": { 17 | "defaultRequire": 1 18 | }, 19 | "overwrites": { 20 | "conformVisibility": true 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /fabric/src/main/resources/frex.pastel.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "io.vram.frex.pastel.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "plugin": "io.vram.frex.pastel.mixin.PastelMixinPlugin", 7 | "mixins": [ 8 | "MixinBlockRenderDispatcher", 9 | "MixinChunkRebuildTask", 10 | "MixinEntityRenderDispatcher", 11 | "MixinItemFrameRenderer", 12 | "MixinItemRenderer", 13 | "MixinModelBlockRenderer", 14 | "MixinRenderChunkRegion", 15 | "MixinRenderRegionCache" 16 | ], 17 | "injectors": { 18 | "defaultRequire": 1 19 | }, 20 | "overwrites": { 21 | "conformVisibility": true 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /forge/src/main/resources/frex.pastel.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "io.vram.frex.pastel.mixin", 5 | "compatibilityLevel": "JAVA_16", 6 | "plugin": "io.vram.frex.pastel.mixin.PastelMixinPlugin", 7 | "refmap": "mixins.frex.refmap.json", 8 | "mixins": [ 9 | "MixinBlockRenderDispatcher", 10 | "MixinChunkRebuildTask", 11 | "MixinCompiledChunk", 12 | "MixinEntityRenderDispatcher", 13 | "MixinItemFrameRenderer", 14 | "MixinItemRenderer", 15 | "MixinModelBlockRenderer", 16 | "MixinRenderChunkRegion" 17 | ], 18 | "injectors": { 19 | "defaultRequire": 1 20 | }, 21 | "overwrites": { 22 | "conformVisibility": true 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /forge/src/main/resources/frex.common.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "io.vram.frex.mixin", 5 | "compatibilityLevel": "JAVA_16", 6 | "refmap": "mixins.frex.refmap.json", 7 | "mixins": [ 8 | "MixinBakedModel", 9 | "MixinBlockColors", 10 | "MixinBlockEntityType", 11 | "MixinItemColors", 12 | "MixinLevelRenderer", 13 | "MixinMatrix3f", 14 | "MixinMatrix4f", 15 | "MixinMultipartBakedModel", 16 | "MixinPoseStack", 17 | "MixinWeightedBakedModel", 18 | "MixinTextureAtlasPreparation", 19 | "MixinTextureAtlasSprite", 20 | "MixinTextureAltasSpriteIndex", 21 | "MixinTextureAltasSpriteLoader" 22 | ], 23 | "injectors": { 24 | "defaultRequire": 1 25 | }, 26 | "overwrites": { 27 | "conformVisibility": true 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /fabric/src/main/resources/frex.common.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "io.vram.frex.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "plugin": "io.vram.frex.mixin.FrexMixinPlugin", 7 | "mixins": [ 8 | "MixinBakedModel", 9 | "MixinBlockColors", 10 | "MixinBlockEntityType", 11 | "MixinItemBlockRenderTypes", 12 | "MixinItemColors", 13 | "MixinLevelRenderer", 14 | "MixinMatrix3f", 15 | "MixinMatrix4f", 16 | "MixinModelBakery", 17 | "MixinMultipartBakedModel", 18 | "MixinPoseStack", 19 | "MixinWeightedBakedModel", 20 | "MixinTerrainParticle", 21 | "MixinTextureAltasCommon", 22 | "MixinTextureAltasNoFabric", 23 | "MixinTextureAtlasPreparation", 24 | "MixinTextureAtlasSprite" 25 | ], 26 | "injectors": { 27 | "defaultRequire": 1 28 | }, 29 | "overwrites": { 30 | "conformVisibility": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | FREX Rendering Extensions 2 | Copyright © Original Authors 3 | 4 | Versions of this work published prior to September 28, 2021 were licensed under 5 | the Apache License, Version 2.0, which can be found here: 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | On and after September 28, 2021 the work is licensed under the GNU 10 | Lesser General Public License as published by the Free Software Foundation, 11 | either version 3 of the License, or (at your option) any later version. 12 | 13 | You should have received a copy of the GNU Lesser General Public License 14 | along with this program. If not, see . 15 | 16 | Versions of the work published prior to September 28, 2021 can be used 17 | under the terms of either license. Additions and changes after that 18 | date are licensed under the GNU Lesser General Public License exclusively. 19 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/shaders/lib/noise/README: -------------------------------------------------------------------------------- 1 | NOTE: shaders in this folder are from https://github.com/stegu/webgl-noise 2 | and are bundled for convenience of shader authors. 3 | Original readme is reproduced below. 4 | -- Grondag 5 | 6 | 7 | These files contain noise functions that are compatible with all 8 | current versions of GLSL (1.20 and up), and all you need to use them 9 | is provided in the source file. There is no external data, and no 10 | setup procedure. Just cut and paste and call the function. 11 | 12 | GLSL has a very rudimentary linker, so some helper functions are 13 | included in several of the files with the same name. If you want to 14 | use more than one of these functions in the same shader, you may run 15 | into problems with redefinition of the functions mod289() and permute(). 16 | If that happens, just delete any superfluous definitions. 17 | -------------------------------------------------------------------------------- /HEADER: -------------------------------------------------------------------------------- 1 | This file is part of FREX and is licensed to the project under 2 | terms that are compatible with the GNU Lesser General Public License. 3 | See the NOTICE file distributed with this work for additional information 4 | regarding copyright ownership and licensing. 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with this program. If not, see . 18 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/shaders/lib/noise/noisecommon.glsl: -------------------------------------------------------------------------------- 1 | /****************************************************** 2 | frex:shaders/lib/noise/noisecommon.glsl 3 | 4 | External MIT noise library - bundled for convenience. 5 | 6 | Modifications include: 7 | + remove the #version header 8 | + add this comment block 9 | + move some shared functions to this file 10 | + use #define for some small functions 11 | ******************************************************/ 12 | 13 | #define mod289(x) (x - floor(x * (1.0 / 289.0)) * 289.0) // Modulo 289 without a division (only multiplications) 14 | #define mod7(x) (x - floor(x * (1.0 / 7.0)) * 7.0) // Modulo 7 without a division 15 | #define taylorInvSqrt(r) (1.79284291400159 - 0.85373472095314 * r) 16 | 17 | // Permutation polynomial: (34x^2 + x) mod 289, ring size 289 = 17*17 18 | // Can't be defined because used recursively 19 | vec4 permute(vec4 x) { return mod289((34.0 * x + 1.0) * x); } 20 | vec3 permute(vec3 x) { return mod289((34.0 * x + 1.0) * x); } 21 | float permute(float x) { return mod289(((x*34.0)+1.0)*x); } 22 | -------------------------------------------------------------------------------- /fabric/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "frex", 4 | "version": "${version}", 5 | "name": "FREX", 6 | "description": "Advanced rendering features for Minecraft mods", 7 | "authors": [ 8 | "Grondag" 9 | ], 10 | "contact": { 11 | "homepage": "https://minecraft.curseforge.com/projects/frex", 12 | "issues": "https://github.com/vram-guild/frex/issues", 13 | "sources": "https://github.com/vram-guild/frex" 14 | }, 15 | "license": "LGPL-3.0", 16 | "icon": "assets/frex/frex_icon.png", 17 | "environment": "client", 18 | "mixins": [ 19 | "frex.common.json", 20 | "frex.fabric.json", 21 | "frex.pastel.json", 22 | "frex.fabricevents.json" 23 | ], 24 | "entrypoints": { 25 | "client": [ "io.vram.frex.fabric.FrexMod" ] 26 | }, 27 | "depends": { 28 | "fabricloader": ">=0.14.19", 29 | "minecraft": ">=1.19.2", 30 | "java": ">=17" 31 | }, 32 | "custom": { 33 | "fabric-renderer-api-v1:contains_renderer": true, 34 | "modmenu": { 35 | "badges": [ "library" ] 36 | } 37 | }, 38 | "accessWidener": "frex.accesswidener" 39 | } 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FREX Rendering Extensions 2 | FREX currently support the Fabric API and Mod Loader. 3 | 4 | Packaged as a separate mod so that rendering implementations and mods that consume these extensions can 5 | depend on it without directly depending on specific implementation. 6 | 7 | More information on using FREX is available on the [Renderosity Wiki](https://github.com/grondag/renderosity/wiki). 8 | 9 | # Using FREX 10 | 11 | Add the maven repo where my libraries live to your build.gradle 12 | 13 | ```gradle 14 | repositories { 15 | maven { 16 | name = "vram" 17 | url = "https://maven.vram.io/" 18 | } 19 | } 20 | ``` 21 | 22 | And add FREX to your dependencies 23 | 24 | ```gradle 25 | dependencies { 26 | modCompile "io.vram:frex-fabric-mc117:6.0.+" 27 | include "io.vram:frex-fabric-mc117:6.0.+" 28 | } 29 | ``` 30 | 31 | The ```include``` is not necessary if you are depending on another mod that also includes FREX. Currently, [Canvas](https://github.com/vram-guild/canvas) and [JMX](https://github.com/grondag/json-model-extensions) both include FREX. 32 | 33 | Note that version is subject to change - look at the repo to find latest. 34 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/texture/PhysicalSpriteAtlas.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.texture; 22 | 23 | public interface PhysicalSpriteAtlas { 24 | // TODO 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/shaders/api/fog.h: -------------------------------------------------------------------------------- 1 | 2 | /**************************************************************** 3 | * Specifies the variables available in the FREX shader 4 | * API to describe fog parameters for the current primitive. 5 | * 6 | * See FREX Shader API.md for license and general informaiton. 7 | ***************************************************************/ 8 | 9 | /* 10 | * Equals 1 if fog is enabled for the current render pass. 11 | */ 12 | const int frx_fogEnabled; 13 | 14 | /* 15 | * The starting distance for fog, following the conventions 16 | * of vanilla fog rendering. Some pipelines with realistic 17 | * fog modeling may not use this or may use it differently. 18 | */ 19 | const float frx_fogStart; 20 | 21 | /* 22 | * The end distance for fog, following the conventions 23 | * of vanilla fog rendering. Some pipelines with realistic 24 | * fog modeling may not use this or may use it differently. 25 | */ 26 | const float frx_fogEnd; 27 | 28 | /* 29 | * The color of fog used in vanilla fog rendering for the 30 | * current rendering pass. Some pipelines with realistic 31 | * fog modeling may not use this or may use it differently. 32 | */ 33 | const vec4 frx_fogColor; 34 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/buffer/PooledQuadEmitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.buffer; 22 | 23 | public interface PooledQuadEmitter extends QuadEmitter, AutoCloseable { 24 | @Override 25 | void close(); 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/buffer/PooledVertexEmitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.buffer; 22 | 23 | public interface PooledVertexEmitter extends VertexEmitter, AutoCloseable { 24 | @Override 25 | void close(); 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/mixinterface/PoseStackExt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.mixinterface; 22 | 23 | import io.vram.frex.api.math.MatrixStack; 24 | 25 | public interface PoseStackExt { 26 | MatrixStack frx_asMatrixStack(); 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/renderer/RendererProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.renderer; 22 | 23 | @FunctionalInterface 24 | public interface RendererProvider { 25 | Renderer getRenderer(); 26 | 27 | default int priority() { 28 | return 0; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/material/MaterialTransform.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.material; 22 | 23 | @FunctionalInterface 24 | public interface MaterialTransform { 25 | void apply(MaterialFinder finder); 26 | 27 | MaterialTransform IDENTITY = (f) -> { }; 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/texture/PhysicalSprite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.texture; 22 | 23 | import net.minecraft.resources.ResourceLocation; 24 | 25 | public interface PhysicalSprite { 26 | ResourceLocation id(); 27 | 28 | PhysicalSpriteAtlas atlas(); 29 | } 30 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/model/DynamicModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.model; 22 | 23 | import io.vram.frex.api.buffer.QuadSink; 24 | 25 | @FunctionalInterface 26 | public interface DynamicModel { 27 | void renderDynamic(InputContext input, QuadSink output); 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/texture/IndexedSprite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.texture; 22 | 23 | import org.jetbrains.annotations.ApiStatus.Internal; 24 | 25 | @Internal 26 | public interface IndexedSprite { 27 | int frex_index(); 28 | 29 | void frex_index(int index); 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/buffer/QuadTransform.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.buffer; 22 | 23 | import io.vram.frex.api.mesh.QuadView; 24 | import io.vram.frex.api.model.InputContext; 25 | 26 | @FunctionalInterface 27 | public interface QuadTransform { 28 | void transform(InputContext context, QuadView input, QuadEmitter output); 29 | } 30 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/light/ItemLightProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.light; 22 | 23 | import net.minecraft.world.item.ItemStack; 24 | 25 | /** 26 | * Implement on items to return light sources programmatically. 27 | */ 28 | @FunctionalInterface 29 | public interface ItemLightProvider { 30 | ItemLight getItemLight(ItemStack stack); 31 | } 32 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/pastel/PastelRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.pastel; 22 | 23 | import io.vram.frex.base.renderer.BaseRenderer; 24 | 25 | public class PastelRenderer extends BaseRenderer { 26 | public static boolean semiFlatLighting = true; 27 | 28 | public PastelRenderer() { 29 | super(PastelRenderMaterial::new); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/mixinterface/ModelBakeryExt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.mixinterface; 22 | 23 | import net.minecraft.client.resources.model.UnbakedModel; 24 | import net.minecraft.resources.ResourceLocation; 25 | 26 | public interface ModelBakeryExt { 27 | void frx_addModel(ResourceLocation id); 28 | 29 | UnbakedModel frx_loadModel(ResourceLocation id); 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/texture/TextureAtlasPreparationExt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.texture; 22 | 23 | import java.util.List; 24 | 25 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 26 | 27 | public interface TextureAtlasPreparationExt { 28 | int frex_atlasWidth(); 29 | 30 | int frex_atlasHeight(); 31 | 32 | List frex_sprites(); 33 | } 34 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/mixin/MixinFabricSpriteFinder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.mixin; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | 25 | import net.fabricmc.fabric.impl.renderer.SpriteFinderImpl; 26 | 27 | import io.vram.frex.api.texture.SpriteFinder; 28 | 29 | @Mixin(SpriteFinderImpl.class) 30 | public abstract class MixinFabricSpriteFinder implements SpriteFinder { } 31 | -------------------------------------------------------------------------------- /gruntle.sh: -------------------------------------------------------------------------------- 1 | readonly MC_VERSION="1.19" 2 | 3 | echo "GRUNTLE REFRESH FOR $MC_VERSION - IF THIS IS NOT A $MC_VERSION BRANCH YOU HAVE DONE A BAD" 4 | 5 | if [[ $1 == 'auto' ]]; then 6 | if ! grep -q gruntle .gitignore; then 7 | echo "Auto-update requires .gitignore to exclude the gruntle folder. Please update .gitignore and retry." 8 | exit 1 9 | fi 10 | 11 | if output=$(git status --porcelain) && [ -z "$output" ]; then 12 | echo "Attempting auto-update. Git starting status is clean." 13 | else 14 | echo "Auto-update requires clean git status. Please commit or stash changes and retry." 15 | exit 1 16 | fi 17 | fi 18 | 19 | echo 'Checking for build updates...' 20 | # delete gruntle repo folder if exists from aborted run 21 | if [ -d gruntle-${MC_VERSION} ]; then 22 | rm -rf gruntle-${MC_VERSION} 23 | fi 24 | 25 | # download and unpack latest gruntle bundle 26 | curl https://github.com/vram-guild/gruntle/archive/refs/heads/${MC_VERSION}.zip -sSOJL 27 | unzip -q gruntle-${MC_VERSION} 28 | 29 | # copy content for our branch and then remove bundle 30 | # this handles simple, file-based updates: checkstyle, standard gradle configs, etc. 31 | cp -R gruntle-${MC_VERSION}/bundle/* . 32 | rm -rf gruntle-${MC_VERSION} 33 | rm gruntle-${MC_VERSION}.zip 34 | 35 | # run latest refresh 36 | source gruntle/refresh.sh 37 | 38 | # remove scripts 39 | rm -rf gruntle 40 | 41 | echo 'Gruntle refresh complete' 42 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/pastel/PastelProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.pastel; 22 | 23 | import io.vram.frex.api.renderer.Renderer; 24 | import io.vram.frex.api.renderer.RendererProvider; 25 | 26 | public class PastelProvider implements RendererProvider { 27 | @Override 28 | public Renderer getRenderer() { 29 | return new PastelRenderer(); 30 | } 31 | 32 | @Override 33 | public int priority() { 34 | return 1000; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/texture/SpriteFinderHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.texture; 22 | 23 | import net.minecraft.client.renderer.texture.TextureAtlas; 24 | 25 | import io.vram.frex.api.texture.SpriteFinder; 26 | 27 | public class SpriteFinderHolder { 28 | // When Fabric API is present, this is changed via Mixin to use the fabric variant 29 | public static SpriteFinder get(TextureAtlas atlas) { 30 | return SpriteFinderImpl.get(atlas); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/renderer/MaterialTextureManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.renderer; 22 | 23 | import net.minecraft.resources.ResourceLocation; 24 | 25 | import io.vram.frex.api.texture.MaterialTexture; 26 | 27 | public interface MaterialTextureManager { 28 | MaterialTexture textureFromId(ResourceLocation id); 29 | 30 | MaterialTexture textureFromIndex(int index); 31 | 32 | MaterialTexture missingTexture(); 33 | 34 | MaterialTexture noTexture(); 35 | } 36 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/mixin/MixinFluidRenderHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.mixin; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | 25 | import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; 26 | 27 | import io.vram.frex.api.model.fluid.FluidAppearance; 28 | 29 | // Makes FluidRenderHandler and FREX equivalents cross-compatible 30 | @Mixin(FluidRenderHandler.class) 31 | public interface MixinFluidRenderHandler extends FluidAppearance { } 32 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/shaders/lib/noise/LICENSE: -------------------------------------------------------------------------------- 1 | NOTE: shaders in this folder are from https://github.com/stegu/webgl-noise 2 | and are bundled for convenience of shader authors. 3 | Original license is reproduced below and applies only to content in this folder. 4 | -- Grondag 5 | 6 | Copyright (C) 2011 by Ashima Arts (Simplex noise) 7 | Copyright (C) 2011-2016 by Stefan Gustavson (Classic noise and others) 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/world/BlockEntityRenderDataProviderAccess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.world; 22 | 23 | import java.util.function.Function; 24 | 25 | import org.jetbrains.annotations.ApiStatus.Internal; 26 | 27 | import net.minecraft.world.level.block.entity.BlockEntity; 28 | 29 | @Internal 30 | public interface BlockEntityRenderDataProviderAccess { 31 | Function frxGetDataProvider(); 32 | 33 | void frxSetDataProvider(Function provider); 34 | } 35 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/model/InputContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.model; 22 | 23 | import net.minecraft.util.RandomSource; 24 | 25 | import io.vram.frex.api.math.MatrixStack; 26 | 27 | public interface InputContext { 28 | RandomSource random(); 29 | 30 | Type type(); 31 | 32 | int overlay(); 33 | 34 | MatrixStack matrixStack(); 35 | 36 | enum Type { 37 | BLOCK, 38 | ITEM, 39 | ENTITY, 40 | ABSENT 41 | } 42 | 43 | default boolean isAbsent() { 44 | return type() == Type.ABSENT; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/config/FrexConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.config; 22 | 23 | // UGLY: really not sure what do about this 24 | public class FrexConfig { 25 | public static boolean suppressMaterialLoadingSpam = true; 26 | public static boolean logMaterialPredicateDuplicates = false; 27 | public static boolean allowDegenerateFluidFaces = false; 28 | public static boolean debugModelLoading = false; 29 | 30 | // Driven by feature flag at renderer setup 31 | public static boolean computeVertexTangents = false; 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/pastel/PastelRenderMaterial.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.pastel; 22 | 23 | import io.vram.frex.base.renderer.material.BaseMaterialManager; 24 | import io.vram.frex.base.renderer.material.BaseMaterialView; 25 | import io.vram.frex.base.renderer.material.BaseRenderMaterial; 26 | 27 | public class PastelRenderMaterial extends BaseRenderMaterial { 28 | public PastelRenderMaterial(BaseMaterialManager manager, int index, BaseMaterialView template) { 29 | super(manager, index, template); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /fabric/project.gradle: -------------------------------------------------------------------------------- 1 | // Hat tip to JellySquid 2 | configurations { 3 | modIncludeImplementation 4 | modImplementation.extendsFrom modIncludeImplementation 5 | include.extendsFrom modIncludeImplementation 6 | } 7 | 8 | dependencies { 9 | modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" 10 | 11 | modIncludeImplementation(fabricApi.module("fabric-api-base", project.fabric_version)) 12 | modIncludeImplementation(fabricApi.module("fabric-resource-loader-v0", project.fabric_version)) 13 | modIncludeImplementation("io.vram:bitkit:1.0.4") 14 | 15 | modCompileOnly(fabricApi.module("fabric-rendering-fluids-v1", project.fabric_version)) 16 | modCompileOnly(fabricApi.module("fabric-rendering-data-attachment-v1", project.fabric_version)) 17 | modCompileOnly(fabricApi.module("fabric-resource-loader-v0", project.fabric_version)) 18 | modCompileOnly(fabricApi.module("fabric-renderer-api-v1", project.fabric_version)) 19 | modCompileOnly(fabricApi.module("fabric-rendering-v1", project.fabric_version)) 20 | modCompileOnly(fabricApi.module("fabric-renderer-indigo", project.fabric_version)) 21 | } 22 | 23 | sourceSets { 24 | main { 25 | java { 26 | srcDirs = ['../common/src/main/java', 'src/main/java', '../fabriquilt/src/main/java'] 27 | include '**/*' 28 | exclude '*.DS_Store' 29 | } 30 | resources { 31 | srcDirs = ['../common/src/main/resources', 'src/main/resources'] 32 | include '**/*' 33 | exclude '*.DS_Store' 34 | } 35 | } 36 | test { 37 | java { 38 | exclude '**/*' 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/mixin/events/MixinWorldRenderContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.mixin.events; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | 25 | import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; 26 | import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext.BlockOutlineContext; 27 | 28 | import io.vram.frex.api.renderloop.WorldRenderContextBase; 29 | 30 | @Mixin(WorldRenderContextBase.class) 31 | public abstract class MixinWorldRenderContext implements WorldRenderContext, BlockOutlineContext { } 32 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/model/BlockItemModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.model; 22 | 23 | import io.vram.frex.api.buffer.QuadSink; 24 | import io.vram.frex.api.model.InputContext.Type; 25 | 26 | public interface BlockItemModel extends BlockModel, ItemModel { 27 | @Override 28 | default void renderDynamic(InputContext input, QuadSink output) { 29 | if (input.type() == Type.BLOCK) { 30 | renderAsBlock((BlockInputContext) input, output); 31 | } else if (input.type() == Type.ITEM) { 32 | renderAsItem((ItemInputContext) input, output); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /fabriquilt/src/main/java/io/vram/frex/pastel/mixinterface/ModelBlockRendererExt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.pastel.mixinterface; 22 | 23 | import java.util.BitSet; 24 | 25 | import net.minecraft.core.BlockPos; 26 | import net.minecraft.core.Direction; 27 | import net.minecraft.world.level.BlockAndTintGetter; 28 | import net.minecraft.world.level.block.state.BlockState; 29 | 30 | public interface ModelBlockRendererExt { 31 | void frx_calculateShape(BlockAndTintGetter blockView, BlockState blockState, BlockPos pos, int[] vertexData, Direction face, float[] aoData, BitSet controlBits); 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/config/FrexFeatureImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.config; 22 | 23 | import org.jetbrains.annotations.ApiStatus.Internal; 24 | 25 | @Internal 26 | public class FrexFeatureImpl { 27 | private static final long[] FLAGS = new long[128]; 28 | 29 | public static boolean isAvailable(int featureId) { 30 | return (FLAGS[featureId >> 6] & (1L << (featureId & 63))) != 0; 31 | } 32 | 33 | public static void registerFeatures(int... features) { 34 | for (final int featureId : features) { 35 | FLAGS[featureId >> 6] |= (1L << (featureId & 63)); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/MaterialFinderPool.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material; 22 | 23 | import org.jetbrains.annotations.ApiStatus.Internal; 24 | 25 | import io.vram.frex.api.material.MaterialFinder; 26 | 27 | @Internal 28 | public final class MaterialFinderPool { 29 | private MaterialFinderPool() { } 30 | 31 | private static ThreadLocal POOL = ThreadLocal.withInitial(MaterialFinder::newInstance); 32 | 33 | public static MaterialFinder threadLocal() { 34 | final MaterialFinder result = POOL.get(); 35 | result.clear(); 36 | return result; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/mixin/MixinTextureAtlasSprite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.mixin; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | 25 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 26 | 27 | import io.vram.frex.impl.texture.IndexedSprite; 28 | 29 | @Mixin(TextureAtlasSprite.class) 30 | public class MixinTextureAtlasSprite implements IndexedSprite { 31 | private int frexIndex; 32 | 33 | @Override 34 | public int frex_index() { 35 | return frexIndex; 36 | } 37 | 38 | @Override 39 | public void frex_index(int index) { 40 | frexIndex = index; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/compat/FabricMaterial.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.compat; 22 | 23 | import io.vram.frex.api.material.RenderMaterial; 24 | 25 | public class FabricMaterial implements net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial { 26 | public static FabricMaterial of(RenderMaterial wrapped) { 27 | return new FabricMaterial(wrapped); 28 | } 29 | 30 | final RenderMaterial wrapped; 31 | 32 | protected FabricMaterial(RenderMaterial wrapped) { 33 | this.wrapped = wrapped; 34 | } 35 | 36 | @Override 37 | public final int spriteDepth() { 38 | return 1; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/mixin/FrexMixinPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.mixin; 22 | 23 | import net.fabricmc.loader.api.FabricLoader; 24 | 25 | import io.vram.frex.fabric.compat.SimpleMixinConfig; 26 | 27 | public class FrexMixinPlugin extends SimpleMixinConfig { 28 | public FrexMixinPlugin() { 29 | super("io.vram.frex.mixin.", c -> { 30 | if (FabricLoader.getInstance().isModLoaded("fabric-renderer-api-v1")) { 31 | c.accept("MixinBakedModel"); 32 | c.accept("MixinMultipartBakedModel"); 33 | c.accept("MixinWeightedBakedModel"); 34 | c.accept("MixinTextureAltasSpriteLoader"); 35 | } 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/shaders/lib/color.glsl: -------------------------------------------------------------------------------- 1 | /****************************************************** 2 | frex:shaders/lib/color.glsl 3 | 4 | Common color processing functions. 5 | 6 | Portions taken from Wisdom Shaders by Cheng (Bob) Cao, Apache 2.0 license 7 | https://github.com/bobcao3/Wisdom-Shaders 8 | 9 | ******************************************************/ 10 | 11 | #define FRX_GAMMA 2.4 12 | #define FRX_INVERSE_GAMMA (1.0 / FRX_GAMMA) 13 | 14 | vec4 frx_fromGamma(vec4 c) { 15 | return pow(c, vec4(FRX_GAMMA)); 16 | } 17 | 18 | vec4 frx_toGamma(vec4 c) { 19 | return pow(c, vec4(FRX_INVERSE_GAMMA)); 20 | } 21 | 22 | vec3 frx_fromGamma(vec3 c) { 23 | return pow(c, vec3(FRX_GAMMA)); 24 | } 25 | 26 | vec3 frx_toGamma(vec3 c) { 27 | return pow(c, vec3(FRX_INVERSE_GAMMA)); 28 | } 29 | 30 | //float frx_luma(vec3 c) { 31 | // return dot(c, vec3(0.2126, 0.7152, 0.0722)); 32 | //} 33 | 34 | const mat3 FRX_ACES_INPUT_MATRIX = mat3( 35 | vec3(0.59719, 0.07600, 0.02840), 36 | vec3(0.35458, 0.90834, 0.13383), 37 | vec3(0.04823, 0.01566, 0.83777) 38 | ); 39 | 40 | // ODT_SAT => XYZ => D60_2_D65 => sRGB 41 | const mat3 FRX_ACES_OUTPUT_MATRIX = mat3( 42 | vec3(1.60475, -0.10208, -0.00327), 43 | vec3(-0.53108, 1.10813, -0.07276), 44 | vec3(-0.07367, -0.00605, 1.07602) 45 | ); 46 | 47 | vec3 FRX_RRT_AND_ODTF_FIT(vec3 v) { 48 | vec3 a = v * (v + 0.0245786f) - 0.000090537f; 49 | vec3 b = v * (0.983729f * v + 0.4329510f) + 0.238081f; 50 | return a / b; 51 | } 52 | 53 | vec3 frx_toneMap(vec3 color) { 54 | color = FRX_ACES_INPUT_MATRIX * color; 55 | color = FRX_RRT_AND_ODTF_FIT(color); 56 | return FRX_ACES_OUTPUT_MATRIX * color; 57 | } 58 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/model/ModelLookups.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.model; 22 | 23 | import org.jetbrains.annotations.ApiStatus.Internal; 24 | 25 | import net.minecraft.client.Minecraft; 26 | import net.minecraft.client.renderer.ItemModelShaper; 27 | import net.minecraft.client.renderer.block.BlockModelShaper; 28 | 29 | /** 30 | * Avoids a few pointer chases. 31 | */ 32 | @Internal 33 | public class ModelLookups { 34 | public static final ItemModelShaper ITEM_MODEL_SHAPER = Minecraft.getInstance().getItemRenderer().getItemModelShaper(); 35 | 36 | public static final BlockModelShaper BLOCK_MODEL_SHAPER = Minecraft.getInstance().getBlockRenderer().getBlockModelShaper(); 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/predicate/MaterialPredicate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.predicate; 22 | 23 | import java.util.function.Predicate; 24 | 25 | import io.vram.frex.api.material.MaterialView; 26 | 27 | public abstract class MaterialPredicate implements Predicate { 28 | public static MaterialPredicate MATERIAL_ALWAYS_TRUE = new MaterialPredicate() { 29 | @Override 30 | public boolean equals(Object obj) { 31 | return obj == MATERIAL_ALWAYS_TRUE; 32 | } 33 | 34 | @Override 35 | public boolean test(MaterialView renderMaterial) { 36 | return true; 37 | } 38 | }; 39 | 40 | @Override 41 | public abstract boolean equals(Object obj); 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/mixin/MixinLevelRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.mixin; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | import org.spongepowered.asm.mixin.injection.At; 25 | import org.spongepowered.asm.mixin.injection.Inject; 26 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 27 | 28 | import net.minecraft.client.renderer.LevelRenderer; 29 | 30 | import io.vram.frex.api.renderloop.RenderReloadListener; 31 | 32 | @Mixin(LevelRenderer.class) 33 | public class MixinLevelRenderer { 34 | @Inject(method = "Lnet/minecraft/client/renderer/LevelRenderer;allChanged()V", at = @At("HEAD")) 35 | private void onReload(CallbackInfo ci) { 36 | RenderReloadListener.invoke(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/mixin/MixinItemColors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.mixin; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | import org.spongepowered.asm.mixin.injection.At; 25 | import org.spongepowered.asm.mixin.injection.Inject; 26 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 27 | 28 | import net.minecraft.client.color.item.ItemColors; 29 | 30 | import io.vram.frex.impl.world.ColorRegistryImpl; 31 | 32 | @Mixin(ItemColors.class) 33 | public class MixinItemColors { 34 | @Inject(method = "createDefault", at = @At("RETURN")) 35 | private static void onCreateDefault(CallbackInfoReturnable ci) { 36 | ColorRegistryImpl.setItemColors(ci.getReturnValue()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/mixin/MixinBlockColors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.mixin; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | import org.spongepowered.asm.mixin.injection.At; 25 | import org.spongepowered.asm.mixin.injection.Inject; 26 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 27 | 28 | import net.minecraft.client.color.block.BlockColors; 29 | 30 | import io.vram.frex.impl.world.ColorRegistryImpl; 31 | 32 | @Mixin(BlockColors.class) 33 | public class MixinBlockColors { 34 | @Inject(method = "createDefault", at = @At("RETURN")) 35 | private static void onCreateDefault(CallbackInfoReturnable ci) { 36 | ColorRegistryImpl.setBlockColors(ci.getReturnValue()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/shaders/api/accessibility.h: -------------------------------------------------------------------------------- 1 | 2 | /**************************************************************** 3 | * Specifies the variables available in the FREX shader API 4 | * to describe accessibility preferences that affect visuals. 5 | * 6 | * See FREX Shader API.md for license and general informaiton. 7 | ***************************************************************/ 8 | 9 | /* 10 | * FOV Effects. 11 | * 12 | * Defaults to 1.0 when unavailable. 13 | */ 14 | const float frx_fovEffects; 15 | 16 | /* 17 | * Distortion Effects. 18 | * 19 | * Defaults to 1.0 when unavailable. 20 | */ 21 | const float frx_distortionEffects; 22 | 23 | /* 24 | * Hide Lightning Flashes. 1 when ON, 0 otherwise. 25 | * 26 | * This setting's effect is precomputed in frx_skyFlashStrength. 27 | * No need to multiply it manually to that variable. 28 | * 29 | * Defaults to 0 when unavailable. 30 | */ 31 | const int frx_hideLightningFlashes; 32 | 33 | /* 34 | * Darkness Pulsing. 35 | * 36 | * This setting's effect is precomputed in frx_darknessEffectFactor. 37 | * No need to blend it manually to that variable. 38 | * 39 | * Defaults to 1.0 when unavailable. 40 | */ 41 | const float frx_darknessPulsing; 42 | 43 | /* 44 | * High Contrast. 1 when ON, 0 otherwise. 45 | * 46 | * Defaults to 0 when unavailable. 47 | */ 48 | const int frx_highContrast; 49 | 50 | /* 51 | * Damage Tilt. 52 | * 53 | * Defaults to 1.0 when unavailable. 54 | */ 55 | const float frx_damageTilt; 56 | 57 | /* 58 | * Glint Strength. 59 | * 60 | * Defaults to 1.0 when unavailable. 61 | */ 62 | const float frx_glintStrength; 63 | 64 | /* 65 | * Glint Speed. 66 | * 67 | * Defaults to 1.0 when unavailable. 68 | */ 69 | const float frx_glintSpeed; 70 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/renderer/Renderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.renderer; 22 | 23 | import io.vram.frex.api.mesh.MeshBuilder; 24 | import io.vram.frex.impl.RendererHolder; 25 | 26 | /** 27 | * Interface for rendering plug-ins that provide enhanced capabilities 28 | * for model lighting, buffering and rendering. Such plug-ins implement the 29 | * enhanced model rendering interfaces specified by the Fabric API. 30 | */ 31 | public interface Renderer { 32 | static Renderer get() { 33 | return RendererHolder.get(); 34 | } 35 | 36 | MeshBuilder meshBuilder(); 37 | 38 | MaterialManager materials(); 39 | 40 | ConditionManager conditions(); 41 | 42 | MaterialTextureManager textures(); 43 | 44 | MaterialShaderManager shaders(); 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/texture/SpriteIndex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.texture; 22 | 23 | import net.minecraft.client.renderer.texture.TextureAtlas; 24 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 25 | import net.minecraft.resources.ResourceLocation; 26 | 27 | import io.vram.frex.impl.texture.SpriteIndexImpl; 28 | 29 | public interface SpriteIndex { 30 | TextureAtlasSprite fromIndex(int spriteId); 31 | 32 | float mapU(int spriteId, float unmappedU); 33 | 34 | float mapV(int spriteId, float unmappedV); 35 | 36 | int atlasWidth(); 37 | 38 | int atlasHeight(); 39 | 40 | TextureAtlas atlas(); 41 | 42 | static SpriteIndex getOrCreate(ResourceLocation id) { 43 | return SpriteIndexImpl.getOrCreate(id); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/FrexLog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl; 22 | 23 | import org.apache.logging.log4j.LogManager; 24 | import org.apache.logging.log4j.Logger; 25 | 26 | public abstract class FrexLog { 27 | private FrexLog() { } 28 | 29 | public static Logger LOG = LogManager.getLogger("FREX CORE API"); 30 | 31 | public static void warn(String string) { 32 | LOG.warn(string); 33 | } 34 | 35 | public static void info(String string) { 36 | LOG.info(string); 37 | } 38 | 39 | public static void warn(String message, Exception e) { 40 | LOG.warn(message, e); 41 | } 42 | 43 | public static void error(Exception e) { 44 | LOG.error(e); 45 | } 46 | 47 | public static void error(String error) { 48 | LOG.error(error); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/mixin/MixinFrex.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.mixin; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | import org.spongepowered.asm.mixin.Overwrite; 25 | 26 | import net.fabricmc.fabric.api.renderer.v1.RendererAccess; 27 | 28 | import io.vram.frex.api.renderer.Renderer; 29 | import io.vram.frex.fabric.FrexMod; 30 | import io.vram.frex.fabric.compat.FrexCompatibilityWrapper; 31 | 32 | @Mixin(FrexMod.class) 33 | public abstract class MixinFrex { 34 | /** 35 | * @author grondag 36 | * @reason Fabric API compatibility 37 | */ 38 | @Overwrite(remap = false) 39 | private static void setupRenderer() { 40 | RendererAccess.INSTANCE.registerRenderer(FrexCompatibilityWrapper.of(Renderer.get())); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/renderer/MaterialShaderManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.renderer; 22 | 23 | import org.jetbrains.annotations.Nullable; 24 | 25 | import net.minecraft.resources.ResourceLocation; 26 | 27 | import io.vram.frex.api.material.MaterialShader; 28 | 29 | public interface MaterialShaderManager { 30 | MaterialShader shaderFromIndex(int index); 31 | 32 | MaterialShader getOrCreate(@Nullable ResourceLocation vertexSourceId, @Nullable ResourceLocation fragmentSourceId); 33 | 34 | MaterialShader getOrCreate(@Nullable ResourceLocation vertexSourceId, @Nullable ResourceLocation fragmentSourceId, @Nullable ResourceLocation depthVertexSourceId, @Nullable ResourceLocation depthFragmentSourceId); 35 | 36 | MaterialShader defaultShader(); 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/predicate/EntityBiPredicate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.predicate; 22 | 23 | import java.util.function.BiPredicate; 24 | 25 | import net.minecraft.world.entity.Entity; 26 | 27 | import io.vram.frex.api.material.MaterialView; 28 | 29 | public abstract class EntityBiPredicate implements BiPredicate { 30 | public static EntityBiPredicate ENTITY_ALWAYS_TRUE = new EntityBiPredicate() { 31 | @Override 32 | public boolean test(Entity entity, MaterialView renderMaterial) { 33 | return true; 34 | } 35 | 36 | @Override 37 | public boolean equals(Object obj) { 38 | return obj == ENTITY_ALWAYS_TRUE; 39 | } 40 | }; 41 | 42 | @Override 43 | public abstract boolean equals(Object obj); 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/base/renderer/mesh/TransformStack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.base.renderer.mesh; 22 | 23 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 24 | 25 | import io.vram.frex.api.buffer.QuadTransform; 26 | import io.vram.frex.api.model.InputContext; 27 | 28 | public class TransformStack { 29 | protected final ObjectArrayList POOL = new ObjectArrayList<>(); 30 | 31 | public TransformingQuadEmitter createTransform(InputContext context, QuadTransform transform, BaseQuadEmitter output) { 32 | return (POOL.isEmpty() ? new TransformingQuadEmitter(this) : POOL.pop()).prepare(context, transform, output); 33 | } 34 | 35 | public void reclaim(TransformingQuadEmitter transformingQuadEmitter) { 36 | POOL.add(transformingQuadEmitter); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/mixin/events/FabricEventsMixinPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.mixin.events; 22 | 23 | import net.fabricmc.loader.api.FabricLoader; 24 | 25 | import io.vram.frex.fabric.compat.SimpleMixinConfig; 26 | 27 | public class FabricEventsMixinPlugin extends SimpleMixinConfig { 28 | public FabricEventsMixinPlugin() { 29 | super("io.vram.frex.fabric.mixin.events.", c -> { 30 | if (FabricLoader.getInstance().isModLoaded("fabric-rendering-v1")) { 31 | // our event handlers only get loaded when Fabric's are not 32 | c.accept("MixinLevelRendererEvents"); 33 | } else { 34 | c.accept("MixinFabricWorldRenderContext"); 35 | c.accept("MixinFabricWorldRenderEvents"); 36 | c.accept("MixinWorldRenderContext"); 37 | } 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/predicate/MaterialPredicateDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.predicate; 22 | 23 | import static io.vram.frex.impl.material.predicate.MaterialPredicate.MATERIAL_ALWAYS_TRUE; 24 | 25 | import com.google.gson.JsonObject; 26 | 27 | public class MaterialPredicateDeserializer { 28 | public static MaterialPredicate deserialize(JsonObject json) { 29 | if (json == null || json.isJsonNull()) { 30 | return MATERIAL_ALWAYS_TRUE; 31 | } 32 | 33 | final ArrayPredicate arrayPredicate = new ArrayPredicate(json); 34 | 35 | if (arrayPredicate.size() == 0) { 36 | return MATERIAL_ALWAYS_TRUE; 37 | } else if (arrayPredicate.size() == 1) { 38 | return arrayPredicate.get(0); 39 | } else { 40 | return arrayPredicate; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/compat/FabricMesh.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.compat; 22 | 23 | import java.util.function.Consumer; 24 | 25 | import net.fabricmc.fabric.api.renderer.v1.mesh.QuadView; 26 | 27 | import io.vram.frex.api.mesh.Mesh; 28 | 29 | public class FabricMesh implements net.fabricmc.fabric.api.renderer.v1.mesh.Mesh { 30 | public static FabricMesh of(Mesh wrapped) { 31 | return new FabricMesh(wrapped); 32 | } 33 | 34 | final Mesh wrapped; 35 | private final FabricQuadView quadWrapper = FabricQuadView.of(null); 36 | 37 | protected FabricMesh(Mesh wrapped) { 38 | this.wrapped = wrapped; 39 | } 40 | 41 | @Override 42 | public void forEach(Consumer consumer) { 43 | wrapped.forEach(q -> { 44 | consumer.accept(quadWrapper.wrap(q)); 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /fabriquilt/src/main/java/io/vram/frex/mixin/MixinBakedModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.mixin; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | 25 | import net.minecraft.client.resources.model.BakedModel; 26 | 27 | import io.vram.frex.api.buffer.QuadSink; 28 | import io.vram.frex.api.model.BlockItemModel; 29 | import io.vram.frex.base.renderer.util.BakedModelTranscoder; 30 | 31 | @Mixin(BakedModel.class) 32 | public interface MixinBakedModel extends BlockItemModel { 33 | @Override 34 | default void renderAsItem(ItemInputContext input, QuadSink output) { 35 | BakedModelTranscoder.accept((BakedModel) this, input, output.asQuadEmitter()); 36 | } 37 | 38 | @Override 39 | default void renderAsBlock(BlockInputContext input, QuadSink output) { 40 | BakedModelTranscoder.accept((BakedModel) this, input, output.asQuadEmitter()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/math/MatrixStack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.math; 22 | 23 | import com.mojang.blaze3d.vertex.PoseStack; 24 | 25 | import io.vram.frex.mixinterface.PoseStackExt; 26 | 27 | public interface MatrixStack { 28 | void push(); 29 | 30 | void pop(); 31 | 32 | FastMatrix4f modelMatrix(); 33 | 34 | FastMatrix3f normalMatrix(); 35 | 36 | default void translate(float x, float y, float z) { 37 | modelMatrix().f_translate(x, y, z); 38 | } 39 | 40 | default void setIdentity() { 41 | modelMatrix().f_setIdentity(); 42 | normalMatrix().f_setIdentity(); 43 | } 44 | 45 | PoseStack toVanilla(); 46 | 47 | static MatrixStack fromVanilla(PoseStack poseStack) { 48 | return ((PoseStackExt) poseStack).frx_asMatrixStack(); 49 | } 50 | 51 | static MatrixStack create() { 52 | return fromVanilla(new PoseStack()); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/base/client/model/SpriteProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.base.client.model; 22 | 23 | import net.minecraft.client.Minecraft; 24 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 25 | import net.minecraft.resources.ResourceLocation; 26 | import net.minecraft.world.inventory.InventoryMenu; 27 | 28 | @FunctionalInterface 29 | public interface SpriteProvider { 30 | TextureAtlasSprite getSprite(ResourceLocation path); 31 | 32 | default TextureAtlasSprite getSprite(String path) { 33 | return getSprite(new ResourceLocation(path)); 34 | } 35 | 36 | @SuppressWarnings("resource") 37 | static SpriteProvider forAtlas(ResourceLocation id) { 38 | return Minecraft.getInstance().getTextureAtlas(id)::apply; 39 | } 40 | 41 | static SpriteProvider forBlocksAndItems() { 42 | return forAtlas(InventoryMenu.BLOCK_ATLAS); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/RendererHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl; 22 | 23 | import java.util.ServiceLoader; 24 | 25 | import io.vram.frex.api.renderer.Renderer; 26 | import io.vram.frex.api.renderer.RendererProvider; 27 | 28 | public class RendererHolder { 29 | private static Renderer renderer = null; 30 | 31 | public static RendererProvider bestProvider() { 32 | final var loader = ServiceLoader.load(RendererProvider.class); 33 | 34 | RendererProvider best = null; 35 | 36 | for (final var rp : loader) { 37 | if (best == null || rp.priority() < best.priority()) { 38 | best = rp; 39 | } 40 | } 41 | 42 | return best; 43 | } 44 | 45 | public static Renderer get() { 46 | var result = renderer; 47 | 48 | if (result == null) { 49 | result = bestProvider().getRenderer(); 50 | renderer = result; 51 | } 52 | 53 | return result; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/predicate/StateBiPredicate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.predicate; 22 | 23 | import java.util.function.BiPredicate; 24 | 25 | import net.minecraft.world.level.block.state.BlockState; 26 | 27 | import io.vram.frex.api.material.MaterialView; 28 | 29 | public abstract class StateBiPredicate implements BiPredicate { 30 | public static StateBiPredicate BLOCK_ALWAYS_TRUE = new StateBiPredicate() { 31 | @Override 32 | public boolean test(BlockState blockState, MaterialView renderMaterial) { 33 | return true; 34 | } 35 | 36 | @Override 37 | public boolean equals(Object obj) { 38 | return obj == BLOCK_ALWAYS_TRUE; 39 | } 40 | }; 41 | 42 | @Override 43 | public abstract boolean equals(Object obj); 44 | 45 | @Override 46 | public int hashCode() { 47 | return super.hashCode(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/shaders/api/sampler.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * Specifies the variables and methods available in the 3 | * FREX shader API to access samplers directly. 4 | * 5 | * See FREX Shader API.md for license and general informaiton. 6 | *************************************************************************/ 7 | 8 | uniform sampler2D frxs_baseColor; 9 | 10 | /* 11 | * When a texture atlas is in use, the renderer will automatically 12 | * map from normalized coordinates to texture coordinates before the 13 | * fragment shader runs. But this doesn't help if you want to 14 | * re-sample during fragment shading using normalized coordinates. 15 | * 16 | * This function will remap normalized coordinates to atlas coordinates. 17 | * It has no effect when the bound texture is not an atlas texture. 18 | */ 19 | vec2 frx_mapNormalizedUV(vec2 coord); 20 | 21 | /* 22 | * Takes texture atlas coordinates and remaps them to normalized. 23 | * Has no effect when the bound texture is not an atlas texture. 24 | */ 25 | vec2 frx_normalizeMappedUV(vec2 coord); 26 | 27 | uniform sampler2D frxs_lightmap; 28 | 29 | /* 30 | * Shadow-type sampler for shadow map texture, useful for final map testing 31 | * and exploits hardware accumulation of shadow test results 32 | * 33 | * Same underlying image as frxs_shadowMapTexture. 34 | * 35 | * Available only in fragment shader when SHADOW_MAP_PRESENT is defined. 36 | */ 37 | uniform sampler2DArrayShadow frxs_shadowMap; 38 | 39 | /* 40 | * Regular sampler for shadow map texture, useful for 41 | * probing depth at specific points for PCSS or Contact-Hardening Shadows. 42 | * 43 | * Same underlying image as frxs_shadowMapTexture. 44 | * 45 | * Available only in fragment shader when SHADOW_MAP_PRESENT is defined. 46 | */ 47 | uniform sampler2DArray frxs_shadowMapTexture; 48 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/rendertype/RenderTypeExclusion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.rendertype; 22 | 23 | import java.util.function.Predicate; 24 | 25 | import org.jetbrains.annotations.ApiStatus.NonExtendable; 26 | 27 | import net.minecraft.client.renderer.RenderType; 28 | import net.minecraft.client.renderer.RenderType.CompositeRenderType; 29 | 30 | import io.vram.frex.impl.material.RenderTypeExclusionImpl; 31 | 32 | @NonExtendable 33 | public interface RenderTypeExclusion { 34 | static void exclude(RenderType renderType) { 35 | RenderTypeExclusionImpl.exclude(renderType); 36 | } 37 | 38 | static void exclude(Predicate filter) { 39 | RenderTypeExclusionImpl.addFilter(filter); 40 | } 41 | 42 | static boolean isExcluded(RenderType renderType) { 43 | return !(renderType instanceof CompositeRenderType) || RenderTypeExclusionImpl.isExcluded(renderType); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/predicate/EntityMaterialOnly.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.predicate; 22 | 23 | import net.minecraft.world.entity.Entity; 24 | 25 | import io.vram.frex.api.material.MaterialView; 26 | 27 | public class EntityMaterialOnly extends EntityBiPredicate { 28 | private final MaterialPredicate materialPredicate; 29 | 30 | public EntityMaterialOnly(MaterialPredicate materialPredicate) { 31 | this.materialPredicate = materialPredicate; 32 | } 33 | 34 | @Override 35 | public boolean test(Entity ignored, MaterialView renderMaterial) { 36 | return materialPredicate.test(renderMaterial); 37 | } 38 | 39 | @Override 40 | public boolean equals(Object obj) { 41 | if (obj instanceof EntityMaterialOnly) { 42 | return materialPredicate.equals(((EntityMaterialOnly) obj).materialPredicate); 43 | } else { 44 | return false; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/base/renderer/context/input/AbsentInputContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.base.renderer.context.input; 22 | 23 | import net.minecraft.client.renderer.texture.OverlayTexture; 24 | 25 | import io.vram.frex.api.math.MatrixStack; 26 | import io.vram.frex.base.renderer.mesh.BaseQuadEmitter; 27 | 28 | public class AbsentInputContext extends BaseInputContext { 29 | public AbsentInputContext() { 30 | super(Type.ABSENT); 31 | this.setMatrixStack(MatrixStack.create()); 32 | this.prepare(OverlayTexture.NO_OVERLAY); 33 | } 34 | 35 | @Override 36 | protected long randomSeed() { 37 | return 42; 38 | } 39 | 40 | @Override 41 | public int flatBrightness(BaseQuadEmitter quad) { 42 | return 0; 43 | } 44 | 45 | @Override 46 | public boolean isAbsent() { 47 | return true; 48 | } 49 | 50 | public static final AbsentInputContext INSTANCE = new AbsentInputContext(); 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/predicate/StateMaterialOnly.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.predicate; 22 | 23 | import net.minecraft.world.level.block.state.BlockState; 24 | 25 | import io.vram.frex.api.material.MaterialView; 26 | 27 | public class StateMaterialOnly extends StateBiPredicate { 28 | private MaterialPredicate materialPredicate; 29 | 30 | public StateMaterialOnly(MaterialPredicate materialPredicate) { 31 | this.materialPredicate = materialPredicate; 32 | } 33 | 34 | @Override 35 | public boolean test(BlockState ignored, MaterialView renderMaterial) { 36 | return materialPredicate.test(renderMaterial); 37 | } 38 | 39 | @Override 40 | public boolean equals(Object obj) { 41 | if (obj instanceof StateMaterialOnly) { 42 | return materialPredicate.equals(((StateMaterialOnly) obj).materialPredicate); 43 | } else { 44 | return false; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/map/SingleInvariantMaterialMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.map; 22 | 23 | import org.jetbrains.annotations.ApiStatus.Internal; 24 | import org.jetbrains.annotations.Nullable; 25 | 26 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 27 | 28 | import io.vram.frex.api.material.MaterialFinder; 29 | import io.vram.frex.api.material.MaterialMap; 30 | import io.vram.frex.api.material.MaterialTransform; 31 | 32 | @Internal 33 | class SingleInvariantMaterialMap implements MaterialMap { 34 | protected final MaterialTransform transform; 35 | 36 | SingleInvariantMaterialMap(MaterialTransform transform) { 37 | assert transform != null; 38 | this.transform = transform; 39 | } 40 | 41 | @Override 42 | public void map(MaterialFinder finder, T gameObject, @Nullable TextureAtlasSprite sprite) { 43 | transform.apply(finder); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/renderloop/FrustumSetupListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.renderloop; 22 | 23 | import io.vram.frex.impl.renderloop.FrustumSetupListenerImpl; 24 | 25 | /** 26 | * Called after view Frustum is computed and all render chunks to be rendered are 27 | * identified and rebuilt but before chunks are uploaded to GPU. 28 | * 29 | *

Use for setup of state that depends on view frustum. 30 | */ 31 | @FunctionalInterface 32 | public interface FrustumSetupListener { 33 | void afterFrustumSetup(WorldRenderContext context); 34 | 35 | static void register(FrustumSetupListener listener) { 36 | FrustumSetupListenerImpl.register(listener); 37 | } 38 | 39 | /** 40 | * Must be called by renderer implementations if they 41 | * disable the hooks implemented by FREX. 42 | */ 43 | static void invoke(WorldRenderContext context) { 44 | FrustumSetupListenerImpl.invoke(context); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/mixin/MixinSpriteFinderHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.mixin; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | import org.spongepowered.asm.mixin.Overwrite; 25 | 26 | import net.minecraft.client.renderer.texture.TextureAtlas; 27 | 28 | import net.fabricmc.fabric.impl.renderer.SpriteFinderImpl; 29 | 30 | import io.vram.frex.api.texture.SpriteFinder; 31 | import io.vram.frex.impl.texture.SpriteFinderHolder; 32 | 33 | @Mixin(SpriteFinderHolder.class) 34 | public abstract class MixinSpriteFinderHolder { 35 | /** 36 | * We use the Fabric implementation when it is available. 37 | * It's the same code either way - I wrote it. (Grondag) 38 | * 39 | * @author grondag 40 | * @reason Fabric API compatibility 41 | */ 42 | @Overwrite(remap = false) 43 | public static SpriteFinder get(TextureAtlas atlas) { 44 | return (SpriteFinder) SpriteFinderImpl.get(atlas); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/predicate/StateOnly.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.predicate; 22 | 23 | import net.minecraft.advancements.critereon.StatePropertiesPredicate; 24 | import net.minecraft.world.level.block.state.BlockState; 25 | 26 | import io.vram.frex.api.material.MaterialView; 27 | 28 | public class StateOnly extends StateBiPredicate { 29 | private final StatePropertiesPredicate statePredicate; 30 | 31 | public StateOnly(StatePropertiesPredicate statePredicate) { 32 | this.statePredicate = statePredicate; 33 | } 34 | 35 | @Override 36 | public boolean test(BlockState blockState, MaterialView renderMaterial) { 37 | return statePredicate.matches(blockState); 38 | } 39 | 40 | @Override 41 | public boolean equals(Object obj) { 42 | if (obj instanceof StateOnly) { 43 | return statePredicate.equals(((StateOnly) obj).statePredicate); 44 | } else { 45 | return false; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/math/MatrixStackEntryHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.math; 22 | 23 | import java.lang.reflect.Constructor; 24 | 25 | import com.mojang.blaze3d.vertex.PoseStack; 26 | import com.mojang.math.Matrix3f; 27 | import com.mojang.math.Matrix4f; 28 | 29 | public class MatrixStackEntryHelper { 30 | private static final Constructor CONSTRUCTOR; 31 | 32 | static { 33 | Constructor c; 34 | 35 | try { 36 | c = PoseStack.Pose.class.getDeclaredConstructor(Matrix4f.class, Matrix3f.class); 37 | } catch (final Exception e) { 38 | throw new RuntimeException(e); 39 | } 40 | 41 | c.setAccessible(true); 42 | CONSTRUCTOR = c; 43 | } 44 | 45 | public static PoseStack.Pose create(Matrix4f matrix4f, Matrix3f matrix3f) { 46 | try { 47 | return CONSTRUCTOR.newInstance(matrix4f, matrix3f); 48 | } catch (final Exception e) { 49 | throw new RuntimeException(e); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/renderloop/RenderReloadListenerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.renderloop; 22 | 23 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 24 | 25 | import io.vram.frex.api.renderloop.RenderReloadListener; 26 | 27 | public class RenderReloadListenerImpl { 28 | private static final ObjectArrayList LISTENERS = new ObjectArrayList<>(); 29 | private static RenderReloadListener active = () -> { }; 30 | 31 | public static void register(RenderReloadListener listener) { 32 | LISTENERS.add(listener); 33 | 34 | if (LISTENERS.size() == 1) { 35 | active = LISTENERS.get(0); 36 | } else if (LISTENERS.size() == 2) { 37 | active = () -> { 38 | final int limit = LISTENERS.size(); 39 | 40 | for (int i = 0; i < limit; ++i) { 41 | LISTENERS.get(i).onRenderReload(); 42 | } 43 | }; 44 | } 45 | } 46 | 47 | public static void invoke() { 48 | active.onRenderReload(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/mixin/MixinBlockEntityType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.mixin; 22 | 23 | import java.util.function.Function; 24 | 25 | import org.spongepowered.asm.mixin.Mixin; 26 | 27 | import net.minecraft.world.level.block.entity.BlockEntity; 28 | import net.minecraft.world.level.block.entity.BlockEntityType; 29 | 30 | import io.vram.frex.impl.world.BlockEntityRenderDataImpl; 31 | import io.vram.frex.impl.world.BlockEntityRenderDataProviderAccess; 32 | 33 | @Mixin(BlockEntityType.class) 34 | public class MixinBlockEntityType implements BlockEntityRenderDataProviderAccess { 35 | private Function frxDataProvider = BlockEntityRenderDataImpl.defaultProvider(); 36 | 37 | @Override 38 | public Function frxGetDataProvider() { 39 | return frxDataProvider; 40 | } 41 | 42 | @Override 43 | public void frxSetDataProvider(Function provider) { 44 | frxDataProvider = provider; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/mixin/MixinBlockEntityRenderDataImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.mixin; 22 | 23 | import java.util.function.Function; 24 | 25 | import org.spongepowered.asm.mixin.Mixin; 26 | import org.spongepowered.asm.mixin.Overwrite; 27 | 28 | import net.minecraft.world.level.block.entity.BlockEntity; 29 | 30 | import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity; 31 | 32 | import io.vram.frex.impl.world.BlockEntityRenderDataImpl; 33 | 34 | @Mixin(BlockEntityRenderDataImpl.class) 35 | public class MixinBlockEntityRenderDataImpl { 36 | private static final Function FABRIC_PROVIDER = be -> ((RenderAttachmentBlockEntity) be).getRenderAttachmentData(); 37 | 38 | /** 39 | * @author Grondag 40 | * @reason how we control interop on FAPI 41 | */ 42 | @Overwrite(remap = false) 43 | public static Function defaultProvider() { 44 | return FABRIC_PROVIDER; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/base/client/model/ItemOverrideProxy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.base.client.model; 22 | 23 | import java.util.Collections; 24 | 25 | import org.jetbrains.annotations.Nullable; 26 | 27 | import net.minecraft.client.multiplayer.ClientLevel; 28 | import net.minecraft.client.renderer.block.model.ItemOverrides; 29 | import net.minecraft.client.resources.model.BakedModel; 30 | import net.minecraft.world.entity.LivingEntity; 31 | import net.minecraft.world.item.ItemStack; 32 | 33 | public class ItemOverrideProxy extends ItemOverrides { 34 | private final BakedModel delegate; 35 | 36 | public ItemOverrideProxy(BaseModel delegate) { 37 | super(null, null, null, Collections.emptyList()); 38 | this.delegate = delegate; 39 | } 40 | 41 | @Override 42 | public BakedModel resolve(BakedModel bakedModel, ItemStack itemStack, @Nullable ClientLevel clientWorld, @Nullable LivingEntity livingEntity, int seed) { 43 | return this.delegate; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/base/renderer/ao/AoFaceData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.base.renderer.ao; 22 | 23 | /** 24 | * Holds per-corner results for a single block face. Handles caching and 25 | * provides various utility methods to simplify code elsewhere. 26 | */ 27 | public class AoFaceData { 28 | public static final int OPAQUE = -1; 29 | public final AoFaceCalc calc = new AoFaceCalc(); 30 | // packed values gathered during compute 31 | public int bottom; 32 | public int top; 33 | public int left; 34 | public int right; 35 | public int bottomLeft; 36 | public int bottomRight; 37 | public int topLeft; 38 | public int topRight; 39 | public int center; 40 | // these values are fully computed at gather time 41 | public int aoBottom; 42 | public int aoTop; 43 | public int aoLeft; 44 | public int aoRight; 45 | public int aoBottomLeft; 46 | public int aoBottomRight; 47 | public int aoTopLeft; 48 | public int aoTopRight; 49 | public int aoCenter; 50 | } 51 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/mixin/MixinFabricBakedModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.mixin; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | 25 | import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel; 26 | 27 | import io.vram.frex.api.buffer.QuadSink; 28 | import io.vram.frex.api.model.BlockItemModel; 29 | import io.vram.frex.fabric.compat.FabricContextWrapper; 30 | 31 | @Mixin(FabricBakedModel.class) 32 | public interface MixinFabricBakedModel extends BlockItemModel { 33 | @Override 34 | default void renderAsItem(ItemInputContext input, QuadSink output) { 35 | ((FabricBakedModel) this).emitItemQuads(input.itemStack(), input::random, FabricContextWrapper.wrap(input, output)); 36 | } 37 | 38 | @Override 39 | default void renderAsBlock(BlockInputContext input, QuadSink output) { 40 | ((FabricBakedModel) this).emitBlockQuads(input.blockView(), input.blockState(), input.pos(), input::random, FabricContextWrapper.wrap(input, output)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/base/renderer/util/ResourceCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.base.renderer.util; 22 | 23 | import java.util.function.Supplier; 24 | 25 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 26 | 27 | /** 28 | * Holds a reference to an object that should be cleared on resource reload. 29 | * @param Type of the cached object 30 | */ 31 | public final class ResourceCache { 32 | private static final ObjectArrayList> CACHED = new ObjectArrayList<>(64); 33 | private final Supplier loader; 34 | private T value; 35 | 36 | public static void invalidateAll() { 37 | CACHED.forEach(ResourceCache::invalidate); 38 | } 39 | 40 | public ResourceCache(Supplier loader) { 41 | CACHED.add(this); 42 | this.loader = loader; 43 | } 44 | 45 | private void invalidate() { 46 | value = null; 47 | } 48 | 49 | public T getOrLoad() { 50 | if (value == null) { 51 | value = loader.get(); 52 | } 53 | 54 | return value; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/mixin/FabricMixinPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.mixin; 22 | 23 | import net.fabricmc.loader.api.FabricLoader; 24 | 25 | import io.vram.frex.fabric.compat.SimpleMixinConfig; 26 | 27 | public class FabricMixinPlugin extends SimpleMixinConfig { 28 | public FabricMixinPlugin() { 29 | super("io.vram.frex.fabric.mixin.", c -> { 30 | if (!FabricLoader.getInstance().isModLoaded("fabric-renderer-api-v1")) { 31 | c.accept("MixinFabricSpriteFinder"); 32 | c.accept("MixinFabricBakedModel"); 33 | c.accept("MixinSpriteFinderHolder"); 34 | c.accept("MixinFrex"); 35 | } 36 | 37 | if (!FabricLoader.getInstance().isModLoaded("fabric-rendering-fluids-v1")) { 38 | c.accept("MixinFluidRenderHandler"); 39 | c.accept("MixinFluidAppearanceImpl"); 40 | } 41 | 42 | if (!FabricLoader.getInstance().isModLoaded("fabric-rendering-data-attachment-v1")) { 43 | c.accept("MixinBlockEntityRenderDataImpl"); 44 | } 45 | }); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/renderloop/WorldRenderPostListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.renderloop; 22 | 23 | import io.vram.frex.impl.renderloop.WorldRenderPostListenerImpl; 24 | 25 | /** 26 | * Called after all world rendering is complete and changes to GL state are unwound. 27 | * 28 | *

Use to draw overlays that handle GL state management independently or to tear 29 | * down transient state in event handlers or as a hook that precedes hand/held item 30 | * and GUI rendering. 31 | */ 32 | @FunctionalInterface 33 | public interface WorldRenderPostListener { 34 | void afterWorldRender(WorldRenderContext context); 35 | 36 | static void register(WorldRenderPostListener listener) { 37 | WorldRenderPostListenerImpl.register(listener); 38 | } 39 | 40 | /** 41 | * Must be called by renderer implementations if they 42 | * disable the hooks implemented by FREX. 43 | */ 44 | static void invoke(WorldRenderContext context) { 45 | WorldRenderPostListenerImpl.invoke(context); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/model/provider/SubModelLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.model.provider; 22 | 23 | import org.jetbrains.annotations.Nullable; 24 | 25 | import net.minecraft.client.resources.model.UnbakedModel; 26 | import net.minecraft.resources.ResourceLocation; 27 | 28 | /** 29 | * Passed to model providers as a way for them to retrieve models on 30 | * which they depend. Makes no guarantee regarding the availability 31 | * of requested models, nor the specific implementation of models returned. 32 | */ 33 | @FunctionalInterface 34 | public interface SubModelLoader { 35 | /** 36 | * Attempts to load the requested model. Will throw an exception and cause loading of the 37 | * current model to fail if a circular dependency is detected. 38 | * 39 | * @param path identifies the sub model to load. 40 | * @return The loaded UnbakedModel or the missing model instance if the requested path is not found. 41 | */ 42 | @Nullable 43 | UnbakedModel loadSubModel(ResourceLocation path); 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/mixin/MixinTextureAtlasPreparation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.mixin; 22 | 23 | import java.util.List; 24 | 25 | import org.spongepowered.asm.mixin.Final; 26 | import org.spongepowered.asm.mixin.Mixin; 27 | import org.spongepowered.asm.mixin.Shadow; 28 | 29 | import net.minecraft.client.renderer.texture.TextureAtlas; 30 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 31 | 32 | import io.vram.frex.impl.texture.TextureAtlasPreparationExt; 33 | 34 | @Mixin(TextureAtlas.Preparations.class) 35 | public class MixinTextureAtlasPreparation implements TextureAtlasPreparationExt { 36 | @Shadow @Final int width; 37 | @Shadow @Final int height; 38 | @Shadow @Final List regions; 39 | 40 | @Override 41 | public int frex_atlasWidth() { 42 | return width; 43 | } 44 | 45 | @Override 46 | public int frex_atlasHeight() { 47 | return height; 48 | } 49 | 50 | @Override 51 | public List frex_sprites() { 52 | return regions; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/mixin/events/MixinFabricWorldRenderContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.mixin.events; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | 25 | import com.mojang.blaze3d.vertex.PoseStack; 26 | 27 | import net.minecraft.client.renderer.LightTexture; 28 | 29 | import net.fabricmc.fabric.impl.client.rendering.WorldRenderContextImpl; 30 | 31 | import io.vram.frex.api.renderloop.BlockOutlineListener.BlockOutlineContext; 32 | import io.vram.frex.api.renderloop.WorldRenderContext; 33 | 34 | @Mixin(WorldRenderContextImpl.class) 35 | public abstract class MixinFabricWorldRenderContext implements WorldRenderContext, BlockOutlineContext { 36 | @Override 37 | public LightTexture lightmapTexture() { 38 | return ((net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext) this).lightmapTextureManager(); 39 | } 40 | 41 | @Override 42 | public PoseStack poseStack() { 43 | return ((net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext) this).matrixStack(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/renderloop/DebugRenderListenerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.renderloop; 22 | 23 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 24 | 25 | import io.vram.frex.api.renderloop.DebugRenderListener; 26 | import io.vram.frex.api.renderloop.WorldRenderContext; 27 | 28 | public class DebugRenderListenerImpl { 29 | private static final ObjectArrayList LISTENERS = new ObjectArrayList<>(); 30 | private static DebugRenderListener active = ctx -> { }; 31 | 32 | public static void register(DebugRenderListener listener) { 33 | LISTENERS.add(listener); 34 | 35 | if (LISTENERS.size() == 1) { 36 | active = LISTENERS.get(0); 37 | } else if (LISTENERS.size() == 2) { 38 | active = ctx -> { 39 | final int limit = LISTENERS.size(); 40 | 41 | for (int i = 0; i < limit; ++i) { 42 | LISTENERS.get(i).beforeDebugRender(ctx); 43 | } 44 | }; 45 | } 46 | } 47 | 48 | public static void invoke(WorldRenderContext ctx) { 49 | active.beforeDebugRender(ctx); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/renderloop/RenderReloadListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.renderloop; 22 | 23 | import io.vram.frex.impl.renderloop.RenderReloadListenerImpl; 24 | 25 | /** 26 | * Called when the world renderer reloads, usually as result of changing resource pack 27 | * or video configuration, or when the player types F3+A in the debug screen. 28 | * Afterwards all render chunks will be reset and reloaded. 29 | * 30 | *

Render chunks and other render-related object instances will be made null 31 | * or invalid after this event so do not use it to capture dependent state. 32 | * Instead, use it to invalidate state and reinitialize lazily. 33 | */ 34 | @FunctionalInterface 35 | public interface RenderReloadListener { 36 | void onRenderReload(); 37 | 38 | static void register(RenderReloadListener listener) { 39 | RenderReloadListenerImpl.register(listener); 40 | } 41 | 42 | /** 43 | * For use by renderer implementations. 44 | */ 45 | static void invoke() { 46 | RenderReloadListenerImpl.invoke(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/model/EntityModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.model; 22 | 23 | import net.minecraft.network.chat.Component; 24 | import net.minecraft.world.entity.Entity; 25 | 26 | import io.vram.frex.api.buffer.QuadSink; 27 | import io.vram.frex.api.model.InputContext.Type; 28 | 29 | @FunctionalInterface 30 | public interface EntityModel extends DynamicModel { 31 | void renderAsEntity(EntityInputContext input, QuadSink output); 32 | 33 | @Override 34 | @SuppressWarnings("unchecked") 35 | default void renderDynamic(InputContext input, QuadSink output) { 36 | if (input.type() == Type.ENTITY) { 37 | renderAsEntity((EntityInputContext) input, output); 38 | } 39 | } 40 | 41 | interface EntityInputContext extends InputContext { 42 | @Override 43 | default Type type() { 44 | return Type.ENTITY; 45 | } 46 | 47 | E entity(); 48 | 49 | Component entityDisplayName(); 50 | 51 | float yawDelta(); 52 | 53 | float tickDelta(); 54 | 55 | int packedLight(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/renderer/ConditionManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.renderer; 22 | 23 | import java.util.function.BooleanSupplier; 24 | 25 | import net.minecraft.resources.ResourceLocation; 26 | 27 | import io.vram.frex.api.material.MaterialCondition; 28 | 29 | public interface ConditionManager { 30 | @Deprecated 31 | /** 32 | * @deprecated Not practical for implementations to segregate item/block usage. 33 | * If this is really needed can use separate conditions. 34 | */ 35 | default MaterialCondition createCondition(BooleanSupplier supplier, boolean affectBlocks, boolean affectItems) { 36 | return createCondition(supplier); 37 | } 38 | 39 | MaterialCondition createCondition(BooleanSupplier supplier); 40 | 41 | int indexOf(MaterialCondition condition); 42 | 43 | MaterialCondition conditionFromIndex(int index); 44 | 45 | boolean registerCondition(ResourceLocation id, MaterialCondition condition); 46 | 47 | MaterialCondition conditionFromId(ResourceLocation id); 48 | 49 | MaterialCondition alwaysTrue(); 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/renderloop/FrustumSetupListenerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.renderloop; 22 | 23 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 24 | 25 | import io.vram.frex.api.renderloop.FrustumSetupListener; 26 | import io.vram.frex.api.renderloop.WorldRenderContext; 27 | 28 | public class FrustumSetupListenerImpl { 29 | private static final ObjectArrayList LISTENERS = new ObjectArrayList<>(); 30 | private static FrustumSetupListener active = ctx -> { }; 31 | 32 | public static void register(FrustumSetupListener listener) { 33 | LISTENERS.add(listener); 34 | 35 | if (LISTENERS.size() == 1) { 36 | active = LISTENERS.get(0); 37 | } else if (LISTENERS.size() == 2) { 38 | active = ctx -> { 39 | final int limit = LISTENERS.size(); 40 | 41 | for (int i = 0; i < limit; ++i) { 42 | LISTENERS.get(i).afterFrustumSetup(ctx); 43 | } 44 | }; 45 | } 46 | } 47 | 48 | public static void invoke(WorldRenderContext ctx) { 49 | active.afterFrustumSetup(ctx); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/world/BlockEntityRenderDataImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.world; 22 | 23 | import java.util.function.Function; 24 | 25 | import org.jetbrains.annotations.ApiStatus.Internal; 26 | 27 | import net.minecraft.world.level.block.entity.BlockEntity; 28 | import net.minecraft.world.level.block.entity.BlockEntityType; 29 | 30 | @Internal 31 | public class BlockEntityRenderDataImpl { 32 | public static void registerProvider(BlockEntityType type, Function provider) { 33 | ((BlockEntityRenderDataProviderAccess) type).frxSetDataProvider(provider); 34 | } 35 | 36 | public static Object get(BlockEntity entity) { 37 | return ((BlockEntityRenderDataProviderAccess) entity.getType()).frxGetDataProvider().apply(entity); 38 | } 39 | 40 | private static final Function DEFAULT_PROVIDER = be -> null; 41 | 42 | /** Overwritten via mixin on Fabric to usse Fabric interface. */ 43 | public static Function defaultProvider() { 44 | return DEFAULT_PROVIDER; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/renderloop/WorldRenderLastListenerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.renderloop; 22 | 23 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 24 | 25 | import io.vram.frex.api.renderloop.WorldRenderContext; 26 | import io.vram.frex.api.renderloop.WorldRenderLastListener; 27 | 28 | public class WorldRenderLastListenerImpl { 29 | private static final ObjectArrayList LISTENERS = new ObjectArrayList<>(); 30 | private static WorldRenderLastListener active = ctx -> { }; 31 | 32 | public static void register(WorldRenderLastListener listener) { 33 | LISTENERS.add(listener); 34 | 35 | if (LISTENERS.size() == 1) { 36 | active = LISTENERS.get(0); 37 | } else if (LISTENERS.size() == 2) { 38 | active = ctx -> { 39 | final int limit = LISTENERS.size(); 40 | 41 | for (int i = 0; i < limit; ++i) { 42 | LISTENERS.get(i).onLastWorldRender(ctx); 43 | } 44 | }; 45 | } 46 | } 47 | 48 | public static void invoke(WorldRenderContext ctx) { 49 | active.onLastWorldRender(ctx); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/renderloop/WorldRenderPostListenerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.renderloop; 22 | 23 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 24 | 25 | import io.vram.frex.api.renderloop.WorldRenderContext; 26 | import io.vram.frex.api.renderloop.WorldRenderPostListener; 27 | 28 | public class WorldRenderPostListenerImpl { 29 | private static final ObjectArrayList LISTENERS = new ObjectArrayList<>(); 30 | private static WorldRenderPostListener active = ctx -> { }; 31 | 32 | public static void register(WorldRenderPostListener listener) { 33 | LISTENERS.add(listener); 34 | 35 | if (LISTENERS.size() == 1) { 36 | active = LISTENERS.get(0); 37 | } else if (LISTENERS.size() == 2) { 38 | active = ctx -> { 39 | final int limit = LISTENERS.size(); 40 | 41 | for (int i = 0; i < limit; ++i) { 42 | LISTENERS.get(i).afterWorldRender(ctx); 43 | } 44 | }; 45 | } 46 | } 47 | 48 | public static void invoke(WorldRenderContext ctx) { 49 | active.afterWorldRender(ctx); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/renderloop/EntityRenderPostListenerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.renderloop; 22 | 23 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 24 | 25 | import io.vram.frex.api.renderloop.EntityRenderPostListener; 26 | import io.vram.frex.api.renderloop.WorldRenderContext; 27 | 28 | public class EntityRenderPostListenerImpl { 29 | private static final ObjectArrayList LISTENERS = new ObjectArrayList<>(); 30 | private static EntityRenderPostListener active = ctx -> { }; 31 | 32 | public static void register(EntityRenderPostListener listener) { 33 | LISTENERS.add(listener); 34 | 35 | if (LISTENERS.size() == 1) { 36 | active = LISTENERS.get(0); 37 | } else if (LISTENERS.size() == 2) { 38 | active = ctx -> { 39 | final int limit = LISTENERS.size(); 40 | 41 | for (int i = 0; i < limit; ++i) { 42 | LISTENERS.get(i).afterEntityRender(ctx); 43 | } 44 | }; 45 | } 46 | } 47 | 48 | public static void invoke(WorldRenderContext ctx) { 49 | active.afterEntityRender(ctx); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/renderloop/EntityRenderPreListenerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.renderloop; 22 | 23 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 24 | 25 | import io.vram.frex.api.renderloop.EntityRenderPreListener; 26 | import io.vram.frex.api.renderloop.WorldRenderContext; 27 | 28 | public class EntityRenderPreListenerImpl { 29 | private static final ObjectArrayList LISTENERS = new ObjectArrayList<>(); 30 | private static EntityRenderPreListener active = ctx -> { }; 31 | 32 | public static void register(EntityRenderPreListener listener) { 33 | LISTENERS.add(listener); 34 | 35 | if (LISTENERS.size() == 1) { 36 | active = LISTENERS.get(0); 37 | } else if (LISTENERS.size() == 2) { 38 | active = ctx -> { 39 | final int limit = LISTENERS.size(); 40 | 41 | for (int i = 0; i < limit; ++i) { 42 | LISTENERS.get(i).beforeEntityRender(ctx); 43 | } 44 | }; 45 | } 46 | } 47 | 48 | public static void invoke(WorldRenderContext ctx) { 49 | active.beforeEntityRender(ctx); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/rendertype/BlockPresets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.rendertype; 22 | 23 | import net.minecraft.client.renderer.RenderType; 24 | import net.minecraft.world.level.block.Block; 25 | import net.minecraft.world.level.material.Fluid; 26 | 27 | import io.vram.frex.impl.material.BlockPresetsImpl; 28 | 29 | /** 30 | * Use to associate blocks or fluids with render types other than default. 31 | * They can be retrieved via the vanilla utility {@code ItemBlockRenderTypes}. 32 | */ 33 | public interface BlockPresets { 34 | static void mapBlocks(int preset, Block... blocks) { 35 | BlockPresetsImpl.mapBlocks(preset, blocks); 36 | } 37 | 38 | static void mapBlocks(RenderType chunkRenderType, Block... blocks) { 39 | BlockPresetsImpl.mapBlocks(chunkRenderType, blocks); 40 | } 41 | 42 | static void mapFluids(int preset, Fluid... fluids) { 43 | BlockPresetsImpl.mapFluids(preset, fluids); 44 | } 45 | 46 | static void mapFluids(RenderType chunkRenderType, Fluid... fluids) { 47 | BlockPresetsImpl.mapFluids(chunkRenderType, fluids); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/renderloop/TranslucentPostListenerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.renderloop; 22 | 23 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 24 | 25 | import io.vram.frex.api.renderloop.TranslucentPostListener; 26 | import io.vram.frex.api.renderloop.WorldRenderContext; 27 | 28 | public class TranslucentPostListenerImpl { 29 | private static final ObjectArrayList LISTENERS = new ObjectArrayList<>(); 30 | private static TranslucentPostListener active = ctx -> { }; 31 | 32 | public static void register(TranslucentPostListener listener) { 33 | LISTENERS.add(listener); 34 | 35 | if (LISTENERS.size() == 1) { 36 | active = LISTENERS.get(0); 37 | } else if (LISTENERS.size() == 2) { 38 | active = ctx -> { 39 | final int limit = LISTENERS.size(); 40 | 41 | for (int i = 0; i < limit; ++i) { 42 | LISTENERS.get(i).afterTranslcuentRender(ctx); 43 | } 44 | }; 45 | } 46 | } 47 | 48 | public static void invoke(WorldRenderContext ctx) { 49 | active.afterTranslcuentRender(ctx); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/renderloop/WorldRenderStartListenerImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.renderloop; 22 | 23 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 24 | 25 | import io.vram.frex.api.renderloop.WorldRenderContext; 26 | import io.vram.frex.api.renderloop.WorldRenderStartListener; 27 | 28 | public class WorldRenderStartListenerImpl { 29 | private static final ObjectArrayList LISTENERS = new ObjectArrayList<>(); 30 | private static WorldRenderStartListener active = ctx -> { }; 31 | 32 | public static void register(WorldRenderStartListener listener) { 33 | LISTENERS.add(listener); 34 | 35 | if (LISTENERS.size() == 1) { 36 | active = LISTENERS.get(0); 37 | } else if (LISTENERS.size() == 2) { 38 | active = ctx -> { 39 | final int limit = LISTENERS.size(); 40 | 41 | for (int i = 0; i < limit; ++i) { 42 | LISTENERS.get(i).onStartWorldRender(ctx); 43 | } 44 | }; 45 | } 46 | } 47 | 48 | public static void invoke(WorldRenderContext ctx) { 49 | active.onStartWorldRender(ctx); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/base/renderer/mesh/RootQuadEmitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.base.renderer.mesh; 22 | 23 | import io.vram.frex.api.buffer.PooledQuadEmitter; 24 | import io.vram.frex.api.buffer.PooledVertexEmitter; 25 | import io.vram.frex.api.buffer.QuadTransform; 26 | import io.vram.frex.api.model.InputContext; 27 | 28 | public abstract class RootQuadEmitter extends BaseQuadEmitter { 29 | protected final TransformStack transformStack; 30 | 31 | public RootQuadEmitter() { 32 | transformStack = createTransformStack(); 33 | } 34 | 35 | /** Override to use custom stack. */ 36 | protected TransformStack createTransformStack() { 37 | return new TransformStack(); 38 | } 39 | 40 | @Override 41 | public PooledQuadEmitter withTransformQuad(InputContext context, QuadTransform transform) { 42 | return transformStack.createTransform(context, transform, this); 43 | } 44 | 45 | @Override 46 | public PooledVertexEmitter withTransformVertex(InputContext context, QuadTransform transform) { 47 | return transformStack.createTransform(context, transform, this); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/predicate/EntityMaterialBoth.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.predicate; 22 | 23 | import net.minecraft.world.entity.Entity; 24 | 25 | import io.vram.frex.api.material.MaterialView; 26 | 27 | public class EntityMaterialBoth extends EntityBiPredicate { 28 | private final EntityOnly entityOnly; 29 | private final MaterialPredicate materialPredicate; 30 | 31 | public EntityMaterialBoth(EntityOnly entityOnly, MaterialPredicate materialPredicate) { 32 | this.entityOnly = entityOnly; 33 | this.materialPredicate = materialPredicate; 34 | } 35 | 36 | @Override 37 | public boolean test(Entity entity, MaterialView renderMaterial) { 38 | return entityOnly.test(entity) && materialPredicate.test(renderMaterial); 39 | } 40 | 41 | @Override 42 | public boolean equals(Object obj) { 43 | if (obj instanceof EntityMaterialBoth) { 44 | return entityOnly.equals(((EntityMaterialBoth) obj).entityOnly) 45 | && materialPredicate.equals(((EntityMaterialBoth) obj).materialPredicate); 46 | } else { 47 | return false; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/mixin/MixinItemBlockRenderTypes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.mixin; 22 | 23 | import java.util.Map; 24 | 25 | import org.spongepowered.asm.mixin.Mixin; 26 | import org.spongepowered.asm.mixin.Shadow; 27 | import org.spongepowered.asm.mixin.injection.At; 28 | import org.spongepowered.asm.mixin.injection.Inject; 29 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 30 | 31 | import net.minecraft.client.renderer.ItemBlockRenderTypes; 32 | import net.minecraft.client.renderer.RenderType; 33 | import net.minecraft.world.level.block.Block; 34 | import net.minecraft.world.level.material.Fluid; 35 | 36 | import io.vram.frex.impl.material.BlockPresetsImpl; 37 | 38 | @Mixin(ItemBlockRenderTypes.class) 39 | public abstract class MixinItemBlockRenderTypes { 40 | @Shadow private static Map TYPE_BY_BLOCK; 41 | @Shadow private static Map TYPE_BY_FLUID; 42 | 43 | @Inject(method = "*", at = @At("RETURN")) 44 | private static void onInitialize(CallbackInfo info) { 45 | BlockPresetsImpl.setConsumers(TYPE_BY_BLOCK::put, TYPE_BY_FLUID::put); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/world/ItemColorRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.world; 22 | 23 | import org.jetbrains.annotations.ApiStatus.NonExtendable; 24 | import org.jetbrains.annotations.Nullable; 25 | 26 | import net.minecraft.client.color.item.ItemColor; 27 | import net.minecraft.client.color.item.ItemColors; 28 | import net.minecraft.world.level.ItemLike; 29 | 30 | import io.vram.frex.impl.world.ColorRegistryImpl; 31 | 32 | /** 33 | * Use this to safely register item colors during initialization 34 | * when the vanilla instances may not yet exist. Guarantees the registrations 35 | * will take place before rendering starts, irrespective of initialization order. 36 | */ 37 | @NonExtendable 38 | public interface ItemColorRegistry { 39 | static void register(ItemColor itemColor, ItemLike... items) { 40 | ColorRegistryImpl.register(itemColor, items); 41 | } 42 | 43 | /** 44 | * Convenient access for the default item colors instance. 45 | * Will be null until the game client initialization creates it. 46 | */ 47 | static @Nullable ItemColors get() { 48 | return ColorRegistryImpl.getItemColors(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/base/renderer/context/input/BaseBakedInputContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.base.renderer.context.input; 22 | 23 | import net.minecraft.client.renderer.RenderType; 24 | import net.minecraft.client.resources.model.BakedModel; 25 | 26 | import io.vram.frex.api.model.BakedInputContext; 27 | 28 | public abstract class BaseBakedInputContext extends BaseInputContext implements BakedInputContext { 29 | protected BakedModel bakedModel; 30 | protected RenderType defaultRenderType; 31 | protected int defaultPreset; 32 | 33 | public BaseBakedInputContext(Type type) { 34 | super(type); 35 | } 36 | 37 | @Override 38 | public int indexedColor(int colorIndex) { 39 | return -1; 40 | } 41 | 42 | @Override 43 | public BakedModel bakedModel() { 44 | return bakedModel; 45 | } 46 | 47 | protected abstract void computeDefaultRenderType(); 48 | 49 | @Override 50 | public RenderType defaultRenderType() { 51 | computeDefaultRenderType(); 52 | return defaultRenderType; 53 | } 54 | 55 | @Override 56 | public int defaultPreset() { 57 | computeDefaultRenderType(); 58 | return defaultPreset; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /fabriquilt/src/main/java/io/vram/frex/pastel/mixinterface/RenderChunkRegionExt.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.pastel.mixinterface; 22 | 23 | import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; 24 | import org.jetbrains.annotations.Nullable; 25 | 26 | import net.minecraft.core.BlockPos; 27 | import net.minecraft.world.level.biome.Biome; 28 | 29 | import io.vram.frex.api.world.RenderRegionBakeListener; 30 | import io.vram.frex.pastel.PastelTerrainRenderContext; 31 | 32 | public interface RenderChunkRegionExt { 33 | int frx_cachedAoLevel(int cacheIndex); 34 | 35 | int frx_cachedBrightness(int cacheIndex); 36 | 37 | int frx_cachedBrightness(BlockPos pos); 38 | 39 | boolean frx_isClosed(int cacheIndex); 40 | 41 | @Nullable 42 | Object frx_getBlockEntityRenderData(BlockPos pos); 43 | 44 | void frx_setBlockEntityRenderData(Long2ObjectOpenHashMap renderData); 45 | 46 | PastelTerrainRenderContext frx_getContext(); 47 | 48 | void frx_setContext(PastelTerrainRenderContext context, BlockPos origin); 49 | 50 | @Nullable 51 | RenderRegionBakeListener[] frx_getRenderRegionListeners(); 52 | 53 | Biome frx_getBiome(BlockPos pos); 54 | } 55 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/world/BlockColorRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.world; 22 | 23 | import org.jetbrains.annotations.ApiStatus.NonExtendable; 24 | import org.jetbrains.annotations.Nullable; 25 | 26 | import net.minecraft.client.color.block.BlockColor; 27 | import net.minecraft.client.color.block.BlockColors; 28 | import net.minecraft.world.level.block.Block; 29 | 30 | import io.vram.frex.impl.world.ColorRegistryImpl; 31 | 32 | /** 33 | * Use this to safely register block colors during initialization 34 | * when the vanilla instances may not yet exist. Guarantees the registrations 35 | * will take place before rendering starts, irrespective of initialization order. 36 | */ 37 | @NonExtendable 38 | public interface BlockColorRegistry { 39 | static void register(BlockColor blockColor, Block... blocks) { 40 | ColorRegistryImpl.register(blockColor, blocks); 41 | } 42 | 43 | /** 44 | * Convenient access for the default block colors instance. 45 | * Will be null until the game client initialization creates it. 46 | */ 47 | static @Nullable BlockColors get() { 48 | return ColorRegistryImpl.getBlockColors(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/map/SpriteMaterialMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.map; 22 | 23 | import java.util.IdentityHashMap; 24 | 25 | import org.jetbrains.annotations.ApiStatus.Internal; 26 | import org.jetbrains.annotations.Nullable; 27 | 28 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 29 | 30 | import io.vram.frex.api.material.MaterialFinder; 31 | import io.vram.frex.api.material.MaterialMap; 32 | import io.vram.frex.api.material.MaterialTransform; 33 | 34 | @Internal 35 | class SpriteMaterialMap implements MaterialMap { 36 | protected final IdentityHashMap spriteMap; 37 | 38 | SpriteMaterialMap(IdentityHashMap spriteMap) { 39 | this.spriteMap = spriteMap; 40 | } 41 | 42 | @Override 43 | public boolean needsSprite() { 44 | return true; 45 | } 46 | 47 | @Override 48 | public void map(MaterialFinder finder, T gameObject, @Nullable TextureAtlasSprite sprite) { 49 | final MaterialTransform result = spriteMap.get(sprite); 50 | 51 | if (result != null) { 52 | result.apply(finder); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/math/FixedMath255.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.math; 22 | 23 | /** 24 | * 8-bit fixed precision math routines. 25 | * Assumes normalized values. 26 | */ 27 | public class FixedMath255 { 28 | public static final int UNIT_VALUE = 0xFF; 29 | public static final int HALF_VALUE = 0x7F; 30 | public static final int UNIT_SHIFT = 8; 31 | public static final float FLOAT_CONVERSION_FACTOR = 1f / 255f; 32 | 33 | public static int clamp(float x) { 34 | if (x < 0f) x = 0; 35 | if (x > 1f) x = 1; 36 | return Math.round(x * UNIT_VALUE); 37 | } 38 | 39 | public static int mul(int x, int y) { 40 | return (x * y + UNIT_VALUE) >> UNIT_SHIFT; 41 | } 42 | 43 | protected static final int RECIPROCAL_DIVIDE_127_MAGIC = 33026; 44 | protected static final int RECIPROCAL_DIVIDE_127_SHIFT = 22; 45 | 46 | /** 47 | * Fast re-scale of normal values from signed 127 to unsigned 0-255. 48 | * See https://www.agner.org/optimize/optimizing_assembly.pdf Sec 16.8 "Division" 49 | */ 50 | public static int from127(int base127) { 51 | return ((Math.abs(base127) * 255 + 1) * RECIPROCAL_DIVIDE_127_MAGIC) >> RECIPROCAL_DIVIDE_127_SHIFT; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/map/SingleMaterialMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.map; 22 | 23 | import java.util.function.BiPredicate; 24 | 25 | import org.jetbrains.annotations.ApiStatus.Internal; 26 | import org.jetbrains.annotations.Nullable; 27 | 28 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 29 | 30 | import io.vram.frex.api.material.MaterialFinder; 31 | import io.vram.frex.api.material.MaterialTransform; 32 | import io.vram.frex.api.material.MaterialView; 33 | 34 | @Internal 35 | class SingleMaterialMap extends SingleInvariantMaterialMap { 36 | protected final BiPredicate predicate; 37 | 38 | SingleMaterialMap(BiPredicate predicate, MaterialTransform transform) { 39 | super(transform); 40 | this.predicate = predicate; 41 | } 42 | 43 | @Override 44 | public void map(MaterialFinder finder, T gameObject, @Nullable TextureAtlasSprite sprite) { 45 | map(finder, gameObject, null); 46 | } 47 | 48 | @Override 49 | public void map(MaterialFinder finder, T gameObject) { 50 | if (predicate.test(gameObject, finder)) { 51 | transform.apply(finder); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /fabric/src/main/java/io/vram/frex/fabric/compat/FabricMeshBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.fabric.compat; 22 | 23 | import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh; 24 | import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter; 25 | 26 | import io.vram.frex.api.mesh.MeshBuilder; 27 | 28 | /** 29 | * Interface for rendering plug-ins that provide enhanced capabilities 30 | * for model lighting, buffering and rendering. Such plug-ins implement the 31 | * enhanced model rendering interfaces specified by the Fabric API. 32 | */ 33 | public class FabricMeshBuilder implements net.fabricmc.fabric.api.renderer.v1.mesh.MeshBuilder { 34 | public static FabricMeshBuilder of(MeshBuilder wrapped) { 35 | return new FabricMeshBuilder(wrapped); 36 | } 37 | 38 | final MeshBuilder wrapped; 39 | 40 | private final FabricQuadEmitter qe; 41 | 42 | protected FabricMeshBuilder(MeshBuilder wrapped) { 43 | this.wrapped = wrapped; 44 | qe = FabricQuadEmitter.of(wrapped.getEmitter()); 45 | } 46 | 47 | @Override 48 | public QuadEmitter getEmitter() { 49 | return qe; 50 | } 51 | 52 | @Override 53 | public Mesh build() { 54 | return FabricMesh.of(wrapped.build()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/renderloop/WorldRenderStartListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.renderloop; 22 | 23 | import net.minecraft.client.renderer.LevelRenderer; 24 | 25 | import io.vram.frex.impl.renderloop.WorldRenderStartListenerImpl; 26 | 27 | /** 28 | * Called before world rendering executes. Input parameters are available but frustum is not. 29 | * Use this event instead of injecting to the HEAD of {@link LevelRenderer#renderLevel} to avoid 30 | * compatibility problems with 3rd-party renderer implementations. 31 | * 32 | *

Use for setup of state that is needed during the world render call that 33 | * does not depend on the view frustum. 34 | */ 35 | @FunctionalInterface 36 | public interface WorldRenderStartListener { 37 | void onStartWorldRender(WorldRenderContext context); 38 | 39 | static void register(WorldRenderStartListener listener) { 40 | WorldRenderStartListenerImpl.register(listener); 41 | } 42 | 43 | /** 44 | * Must be called by renderer implementations if they 45 | * disable the hooks implemented by FREX. 46 | */ 47 | static void invoke(WorldRenderContext context) { 48 | WorldRenderStartListenerImpl.invoke(context); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/base/client/model/MeshFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.base.client.model; 22 | 23 | import io.vram.frex.api.material.MaterialFinder; 24 | import io.vram.frex.api.mesh.Mesh; 25 | import io.vram.frex.api.mesh.MeshBuilder; 26 | import io.vram.frex.api.renderer.Renderer; 27 | 28 | @FunctionalInterface 29 | public interface MeshFactory { 30 | default Mesh createMesh(SpriteProvider spriteProvider) { 31 | return createMesh(Renderer.get().meshBuilder(), MaterialFinder.threadLocal(), spriteProvider); 32 | } 33 | 34 | Mesh createMesh(MeshBuilder meshBuilder, MaterialFinder finder, SpriteProvider spriteProvider); 35 | 36 | static MeshFactory shared(MeshFactory factory) { 37 | return new MeshFactory() { 38 | Mesh mesh = null; 39 | 40 | @Override 41 | public Mesh createMesh(MeshBuilder meshBuilder, MaterialFinder finder, SpriteProvider spriteProvider) { 42 | Mesh result = mesh; 43 | 44 | if (result == null) { 45 | result = factory.createMesh(meshBuilder, finder, spriteProvider); 46 | mesh = result; 47 | } 48 | 49 | return result; 50 | } 51 | }; 52 | } 53 | 54 | MeshFactory EMPTY = (mb, finder, sp) -> Mesh.EMPTY; 55 | } 56 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/renderloop/WorldRenderLastListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.renderloop; 22 | 23 | import io.vram.frex.impl.renderloop.WorldRenderLastListenerImpl; 24 | 25 | /** 26 | * Called after all framebuffer writes are complete but before all world 27 | * rendering is torn down. 28 | * 29 | *

Unlike most other events, renders in this event are expected to be drawn 30 | * directly and immediately to the framebuffer. The OpenGL render state view 31 | * matrix will be transformed to match the camera view before the event is called. 32 | * 33 | *

Use to draw content that should appear on top of the world before hand and GUI rendering occur. 34 | */ 35 | @FunctionalInterface 36 | public interface WorldRenderLastListener { 37 | void onLastWorldRender(WorldRenderContext context); 38 | 39 | static void register(WorldRenderLastListener listener) { 40 | WorldRenderLastListenerImpl.register(listener); 41 | } 42 | 43 | /** 44 | * Must be called by renderer implementations if they 45 | * disable the hooks implemented by FREX. 46 | */ 47 | static void invoke(WorldRenderContext context) { 48 | WorldRenderLastListenerImpl.invoke(context); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/map/DefaultedSpriteMaterialMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.map; 22 | 23 | import java.util.IdentityHashMap; 24 | 25 | import org.jetbrains.annotations.ApiStatus.Internal; 26 | import org.jetbrains.annotations.Nullable; 27 | 28 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 29 | 30 | import io.vram.frex.api.material.MaterialFinder; 31 | import io.vram.frex.api.material.MaterialMap; 32 | import io.vram.frex.api.material.MaterialTransform; 33 | 34 | @Internal 35 | class DefaultedSpriteMaterialMap extends SpriteMaterialMap implements MaterialMap { 36 | protected final MaterialTransform defaultTransform; 37 | 38 | DefaultedSpriteMaterialMap(MaterialTransform defaultTransform, IdentityHashMap spriteMap) { 39 | super(spriteMap); 40 | this.defaultTransform = defaultTransform; 41 | } 42 | 43 | @Override 44 | public void map(MaterialFinder finder, T gameObject, @Nullable TextureAtlasSprite sprite) { 45 | final MaterialTransform result = spriteMap.getOrDefault(sprite, defaultTransform); 46 | 47 | if (result != null) { 48 | result.apply(finder); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/api/renderloop/EntityRenderPostListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.api.renderloop; 22 | 23 | import io.vram.frex.impl.renderloop.EntityRenderPostListenerImpl; 24 | 25 | /** 26 | * Called after entities are rendered and solid entity layers 27 | * have been drawn to the main frame buffer target, before 28 | * block entity rendering begins. 29 | * 30 | *

Use for global block entity render setup, or 31 | * to append block-related quads to the entity consumers using the 32 | * {@VertexConsumerProvider} from the provided context. This 33 | * will generally give better (if not perfect) results 34 | * for non-terrain translucency vs. drawing directly later on. 35 | */ 36 | @FunctionalInterface 37 | public interface EntityRenderPostListener { 38 | void afterEntityRender(WorldRenderContext context); 39 | 40 | static void register(EntityRenderPostListener listener) { 41 | EntityRenderPostListenerImpl.register(listener); 42 | } 43 | 44 | /** 45 | * Must be called by renderer implementations if they 46 | * disable the hooks implemented by FREX. 47 | */ 48 | static void invoke(WorldRenderContext context) { 49 | EntityRenderPostListenerImpl.invoke(context); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /common/src/main/resources/assets/frex/shaders/api/header.h: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | /**************************************************************** 4 | * Specifies the definitions used in the FREX shader 5 | * API to indicate the operating mode of renderer. 6 | * 7 | * Typical usage is to control conditional compilation of 8 | * features that may not work or work differently in, 9 | * for example, GUI vs world rendering. 10 | * 11 | * These definitions will be automatically included by the 12 | * renderer implementation at the top of the combined source 13 | * file. It is never necessary to include header.h or header.glsl. 14 | * 15 | * Do not declare versions in any pipeline or material shader 16 | * source files. GLSL version is controlled by the active pipeline 17 | * and will be AT LEAST 330 but can be higher if the active pipeline 18 | * requests it. The renderer will automatically pre-pend the 19 | * configured version at the top of the combined source file and 20 | * will strip any version declarations from input source files. 21 | * 22 | * See FREX Shader API.md for license and general informaiton. 23 | ***************************************************************/ 24 | 25 | // If not present, lightmaps and other vanilla-specific data will not be valid or may not present. 26 | // Access to vanilla lighting data should be guarded by #ifdef on this constant. 27 | // Controlled by the active pipeline. 28 | #define VANILLA_LIGHTING 29 | 30 | // present in world context only when feature is enabled - if not present then foliage shaders should NOOP 31 | #define ANIMATED_FOLIAGE 32 | 33 | // Will define VERTEX_SHADER or FRAGMENT_SHADER - useful for checks in common libraries 34 | #define VERTEX_SHADER 35 | 36 | // Present only when pipeline supports the shadowmap feature and it is enabled 37 | #define SHADOW_MAP_PRESENT 38 | 39 | // Present only when shadow map enabled 40 | #define SHADOW_MAP_SIZE 1024 41 | 42 | // Present when material shaders are being run to generate a shadow map or depth math 43 | #define DEPTH_PASS 44 | 45 | // Present when extended texture maps to support Physically-Based Rendering are available 46 | // Will not be defined during depth/shadow pass. 47 | #define PBR_ENABLED 48 | -------------------------------------------------------------------------------- /fabriquilt/src/main/java/io/vram/frex/pastel/mixin/MixinEntityRenderDispatcher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.pastel.mixin; 22 | 23 | import org.spongepowered.asm.mixin.Mixin; 24 | import org.spongepowered.asm.mixin.injection.At; 25 | import org.spongepowered.asm.mixin.injection.Inject; 26 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 27 | 28 | import com.mojang.blaze3d.vertex.PoseStack; 29 | 30 | import net.minecraft.client.renderer.MultiBufferSource; 31 | import net.minecraft.client.renderer.entity.EntityRenderDispatcher; 32 | import net.minecraft.world.entity.Entity; 33 | 34 | import io.vram.frex.pastel.PastelEntityBlockRenderContext; 35 | 36 | @Mixin(EntityRenderDispatcher.class) 37 | public abstract class MixinEntityRenderDispatcher { 38 | /** Ensure input context for held blocks and other blocks rendered as part of an entity have world and tick delta. */ 39 | @Inject(at = @At("HEAD"), method = "render") 40 | private void onRender(Entity entity, double d, double e, double f, float g, float h, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { 41 | final var ctx = PastelEntityBlockRenderContext.get(); 42 | ctx.setPosAndWorldFromEntity(entity); 43 | ctx.tickDelta(h); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /common/src/main/java/io/vram/frex/impl/material/predicate/StateMaterialBoth.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FREX and is licensed to the project under 3 | * terms that are compatible with the GNU Lesser General Public License. 4 | * See the NOTICE file distributed with this work for additional information 5 | * regarding copyright ownership and licensing. 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation, either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package io.vram.frex.impl.material.predicate; 22 | 23 | import net.minecraft.advancements.critereon.StatePropertiesPredicate; 24 | import net.minecraft.world.level.block.state.BlockState; 25 | 26 | import io.vram.frex.api.material.MaterialView; 27 | 28 | public class StateMaterialBoth extends StateBiPredicate { 29 | private final StatePropertiesPredicate statePredicate; 30 | private final MaterialPredicate materialPredicate; 31 | 32 | public StateMaterialBoth(StatePropertiesPredicate statePredicate, MaterialPredicate materialPredicate) { 33 | this.statePredicate = statePredicate; 34 | this.materialPredicate = materialPredicate; 35 | } 36 | 37 | @Override 38 | public boolean test(BlockState blockState, MaterialView renderMaterial) { 39 | return statePredicate.matches(blockState) && materialPredicate.test(renderMaterial); 40 | } 41 | 42 | @Override 43 | public boolean equals(Object obj) { 44 | if (obj instanceof StateMaterialBoth) { 45 | return statePredicate.equals(((StateMaterialBoth) obj).statePredicate) 46 | && materialPredicate.equals(((StateMaterialBoth) obj).materialPredicate); 47 | } else { 48 | return false; 49 | } 50 | } 51 | } 52 | --------------------------------------------------------------------------------