mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
Overload improved (not optimal, but better than list of string arguments) to set_shader_auto to allow any of normal, glow, gloss, ramp, shadow to be turned on or off via bitmask
This commit is contained in:
parent
6a7580ca45
commit
ad30e4c71f
@ -60,6 +60,22 @@ PUBLISHED:
|
||||
ST_geometry,
|
||||
};
|
||||
|
||||
enum AutoShaderSwitch {
|
||||
AS_normal = 0x01,
|
||||
AS_glow = 0x02,
|
||||
AS_gloss = 0x04,
|
||||
AS_ramp = 0x08,
|
||||
AS_shadow = 0x10,
|
||||
};
|
||||
|
||||
enum AutoShaderBit {
|
||||
bit_AutoShaderNormal = 0, // bit for AS_normal
|
||||
bit_AutoShaderGlow = 1, // bit for AS_glow
|
||||
bit_AutoShaderGloss = 2, // bit for AS_gloss
|
||||
bit_AutoShaderRamp = 3, // bit for AS_ramp
|
||||
bit_AutoShaderShadow = 4, // bit for AS_shadow
|
||||
};
|
||||
|
||||
static PT(Shader) load(const Filename &file, const ShaderLanguage &lang = SL_none);
|
||||
static PT(Shader) make(const string &body, const ShaderLanguage &lang = SL_none);
|
||||
static PT(Shader) load(const ShaderLanguage &lang, const Filename &vertex, const Filename &fragment, const Filename &geometry = "");
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Created by: drose (25Feb02)
|
||||
// Updated by: fperazzi, PandaSE (06Apr10) (added more overloads
|
||||
// for set_shader_input)
|
||||
// Updated by: weifengh, PandaSE(15Apr10) (added set_shader_auto)
|
||||
// Updated by: weifengh, PandaSE(30Apr10) (added set_shader_auto)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -3725,11 +3725,10 @@ set_shader_auto(int priority) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: NodePath::set_shader_auto
|
||||
// Access: Published
|
||||
// Description: overloaded for auto shader selective on/off of
|
||||
// normal, glow, gloss, ramp, shadow
|
||||
// Description: overloaded for auto shader customization
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void NodePath::
|
||||
set_shader_auto(const char* normal_on, const char* glow_on, const char* gloss_on, const char* ramp_on, const char* shadow_on, int priority) {
|
||||
set_shader_auto(BitMask32 shader_switch, int priority) {
|
||||
nassertv_always(!is_empty());
|
||||
|
||||
const RenderAttrib *attrib =
|
||||
@ -3738,11 +3737,11 @@ set_shader_auto(const char* normal_on, const char* glow_on, const char* gloss_on
|
||||
priority = max(priority,
|
||||
node()->get_state()->get_override(ShaderAttrib::get_class_slot()));
|
||||
const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib);
|
||||
node()->set_attrib(sa->set_shader_auto(normal_on, glow_on, gloss_on, ramp_on, shadow_on, priority));
|
||||
node()->set_attrib(sa->set_shader_auto(shader_switch, priority));
|
||||
} else {
|
||||
// Create a new ShaderAttrib for this node.
|
||||
CPT(ShaderAttrib) sa = DCAST(ShaderAttrib, ShaderAttrib::make());
|
||||
node()->set_attrib(sa->set_shader_auto(normal_on, glow_on, gloss_on, ramp_on, shadow_on, priority));
|
||||
node()->set_attrib(sa->set_shader_auto(shader_switch, priority));
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Created by: drose (25Feb02)
|
||||
// Updated by: fperazzi, PandaSE (06Apr10) (added more overloads
|
||||
// for set_shader_input)
|
||||
// Updated by: weifengh, PandaSE(15Apr10)
|
||||
// Updated by: weifengh, PandaSE(30Apr10)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -605,7 +605,7 @@ PUBLISHED:
|
||||
void set_shader(const Shader *sha, int priority = 0);
|
||||
void set_shader_off(int priority = 0);
|
||||
void set_shader_auto(int priority = 0);
|
||||
void set_shader_auto(const char* normal_on, const char* glow_on, const char* gloss_on, const char* ramp_on, const char* shadow_on, int priority=0);
|
||||
void set_shader_auto(BitMask32 shader_switch, int priority=0);
|
||||
void clear_shader();
|
||||
|
||||
void set_shader_input(const ShaderInput *inp);
|
||||
|
@ -132,30 +132,22 @@ set_shader_auto(int priority) const {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ShaderAttrib::set_shader_auto
|
||||
// Access: Published
|
||||
// Description: Set auto shader with control over whether to keep
|
||||
// normal, glow, etc., on or off (e.g., all on via
|
||||
// "normal-on","glow-on","gloss-on","ramp-on","shadow-on")
|
||||
// Description: Set auto shader with bitmask to customize use,
|
||||
// e.g., to keep normal, glow, etc., on or off
|
||||
////////////////////////////////////////////////////////////////////
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
set_shader_auto(const char* normal_on, const char* glow_on, const char* gloss_on, const char* ramp_on, const char* shadow_on, int priority) const {
|
||||
set_shader_auto(BitMask32 shader_switch, int priority) const {
|
||||
|
||||
ShaderAttrib *result = new ShaderAttrib(*this);
|
||||
result->_shader = NULL;
|
||||
result->_shader_priority = priority;
|
||||
result->_auto_shader = true;
|
||||
result->_has_shader = true;
|
||||
string cleanedFlag;
|
||||
|
||||
cleanedFlag = downcase(normal_on);
|
||||
result->_auto_normal_on = (cleanedFlag == "normal_on");
|
||||
cleanedFlag = downcase(glow_on);
|
||||
result->_auto_glow_on = (cleanedFlag == "glow_on");
|
||||
cleanedFlag = downcase(gloss_on);
|
||||
result->_auto_gloss_on = (cleanedFlag == "gloss_on");
|
||||
cleanedFlag = downcase(ramp_on);
|
||||
result->_auto_ramp_on = (cleanedFlag == "ramp_on");
|
||||
cleanedFlag = downcase(shadow_on);
|
||||
result->_auto_shadow_on = (cleanedFlag == "shadow_on");
|
||||
result->_auto_normal_on = shader_switch.get_bit(Shader::bit_AutoShaderNormal);
|
||||
result->_auto_glow_on = shader_switch.get_bit(Shader::bit_AutoShaderGlow);
|
||||
result->_auto_gloss_on = shader_switch.get_bit(Shader::bit_AutoShaderGloss);
|
||||
result->_auto_ramp_on = shader_switch.get_bit(Shader::bit_AutoShaderRamp);
|
||||
result->_auto_shadow_on = shader_switch.get_bit(Shader::bit_AutoShaderShadow);
|
||||
|
||||
return return_new(result);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ PUBLISHED:
|
||||
CPT(RenderAttrib) set_shader_off(int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_auto(int priority=0) const;
|
||||
|
||||
CPT(RenderAttrib) set_shader_auto(const char* normal_on, const char* glow_on, const char* gloss_on, const char* ramp_on, const char* shadow_on, int priority=0) const;
|
||||
CPT(RenderAttrib) set_shader_auto(BitMask32 shader_switch, int priority=0) const;
|
||||
|
||||
CPT(RenderAttrib) clear_shader() const;
|
||||
// Shader Inputs
|
||||
|
Loading…
x
Reference in New Issue
Block a user