Jump to content

[1.7.2] [Solved] SkyRender and WorldProvider


delpi

Recommended Posts

I've got a custom sky render working but I've got an odd problem.  The color of the sky gets lighter if I'm near a light source. 

 

This doesn't seem to happen in a normal dimension.  Anybody had this experience?

 

I want it to be a black sky with starts, but when i get near a torch it becomes closer to blue.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

Here is the relevant code.

 

Provider Class

 

 

 

public class MyWorldProviderCreep extends MyWorldProvider {

 

public MyWorldProviderCreep() {

super();

 

// Setup parameters

hasNoSky = true;

}

 

    @Override

    public IChunkProvider createChunkGenerator() {

   

        return new MyChunkProviderCreep(worldObj, instance.world_manager().seed(this.dimensionId), true, instance.world_manager().worldtype(dimensionId));

 

    }

 

    @Override

    @SideOnly(Side.CLIENT)

    public float getStarBrightness(float par1) {

   

        return 1.0F;

   

    }

 

    @SideOnly(Side.CLIENT)

    public float calculateCelestialAngle(long par1, float par3) {

   

        return 0.90F;

       

    }

   

    @Override

    protected void generateLightBrightnessTable() {

   

        float f = 0.0F;

 

        for (int i = 0; i <= 15; ++i) {

       

        this.lightBrightnessTable = 1.35F *  (float) Math.pow((1.0f - 0.0895f), 15.0f - i) - 0.35f;

        //this.lightBrightnessTable = 1.25F *  (float) Math.pow((1.0f - 0.10f), 15.0f - i) - 0.35f;

           

        }

       

    }

   

    @Override

    public double getHorizon() {

   

        return 0.0D;

       

    }

   

    @Override

    @SideOnly(Side.CLIENT)

    public IRenderHandler getSkyRenderer() {

   

            return new CreeperSkyRender();

           

    }

   

    @Override

    @SideOnly(Side.CLIENT)

    public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) {

   

    // Return pitch Black

    return this.worldObj.getWorldVec3Pool().getVecFromPool(0, 0, 0);

 

    }

   

    @Override

    @SideOnly(Side.CLIENT)

    public float getCloudHeight() {

   

        return 256.0f;

       

    }

       

 

}

 

 

 

 

Skyrender Class

 

 

 

public class CreeperSkyRender extends IRenderHandler {

 

// Setup Variables

private int starGLCallList;

private int glSkyList;

private int glSkyList2;

 

public CreeperSkyRender() {

 

RenderGlobal renderGlobal = Minecraft.getMinecraft().renderGlobal;

//this.glSkyList2 = (this.glSkyList = (this.starGLCallList = ReflectionHelper.getPrivateValue(RenderGlobal.class, renderGlobal, "starGLCallList")) + 1) + 1;

this.glSkyList2 = (this.glSkyList = (this.starGLCallList = ObfuscationReflectionHelper.getPrivateValue(RenderGlobal.class, renderGlobal, "starGLCallList", "field_72772_v")) + 1) + 1;

 

}

 

@Override

public void render(float partialTicks, WorldClient world, Minecraft mc) {

System.out.println("Start Sky Render");

 

GL11.glDisable(GL11.GL_TEXTURE_2D);

        Vec3 vec3 = world.getSkyColor(mc.renderViewEntity, partialTicks);

        float f1 = (float)vec3.xCoord;

        float f2 = (float)vec3.yCoord;

        float f3 = (float)vec3.zCoord;

        float f6;

        System.out.println("  - color of " + f1 + "/" + f2 + "/" + f3);

 

        if (mc.gameSettings.anaglyph)

        {

            float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;

            float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;

            f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;

            //f1 = f4;

            //f2 = f5;

            //f3 = f6;

            f1 = 0;

            f2 = 0;

            f3 = 0;

        }

 

        GL11.glColor3f(f1, f2, f3);

        Tessellator tessellator1 = Tessellator.instance;

        GL11.glDepthMask(false);

        GL11.glEnable(GL11.GL_FOG);

        GL11.glColor3f(f1, f2, f3);

        GL11.glCallList(this.glSkyList);

        GL11.glDisable(GL11.GL_FOG);

        GL11.glDisable(GL11.GL_ALPHA_TEST);

        GL11.glEnable(GL11.GL_BLEND);

        OpenGlHelper.glBlendFunc(770, 771, 1, 0);

        RenderHelper.disableStandardItemLighting();

        float f7;

        float f8;

        float f9;

        float f10;

 

        GL11.glEnable(GL11.GL_TEXTURE_2D);

        OpenGlHelper.glBlendFunc(770, 1, 1, 0);

        GL11.glPushMatrix();

        f6 = 1.0F - world.getRainStrength(partialTicks);

        f7 = 0.0F;

        f8 = 0.0F;

        f9 = 0.0F;

        GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);

