mirror of
https://github.com/wisplite/crystalline-sky.git
synced 2026-10-30 13:32:18 -05:00
rendering improvements
begin adding weeping sky datagen bayer transparency
This commit is contained in:
@@ -9,5 +9,6 @@ public class CrystallineSkyClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
BlockRenderLayerMap.putBlock(CrystallineBlocks.SKY, BlockRenderLayerExt.CRYSTALLINE_SKY_SKY);
|
||||
BlockRenderLayerMap.putBlock(CrystallineBlocks.WEEPING_SKY, BlockRenderLayerExt.CRYSTALLINE_SKY_SKY);
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package io.github.slimeistdev.crystalline_sky.datagen;
|
||||
|
||||
import io.github.slimeistdev.crystalline_sky.datagen.providers.CrystallineSkyLootProvider;
|
||||
import io.github.slimeistdev.crystalline_sky.datagen.providers.CrystallineSkyModelProvider;
|
||||
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
|
||||
@@ -10,5 +11,6 @@ public class CrystallineSkyDataGenerator implements DataGeneratorEntrypoint {
|
||||
FabricDataGenerator.Pack pack = gen.createPack();
|
||||
|
||||
pack.addProvider(CrystallineSkyModelProvider::new);
|
||||
pack.addProvider(CrystallineSkyLootProvider::new);
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package io.github.slimeistdev.crystalline_sky.datagen.providers;
|
||||
|
||||
import io.github.slimeistdev.crystalline_sky.registry.CrystallineBlocks;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class CrystallineSkyLootProvider extends FabricBlockLootTableProvider {
|
||||
public CrystallineSkyLootProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
|
||||
super(dataOutput, registryLookup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
addDropWithSilkTouch(CrystallineBlocks.SKY);
|
||||
addDropWithSilkTouch(CrystallineBlocks.WEEPING_SKY);
|
||||
}
|
||||
}
|
||||
+18
-11
@@ -4,10 +4,12 @@ import io.github.slimeistdev.crystalline_sky.registry.CrystallineBlocks;
|
||||
import io.github.slimeistdev.crystalline_sky.registry.CrystallineItems;
|
||||
import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricModelProvider;
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.LightBlock;
|
||||
import net.minecraft.client.data.*;
|
||||
import net.minecraft.client.render.item.model.ItemModel;
|
||||
import net.minecraft.client.render.model.json.WeightedVariant;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
@@ -17,6 +19,7 @@ import java.util.Map;
|
||||
|
||||
import static net.minecraft.client.data.BlockStateModelGenerator.createWeightedVariant;
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
public class CrystallineSkyModelProvider extends FabricModelProvider {
|
||||
public CrystallineSkyModelProvider(FabricDataOutput output) {
|
||||
super(output);
|
||||
@@ -24,33 +27,37 @@ public class CrystallineSkyModelProvider extends FabricModelProvider {
|
||||
|
||||
@Override
|
||||
public void generateBlockStateModels(BlockStateModelGenerator gen) {
|
||||
gen.registerBuiltinWithParticle(CrystallineBlocks.SKY, CrystallineItems.SKY);
|
||||
gen.registerItemModel(CrystallineItems.SKY);
|
||||
|
||||
registerSkyLightBlock(gen);
|
||||
registerSkyBlock(gen, CrystallineBlocks.SKY);
|
||||
registerSkyBlock(gen, CrystallineBlocks.WEEPING_SKY);
|
||||
registerSkyLightBlock(gen, CrystallineBlocks.SKY_LIGHT, CrystallineItems.SKY_LIGHT);
|
||||
}
|
||||
|
||||
private void registerSkyLightBlock(BlockStateModelGenerator gen) {
|
||||
ItemModel.Unbaked fallback = ItemModels.basic(gen.uploadItemModel(CrystallineItems.SKY_LIGHT));
|
||||
private void registerSkyBlock(BlockStateModelGenerator gen, Block block) {
|
||||
gen.registerSimpleCubeAll(block);
|
||||
gen.registerItemModel(block);
|
||||
}
|
||||
|
||||
private void registerSkyLightBlock(BlockStateModelGenerator gen, Block block, Item item) {
|
||||
ItemModel.Unbaked fallback = ItemModels.basic(gen.uploadItemModel(item));
|
||||
Map<Integer, ItemModel.Unbaked> itemModels = new HashMap<>(16);
|
||||
BlockStateVariantMap.SingleProperty<WeightedVariant, Integer> levelProp = BlockStateVariantMap.models(Properties.LEVEL_15);
|
||||
|
||||
for (int level = 0; level <= 15; level++) {
|
||||
String suffix = String.format(Locale.ROOT, "_%02d", level);
|
||||
Identifier texture = TextureMap.getSubId(CrystallineItems.SKY_LIGHT, suffix);
|
||||
Identifier texture = TextureMap.getSubId(item, suffix);
|
||||
|
||||
levelProp.register(level, createWeightedVariant(Models.PARTICLE.upload(CrystallineBlocks.SKY_LIGHT, suffix, TextureMap.particle(texture), gen.modelCollector)));
|
||||
levelProp.register(level, createWeightedVariant(Models.PARTICLE.upload(block, suffix, TextureMap.particle(texture), gen.modelCollector)));
|
||||
|
||||
ItemModel.Unbaked levelItemModel = ItemModels.basic(Models.GENERATED.upload(
|
||||
ModelIds.getItemSubModelId(CrystallineItems.SKY_LIGHT, suffix),
|
||||
ModelIds.getItemSubModelId(item, suffix),
|
||||
TextureMap.layer0(texture),
|
||||
gen.modelCollector
|
||||
));
|
||||
itemModels.put(level, levelItemModel);
|
||||
}
|
||||
|
||||
gen.itemModelOutput.accept(CrystallineItems.SKY_LIGHT, ItemModels.select(LightBlock.LEVEL_15, fallback, itemModels));
|
||||
gen.blockStateCollector.accept(VariantsBlockModelDefinitionCreator.of(CrystallineBlocks.SKY_LIGHT).with(levelProp));
|
||||
gen.itemModelOutput.accept(item, ItemModels.select(LightBlock.LEVEL_15, fallback, itemModels));
|
||||
gen.blockStateCollector.accept(VariantsBlockModelDefinitionCreator.of(block).with(levelProp));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,5 +25,7 @@ public class ClientWorldMixin {
|
||||
private static void modifyBlockMarkerItems(CallbackInfo ci) {
|
||||
BLOCK_MARKER_ITEMS = new HashSet<>(BLOCK_MARKER_ITEMS);
|
||||
BLOCK_MARKER_ITEMS.add(CrystallineItems.SKY_LIGHT);
|
||||
BLOCK_MARKER_ITEMS.add(CrystallineItems.SKY);
|
||||
BLOCK_MARKER_ITEMS.add(CrystallineItems.WEEPING_SKY);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -18,6 +18,7 @@ import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.util.Handle;
|
||||
import net.minecraft.client.util.ObjectAllocator;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.*;
|
||||
@@ -158,7 +159,13 @@ public abstract class WorldRendererMixin {
|
||||
&& client.player != null
|
||||
&& (client.player.getMainHandStack().isOf(CrystallineItems.SKY)
|
||||
|| client.player.getOffHandStack().isOf(CrystallineItems.SKY))) {
|
||||
colorModulator = new Vector4f(1.0f, 0.5f, 0.5f, 1.0f).mul(colorModulator);
|
||||
|
||||
float f = ticks + client.getRenderTickCounter().getTickProgress(true);
|
||||
float alpha = (MathHelper.sin(f / 10.0f) + 1.0f) / 2.0f;
|
||||
// remap alpha from [0, 1] to [0, 0.75]
|
||||
float maxAlpha = 1.0f - 0.25f;
|
||||
alpha = alpha * maxAlpha;
|
||||
colorModulator = new Vector4f(1.0f, 1.0f, 1.0f, alpha).mul(colorModulator);
|
||||
}
|
||||
|
||||
return original.call(modelView, colorModulator, modelOffset, textureMatrix, lineWidth);
|
||||
|
||||
@@ -24,6 +24,8 @@ public class CrystallineBlocks {
|
||||
.blockVision(Blocks::never)
|
||||
.emissiveLighting(Blocks::always));
|
||||
|
||||
public static final Block WEEPING_SKY = register("weeping_sky", TransparentBlock::new, Settings.copy(SKY));
|
||||
|
||||
public static final Block SKY_LIGHT = register(
|
||||
"sky_light",
|
||||
LightBlock::new,
|
||||
@@ -46,10 +48,14 @@ public class CrystallineBlocks {
|
||||
return getSkyLightLevel(state) > 0;
|
||||
}
|
||||
|
||||
public static boolean isWeepingSky(BlockState state) {
|
||||
return state.isOf(WEEPING_SKY);
|
||||
}
|
||||
|
||||
public static int getSkyLightLevel(BlockState state) {
|
||||
if (state.isOf(SKY_LIGHT)) {
|
||||
return state.get(LightBlock.LEVEL_15);
|
||||
} else if (state.isOf(SKY)) {
|
||||
} else if (state.isOf(SKY) || state.isOf(WEEPING_SKY)) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,11 @@ public class CrystallineItems {
|
||||
settings -> settings.rarity(Rarity.EPIC)
|
||||
);
|
||||
|
||||
public static final Item WEEPING_SKY = Items.register(
|
||||
CrystallineBlocks.WEEPING_SKY,
|
||||
settings -> settings.rarity(Rarity.EPIC)
|
||||
);
|
||||
|
||||
public static final Item SKY_LIGHT = Items.register(
|
||||
CrystallineBlocks.SKY_LIGHT,
|
||||
settings -> settings.rarity(Rarity.EPIC)
|
||||
|
||||
+1
@@ -13,6 +13,7 @@ public class CrystallineRenderPipelines {
|
||||
.withFragmentShader(CrystallineSky.id("core/terrain_sky"))
|
||||
.withVertexShader(CrystallineSky.id("core/terrain_sky"))
|
||||
.withLocation(CrystallineSky.id("pipeline/sky"))
|
||||
.withShaderDefine("BAYER_BIAS", 0.03125f)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
{
|
||||
"block.crystalline_sky.sky": "Sky",
|
||||
"block.crystalline_sky.weeping_sky": "Weeping Sky",
|
||||
"block.crystalline_sky.sky_light": "Sky Light"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#version 150
|
||||
|
||||
#moj_import <minecraft:globals.glsl>
|
||||
#moj_import <minecraft:fog.glsl>
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
|
||||
@@ -11,12 +12,30 @@ in vec4 texProj0;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
#ifndef BAYER_BIAS
|
||||
#define BAYER_BIAS 0.0
|
||||
#endif
|
||||
|
||||
#ifndef SCALE
|
||||
#define SCALE 1
|
||||
#endif
|
||||
|
||||
const mat4x4 bayerMatrix4x4 = mat4x4(
|
||||
0.0, 8.0, 2.0, 10.0,
|
||||
12.0, 4.0, 14.0, 6.0,
|
||||
3.0, 11.0, 1.0, 9.0,
|
||||
15.0, 7.0, 13.0, 5.0
|
||||
) / 16.0;
|
||||
|
||||
void main() {
|
||||
vec4 color = textureProj(Sampler0, texProj0) * ColorModulator;
|
||||
#ifdef ALPHA_CUTOUT
|
||||
if (color.a < ALPHA_CUTOUT) {
|
||||
int x = int(gl_FragCoord.x / SCALE) % 4;
|
||||
int y = int(gl_FragCoord.y / SCALE) % 4;
|
||||
float bayer = bayerMatrix4x4[y][x];
|
||||
|
||||
if (ColorModulator.a <= bayer + BAYER_BIAS) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec4 color = textureProj(Sampler0, texProj0) * vec4(ColorModulator.rgb, 1.0);
|
||||
fragColor = apply_fog(color, sphericalVertexDistance, cylindricalVertexDistance, FogEnvironmentalStart, FogEnvironmentalEnd, FogRenderDistanceStart, FogRenderDistanceEnd, FogColor);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
Reference in New Issue
Block a user