Search in sources :

Example 1 with BatchRenderContext

use of hellfirepvp.astralsorcery.client.effect.context.base.BatchRenderContext in project AstralSorcery by HellFirePvP.

the class FXCrystal method renderNow.

@Override
public <T extends EntityVisualFX & EntityDynamicFX> void renderNow(BatchRenderContext<T> ctx, MatrixStack renderStack, IDrawRenderTypeBuffer drawBuffer, float pTicks) {
    if (this.alternativeTexture != null) {
        this.alternativeTexture.bindTexture();
    }
    int alpha = this.getAlpha(pTicks);
    Color c = this.getColor(pTicks);
    Vector3 vec = this.getRenderPosition(pTicks).subtract(RenderingVectorUtils.getStandardTranslationRemovalVector(pTicks));
    float scale = this.getScale(pTicks);
    if (this.lightRayColor != null) {
        long seed = 0x515F1EB654AB915EL;
        renderStack.push();
        renderStack.translate(vec.getX(), vec.getY(), vec.getZ());
        RenderingDrawUtils.renderLightRayFan(renderStack, drawBuffer, this.lightRayColor, seed, 5, 1F, 50);
        renderStack.pop();
        drawBuffer.draw();
    }
    renderStack.push();
    renderStack.translate(vec.getX(), vec.getY() - 0.05F, vec.getZ());
    renderStack.scale(scale, scale, scale);
    renderStack.rotate(Vector3f.XP.rotationDegrees((float) rotation.getX()));
    renderStack.rotate(Vector3f.YP.rotationDegrees((float) rotation.getY()));
    renderStack.rotate(Vector3f.ZP.rotationDegrees((float) rotation.getZ()));
    BufferDecoratorBuilder.withColor((r, g, b, a) -> new int[] { c.getRed(), c.getGreen(), c.getBlue(), alpha }).decorate(drawBuffer.getBuffer(ctx.getRenderType()), decorated -> ObjModelRender.renderCrystal(renderStack, decorated, drawBuffer::draw));
    renderStack.pop();
    if (this.alternativeTexture != null) {
        ctx.getSprite().bindTexture();
    }
}
Also used : EntityDynamicFX(hellfirepvp.astralsorcery.client.effect.EntityDynamicFX) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) TextureQuery(hellfirepvp.astralsorcery.client.resource.query.TextureQuery) ObjModelRender(hellfirepvp.astralsorcery.client.render.ObjModelRender) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder) RenderingDrawUtils(hellfirepvp.astralsorcery.client.util.RenderingDrawUtils) BufferDecoratorBuilder(hellfirepvp.observerlib.client.util.BufferDecoratorBuilder) java.awt(java.awt) IDrawRenderTypeBuffer(hellfirepvp.astralsorcery.client.render.IDrawRenderTypeBuffer) Vector3f(net.minecraft.util.math.vector.Vector3f) AbstractRenderableTexture(hellfirepvp.astralsorcery.client.resource.AbstractRenderableTexture) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) EntityVisualFX(hellfirepvp.astralsorcery.client.effect.EntityVisualFX) RenderingVectorUtils(hellfirepvp.astralsorcery.client.util.RenderingVectorUtils) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) BatchRenderContext(hellfirepvp.astralsorcery.client.effect.context.base.BatchRenderContext) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3)

Example 2 with BatchRenderContext

use of hellfirepvp.astralsorcery.client.effect.context.base.BatchRenderContext in project AstralSorcery by HellFirePvP.

the class RegistryEffectTemplates method init.

