set the dark color when using light falloff.

edited August 2017 in Library Questions

hi there, I'm currently working on a 3d game in processing 3. I am trying to use an ambient light at the camera position and light falloff to fake a fog falloff effect. it's working great except I want to be able to set the color of the "fog" instead of the world just fading off into infinite darkness. I'm not trying to make a horror game just trying to hide object culling. Is there something I'm missing?

Answers

  • edited August 2017

    Can you share a brief MCVE sketch to show the approach that you are currently using and attempting to alter? e.g. perhaps just your camera+falloff setup on a cube or a grid of cubes.

    https://stackoverflow.com/help/mcve

  • sure, this should work? I wrote it in Processing 3.3.5.

    import queasycam.*;
    
    QueasyCam cam;
    
    void setup(){
      size(800,600,P3D);
      frameRate(60);
      cam = new QueasyCam(this);
      cam.sensitivity = 0.2;
      cam.speed = 0.1;
    
    }
    
    void draw() {
      background(0);
      lightFalloff(1.0, 0.00, 0.01);
      ambientLight(255, 255, 255, cam.position.x, cam.position.y, cam.position.z);
      for(int i=0;i<10;i++){
        translate(1,1,1);
        box(1);
      }
    }
    
  • edited August 2017

    Huh. The sketch looks the same to me whether I include the lightFalloff() line or not -- your demo doesn't look like "the world just fading off into infinite darkness," color aside. Maybe the wrong settings, or maybe I'm missing something?

    I'm guessing that a simple background color won't work for you for "set the color of the fog"?

    You could try lighting your scene on a PGraphics buffer against a black background, then applying the result (with an appropriate blendMode or masking) on top of a colored canvas -- with background(128), or 255,0,0, or whatever.

Sign In or Register to comment.