Author Topic: Per Submodel lighting assignment fix  (Read 1027 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!
Per Submodel lighting assignment fix
Per Swifty's suggestion here a patch so light setting and sorting doesn't happen for every submodel. This patch changes so that lighting is applied only once per model. I tested it and lighting should still work ^^
Code: [Select]
Index: code/graphics/gropengltnl.cpp
===================================================================
--- code/graphics/gropengltnl.cpp (Revision 7344)
+++ code/graphics/gropengltnl.cpp (Arbeitskopie)
@@ -525,9 +525,6 @@
 
  int textured = ((flags & TMAP_FLAG_TEXTURED) && (bufferp->flags & VB_FLAG_UV1));
 
- // init lights
- opengl_change_active_lights(0);
-
  // setup shader flags for the things that we want/need
  if (lighting_is_enabled) {
  shader_flags |= SDR_FLAG_LIGHT;
@@ -797,8 +794,6 @@
 
  render_pass = 0;
 
- // init lights
- opengl_change_active_lights(0);
  opengl_default_light_settings( !GL_center_alpha, (Interp_light > 0.25f), (using_spec) ? 0 : 1 );
  gr_opengl_set_center_alpha(GL_center_alpha);
 
Index: code/model/modelinterp.cpp
===================================================================
--- code/model/modelinterp.cpp (Revision 7344)
+++ code/model/modelinterp.cpp (Arbeitskopie)
@@ -30,6 +30,7 @@
 #include "globalincs/linklist.h"
 #include "weapon/shockwave.h"
 #include "parse/parselo.h" //strextcmp
+#include "graphics/gropengllight.h"
 
 #include <limits.h>
 
@@ -3285,7 +3286,18 @@
  if ( !(Interp_flags & MR_NO_LIGHTING) ) {
  gr_set_lighting(true, true);
  }
+
+ // rotate lights
+ if ( !(Interp_flags & MR_NO_LIGHTING) ) {
+ light_rotate_all();
 
+ if ( !Cmdline_nohtl ) {
+ light_set_all_relevent();
+ }
+ }
+ if ( !(Interp_flags & MR_NO_LIGHTING) && (is_outlines_only_htl || (!Cmdline_nohtl && !is_outlines_only)) ) {
+ opengl_change_active_lights(0); // Set up OpenGl lighting;
+ }
  if (is_outlines_only_htl || (!Cmdline_nohtl && !is_outlines_only)) {
  gr_set_buffer(pm->vertex_buffer_id);
  }
@@ -3308,15 +3320,7 @@
  i = pm->submodel[i].next_sibling;
  }
 
- // rotate lights for the hull
- if ( !(Interp_flags & MR_NO_LIGHTING) ) {
- light_rotate_all();
 
- if ( !Cmdline_nohtl ) {
- light_set_all_relevent();
- }
- }
-
  gr_zbias(0);
 
  model_radius = pm->submodel[pm->detail[Interp_detail_level]].rad;
@@ -4750,14 +4754,6 @@
 
  g3_start_instance_matrix(&model->offset, &submodel_matrix, true);
 
- if ( !(Interp_flags & MR_NO_LIGHTING) ) {
- light_rotate_all();
-
- if ( !Cmdline_nohtl ) {
- light_set_all_relevent();
- }
- }
-
  model_render_buffers(pm, mn, true);
 
  if (Interp_flags & MR_SHOW_PIVOTS)
┏┓╋┏┓╋╋╋╋╋╋╋╋╋┏┓
┃┃╋┃┃╋╋╋╋╋╋╋╋╋┃┃
┃┃┏┫┃┏┳━━┓┏━━┓┃┗━┳━━┳━━┳━━┓
┃┃┣┫┗┛┫┃━┫┃┏┓┃┃┏┓┃┏┓┃━━┫━━┫
┃┗┫┃┏┓┫┃━┫┃┏┓┃┃┗┛┃┗┛┣━━┣━━┃
┗━┻┻┛┗┻━━┛┗┛┗┛┗━━┻━━┻━━┻━━┛