Blending fog with skysphere

Hello team!

I have a skysphere egg that looks pretty cool. I want a fog node to blender with it though. Right now, it just completes whites it out.

def _set_up_environment_lighting(self):
        self.sun = DirectionalLight("sun")
        self.sun.setColor((1, 1, 1, 1))
        base.sunnp = base.render.attachNewNode(self.sun)
        base.sunnp.setZ(base.sunnp, 50)
        base.sunnp.setY(base.sunnp, -30)
        base.sunnp.setP(base.sunnp, -90)
        base.sunnp.node().getLens().setFilmSize(50,50)
        base.render.setLight(base.sunnp)
        self.ambient_light = AmbientLight('alight')
        self.ambient_light.setColor((0.8,0.8,0.8, 1))
        self.alnp = base.render.attachNewNode(self.ambient_light)
        base.render.setLight(self.alnp)
        #myFog = Fog("Fog Name")
        #myFog.setColor(1, 1, 1)
        #base.render.setFog(myFog)

With Fog:

def _set_up_environment_lighting(self):
        self.sun = DirectionalLight("sun")
        self.sun.setColor((1, 1, 1, 1))
        base.sunnp = base.render.attachNewNode(self.sun)
        base.sunnp.setZ(base.sunnp, 50)
        base.sunnp.setY(base.sunnp, -30)
        base.sunnp.setP(base.sunnp, -90)
        base.sunnp.node().getLens().setFilmSize(50,50)
        base.render.setLight(base.sunnp)
        self.ambient_light = AmbientLight('alight')
        self.ambient_light.setColor((0.8,0.8,0.8, 1))
        self.alnp = base.render.attachNewNode(self.ambient_light)
        base.render.setLight(self.alnp)
        myFog = Fog("Fog Name")
        myFog.setColor(1, 1, 1)
        base.render.setFog(myFog)

As always, you guys are the best for helping, cheers.

Wow, im dumb, i figured it out. Apply to the right node!!! not render, but the level!

I do have a followup question though. So I have the desired behavior I want, fog applies to level objects by distance. Problem is, They show up complete white at some point obviously. If I set the camLens near plane to get the to cull properly, i then cull my skysphere because its so far out!! Any thoughts on how to handle that?

I have two thoughts:

First, that I’m pretty confident that you can set the colour of the fog, allowing your objects to fade to something other than white–ideally a colour shared by your sky-sphere in the region around its horizon-line.

And second, that your sky-sphere needn’t be all that big at all: after all, if it’s in the “background” culling-bin and has depth-writing disabled, then even things that are technically behind it will nevertheless render over it.

1 Like

Yeah, I think swapping the color made it good enough!

1 Like