public static void init() {
    GENERIC_DEPTH_PARTICLE = register(new RenderContextGenericDepthParticle());
    GENERIC_PARTICLE = register(new RenderContextGenericParticle());
    GENERIC_ATLAS_PARTICLE = register(new RenderContextAtlasParticle());
    LIGHTNING = register(new RenderContextLightning());
    CRYSTAL_BURST_1 = register(new RenderContextBurst(SPR_CRYSTAL_EFFECT_1));
    CRYSTAL_BURST_2 = register(new RenderContextBurst(SPR_CRYSTAL_EFFECT_2));
    CRYSTAL_BURST_3 = register(new RenderContextBurst(SPR_CRYSTAL_EFFECT_3));
    CRYSTAL = register(new RenderContextCrystal(TEX_MODEL_CRYSTAL_WHITE));
    COLLECTOR_BURST = register(new RenderContextBurst(SPR_COLLECTOR_EFFECT));
    GEM_CRYSTAL_BURST = register(new RenderContextBurst(SPR_GEM_CRYSTAL_BURST));
    GEM_CRYSTAL_BURST_SKY = register(new RenderContextBurst(SPR_GEM_CRYSTAL_BURST_SKY));
    GEM_CRYSTAL_BURST_DAY = register(new RenderContextBurst(SPR_GEM_CRYSTAL_BURST_DAY));
    GEM_CRYSTAL_BURST_NIGHT = register(new RenderContextBurst(SPR_GEM_CRYSTAL_BURST_NIGHT));
    LIGHTBEAM = register(new RenderContextLightbeam(SPR_LIGHTBEAM));
    LIGHTBEAM_TRANSFER = register(new RenderContextLightbeam(SPR_LIGHTBEAM_TRANSFER));
    TEXTURE_SPRITE = register(new RenderContextSpritePlaneDynamic());
    FACING_SPRITE = register(new RenderContextFacingSprite());
    CUBE_OPAQUE_ATLAS = register(new BatchRenderContext<>(RenderTypesAS.EFFECT_FX_CUBE_OPAQUE_ATLAS, (ctx, pos) -> new FXCube(pos)));
    CUBE_TRANSLUCENT_ATLAS = register(new BatchRenderContext<>(RenderTypesAS.EFFECT_FX_CUBE_TRANSLUCENT_ATLAS, (ctx, pos) -> new FXCube(pos)));
    CUBE_TRANSLUCENT_ATLAS_IGNORE_DEPTH = register(new BatchRenderContext<>(RenderTypesAS.EFFECT_FX_CUBE_TRANSLUCENT_ATLAS_DEPTH, (ctx, pos) -> new FXCube(pos)));
    CUBE_AREA_OF_EFFECT = register(new BatchRenderContext<>(RenderTypesAS.EFFECT_FX_CUBE_AREA_OF_EFFECT, (ctx, pos) -> new FXCube(pos)));
    BLOCK_TRANSLUCENT = register(new BatchRenderContext<>(RenderTypesAS.EFFECT_FX_BLOCK_TRANSLUCENT, (ctx, pos) -> new FXBlock(pos)));
    BLOCK_TRANSLUCENT_IGNORE_DEPTH = register(new BatchRenderContext<>(RenderTypesAS.EFFECT_FX_BLOCK_TRANSLUCENT_DEPTH, (ctx, pos) -> new FXBlock(pos)));
    COLOR_SPHERE = register(new BatchRenderContext<>(RenderTypesAS.EFFECT_FX_COLOR_SPHERE, (ctx, pos) -> new FXColorEffectSphere(pos)));
    COLOR_SPHERE.setDrawWithTexture(false);
    GENERIC_GATEWAY_PARTICLE = register(new RenderContextGenericParticle());
    setupRenderOrder();
}
Also used : BatchRenderContext(hellfirepvp.astralsorcery.client.effect.context.base.BatchRenderContext) FXColorEffectSphere(hellfirepvp.astralsorcery.client.effect.vfx.FXColorEffectSphere) FXBlock(hellfirepvp.astralsorcery.client.effect.vfx.FXBlock) FXCube(hellfirepvp.astralsorcery.client.effect.vfx.FXCube)

Example 3 with BatchRenderContext

use of hellfirepvp.astralsorcery.client.effect.context.base.BatchRenderContext in project AstralSorcery by HellFirePvP.

the class FXBlock method render.

