Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.7.10] Unable to get FogDensity working.


dncwalk99
 Share

Recommended Posts

	

            @SubscribeEvent
            public void EntityViewRenderEvent(EntityViewRenderEvent.FogDensity event){
                   
                    if(event.entity.isInsideOfMaterial(Material.lava)){
                            event.setCanceled(true);
                            event.density = 0.5f;
                    }
            }

 

The event is getting canceled, but the new density setting it not taking effect.

 

Any help would be appreciated.

Link to comment
Share on other sites

It is a method named EntityRenderer#setupFog() that does this and it seems like when the event is cancelled all further interactions with Fog are cancelled. This means that GL11.glFogi(); is never called and you have to do it yourself.

 

Note: You may also want to call

                    GL11.glFogf(GL11.GL_FOG_START, whereFogStarts);

                    GL11.glFogf(GL11.GL_FOG_END, whereFogIsAtFullValue);

 

I didn't try it out though and I don't really see what could change except that fog is linearly sampled.... try it out, I guess.

Link to comment
Share on other sites

I don't know.  I have a great fog effect for a "Jack and the Beanstalk" mod where as you climb up the beanstalk the fog gets thicker and thicker.  It works without doing anything with GL11.

 

Here is the code I used.  You can try it and go into Creative Mode and just fly up to cloud level (I made the fog get thicker when you got into the clouds).

 

    @SideOnly(Side.CLIENT)
    @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
    public void onEvent(FogDensity event)
    {
        event.density = (float) Math.abs(Math.pow(((event.entity.posY-63)/(255-63)),4));
        event.setCanceled(true); // must be canceled to affect the fog density   		
     }

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

  • 2 years later...
On 29.7.2014 at 4:55 AM, WorldsEnder said:

It is a method named EntityRenderer#setupFog() that does this and it seems like when the event is cancelled all further interactions with Fog are cancelled. This means that GL11.glFogi(); is never called and you have to do it yourself.

 

Note: You may also want to call

                    GL11.glFogf(GL11.GL_FOG_START, whereFogStarts);

                    GL11.glFogf(GL11.GL_FOG_END, whereFogIsAtFullValue);

 

I didn't try it out though and I don't really see what could change except that fog is linearly sampled.... try it out, I guess.

 

EntityRenderer#setupFog() is private in 1.11.2

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.