Просмотр исходного кода

Show materials with only base color applied properly

rdb 7 лет назад
Родитель
Сommit
47496068d3

+ 3 - 3
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -3463,7 +3463,7 @@ do_issue_material() {
   cur_material.Emissive = *(D3DCOLORVALUE *)(color.get_data());
   cur_material.Power = material->get_shininess();
 
-  if (material->has_diffuse()) {
+  if (material->has_diffuse() || material->has_base_color()) {
     // If the material specifies an diffuse color, use it.
     set_render_state(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
   } else {
@@ -3476,7 +3476,7 @@ do_issue_material() {
       set_render_state(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
     }
   }
-  if (material->has_ambient()) {
+  if (material->has_ambient() || material->has_base_color()) {
     // If the material specifies an ambient color, use it.
     set_render_state(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
   } else {
@@ -3490,7 +3490,7 @@ do_issue_material() {
     }
   }
 
-  if (material->has_specular()) {
+  if (material->has_specular() || material->has_base_color()) {
     set_render_state(D3DRS_SPECULARENABLE, TRUE);
   } else {
     set_render_state(D3DRS_SPECULARENABLE, FALSE);

+ 1 - 1
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -7627,7 +7627,7 @@ do_issue_material() {
   call_glMaterialfv(face, GL_EMISSION, material->get_emission());
   glMaterialf(face, GL_SHININESS, max(min(material->get_shininess(), (PN_stdfloat)128), (PN_stdfloat)0));
 
-  if (material->has_ambient() && material->has_diffuse()) {
+  if ((material->has_ambient() && material->has_diffuse()) || material->has_base_color()) {
     // The material has both an ambient and diffuse specified.  This means we
     // do not need glMaterialColor().
     glDisable(GL_COLOR_MATERIAL);

+ 5 - 0
panda/src/pgraphnodes/shaderGenerator.cxx

@@ -258,6 +258,11 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) {
     // states to be rehashed.
     mat->mark_used_by_auto_shader();
     key._material_flags = mat->get_flags();
+
+    if ((key._material_flags & Material::F_base_color) != 0) {
+      key._material_flags |= (Material::F_diffuse | Material::F_specular | Material::F_ambient);
+      key._material_flags &= ~Material::F_base_color;
+    }
   }
 
   // Break out the lights by type.

+ 2 - 2
panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx

@@ -2951,7 +2951,7 @@ setup_material(GLMaterial *gl_material, const Material *material) {
 
   _color_material_flags = CMF_ambient | CMF_diffuse;
 
-  if (material->has_ambient()) {
+  if (material->has_ambient() || material->has_base_color()) {
     const LColor &ambient = material->get_ambient();
     gl_material->ambient.v[0] = ambient[0];
     gl_material->ambient.v[1] = ambient[1];
@@ -2961,7 +2961,7 @@ setup_material(GLMaterial *gl_material, const Material *material) {
     _color_material_flags &= ~CMF_ambient;
   }
 
-  if (material->has_diffuse()) {
+  if (material->has_diffuse() || material->has_base_color()) {
     const LColor &diffuse = material->get_diffuse();
     gl_material->diffuse.v[0] = diffuse[0];
     gl_material->diffuse.v[1] = diffuse[1];