@Override
public <T extends EntityVisualFX> void render(BatchRenderContext<T> ctx, MatrixStack renderStack, IVertexBuilder vb, float pTicks) {
    if (this.blockState == null) {
        return;
    }
    int alpha = this.getAlpha(pTicks);
    Color c = this.getColor(pTicks);
    int[] colorOverride = new int[] { c.getRed(), c.getGreen(), c.getBlue(), alpha };
    Vector3 translate = this.getRenderPosition(pTicks).subtract(RenderingVectorUtils.getStandardTranslationRemovalVector(pTicks));
    Vector3 rotation = this.getInterpolatedRotation(pTicks);
    float scale = this.getScale(pTicks);
    renderStack.push();
    renderStack.translate(translate.getX(), translate.getY(), translate.getZ());
    renderStack.translate(0.5, 0.5, 0.5);
    renderStack.scale(scale, scale, scale);
    renderStack.rotate(Vector3f.XP.rotationDegrees((float) rotation.getX()));
    renderStack.rotate(Vector3f.YP.rotationDegrees((float) rotation.getY()));
    renderStack.rotate(Vector3f.ZP.rotationDegrees((float) rotation.getZ()));
    renderStack.translate(-0.5, -0.5, -0.5);
    new BufferDecoratorBuilder().setColorDecorator((r, g, b, a) -> colorOverride).decorate(vb, decorated -> RenderingUtils.renderSimpleBlockModel(this.blockState, renderStack, decorated));
    renderStack.pop();
}
Also used : BufferDecoratorBuilder(hellfirepvp.observerlib.client.util.BufferDecoratorBuilder) java.awt(java.awt) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3) Vector3f(net.minecraft.util.math.vector.Vector3f) EntityVisualFX(hellfirepvp.astralsorcery.client.effect.EntityVisualFX) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder) RenderingVectorUtils(hellfirepvp.astralsorcery.client.util.RenderingVectorUtils) BlockState(net.minecraft.block.BlockState) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) BatchRenderContext(hellfirepvp.astralsorcery.client.effect.context.base.BatchRenderContext) RenderingUtils(hellfirepvp.astralsorcery.client.util.RenderingUtils) BufferDecoratorBuilder(hellfirepvp.observerlib.client.util.BufferDecoratorBuilder) Vector3(hellfirepvp.astralsorcery.common.util.data.Vector3)

Aggregations

BatchRenderContext (hellfirepvp.astralsorcery.client.effect.context.base.BatchRenderContext)3 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)2 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)2 EntityVisualFX (hellfirepvp.astralsorcery.client.effect.EntityVisualFX)2 RenderingVectorUtils (hellfirepvp.astralsorcery.client.util.RenderingVectorUtils)2 Vector3 (hellfirepvp.astralsorcery.common.util.data.Vector3)2 BufferDecoratorBuilder (hellfirepvp.observerlib.client.util.BufferDecoratorBuilder)2 java.awt (java.awt)2 Vector3f (net.minecraft.util.math.vector.Vector3f)2 RenderSystem (com.mojang.blaze3d.systems.RenderSystem)1 EntityDynamicFX (hellfirepvp.astralsorcery.client.effect.EntityDynamicFX)1 FXBlock (hellfirepvp.astralsorcery.client.effect.vfx.FXBlock)1 FXColorEffectSphere (hellfirepvp.astralsorcery.client.effect.vfx.FXColorEffectSphere)1 FXCube (hellfirepvp.astralsorcery.client.effect.vfx.FXCube)1 IDrawRenderTypeBuffer (hellfirepvp.astralsorcery.client.render.IDrawRenderTypeBuffer)1 ObjModelRender (hellfirepvp.astralsorcery.client.render.ObjModelRender)1 AbstractRenderableTexture (hellfirepvp.astralsorcery.client.resource.AbstractRenderableTexture)1 TextureQuery (hellfirepvp.astralsorcery.client.resource.query.TextureQuery)1 RenderingDrawUtils (hellfirepvp.astralsorcery.client.util.RenderingDrawUtils)1 RenderingUtils (hellfirepvp.astralsorcery.client.util.RenderingUtils)1