mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
Commit patch by nikolm to support AmbientLight shader inputs in GLSL
This commit is contained in:
parent
d447ec3bc6
commit
0fda35d88c
@ -1407,22 +1407,29 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
|
|||||||
static const CPT_InternalName IN_quadraticAttenuation("quadraticAttenuation");
|
static const CPT_InternalName IN_quadraticAttenuation("quadraticAttenuation");
|
||||||
|
|
||||||
if (attrib == IN_ambient) {
|
if (attrib == IN_ambient) {
|
||||||
#ifndef NDEBUG
|
|
||||||
Light *light = np.node()->as_light();
|
Light *light = np.node()->as_light();
|
||||||
nassertr(light != (Light *)NULL, &LMatrix4::ident_mat());
|
nassertr(light != (Light *)NULL, &LMatrix4::ident_mat());
|
||||||
#endif
|
if (np.node()->is_of_type(AmbientLight::get_class_type())) {
|
||||||
// Lights don't currently have an ambient color in Panda3D.
|
LColor c = light->get_color();
|
||||||
// We still have to support the attribute.
|
c.componentwise_mult(_light_color_scale);
|
||||||
|
t.set_row(3, c);
|
||||||
|
} else {
|
||||||
|
// Non-ambient lights don't currently have an ambient color in Panda3D.
|
||||||
t.set_row(3, LColor(0.0f, 0.0f, 0.0f, 1.0f));
|
t.set_row(3, LColor(0.0f, 0.0f, 0.0f, 1.0f));
|
||||||
|
}
|
||||||
return &t;
|
return &t;
|
||||||
|
|
||||||
} else if (attrib == IN_diffuse) {
|
} else if (attrib == IN_diffuse) {
|
||||||
Light *light = np.node()->as_light();
|
Light *light = np.node()->as_light();
|
||||||
nassertr(light != (Light *)NULL, &LMatrix4::ones_mat());
|
nassertr(light != (Light *)NULL, &LMatrix4::ones_mat());
|
||||||
|
if (np.node()->is_of_type(AmbientLight::get_class_type())) {
|
||||||
|
// Ambient light has no diffuse color.
|
||||||
|
t.set_row(3, LColor(0.0f, 0.0f, 0.0f, 1.0f));
|
||||||
|
} else {
|
||||||
LColor c = light->get_color();
|
LColor c = light->get_color();
|
||||||
c.componentwise_mult(_light_color_scale);
|
c.componentwise_mult(_light_color_scale);
|
||||||
t.set_row(3, c);
|
t.set_row(3, c);
|
||||||
|
}
|
||||||
return &t;
|
return &t;
|
||||||
|
|
||||||
} else if (attrib == IN_specular) {
|
} else if (attrib == IN_specular) {
|
||||||
@ -1432,7 +1439,11 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
|
|||||||
return &t;
|
return &t;
|
||||||
|
|
||||||
} else if (attrib == IN_position) {
|
} else if (attrib == IN_position) {
|
||||||
if (np.node()->is_of_type(DirectionalLight::get_class_type())) {
|
if (np.node()->is_of_type(AmbientLight::get_class_type())) {
|
||||||
|
// Ambient light has no position.
|
||||||
|
t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
|
||||||
|
return &t;
|
||||||
|
} else if (np.node()->is_of_type(DirectionalLight::get_class_type())) {
|
||||||
DirectionalLight *light;
|
DirectionalLight *light;
|
||||||
DCAST_INTO_R(light, np.node(), &LMatrix4::ident_mat());
|
DCAST_INTO_R(light, np.node(), &LMatrix4::ident_mat());
|
||||||
|
|
||||||
@ -1458,7 +1469,11 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (attrib == IN_halfVector) {
|
} else if (attrib == IN_halfVector) {
|
||||||
if (np.node()->is_of_type(DirectionalLight::get_class_type())) {
|
if (np.node()->is_of_type(AmbientLight::get_class_type())) {
|
||||||
|
// Ambient light has no half-vector.
|
||||||
|
t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
|
||||||
|
return &t;
|
||||||
|
} else if (np.node()->is_of_type(DirectionalLight::get_class_type())) {
|
||||||
DirectionalLight *light;
|
DirectionalLight *light;
|
||||||
DCAST_INTO_R(light, np.node(), &LMatrix4::ident_mat());
|
DCAST_INTO_R(light, np.node(), &LMatrix4::ident_mat());
|
||||||
|
|
||||||
@ -1490,6 +1505,11 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (attrib == IN_spotDirection) {
|
} else if (attrib == IN_spotDirection) {
|
||||||
|
if (np.node()->is_of_type(AmbientLight::get_class_type())) {
|
||||||
|
// Ambient light has no spot direction.
|
||||||
|
t.set_row(3, LVector3(0.0f, 0.0f, 0.0f));
|
||||||
|
return &t;
|
||||||
|
} else {
|
||||||
LightLensNode *light;
|
LightLensNode *light;
|
||||||
DCAST_INTO_R(light, np.node(), &LMatrix4::ident_mat());
|
DCAST_INTO_R(light, np.node(), &LMatrix4::ident_mat());
|
||||||
Lens *lens = light->get_lens();
|
Lens *lens = light->get_lens();
|
||||||
@ -1503,6 +1523,7 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
|
|||||||
LVector3 dir = lens->get_view_vector() * light_mat;
|
LVector3 dir = lens->get_view_vector() * light_mat;
|
||||||
t.set_row(3, dir);
|
t.set_row(3, dir);
|
||||||
return &t;
|
return &t;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (attrib == IN_spotCutoff) {
|
} else if (attrib == IN_spotCutoff) {
|
||||||
if (np.node()->is_of_type(Spotlight::get_class_type())) {
|
if (np.node()->is_of_type(Spotlight::get_class_type())) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user