Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Valathil on July 01, 2011, 04:31:23 am

Title: Lights sorting Patch
Post by: Valathil on July 01, 2011, 04:31:23 am
Little enhancement for the rendering loop there was a funtion implemented to sort lights by priority but it never got executed so this should clear up the light flickering a bit till i get the 8 light limit a little higher with the pipeline rewrite.

Code: [Select]
Index: code/graphics/gropengllight.cpp
===================================================================
--- code/graphics/gropengllight.cpp     (Revision 7291)
+++ code/graphics/gropengllight.cpp     (Arbeitskopie)
@@ -293,6 +293,8 @@
        glTranslated(-eyex, -eyey, -eyez);
        glScalef(1.0f, 1.0f, -1.0f);

+       //Valathil: Sort lights by priority
+       opengl_pre_render_init_lights();

        for (i = 0; i < GL_max_lights; i++) {
                if ( (offset + i) >= Num_active_gl_lights ) {
Title: Re: Lights sorting Patch
Post by: The E on July 01, 2011, 05:01:12 am
Thank you very much. Has been committed to trunk.
Title: Re: Lights sorting Patch
Post by: Valathil on July 06, 2011, 02:55:55 pm
you know the thing with this patch is that the intention was good and fine but now i see i did the biggest troll on you guys. the function that i called in the patch did the sorting alright, only it did it in the worst way possible it did it exactly backwards. i only found out now after looking at it again. im so sry guys

Code: [Select]
Index: code/graphics/gropengllight.cpp
===================================================================
--- code/graphics/gropengllight.cpp (Revision 7331)
+++ code/graphics/gropengllight.cpp (Arbeitskopie)
@@ -169,22 +169,22 @@
 
  // directional lights always go first
  if ( (la->type != LT_DIRECTIONAL) && (lb->type == LT_DIRECTIONAL) )
+ return -1;
+ else if ( (la->type == LT_DIRECTIONAL) && (lb->type != LT_DIRECTIONAL) )
  return 1;
- else if ( (la->type == LT_DIRECTIONAL) && (lb->type != LT_DIRECTIONAL) )
- return -1;
 
  // tube lights go next, they are generally large and intense
  if ( (la->type != LT_TUBE) && (lb->type == LT_TUBE) )
+ return -1;
+ else if ( (la->type == LT_TUBE) && (lb->type != LT_TUBE) )
  return 1;
- else if ( (la->type == LT_TUBE) && (lb->type != LT_TUBE) )
- return -1;
 
  // everything else is sorted by linear atten (light size)
  // NOTE: smaller atten is larger light radius!
  if ( la->LinearAtten > lb->LinearAtten )
+ return -1;
+ else if ( la->LinearAtten < lb->LinearAtten )
  return 1;
- else if ( la->LinearAtten < lb->LinearAtten )
- return -1;
 
  // as one extra check, if we're still here, go with overall brightness of light
 
Title: Re: Lights sorting Patch
Post by: Kolgena on July 06, 2011, 02:58:10 pm
Haha, that's fine. I'm more surprised no one noticed after it hit the nightlies.
Title: Re: Lights sorting Patch
Post by: Valathil on July 07, 2011, 10:21:20 am
Thats cause It was right the first time and i am just a bumbling moron.