[Change] Removed Canvas Support
This commit is contained in:
parent
e826dbc623
commit
d9a586741e
11 changed files with 0 additions and 552 deletions
|
@ -106,44 +106,4 @@ public class CustomModelBakery {
|
|||
BlockModel model = provider.getItemModel(modelLocation);
|
||||
models.put(modelLocation, model);
|
||||
}
|
||||
|
||||
//TODO: 1.19.3 Handled differently now
|
||||
// public static void loadEmissiveModels(Map<ResourceLocation, UnbakedModel> unbakedCache) {
|
||||
// if (!ModIntegrationAPI.hasCanvas()) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Map<ResourceLocation, UnbakedModel> cacheCopy = new HashMap<>(unbakedCache);
|
||||
// Set<Pair<String, String>> strings = Sets.newConcurrentHashSet();
|
||||
// Registry.BLOCK.keySet().forEach(blockID -> {
|
||||
// Block block = Registry.BLOCK.get(blockID);
|
||||
// ImmutableList<BlockState> states = block.getStateDefinition().getPossibleStates();
|
||||
// boolean addBlock = false;
|
||||
//
|
||||
// for (BlockState state : states) {
|
||||
// ResourceLocation stateID = BlockModelShaper.stateToModelLocation(blockID, state);
|
||||
// UnbakedModel model = cacheCopy.get(stateID);
|
||||
// if (model == null) {
|
||||
// continue;
|
||||
// }
|
||||
// Collection<Material> materials = model.getMaterials(cacheCopy::get, strings);
|
||||
// if (materials == null) {
|
||||
// continue;
|
||||
// }
|
||||
// for (Material material : materials) {
|
||||
// if (EmissiveTextureInfo.isEmissiveTexture(material.texture())) {
|
||||
// addBlock = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (addBlock) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (addBlock) {
|
||||
// EmissiveTextureInfo.addBlock(blockID);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package org.betterx.bclib.client.render;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class EmissiveTextureInfo {
|
||||
private static final Set<ResourceLocation> EMISSIVE_TEXTURES = Sets.newHashSet();
|
||||
private static final Set<ResourceLocation> EMISSIVE_BLOCKS = Sets.newHashSet();
|
||||
|
||||
public static void clear() {
|
||||
EMISSIVE_TEXTURES.clear();
|
||||
EMISSIVE_BLOCKS.clear();
|
||||
}
|
||||
|
||||
public static void addTexture(ResourceLocation texture) {
|
||||
EMISSIVE_TEXTURES.add(texture);
|
||||
}
|
||||
|
||||
public static void addBlock(ResourceLocation blockID) {
|
||||
EMISSIVE_BLOCKS.add(blockID);
|
||||
}
|
||||
|
||||
public static boolean isEmissiveTexture(ResourceLocation texture) {
|
||||
return EMISSIVE_TEXTURES.contains(texture);
|
||||
}
|
||||
|
||||
public static boolean isEmissiveBlock(ResourceLocation blockID) {
|
||||
return EMISSIVE_BLOCKS.contains(blockID);
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package org.betterx.bclib.mixin.client;
|
||||
|
||||
import org.betterx.bclib.api.v2.ModIntegrationAPI;
|
||||
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.UnbakedModel;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(ModelBakery.class)
|
||||
public abstract class ModelBakeryMixin {
|
||||
@Final
|
||||
@Shadow
|
||||
private Map<ResourceLocation, UnbakedModel> unbakedCache;
|
||||
|
||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||
private void bclib_findEmissiveModels(
|
||||
BlockColors blockColors, ProfilerFiller profilerFiller, Map map, Map map2, CallbackInfo ci
|
||||
) {
|
||||
//CustomModelBakery.setModelsLoaded(false);
|
||||
if (ModIntegrationAPI.hasCanvas()) {
|
||||
//TODO:1.19.3 this needs to change
|
||||
//CustomModelBakery.loadEmissiveModels(unbakedCache);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package org.betterx.bclib.mixin.client;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v2.ModIntegrationAPI;
|
||||
import org.betterx.bclib.client.render.EmissiveTextureInfo;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.FallbackResourceManager;
|
||||
import net.minecraft.server.packs.resources.MultiPackResourceManager;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(MultiPackResourceManager.class)
|
||||
public class MultiPackResourceManagerMixin {
|
||||
@Final
|
||||
@Shadow
|
||||
private Map<String, FallbackResourceManager> namespacedManagers;
|
||||
|
||||
private final ResourceLocation bclib_alphaEmissionMaterial = BCLib.makeID("materialmaps/block/alpha_emission.json");
|
||||
|
||||
@Inject(method = "getResource", at = @At("HEAD"), cancellable = true)
|
||||
private void bclib_getResource(
|
||||
ResourceLocation resourceLocation,
|
||||
CallbackInfoReturnable<Resource> info
|
||||
) throws IOException {
|
||||
if (!ModIntegrationAPI.hasCanvas()) {
|
||||
return;
|
||||
}
|
||||
if (!resourceLocation.getPath().startsWith("materialmaps")) {
|
||||
return;
|
||||
}
|
||||
if (!resourceLocation.getPath().contains("/block/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String name = resourceLocation.getPath().replace("materialmaps/block/", "").replace(".json", "");
|
||||
ResourceLocation blockID = new ResourceLocation(resourceLocation.getNamespace(), name);
|
||||
|
||||
if (!EmissiveTextureInfo.isEmissiveBlock(blockID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ResourceManager resourceManager = this.namespacedManagers.get(resourceLocation.getNamespace());
|
||||
if (resourceManager != null && resourceManager.getResource(resourceLocation).isEmpty()) {
|
||||
info.setReturnValue(resourceManager.getResource(bclib_alphaEmissionMaterial).get());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
package org.betterx.bclib.mixin.client;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.client.render.EmissiveTextureInfo;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.client.renderer.texture.SpriteContents;
|
||||
import net.minecraft.client.renderer.texture.SpriteLoader;
|
||||
import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection;
|
||||
import net.minecraft.client.resources.metadata.animation.FrameSize;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@Mixin(SpriteLoader.class)
|
||||
public class TextureAtlasMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private ResourceLocation location;
|
||||
private static final int EMISSIVE_ALPHA = 254 << 24;
|
||||
private boolean bclib_modifyAtlas;
|
||||
private static ResourceManager bclib_resourceManager;
|
||||
|
||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||
private void bclib_onAtlasInit(
|
||||
ResourceLocation textureAtlasLocation,
|
||||
int maxSupportedTextureSize,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
|
||||
boolean hasOptifine = FabricLoader.getInstance().isModLoaded("optifabric");
|
||||
bclib_modifyAtlas = !hasOptifine && textureAtlasLocation.toString()
|
||||
.equals("minecraft:textures/atlas/blocks.png");
|
||||
if (bclib_modifyAtlas) {
|
||||
EmissiveTextureInfo.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "listSprites(Lnet/minecraft/server/packs/resources/ResourceManager;Ljava/lang/String;Ljava/lang/String;Ljava/util/function/BiConsumer;)V", at = @At("HEAD"), cancellable = true)
|
||||
private static void bclib_listSprites(
|
||||
ResourceManager resourceManager,
|
||||
String string,
|
||||
String string2,
|
||||
BiConsumer<ResourceLocation, Resource> biConsumer,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
bclib_resourceManager = resourceManager;
|
||||
}
|
||||
|
||||
@Inject(method = "loadSprite", at = @At("HEAD"), cancellable = true)
|
||||
private void bclib_loadSprite(
|
||||
ResourceLocation location, Resource resource, CallbackInfoReturnable<SpriteContents> cir
|
||||
) {
|
||||
if (!bclib_modifyAtlas || bclib_resourceManager == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!location.getPath().startsWith("block")) {
|
||||
return;
|
||||
}
|
||||
|
||||
AnimationMetadataSection animationMetadataSection;
|
||||
try {
|
||||
animationMetadataSection = resource.metadata()
|
||||
.getSection(AnimationMetadataSection.SERIALIZER)
|
||||
.orElse(AnimationMetadataSection.EMPTY);
|
||||
} catch (Exception exception) {
|
||||
BCLib.LOGGER.error("Unable to parse metadata from {} : {}", (Object) this.location, (Object) exception);
|
||||
cir.setReturnValue(null);
|
||||
cir.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
ResourceLocation emissiveLocation = new ResourceLocation(
|
||||
location.getNamespace(),
|
||||
"textures/" + location.getPath() + "_e.png"
|
||||
);
|
||||
Optional<Resource> emissiveRes = bclib_resourceManager.getResource(emissiveLocation);
|
||||
if (emissiveRes.isPresent()) {
|
||||
NativeImage sprite = null;
|
||||
NativeImage emission = null;
|
||||
try {
|
||||
// ResourceLocation spriteLocation = new ResourceLocation(
|
||||
// location.getNamespace(),
|
||||
// "textures/" + location.getPath() + ".png"
|
||||
// );
|
||||
//Resource resource = resourceManager.getResource(spriteLocation).orElse(null);
|
||||
sprite = NativeImage.read(resource.open());
|
||||
|
||||
resource = emissiveRes.get();
|
||||
emission = NativeImage.read(resource.open());
|
||||
} catch (IOException e) {
|
||||
BCLib.LOGGER.warning(e.getMessage());
|
||||
}
|
||||
if (sprite != null && emission != null) {
|
||||
int width = Math.min(sprite.getWidth(), emission.getWidth());
|
||||
int height = Math.min(sprite.getHeight(), emission.getHeight());
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
int argb = emission.getPixelRGBA(x, y);
|
||||
int alpha = (argb >> 24) & 255;
|
||||
if (alpha > 127) {
|
||||
int r = (argb >> 16) & 255;
|
||||
int g = (argb >> 8) & 255;
|
||||
int b = argb & 255;
|
||||
if (r > 0 || g > 0 || b > 0) {
|
||||
argb = (argb & 0x00FFFFFF) | EMISSIVE_ALPHA;
|
||||
sprite.setPixelRGBA(x, y, argb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FrameSize frameSize = animationMetadataSection.calculateFrameSize(
|
||||
sprite.getWidth(),
|
||||
sprite.getHeight()
|
||||
);
|
||||
if (!Mth.isDivisionInteger(
|
||||
sprite.getWidth(),
|
||||
frameSize.width()
|
||||
) || !Mth.isDivisionInteger(sprite.getHeight(), frameSize.height())) {
|
||||
BCLib.LOGGER.error(
|
||||
"Image {} size {},{} is not multiple of frame size {},{}",
|
||||
this.location,
|
||||
sprite.getWidth(),
|
||||
sprite.getHeight(),
|
||||
frameSize.width(),
|
||||
frameSize.height()
|
||||
);
|
||||
sprite.close();
|
||||
cir.setReturnValue(null);
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
SpriteContents result = new SpriteContents(location, frameSize, sprite, animationMetadataSection);
|
||||
|
||||
EmissiveTextureInfo.addTexture(location);
|
||||
cir.setReturnValue(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#include frex:shaders/api/fragment.glsl
|
||||
#include frex:shaders/lib/math.glsl
|
||||
|
||||
// Value near 254
|
||||
bool isEmissive(float alpha) {
|
||||
return 0.9960 < alpha && alpha < 0.9962;
|
||||
}
|
||||
|
||||
void frx_startFragment(inout frx_FragmentData fragData) {
|
||||
if (isEmissive(fragData.spriteColor.a)) {
|
||||
fragData.emissivity = 1.0;
|
||||
fragData.spriteColor.a = 1.0;
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
#version 150
|
||||
#moj_import <fog.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
uniform vec4 ColorModulator;
|
||||
uniform float FogStart;
|
||||
uniform float FogEnd;
|
||||
uniform vec4 FogColor;
|
||||
|
||||
in float vertexDistance;
|
||||
in vec4 vertexColor;
|
||||
in vec2 texCoord0;
|
||||
in vec4 normal;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
vec3 rgbToHSV(vec3 color) {
|
||||
vec4 k = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(color.bg, k.wz), vec4(color.gb, k.xy), step(color.b, color.g));
|
||||
vec4 q = mix(vec4(p.xyw, color.r), vec4(color.r, p.yzx), step(p.x, color.r));
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
vec3 hsvToRGB(vec3 color) {
|
||||
vec4 k = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(color.xxx + k.xyz) * 6.0 - k.www);
|
||||
return color.z * mix(k.xxx, clamp(p - k.xxx, 0.0, 1.0), color.y);
|
||||
}
|
||||
|
||||
// Value near 254
|
||||
bool isEmissive(float alpha) {
|
||||
return 0.9960 < alpha && alpha < 0.9962;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 tex = texture(Sampler0, texCoord0);
|
||||
if (tex.a < 0.1) {
|
||||
discard;
|
||||
}
|
||||
vec4 color = tex * ColorModulator;
|
||||
vec4 vertex = vertexColor;
|
||||
if (isEmissive(tex.a)) {
|
||||
vec3 hsv = rgbToHSV(vertex.rgb);
|
||||
hsv.z = 1.0;
|
||||
vertex.rgb = hsvToRGB(hsv);
|
||||
color.a = 1.0;
|
||||
}
|
||||
color = linear_fog(color * vertex, vertexDistance, FogStart, FogEnd, FogColor);
|
||||
fragColor = color;
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
#version 150
|
||||
#moj_import <fog.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
uniform vec4 ColorModulator;
|
||||
uniform float FogStart;
|
||||
uniform float FogEnd;
|
||||
uniform vec4 FogColor;
|
||||
|
||||
in float vertexDistance;
|
||||
in vec4 vertexColor;
|
||||
in vec4 lightMapColor;
|
||||
in vec4 overlayColor;
|
||||
in vec2 texCoord0;
|
||||
in vec4 normal;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
vec3 rgbToHSV(vec3 color) {
|
||||
vec4 k = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(color.bg, k.wz), vec4(color.gb, k.xy), step(color.b, color.g));
|
||||
vec4 q = mix(vec4(p.xyw, color.r), vec4(color.r, p.yzx), step(p.x, color.r));
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
vec3 hsvToRGB(vec3 color) {
|
||||
vec4 k = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(color.xxx + k.xyz) * 6.0 - k.www);
|
||||
return color.z * mix(k.xxx, clamp(p - k.xxx, 0.0, 1.0), color.y);
|
||||
}
|
||||
|
||||
// Value near 254
|
||||
bool isEmissive(float alpha) {
|
||||
return 0.9960 < alpha && alpha < 0.9962;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 tex = texture(Sampler0, texCoord0);
|
||||
if (tex.a < 0.1) {
|
||||
discard;
|
||||
}
|
||||
vec4 color = tex * ColorModulator;
|
||||
color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a);
|
||||
vec4 vertex = vertexColor * lightMapColor;
|
||||
if (isEmissive(tex.a)) {
|
||||
vec3 hsv = rgbToHSV(vertex.rgb);
|
||||
hsv.z = 1.0;
|
||||
vertex.rgb = hsvToRGB(hsv);
|
||||
color.a = 1.0;
|
||||
}
|
||||
color = linear_fog(color * vertex, vertexDistance, FogStart, FogEnd, FogColor);
|
||||
fragColor = color;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
#version 150
|
||||
#moj_import <fog.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
uniform vec4 ColorModulator;
|
||||
uniform float FogStart;
|
||||
uniform float FogEnd;
|
||||
uniform vec4 FogColor;
|
||||
|
||||
in float vertexDistance;
|
||||
in vec4 vertexColor;
|
||||
in vec2 texCoord0;
|
||||
in vec2 texCoord1;
|
||||
in vec4 normal;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
vec3 rgbToHSV(vec3 color) {
|
||||
vec4 k = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(color.bg, k.wz), vec4(color.gb, k.xy), step(color.b, color.g));
|
||||
vec4 q = mix(vec4(p.xyw, color.r), vec4(color.r, p.yzx), step(p.x, color.r));
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
vec3 hsvToRGB(vec3 color) {
|
||||
vec4 k = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(color.xxx + k.xyz) * 6.0 - k.www);
|
||||
return color.z * mix(k.xxx, clamp(p - k.xxx, 0.0, 1.0), color.y);
|
||||
}
|
||||
|
||||
// Value near 254
|
||||
bool isEmissive(float alpha) {
|
||||
return 0.9960 < alpha && alpha < 0.9962;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 tex = texture(Sampler0, texCoord0);
|
||||
if (tex.a < 0.1) {
|
||||
discard;
|
||||
}
|
||||
vec4 color = tex * ColorModulator;
|
||||
vec4 vertex = vertexColor;
|
||||
if (isEmissive(tex.a)) {
|
||||
vec3 hsv = rgbToHSV(vertex.rgb);
|
||||
hsv.z = 1.0;
|
||||
vertex.rgb = hsvToRGB(hsv);
|
||||
}
|
||||
color = linear_fog(color * vertex, vertexDistance, FogStart, FogEnd, FogColor);
|
||||
fragColor = color;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
#version 150
|
||||
#moj_import <fog.glsl>
|
||||
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
uniform vec4 ColorModulator;
|
||||
uniform float FogStart;
|
||||
uniform float FogEnd;
|
||||
uniform vec4 FogColor;
|
||||
|
||||
in float vertexDistance;
|
||||
in vec4 vertexColor;
|
||||
in vec2 texCoord0;
|
||||
in vec4 normal;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
vec3 rgbToHSV(vec3 color) {
|
||||
vec4 k = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(color.bg, k.wz), vec4(color.gb, k.xy), step(color.b, color.g));
|
||||
vec4 q = mix(vec4(p.xyw, color.r), vec4(color.r, p.yzx), step(p.x, color.r));
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
vec3 hsvToRGB(vec3 color) {
|
||||
vec4 k = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(color.xxx + k.xyz) * 6.0 - k.www);
|
||||
return color.z * mix(k.xxx, clamp(p - k.xxx, 0.0, 1.0), color.y);
|
||||
}
|
||||
|
||||
// Value near 254
|
||||
bool isEmissive(float alpha) {
|
||||
return 0.9960 < alpha && alpha < 0.9962;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 tex = texture(Sampler0, texCoord0);
|
||||
vec4 color = tex * ColorModulator;
|
||||
vec4 vertex = vertexColor;
|
||||
if (isEmissive(tex.a)) {
|
||||
vec3 hsv = rgbToHSV(vertex.rgb);
|
||||
hsv.z = 1.0;
|
||||
vertex.rgb = hsvToRGB(hsv);
|
||||
color.a = 1.0;
|
||||
}
|
||||
color = linear_fog(color * vertex, vertexDistance, FogStart, FogEnd, FogColor);
|
||||
fragColor = color;
|
||||
}
|
|
@ -10,11 +10,9 @@
|
|||
"FogRendererMixin",
|
||||
"GameMixin",
|
||||
"MinecraftMixin",
|
||||
"ModelBakeryMixin",
|
||||
"ModelManagerMixin",
|
||||
"PresetEditorMixin",
|
||||
"SignEditScreenMixin",
|
||||
"TextureAtlasMixin",
|
||||
"boat.BoatRendererMixin"
|
||||
],
|
||||
"injectors": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue