Author Topic: Lights sorting Patch  (Read 1957 times)

0 Members and 1 Guest are viewing this topic.

Offline Valathil

  • ...And I would have had a custom title if it wasn't for you meddling kids!
  • 29
  • Custom Title? Wizards need no Custom Title!
Lights sorting Patch
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 ) {
┏┓╋┏┓╋╋╋╋╋╋╋╋╋┏┓
┃┃╋┃┃╋╋╋╋╋╋╋╋╋┃┃
┃┃┏┫┃┏┳━━┓┏━━┓┃┗━┳━━┳━━┳━━┓
┃┃┣┫┗┛┫┃━┫┃┏┓┃┃┏┓┃┏┓┃━━┫━━┫
┃┗┫┃┏┓┫┃━┫┃┏┓┃┃┗┛┃┗┛┣━━┣━━┃
┗━┻┻┛┗┻━━┛┗┛┗┛┗━━┻━━┻━━┻━━┛

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Lights sorting Patch
Thank you very much. Has been committed to trunk.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline Valathil

  • ...And I would have had a custom title if it wasn't for you meddling kids!
  • 29
  • Custom Title? Wizards need no Custom Title!
Re: Lights sorting Patch
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
 
« Last Edit: July 06, 2011, 03:26:21 pm by Zacam »
┏┓╋┏┓╋╋╋╋╋╋╋╋╋┏┓
┃┃╋┃┃╋╋╋╋╋╋╋╋╋┃┃
┃┃┏┫┃┏┳━━┓┏━━┓┃┗━┳━━┳━━┳━━┓
┃┃┣┫┗┛┫┃━┫┃┏┓┃┃┏┓┃┏┓┃━━┫━━┫
┃┗┫┃┏┓┫┃━┫┃┏┓┃┃┗┛┃┗┛┣━━┣━━┃
┗━┻┻┛┗┻━━┛┗┛┗┛┗━━┻━━┻━━┻━━┛

 

Offline Kolgena

  • 211
Re: Lights sorting Patch
Haha, that's fine. I'm more surprised no one noticed after it hit the nightlies.

  

Offline Valathil

  • ...And I would have had a custom title if it wasn't for you meddling kids!
  • 29
  • Custom Title? Wizards need no Custom Title!
Re: Lights sorting Patch
Thats cause It was right the first time and i am just a bumbling moron.
┏┓╋┏┓╋╋╋╋╋╋╋╋╋┏┓
┃┃╋┃┃╋╋╋╋╋╋╋╋╋┃┃
┃┃┏┫┃┏┳━━┓┏━━┓┃┗━┳━━┳━━┳━━┓
┃┃┣┫┗┛┫┃━┫┃┏┓┃┃┏┓┃┏┓┃━━┫━━┫
┃┗┫┃┏┓┫┃━┫┃┏┓┃┃┗┛┃┗┛┣━━┣━━┃
┗━┻┻┛┗┻━━┛┗┛┗┛┗━━┻━━┻━━┻━━┛