Jump to content

[SOLVED]Better Sky rendering?


code4240

Recommended Posts

I'm currently using a custom dimension that has custom sky color.

 

WorldProvider: https://github.com/code4240/DarwinMod/blob/master/mod/Minecraft/src/code4240/alien/world/WorldProviderDarwin.java

 

The sky color code:

/*** Sky color ***/
        
    @Override
    public Vec3 getSkyColor(Entity cameraEntity, float partialTicks)
        {
         return this.worldObj.getWorldVec3Pool().getVecFromPool(0.6, 0.4, 0.4);
        }

    @Override
    public boolean isSkyColored()
        {
         return true;
        }
        
        @Override
        /**
* Return Vec3D with biome specific fog color
*/
    public Vec3 getFogColor(float par1, float par2)
    {
        float f2 = MathHelper.cos(par1 * (float)Math.PI * 0.6F) * 0.4F + 0.4F;

        if (f2 < 0.0F)
        {
            f2 = 0.0F;
        }

        if (f2 > 1.0F)
        {
            f2 = 1.0F;
        }

        float f3 = 0.7529412F;
        float f4 = 0.84705883F;
        float f5 = 1.0F;
        f3 *= f2 * 0.94F + 0.06F;
        f4 *= f2 * 0.94F + 0.06F;
        f5 *= f2 * 0.91F + 0.09F;
        return this.worldObj.getWorldVec3Pool().getVecFromPool((double)f3, (double)f4, (double)f5);
    }
}

 

This achieves the desired effect during the day. However, this color appears over the nighttime sky as well, and it looks hideous.

 

 

 

Daytime

dt5h.png

 

Nighttime

gqhh.png

 

 

 

Is there a way to make the sky color go away at night without overhauling the renderer?

I am the Queen/King of gender ambiguity. At least, I try to be.

Link to comment
Share on other sites

The easy way is to implement your own SkyRenderer which is simple to do since WorldProvider has a way to set SkyRenderer for it's world.

That would be the easy way at least.

 

Although from what you need, couldn't you just use the world obj, and check which time it is before deciding the colors?

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Although from what you need, couldn't you just use the world obj, and check which time it is before deciding the colors?

 

That works, but what I have is a very abrupt change:

 

@Override
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks)
{
	if (this.worldObj.getWorldTime() < 14000) 
	{
         return this.worldObj.getWorldVec3Pool().getVecFromPool(0.6, 0.4, 0.4);
	} 
	else 
	{ 
		return this.worldObj.getWorldVec3Pool().getVecFromPool(0, 0, 0);
	}
}

 

How can I make the time fade from night to day and vice versa?

I am the Queen/King of gender ambiguity. At least, I try to be.

Link to comment
Share on other sites

Well the time moves at a constant rate, so it always fades from night to day ;)

 

As for the light, you have said if time is < 14 be this color and if time > 14 be that color.

What do you think you would have to do in order for it to fade?

 

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Well the time moves at a constant rate, so it always fades from night to day ;)

 

As for the light, you have said if time is < 14 be this color and if time > 14 be that color.

What do you think you would have to do in order for it to fade?

 

I figured it was something like that, it's just that math is my worst skill and looking at math in general fries my brain.

 

The hardest part of it was dealing with the fact that sunrise range is (22000 -> 0 -> 500).

 

For anyone looking to do this, here's what I did:

 

@Override
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) {

	long time = this.worldObj.getWorldTime();
	float red = 1;
	float green = 1;
                // Green and blue use the same values in this instance

	// DAY
	if (time >= 500 && time <= 11500) {
		return this.worldObj.getWorldVec3Pool().getVecFromPool(0.6, 0.4, 0.4);
		}

	// NIGHT
	else if (time >= 14000 && time <= 22000) {
		return this.worldObj.getWorldVec3Pool().getVecFromPool(0, 0, 0);
		}

	else {
		//SUNRISE
		if (time > 22000 || time < 500) {

			// CREATE RANGE OF 1 - 2499
			if (time > 22000) {
				time = (time - 500) - 21500;
				// 1 -> 1999
			} else if (time < 500) {
				time = 2000 + time;
				// 2000 - 2499
			}
			red = (float) (0.00023999999999999998 * time);
			green = (float) (0.00016 * time);
		}


		//SUNSET
		else {
			red = (float) (-(0.00024019215372297838 * time) + 3.3624499599679742);
			green = (float) (-(0.0001601281024819856 * time) + 2.2416333066453165);
		}

		return this.worldObj.getWorldVec3Pool().getVecFromPool(red, green, green);
	}
}

I am the Queen/King of gender ambiguity. At least, I try to be.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...

Important Information

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