        GL11.glTranslatef(f7, f8, f9);

        GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);

        GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);

        System.out.println("  - celestialange of " + world.getCelestialAngle(partialTicks));

        f10 = 30.0F;

       

// Deleted moon/sun code

       

        GL11.glDisable(GL11.GL_TEXTURE_2D);

        float f18 = world.getStarBrightness(partialTicks) * f6;

 

        if (f18 > 0.0F)

        {

            GL11.glColor4f(f18, f18, f18, f18);

            GL11.glCallList(this.starGLCallList);

        }

 

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        GL11.glDisable(GL11.GL_BLEND);

        GL11.glEnable(GL11.GL_ALPHA_TEST);

        GL11.glEnable(GL11.GL_FOG);

        GL11.glPopMatrix();

        GL11.glDisable(GL11.GL_TEXTURE_2D);

        GL11.glColor3f(0.0F, 0.0F, 0.0F);

        double d0 = mc.thePlayer.getPosition(partialTicks).yCoord - world.getHorizon();

 

        if (d0 < 0.0D)

        {

            GL11.glPushMatrix();

            GL11.glTranslatef(0.0F, 12.0F, 0.0F);

            GL11.glCallList(this.glSkyList2);

            GL11.glPopMatrix();

            f8 = 1.0F;

            f9 = -((float)(d0 + 65.0D));

            f10 = -f8;

            tessellator1.startDrawingQuads();

            tessellator1.setColorRGBA_I(0, 255);

            tessellator1.addVertex((double)(-f8), (double)f9, (double)f8);

            tessellator1.addVertex((double)f8, (double)f9, (double)f8);

            tessellator1.addVertex((double)f8, (double)f10, (double)f8);

            tessellator1.addVertex((double)(-f8), (double)f10, (double)f8);

            tessellator1.addVertex((double)(-f8), (double)f10, (double)(-f8));

            tessellator1.addVertex((double)f8, (double)f10, (double)(-f8));

            tessellator1.addVertex((double)f8, (double)f9, (double)(-f8));

            tessellator1.addVertex((double)(-f8), (double)f9, (double)(-f8));

            tessellator1.addVertex((double)f8, (double)f10, (double)(-f8));

            tessellator1.addVertex((double)f8, (double)f10, (double)f8);

            tessellator1.addVertex((double)f8, (double)f9, (double)f8);

            tessellator1.addVertex((double)f8, (double)f9, (double)(-f8));

            tessellator1.addVertex((double)(-f8), (double)f9, (double)(-f8));

            tessellator1.addVertex((double)(-f8), (double)f9, (double)f8);

            tessellator1.addVertex((double)(-f8), (double)f10, (double)f8);

            tessellator1.addVertex((double)(-f8), (double)f10, (double)(-f8));

            tessellator1.addVertex((double)(-f8), (double)f10, (double)(-f8));

            tessellator1.addVertex((double)(-f8), (double)f10, (double)f8);

            tessellator1.addVertex((double)f8, (double)f10, (double)f8);

            tessellator1.addVertex((double)f8, (double)f10, (double)(-f8));

            tessellator1.draw();

        }

 

        if (world.provider.isSkyColored())

        {

        System.out.println("  - sky colored - YES");

       

            GL11.glColor3f(f1 * 0.2F + 0.04F, f2 * 0.2F + 0.04F, f3 * 0.6F + 0.1F);

        }

        else

        {

        System.out.println("  - sky colored - NO");

       

            GL11.glColor3f(f1, f2, f3);

        }

 

        GL11.glPushMatrix();

        GL11.glTranslatef(0.0F, -((float)(d0 - 16.0D)), 0.0F);

        GL11.glCallList(this.glSkyList2);

        GL11.glPopMatrix();

        GL11.glEnable(GL11.GL_TEXTURE_2D);

        GL11.glDepthMask(true);

 

}

 

}

 

 

 

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

For now (also the sun).  There are some other reasons I want a custom render later.

 

Are you thinking that is the reason for the sky color oddity?  Not sure I follow how those are connected.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

Fixed it.

 

Need to set the fog color.

 

That introduced a new problem, now the clouds lit up.  So I removed the clouds and now it is the just the starts twinkling large in the sky.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.