Distance rendering..?

Please correct me if this is the wrong section.



Alright, so I'm working on this game, on which I made a globe and a sun. Basically its super sexy and all, but if you make the globe bigger(definitely needs to be bigger), the sun disappears from the horizon, althrough the LightState still effects. :frowning:

I took a few pictures from the "space", which pretty much shows what I'm talking about.



/*

  • Just disappered.

    /





    /

  • Moving a tad bit forward, and it reappears.

    */





    My sun node:



   /**
    * Constructs a new sun.
    * @param display The DisplaySystem - to create a light state with.
    * @param globe The games globe / planet - used to set the light diffuse.
    * @param time The server / client time.
    */
   public Sun(DisplaySystem display, Globe globe, Time time) {
      super("Sun");
      this.globe = globe;
      this.time = time;
      /*
       * We create a point light (no need to light in more than one direction - towards our globe).
       */
      PointLight pl = new PointLight();

      /*
       * We make sure its enabled.
       */
      pl.setEnabled(true);

      /*
       * Create and attach the light to a lightState and the lightState to rootNode.
       */
      lightState = display.getRenderer().createLightState();
      lightState.setEnabled(true);
      lightState.attach(pl);
      
      /*
       * We create a light node, as a bridge between nodes
       * and lights.
       */
      ln = new SimpleLightNode("Sun Light Node", pl);

      /*
       * We set it a good bit our in the space.
       */
      ln.setLocalTranslation(new Vector3f(0, globe.getRadius() + globe.getRadius() * 0.15f, 0));

      /*
       * We attach the light node to this sun node.
       */
      this.attachChild(ln);

      /*
       * We create a sphere to emulate a sun. It doesn't
       * have to be super detailed or anything, as its barely seen anyway.
       */
      Sphere sun = new Sphere("Sun", 20, 20, 35);

      /*
       * We give our model bounds.
       */
      sun.setModelBound(new BoundingSphere());
      sun.updateModelBound();
      
      /*
       * And attach it to the light node.
       */
      ln.attachChild(sun);
      
      /*
       * We set the current angle of the sun, based on the time from the server.
       */
      currentAngle = getAngleForTime();

      /*
       * We make sure the sun is at this angle, simply by rotating it there.
       */
      Quaternion rotation = new Quaternion();
      rotation.fromAngleAxis(FastMath.DEG_TO_RAD * currentAngle, Z_AXIS);
      setLocalRotation(rotation);
   }


Simple class extending node.
The sun node is attached to a landscape node (simple class that extends node + uses a ZBufferState)

Have anyone experienced the same thing? Is there any way to forcerender just this single node from a larger distance?

Thanks in advance. ;)

- Mikkel.

Maybe the sun is simply out of the camera range?

lesto said:

Maybe the sun is simply out of the camera range?

In which case I would do what..? :p

Yep most likely it's outside the view frustum. Look it up on the wiki or just google it. A view frustum is basically the a volume (like a pyramid, but with its top cut off) that represents what is visible to the camera. The point of interest here would be the "far plane" in the frustum, basically anything beyond it gets clipped automatically during rendering. So you should tweak that value.



Consult the wiki or look at source code for SimpleGame (or BaseSimpleGame…basically wherever the default camera values get instanced).

Starnick said:

Yep most likely it's outside the view frustum. Look it up on the wiki or just google it. A view frustum is basically the a volume (like a pyramid, but with its top cut off) that represents what is visible to the camera. The point of interest here would be the "far plane" in the frustum, basically anything beyond it gets clipped automatically during rendering. So you should tweak that value.

Consult the wiki or look at source code for SimpleGame (or BaseSimpleGame...basically wherever the default camera values get instanced).


Alright thanks! :)
But then again, that would go for everything right? I mean, theres no need to render everything from a distance like that.. Just simply the sun :s

- Mikkel
Mikkel said:

Starnick said:

Yep most likely it's outside the view frustum. Look it up on the wiki or just google it. A view frustum is basically the a volume (like a pyramid, but with its top cut off) that represents what is visible to the camera. The point of interest here would be the "far plane" in the frustum, basically anything beyond it gets clipped automatically during rendering. So you should tweak that value.

Consult the wiki or look at source code for SimpleGame (or BaseSimpleGame...basically wherever the default camera values get instanced).


Alright thanks! :)
But then again, that would go for everything right? I mean, theres no need to render everything from a distance like that.. Just simply the sun :s

- Mikkel


Yes, that would be for everything.

Now what you're saying, that goes a bit beyond moving the far plane. If I understand right, you're saying like, you just want to have the sun visible when you're at planet C, but say you have planet A a lot closer...you do not want to render a space station in orbit around it (because it'll be so tiny)? Or something like that?

In that case, you may want to do culling based on distance to the camera (opposed to just culling from if an object is inside the view frustum for example). This could go further into the realm of scene partitioning also (e.g. if you're on a planet, you only want to render the terrain blocks you're on and are adjacent to...so you probably wouldn't want to render the objects on the terrain blocks that aren't rendered either, regardless of the far plane). But that's a whole other story!