ShaderGenerator: big overhaul, don't generate more shaders than needed
This commit is contained in:
parent
1b690e528f
commit
f79fbf25c3
|
|
@ -44,6 +44,7 @@
|
|||
#include "ambientLight.h"
|
||||
#include "directionalLight.h"
|
||||
#include "pointLight.h"
|
||||
#include "sphereLight.h"
|
||||
#include "spotlight.h"
|
||||
#include "textureReloadRequest.h"
|
||||
#include "shaderAttrib.h"
|
||||
|
|
@ -1122,6 +1123,28 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
|
|||
return &LMatrix4::ident_mat();
|
||||
}
|
||||
}
|
||||
case Shader::SMO_texscale_i: {
|
||||
const TexMatrixAttrib *tma;
|
||||
const TextureAttrib *ta;
|
||||
if (_target_rs->get_attrib(ta) && _target_rs->get_attrib(tma) &&
|
||||
index < ta->get_num_on_stages()) {
|
||||
LVecBase3 scale = tma->get_transform(ta->get_on_stage(index))->get_scale();
|
||||
t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,scale[0],scale[1],scale[2],0);
|
||||
return &t;
|
||||
} else {
|
||||
return &LMatrix4::ident_mat();
|
||||
}
|
||||
}
|
||||
case Shader::SMO_texcolor_i: {
|
||||
const TextureAttrib *ta;
|
||||
if (_target_rs->get_attrib(ta) && index < ta->get_num_on_stages()) {
|
||||
TextureStage *ts = ta->get_on_stage(index);
|
||||
t.set_row(3, ts->get_color());
|
||||
return &t;
|
||||
} else {
|
||||
return &LMatrix4::zeros_mat();
|
||||
}
|
||||
}
|
||||
case Shader::SMO_tex_is_alpha_i: {
|
||||
// This is a hack so we can support both F_alpha and other formats in the
|
||||
// default shader, to fix font rendering in GLES2
|
||||
|
|
@ -1156,9 +1179,14 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
|
|||
nassertr(!np.is_empty(), &LMatrix4::zeros_mat());
|
||||
const PlaneNode *plane_node;
|
||||
DCAST_INTO_R(plane_node, np.node(), &LMatrix4::zeros_mat());
|
||||
LPlane p (plane_node->get_plane());
|
||||
p.xform(np.get_net_transform()->get_mat()); // World-space
|
||||
t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,p[0],p[1],p[2],p[3]);
|
||||
|
||||
// Transform plane to world space
|
||||
CPT(TransformState) transform = np.get_net_transform();
|
||||
LPlane plane = plane_node->get_plane();
|
||||
if (!transform->is_identity()) {
|
||||
plane.xform(transform->get_mat());
|
||||
}
|
||||
t.set_row(3, plane);
|
||||
return &t;
|
||||
}
|
||||
case Shader::SMO_apiview_clipplane_i: {
|
||||
|
|
@ -1195,7 +1223,6 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
|
|||
}
|
||||
case Shader::SMO_world_to_view: {
|
||||
return &(_scene_setup->get_world_transform()->get_mat());
|
||||
break;
|
||||
}
|
||||
case Shader::SMO_view_to_world: {
|
||||
return &(_scene_setup->get_camera_transform()->get_mat());
|
||||
|
|
@ -1387,6 +1414,62 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
|
|||
}
|
||||
return fetch_specified_member(NodePath(), name, t);
|
||||
}
|
||||
case Shader::SMO_light_source_i_packed: {
|
||||
// The light matrix contains COLOR, ATTENUATION, POSITION, VIEWVECTOR
|
||||
const LightAttrib *target_light;
|
||||
_target_rs->get_attrib_def(target_light);
|
||||
|
||||
// We don't count ambient lights, which would be pretty silly to handle
|
||||
// via this mechanism.
|
||||
size_t num_lights = target_light->get_num_non_ambient_lights();
|
||||
if (index >= 0 && (size_t)index < num_lights) {
|
||||
NodePath np = target_light->get_on_light((size_t)index);
|
||||
nassertr(!np.is_empty(), &LMatrix4::ident_mat());
|
||||
PandaNode *node = np.node();
|
||||
Light *light = node->as_light();
|
||||
nassertr(light != nullptr, &LMatrix4::zeros_mat());
|
||||
t.set_row(0, light->get_color());
|
||||
t.set_row(1, light->get_attenuation());
|
||||
|
||||
LMatrix4 mat = np.get_net_transform()->get_mat() *
|
||||
_scene_setup->get_world_transform()->get_mat();
|
||||
|
||||
if (node->is_of_type(DirectionalLight::get_class_type())) {
|
||||
LVecBase3 d = mat.xform_vec(((const DirectionalLight *)node)->get_direction());
|
||||
d.normalize();
|
||||
t.set_row(2, LVecBase4(d, 0));
|
||||
t.set_row(3, LVecBase4(-d, 0));
|
||||
|
||||
} else if (node->is_of_type(LightLensNode::get_class_type())) {
|
||||
const Lens *lens = ((const LightLensNode *)node)->get_lens();
|
||||
|
||||
LPoint3 p = mat.xform_point(lens->get_nodal_point());
|
||||
t.set_row(3, LVecBase4(p));
|
||||
|
||||
// For shadowed point light we need to store near/far.
|
||||
// For spotlight we need to store cutoff angle.
|
||||
if (node->is_of_type(Spotlight::get_class_type())) {
|
||||
PN_stdfloat cutoff = ccos(deg_2_rad(lens->get_hfov() * 0.5f));
|
||||
LVecBase3 d = -(mat.xform_vec(lens->get_view_vector()));
|
||||
t.set_cell(1, 3, ((const Spotlight *)node)->get_exponent());
|
||||
t.set_row(2, LVecBase4(d, cutoff));
|
||||
|
||||
} else if (node->is_of_type(PointLight::get_class_type())) {
|
||||
t.set_cell(1, 3, lens->get_near());
|
||||
t.set_cell(3, 3, lens->get_far());
|
||||
|
||||
if (node->is_of_type(SphereLight::get_class_type())) {
|
||||
t.set_cell(2, 3, ((const SphereLight *)node)->get_radius());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (index == 0) {
|
||||
// Apply the default OpenGL lights otherwise.
|
||||
// Special exception for light 0, which defaults to white.
|
||||
t.set_row(0, _light_color_scale);
|
||||
}
|
||||
return &t;
|
||||
}
|
||||
default:
|
||||
nassertr(false /*should never get here*/, &LMatrix4::ident_mat());
|
||||
return &LMatrix4::ident_mat();
|
||||
|
|
|
|||
|
|
@ -343,28 +343,29 @@ munge_state_impl(const RenderState *state) {
|
|||
|
||||
#ifdef HAVE_CG
|
||||
if (_auto_shader) {
|
||||
CPT(RenderState) shader_state = munged_state->get_auto_shader_state();
|
||||
GraphicsStateGuardian *gsg = get_gsg();
|
||||
ShaderGenerator *shader_generator = gsg->get_shader_generator();
|
||||
if (shader_generator == nullptr) {
|
||||
shader_generator = new ShaderGenerator(gsg);
|
||||
gsg->set_shader_generator(shader_generator);
|
||||
}
|
||||
if (shader_state->_generated_shader == NULL) {
|
||||
if (munged_state->_generated_shader == nullptr) {
|
||||
// Cache the generated ShaderAttrib on the shader state.
|
||||
GeomVertexAnimationSpec spec;
|
||||
|
||||
// Currently we overload this flag to request vertex animation for the
|
||||
// shader generator.
|
||||
const ShaderAttrib *sattr;
|
||||
shader_state->get_attrib_def(sattr);
|
||||
munged_state->get_attrib_def(sattr);
|
||||
if (sattr->get_flag(ShaderAttrib::F_hardware_skinning)) {
|
||||
spec.set_hardware(4, true);
|
||||
}
|
||||
|
||||
shader_state->_generated_shader = shader_generator->synthesize_shader(shader_state, spec);
|
||||
munged_state->_generated_shader = shader_generator->synthesize_shader(munged_state, spec);
|
||||
}
|
||||
if (munged_state->_generated_shader != nullptr) {
|
||||
munged_state = munged_state->set_attrib(munged_state->_generated_shader);
|
||||
}
|
||||
munged_state = munged_state->set_attrib(shader_state->_generated_shader);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -327,3 +327,11 @@ INLINE void Material::
|
|||
set_attrib_lock() {
|
||||
_flags |= F_attrib_lock;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE int Material::
|
||||
get_flags() const {
|
||||
return _flags;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,6 +128,8 @@ PUBLISHED:
|
|||
MAKE_PROPERTY(twoside, get_twoside, set_twoside);
|
||||
|
||||
public:
|
||||
INLINE int get_flags() const;
|
||||
|
||||
enum Flags {
|
||||
F_ambient = 0x001,
|
||||
F_diffuse = 0x002,
|
||||
|
|
@ -157,8 +159,6 @@ private:
|
|||
|
||||
int _flags;
|
||||
|
||||
friend class MaterialAttrib;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory();
|
||||
virtual void write_datagram(BamWriter *manager, Datagram &me);
|
||||
|
|
|
|||
|
|
@ -450,9 +450,11 @@ cp_dependency(ShaderMatInput inp) {
|
|||
}
|
||||
}
|
||||
if ((inp == SMO_light_ambient) ||
|
||||
(inp == SMO_light_source_i_attrib)) {
|
||||
dep |= SSD_light;
|
||||
if (inp == SMO_light_source_i_attrib) {
|
||||
(inp == SMO_light_source_i_attrib) ||
|
||||
(inp == SMO_light_source_i_packed)) {
|
||||
dep |= SSD_light | SSD_frame;
|
||||
if (inp == SMO_light_source_i_attrib ||
|
||||
inp == SMO_light_source_i_packed) {
|
||||
dep |= SSD_view_transform;
|
||||
}
|
||||
}
|
||||
|
|
@ -465,7 +467,7 @@ cp_dependency(ShaderMatInput inp) {
|
|||
(inp == SMO_apiview_clipplane_i)) {
|
||||
dep |= SSD_clip_planes;
|
||||
}
|
||||
if (inp == SMO_texmat_i || inp == SMO_inv_texmat_i) {
|
||||
if (inp == SMO_texmat_i || inp == SMO_inv_texmat_i || inp == SMO_texscale_i) {
|
||||
dep |= SSD_tex_matrix;
|
||||
}
|
||||
if ((inp == SMO_window_size) ||
|
||||
|
|
@ -483,7 +485,7 @@ cp_dependency(ShaderMatInput inp) {
|
|||
(inp == SMO_apiclip_to_apiview)) {
|
||||
dep |= SSD_projection;
|
||||
}
|
||||
if (inp == SMO_tex_is_alpha_i) {
|
||||
if (inp == SMO_tex_is_alpha_i || inp == SMO_texcolor_i) {
|
||||
dep |= SSD_texture | SSD_frame;
|
||||
}
|
||||
|
||||
|
|
@ -734,6 +736,29 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (pieces[0] == "mat" && pieces[1] == "shadow") {
|
||||
if ((!cp_errchk_parameter_words(p,3))||
|
||||
(!cp_errchk_parameter_in(p)) ||
|
||||
(!cp_errchk_parameter_uniform(p))||
|
||||
(!cp_errchk_parameter_float(p,16,16))) {
|
||||
return false;
|
||||
}
|
||||
ShaderMatSpec bind;
|
||||
bind._id = p._id;
|
||||
bind._piece = SMP_whole;
|
||||
bind._func = SMF_compose;
|
||||
bind._part[1] = SMO_light_source_i_attrib;
|
||||
bind._arg[1] = InternalName::make("shadowViewMatrix");
|
||||
bind._part[0] = SMO_view_to_apiview;
|
||||
bind._arg[0] = NULL;
|
||||
bind._index = atoi(pieces[2].c_str());
|
||||
|
||||
cp_optimize_mat_spec(bind);
|
||||
_mat_spec.push_back(bind);
|
||||
_mat_deps |= bind._dep[0] | bind._dep[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
// Implement some macros. Macros work by altering the contents of the
|
||||
// 'pieces' array, and then falling through.
|
||||
|
||||
|
|
@ -833,7 +858,13 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) {
|
|||
|
||||
ShaderMatSpec bind;
|
||||
bind._id = p._id;
|
||||
bind._piece = SMP_whole;
|
||||
bind._func = SMF_compose;
|
||||
bind._part[1] = SMO_light_source_i_attrib;
|
||||
bind._arg[1] = InternalName::make("shadowViewMatrix");
|
||||
bind._part[0] = SMO_view_to_apiview;
|
||||
bind._arg[0] = NULL;
|
||||
bind._index = atoi(pieces[2].c_str());
|
||||
|
||||
int next = 1;
|
||||
pieces.push_back("");
|
||||
|
|
@ -958,6 +989,30 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) {
|
|||
bind._arg[0] = NULL;
|
||||
bind._part[1] = SMO_identity;
|
||||
bind._arg[1] = NULL;
|
||||
} else if (pieces[1].compare(0, 5, "light") == 0) {
|
||||
if (!cp_errchk_parameter_float(p,16,16)) {
|
||||
return false;
|
||||
}
|
||||
bind._id = p._id;
|
||||
bind._piece = SMP_transpose;
|
||||
bind._func = SMF_first;
|
||||
bind._part[0] = SMO_light_source_i_packed;
|
||||
bind._arg[0] = NULL;
|
||||
bind._part[1] = SMO_identity;
|
||||
bind._arg[1] = NULL;
|
||||
bind._index = atoi(pieces[1].c_str() + 5);
|
||||
} else if (pieces[1].compare(0, 5, "lspec") == 0) {
|
||||
if (!cp_errchk_parameter_float(p,3,4)) {
|
||||
return false;
|
||||
}
|
||||
bind._id = p._id;
|
||||
bind._piece = SMP_row3;
|
||||
bind._func = SMF_first;
|
||||
bind._part[0] = SMO_light_source_i_attrib;
|
||||
bind._arg[0] = InternalName::make("specular");
|
||||
bind._part[1] = SMO_identity;
|
||||
bind._arg[1] = NULL;
|
||||
bind._index = atoi(pieces[1].c_str() + 5);
|
||||
} else {
|
||||
cp_report_error(p,"Unknown attr parameter.");
|
||||
return false;
|
||||
|
|
@ -1094,6 +1149,52 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (pieces[0] == "texscale") {
|
||||
if ((!cp_errchk_parameter_words(p,2))||
|
||||
(!cp_errchk_parameter_in(p)) ||
|
||||
(!cp_errchk_parameter_uniform(p))||
|
||||
(!cp_errchk_parameter_float(p,3,4))) {
|
||||
return false;
|
||||
}
|
||||
ShaderMatSpec bind;
|
||||
bind._id = p._id;
|
||||
bind._piece = SMP_row3;
|
||||
bind._func = SMF_first;
|
||||
bind._part[0] = SMO_texscale_i;
|
||||
bind._arg[0] = NULL;
|
||||
bind._part[1] = SMO_identity;
|
||||
bind._arg[1] = NULL;
|
||||
bind._index = atoi(pieces[1].c_str());
|
||||
|
||||
cp_optimize_mat_spec(bind);
|
||||
_mat_spec.push_back(bind);
|
||||
_mat_deps |= bind._dep[0] | bind._dep[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pieces[0] == "texcolor") {
|
||||
if ((!cp_errchk_parameter_words(p,2))||
|
||||
(!cp_errchk_parameter_in(p)) ||
|
||||
(!cp_errchk_parameter_uniform(p))||
|
||||
(!cp_errchk_parameter_float(p,3,4))) {
|
||||
return false;
|
||||
}
|
||||
ShaderMatSpec bind;
|
||||
bind._id = p._id;
|
||||
bind._piece = SMP_row3;
|
||||
bind._func = SMF_first;
|
||||
bind._part[0] = SMO_texcolor_i;
|
||||
bind._arg[0] = NULL;
|
||||
bind._part[1] = SMO_identity;
|
||||
bind._arg[1] = NULL;
|
||||
bind._index = atoi(pieces[1].c_str());
|
||||
|
||||
cp_optimize_mat_spec(bind);
|
||||
_mat_spec.push_back(bind);
|
||||
_mat_deps |= bind._dep[0] | bind._dep[1];
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pieces[0] == "plane") {
|
||||
if ((!cp_errchk_parameter_words(p,2))||
|
||||
(!cp_errchk_parameter_in(p)) ||
|
||||
|
|
@ -1233,9 +1334,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) {
|
|||
}
|
||||
ShaderTexSpec bind;
|
||||
bind._id = p._id;
|
||||
bind._name = InternalName::make(pieces[1])->append("shadowMap");
|
||||
bind._stage = -1;
|
||||
bind._part = STO_named_input;
|
||||
bind._name = nullptr;
|
||||
bind._stage = atoi(pieces[1].c_str());
|
||||
bind._part = STO_light_i_shadow_map;
|
||||
switch (p._type) {
|
||||
case SAT_sampler2d: bind._desired_type = Texture::TT_2d_texture; break;
|
||||
case SAT_sampler_cube: bind._desired_type = Texture::TT_cube_map; break;
|
||||
|
|
|
|||
|
|
@ -202,6 +202,17 @@ public:
|
|||
// Hack for text rendering. Don't use in user shaders.
|
||||
SMO_tex_is_alpha_i,
|
||||
|
||||
SMO_transform_i,
|
||||
SMO_slider_i,
|
||||
|
||||
SMO_light_source_i_packed,
|
||||
|
||||
// Texture scale component of texture matrix.
|
||||
SMO_texscale_i,
|
||||
|
||||
// Color of an M_blend texture stage.
|
||||
SMO_texcolor_i,
|
||||
|
||||
SMO_INVALID
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -94,22 +94,6 @@ get_hash_impl() const {
|
|||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) AlphaTestAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
// This is only important if the shader subsumes the alpha test, which only
|
||||
// happens if there is an AuxBitplaneAttrib with ABO_glow.
|
||||
const AuxBitplaneAttrib *aux;
|
||||
if (!state->get_attrib(aux) ||
|
||||
(aux->get_outputs() & AuxBitplaneAttrib::ABO_glow) == 0) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the BamReader how to create objects of type AlphaTestAttrib.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ public:
|
|||
protected:
|
||||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
PandaCompareFunc _mode;
|
||||
|
|
|
|||
|
|
@ -97,14 +97,6 @@ get_hash_impl() const {
|
|||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) AuxBitplaneAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the BamReader how to create objects of type AuxBitplaneAttrib.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ public:
|
|||
protected:
|
||||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
int _outputs;
|
||||
|
|
|
|||
|
|
@ -833,14 +833,6 @@ invert_compose_impl(const RenderAttrib *other) const {
|
|||
return other;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) ClipPlaneAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is patterned after TextureAttrib::sort_on_stages(), but since
|
||||
* planeNodes don't actually require sorting, this only empties the _filtered
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@ protected:
|
|||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
INLINE void check_filtered() const;
|
||||
|
|
|
|||
|
|
@ -132,19 +132,6 @@ get_hash_impl() const {
|
|||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) ColorAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
// For a ColorAttrib, the only relevant information is the type: is it flat-
|
||||
// shaded or vertex-shaded? The actual color value is read by the shader
|
||||
// from the graphics state.
|
||||
|
||||
ColorAttrib *attrib = new ColorAttrib(_type, LColor(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
return return_new(attrib);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quantizes the color color to the nearest multiple of 1000, just to prevent
|
||||
* runaway accumulation of only slightly-different ColorAttribs.
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ public:
|
|||
protected:
|
||||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
void quantize_color();
|
||||
|
|
|
|||
|
|
@ -148,14 +148,6 @@ get_hash_impl() const {
|
|||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) ColorBlendAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the BamReader how to create objects of type ColorBlendAttrib.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ public:
|
|||
protected:
|
||||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
Mode _mode;
|
||||
|
|
|
|||
|
|
@ -229,17 +229,6 @@ invert_compose_impl(const RenderAttrib *other) const {
|
|||
return return_new(attrib);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) ColorScaleAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
// A ColorScaleAttrib doesn't directly contribute to the auto-shader
|
||||
// contents--instead, the shader is always written to query attr_colorscale
|
||||
// at runtime. So the attrib itself means nothing to the shader.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quantizes the color scale to the nearest multiple of 1000, just to prevent
|
||||
* runaway accumulation of only slightly-different ColorScaleAttribs.
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ protected:
|
|||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
void quantize_scale();
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
CullableObject::FormatMap CullableObject::_format_map;
|
||||
LightMutex CullableObject::_format_lock;
|
||||
|
||||
PStatCollector CullableObject::_munge_pcollector("*:Munge");
|
||||
PStatCollector CullableObject::_munge_geom_pcollector("*:Munge:Geom");
|
||||
PStatCollector CullableObject::_munge_sprites_pcollector("*:Munge:Sprites");
|
||||
PStatCollector CullableObject::_munge_sprites_verts_pcollector("*:Munge:Sprites:Verts");
|
||||
|
|
@ -55,7 +56,7 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger,
|
|||
nassertr(munger != nullptr, false);
|
||||
|
||||
Thread *current_thread = traverser->get_current_thread();
|
||||
PStatTimer timer(_munge_geom_pcollector, current_thread);
|
||||
PStatTimer timer(_munge_pcollector, current_thread);
|
||||
if (_geom != nullptr) {
|
||||
GraphicsStateGuardianBase *gsg = traverser->get_gsg();
|
||||
int gsg_bits = gsg->get_supported_geom_rendering();
|
||||
|
|
@ -123,8 +124,11 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger,
|
|||
|
||||
// Now invoke the munger to ensure the resulting geometry is in a GSG-
|
||||
// friendly form.
|
||||
if (!munger->munge_geom(_geom, _munged_data, force, current_thread)) {
|
||||
return false;
|
||||
{
|
||||
PStatTimer timer(_munge_geom_pcollector, current_thread);
|
||||
if (!munger->munge_geom(_geom, _munged_data, force, current_thread)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have prepared it for skinning via the shader generator, mark a
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ private:
|
|||
static FormatMap _format_map;
|
||||
static LightMutex _format_lock;
|
||||
|
||||
static PStatCollector _munge_pcollector;
|
||||
static PStatCollector _munge_geom_pcollector;
|
||||
static PStatCollector _munge_sprites_pcollector;
|
||||
static PStatCollector _munge_sprites_verts_pcollector;
|
||||
|
|
|
|||
|
|
@ -100,14 +100,6 @@ get_hash_impl() const {
|
|||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) FogAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the BamReader how to create objects of type FogAttrib.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ public:
|
|||
protected:
|
||||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
PT(Fog) _fog;
|
||||
|
|
|
|||
|
|
@ -850,14 +850,6 @@ invert_compose_impl(const RenderAttrib *other) const {
|
|||
return other;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) LightAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure the lights are sorted in order of priority. Also counts the
|
||||
* number of non-ambient lights.
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ protected:
|
|||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
INLINE void check_sorted() const;
|
||||
|
|
|
|||
|
|
@ -254,14 +254,6 @@ get_hash_impl() const {
|
|||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) LightRampAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the BamReader how to create objects of type LightRampAttrib.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ public:
|
|||
protected:
|
||||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
LightRampMode _mode;
|
||||
|
|
|
|||
|
|
@ -88,14 +88,6 @@ get_hash_impl() const {
|
|||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) LogicOpAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
return RenderAttribRegistry::quick_get_global_ptr()->get_slot_default(_attrib_slot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the BamReader how to create objects of type LogicOpAttrib.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ public:
|
|||
protected:
|
||||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
Operation _op;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* Use MaterialAttrib::make() to construct a new MaterialAttrib object.
|
||||
*/
|
||||
INLINE MaterialAttrib::
|
||||
MaterialAttrib() : _flags(0) {
|
||||
MaterialAttrib() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -24,7 +24,7 @@ MaterialAttrib() : _flags(0) {
|
|||
*/
|
||||
INLINE bool MaterialAttrib::
|
||||
is_off() const {
|
||||
return _flags == 0;
|
||||
return _material == nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -35,11 +35,3 @@ INLINE Material *MaterialAttrib::
|
|||
get_material() const {
|
||||
return _material;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to get_material()->get_flags().
|
||||
*/
|
||||
INLINE int MaterialAttrib::
|
||||
get_material_flags() const {
|
||||
return _flags;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ make(Material *material) {
|
|||
MaterialAttrib *attrib = new MaterialAttrib;
|
||||
attrib->_material = material;
|
||||
material->set_attrib_lock();
|
||||
attrib->_flags = material->_flags;
|
||||
nassertr(attrib->_flags & Material::F_attrib_lock, nullptr);
|
||||
return return_new(attrib);
|
||||
}
|
||||
|
||||
|
|
@ -64,30 +62,6 @@ output(ostream &out) const {
|
|||
out << *_material;
|
||||
} else if (is_off()) {
|
||||
out << "(off)";
|
||||
} else {
|
||||
// This is a state returned from get_auto_shader_attrib().
|
||||
out << "(on";
|
||||
#ifndef NDEBUG
|
||||
if (_flags & Material::F_ambient) {
|
||||
out << " amb";
|
||||
}
|
||||
if (_flags & Material::F_diffuse) {
|
||||
out << " diff";
|
||||
}
|
||||
if (_flags & Material::F_specular) {
|
||||
out << " spec";
|
||||
}
|
||||
if (_flags & Material::F_emission) {
|
||||
out << " emit";
|
||||
}
|
||||
if (_flags & Material::F_local) {
|
||||
out << " local";
|
||||
}
|
||||
if (_flags & Material::F_twoside) {
|
||||
out << " twoside";
|
||||
}
|
||||
#endif
|
||||
out << ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +87,7 @@ compare_to_impl(const RenderAttrib *other) const {
|
|||
if (_material != ta->_material) {
|
||||
return _material < ta->_material ? -1 : 1;
|
||||
}
|
||||
return _flags < ta->_flags;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -124,26 +98,7 @@ compare_to_impl(const RenderAttrib *other) const {
|
|||
*/
|
||||
size_t MaterialAttrib::
|
||||
get_hash_impl() const {
|
||||
size_t hash = 0;
|
||||
hash = pointer_hash::add_hash(hash, _material);
|
||||
hash = int_hash::add_hash(hash, _flags);
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) MaterialAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
if (_material == nullptr) {
|
||||
return this;
|
||||
} else {
|
||||
// Make a copy, but only with the flags, not with the material itself.
|
||||
MaterialAttrib *attrib = new MaterialAttrib();
|
||||
attrib->_material = nullptr;
|
||||
attrib->_flags = _flags;
|
||||
return return_new(attrib);
|
||||
}
|
||||
return pointer_hash::add_hash(0, _material);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -174,13 +129,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
|
|||
int pi = RenderAttrib::complete_pointers(p_list, manager);
|
||||
|
||||
TypedWritable *material = p_list[pi++];
|
||||
if (material != nullptr) {
|
||||
_material = DCAST(Material, material);
|
||||
_flags = _material->_flags | Material::F_attrib_lock;
|
||||
} else {
|
||||
_material = nullptr;
|
||||
_flags = 0;
|
||||
}
|
||||
_material = DCAST(Material, material);
|
||||
|
||||
return pi;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,9 +36,6 @@ PUBLISHED:
|
|||
INLINE bool is_off() const;
|
||||
INLINE Material *get_material() const;
|
||||
|
||||
public:
|
||||
INLINE int get_material_flags() const;
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(material, get_material);
|
||||
|
||||
|
|
@ -48,11 +45,9 @@ public:
|
|||
protected:
|
||||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
PT(Material) _material;
|
||||
int _flags;
|
||||
|
||||
PUBLISHED:
|
||||
static int get_class_slot() {
|
||||
|
|
|
|||
|
|
@ -82,25 +82,6 @@ get_unique() const {
|
|||
return return_unique((RenderAttrib *)this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the variant of this RenderAttrib that's most relevant for
|
||||
* associating with an auto-generated shader. This should be a new
|
||||
* RenderAttrib of the same type as this one, with any superfluous data set to
|
||||
* neutral. Only the parts of the attrib that contribute to the shader should
|
||||
* be reflected in the returned attrib. The idea is to associate the auto-
|
||||
* generated shader with the most neutral form of all states, to allow it to
|
||||
* be shared across as many RenderState objects as possible.
|
||||
*
|
||||
* If this RenderAttrib is completely irrelevant to the auto-shader, this
|
||||
* should return NULL to indicate that the attrib won't be assocaited with the
|
||||
* shader at all. In this case the attrib does not contribute to the shader
|
||||
* meaningfully.
|
||||
*/
|
||||
INLINE CPT(RenderAttrib) RenderAttrib::
|
||||
get_auto_shader_attrib(const RenderState *state) const {
|
||||
return get_auto_shader_attrib_impl(state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a suitable hash value for phash_map.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -112,14 +112,6 @@ cull_callback(CullTraverser *, const CullTraverserData &) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) RenderAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method overrides ReferenceCount::unref() to clear the pointer from the
|
||||
* global object pool when its reference count goes to zero.
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ PUBLISHED:
|
|||
INLINE int compare_to(const RenderAttrib &other) const;
|
||||
INLINE size_t get_hash() const;
|
||||
INLINE CPT(RenderAttrib) get_unique() const;
|
||||
INLINE CPT(RenderAttrib) get_auto_shader_attrib(const RenderState *state) const;
|
||||
|
||||
virtual bool unref() const FINAL;
|
||||
|
||||
|
|
@ -170,7 +169,6 @@ protected:
|
|||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
void output_comparefunc(ostream &out, PandaCompareFunc fn) const;
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ TypeHandle RenderState::_type_handle;
|
|||
RenderState::
|
||||
RenderState() :
|
||||
_flags(0),
|
||||
_auto_shader_state(NULL),
|
||||
_lock("RenderState")
|
||||
{
|
||||
if (_states == (States *)NULL) {
|
||||
|
|
@ -88,7 +87,6 @@ RenderState::
|
|||
RenderState(const RenderState ©) :
|
||||
_filled_slots(copy._filled_slots),
|
||||
_flags(0),
|
||||
_auto_shader_state(NULL),
|
||||
_lock("RenderState")
|
||||
{
|
||||
// Copy over the attributes.
|
||||
|
|
@ -131,14 +129,6 @@ RenderState::
|
|||
nassertv(_saved_entry == -1);
|
||||
nassertv(_composition_cache.is_empty() && _invert_composition_cache.is_empty());
|
||||
|
||||
// Make sure the _auto_shader_state cache pointer is cleared.
|
||||
if (_auto_shader_state != (const RenderState *)NULL) {
|
||||
if (_auto_shader_state != this) {
|
||||
cache_unref_delete(_auto_shader_state);
|
||||
}
|
||||
_auto_shader_state = NULL;
|
||||
}
|
||||
|
||||
// If this was true at the beginning of the destructor, but is no longer
|
||||
// true now, probably we've been double-deleted.
|
||||
nassertv(get_ref_count() == 0);
|
||||
|
|
@ -665,24 +655,6 @@ unref() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base RenderState that should have the generated_shader stored
|
||||
* within it, for generated shader states. The returned object might be the
|
||||
* same as this object, or it might be a different RenderState with certain
|
||||
* attributes removed, or set to their default values.
|
||||
*
|
||||
* The point is to avoid needless regeneration of the shader attrib by storing
|
||||
* the generated shader on a common RenderState object, with all irrelevant
|
||||
* attributes removed.
|
||||
*/
|
||||
const RenderState *RenderState::
|
||||
get_auto_shader_state() const {
|
||||
if (_auto_shader_state == (const RenderState *)NULL) {
|
||||
((RenderState *)this)->assign_auto_shader_state();
|
||||
}
|
||||
return _auto_shader_state;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
@ -1259,54 +1231,6 @@ do_calc_hash() {
|
|||
_flags |= F_hash_known;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets _auto_shader_state to the appropriate RenderState object pointer,
|
||||
* either the same pointer as this object, or some other (simpler)
|
||||
* RenderState.
|
||||
*/
|
||||
void RenderState::
|
||||
assign_auto_shader_state() {
|
||||
CPT(RenderState) state = do_calc_auto_shader_state();
|
||||
|
||||
{
|
||||
LightReMutexHolder holder(*_states_lock);
|
||||
if (_auto_shader_state == (const RenderState *)NULL) {
|
||||
_auto_shader_state = state;
|
||||
if (_auto_shader_state != this) {
|
||||
_auto_shader_state->cache_ref();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the appropriate RenderState that should be used to store the auto
|
||||
* shader pointer for nodes that shader this RenderState.
|
||||
*/
|
||||
CPT(RenderState) RenderState::
|
||||
do_calc_auto_shader_state() {
|
||||
RenderState *state = new RenderState;
|
||||
|
||||
SlotMask mask = _filled_slots;
|
||||
int slot = mask.get_lowest_on_bit();
|
||||
while (slot >= 0) {
|
||||
const Attribute &attrib = _attributes[slot];
|
||||
nassertr(attrib._attrib != (RenderAttrib *)NULL, this);
|
||||
CPT(RenderAttrib) new_attrib = attrib._attrib->get_auto_shader_attrib(this);
|
||||
if (new_attrib != NULL) {
|
||||
nassertr(new_attrib->get_slot() == slot, this);
|
||||
state->_attributes[slot].set(new_attrib, 0);
|
||||
state->_filled_slots.set_bit(slot);
|
||||
}
|
||||
|
||||
mask.clear_bit(slot);
|
||||
slot = mask.get_lowest_on_bit();
|
||||
}
|
||||
|
||||
return return_new(state);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is used to share a common RenderState pointer for all
|
||||
* equivalent RenderState objects.
|
||||
|
|
@ -1705,14 +1629,6 @@ void RenderState::
|
|||
remove_cache_pointers() {
|
||||
nassertv(_states_lock->debug_is_locked());
|
||||
|
||||
// First, make sure the _auto_shader_state cache pointer is cleared.
|
||||
if (_auto_shader_state != (const RenderState *)NULL) {
|
||||
if (_auto_shader_state != this) {
|
||||
cache_unref_delete(_auto_shader_state);
|
||||
}
|
||||
_auto_shader_state = NULL;
|
||||
}
|
||||
|
||||
// Fortunately, since we added CompositionCache records in pairs, we know
|
||||
// exactly the set of RenderState objects that have us in their cache: it's
|
||||
// the same set of RenderState objects that we have in our own cache.
|
||||
|
|
|
|||
|
|
@ -130,8 +130,6 @@ PUBLISHED:
|
|||
EXTENSION(PyObject *get_composition_cache() const);
|
||||
EXTENSION(PyObject *get_invert_composition_cache() const);
|
||||
|
||||
const RenderState *get_auto_shader_state() const;
|
||||
|
||||
void output(ostream &out) const;
|
||||
void write(ostream &out, int indent_level) const;
|
||||
|
||||
|
|
@ -173,8 +171,6 @@ private:
|
|||
INLINE bool do_node_unref() const;
|
||||
INLINE void calc_hash();
|
||||
void do_calc_hash();
|
||||
void assign_auto_shader_state();
|
||||
CPT(RenderState) do_calc_auto_shader_state();
|
||||
|
||||
class CompositionCycleDescEntry {
|
||||
public:
|
||||
|
|
@ -317,8 +313,6 @@ private:
|
|||
int _draw_order;
|
||||
size_t _hash;
|
||||
|
||||
const RenderState *_auto_shader_state;
|
||||
|
||||
enum Flags {
|
||||
F_checked_bin_index = 0x000001,
|
||||
F_checked_cull_callback = 0x000002,
|
||||
|
|
|
|||
|
|
@ -80,22 +80,6 @@ get_hash_impl() const {
|
|||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) RescaleNormalAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
// We currently only support M_normalize in the ShaderGenerator.
|
||||
/*if (_mode == M_none || _mode == M_normalize) {
|
||||
return this;
|
||||
} else {
|
||||
return RescaleNormalAttrib::make(M_normalize);
|
||||
}*/
|
||||
// Actually, we currently ignore this attribute in the shader generator,
|
||||
// and always normalize the normals. It's too much of a bother.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the BamReader how to create objects of type RescaleNormalAttrib.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ public:
|
|||
protected:
|
||||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
Mode _mode;
|
||||
|
|
|
|||
|
|
@ -695,26 +695,6 @@ compose_impl(const RenderAttrib *other) const {
|
|||
return return_new(attr);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) ShaderAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
// For a ShaderAttrib, we only need to preserve the auto-shader flags.
|
||||
// Custom shaders, and custom shader inputs, aren't relevant to the shader
|
||||
// generator.
|
||||
ShaderAttrib *attrib = new ShaderAttrib;
|
||||
attrib->_auto_shader = _auto_shader;
|
||||
attrib->_has_shader = _has_shader;
|
||||
attrib->_auto_normal_on = _auto_normal_on;
|
||||
attrib->_auto_glow_on = _auto_glow_on;
|
||||
attrib->_auto_gloss_on = _auto_gloss_on;
|
||||
attrib->_auto_ramp_on = _auto_ramp_on;
|
||||
attrib->_auto_shadow_on = _auto_shadow_on;
|
||||
attrib->_flags = _flags;
|
||||
return return_new(attrib);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to generate a Shader object
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -127,7 +127,6 @@ protected:
|
|||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -432,14 +432,6 @@ invert_compose_impl(const RenderAttrib *other) const {
|
|||
return return_new(attrib);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) TexGenAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to be called after the _stages map has been built up
|
||||
* internally through some artificial means; it copies the appropriate
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ protected:
|
|||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
class ModeDef;
|
||||
|
|
|
|||
|
|
@ -415,28 +415,6 @@ invert_compose_impl(const RenderAttrib *other) const {
|
|||
return return_new(attrib);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) TexMatrixAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
// For a TexMatrixAttrib, the particular matrix per TextureStage isn't
|
||||
// important, just whether there is a matrix at all. So we create a new
|
||||
// state with an identity matrix everywhere there is a matrix at all in the
|
||||
// original.
|
||||
|
||||
TexMatrixAttrib *attrib = new TexMatrixAttrib;
|
||||
|
||||
Stages::const_iterator ai;
|
||||
for (ai = _stages.begin(); ai != _stages.end(); ++ai) {
|
||||
StageNode sn((*ai)._stage);
|
||||
sn._transform = TransformState::make_identity();
|
||||
attrib->_stages.insert(attrib->_stages.end(), sn);
|
||||
}
|
||||
|
||||
return return_new(attrib);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the BamReader how to create objects of type TexMatrixAttrib.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ protected:
|
|||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
INLINE void check_stage_list() const;
|
||||
|
|
|
|||
|
|
@ -140,26 +140,6 @@ get_on_texture(TextureStage *stage) const {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the texture associated with the indicated stage. It is
|
||||
* an error to call this if has_on_stage(stage) returns false.
|
||||
*
|
||||
* This method is no different than get_on_texture(stage)->get_texture_type();
|
||||
* it merely exists to address a corner case for the shader generator.
|
||||
*/
|
||||
INLINE Texture::TextureType TextureAttrib::
|
||||
get_on_texture_type(TextureStage *stage) const {
|
||||
Stages::const_iterator si;
|
||||
si = _on_stages.find(StageNode(stage));
|
||||
nassertr(si != _on_stages.end(), Texture::TT_2d_texture);
|
||||
|
||||
if ((*si)._texture == nullptr) {
|
||||
return (*si)._texture_type;
|
||||
} else {
|
||||
return (*si)._texture->get_texture_type();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the sampler associated with the indicated stage, or the one
|
||||
* associated with its texture if no custom stage has been specified. It is
|
||||
|
|
@ -235,26 +215,6 @@ is_identity() const {
|
|||
return _on_stages.empty() && _off_stages.empty() && !_off_all_stages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call only on a state returned by get_auto_shader_attrib.
|
||||
*/
|
||||
bool TextureAttrib::
|
||||
on_stage_affects_rgb(size_t n) const {
|
||||
nassertr(n < _render_stages.size(), false);
|
||||
StageNode *stage = _render_stages[n];
|
||||
return stage->_texture_affects_rgb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call only on a state returned by get_auto_shader_attrib.
|
||||
*/
|
||||
bool TextureAttrib::
|
||||
on_stage_affects_alpha(size_t n) const {
|
||||
nassertr(n < _render_stages.size(), false);
|
||||
StageNode *stage = _render_stages[n];
|
||||
return stage->_texture_affects_alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirms whether the _on_stages list is still sorted. It will become
|
||||
* unsorted if someone calls TextureStage::set_sort().
|
||||
|
|
@ -263,7 +223,7 @@ on_stage_affects_alpha(size_t n) const {
|
|||
*/
|
||||
INLINE void TextureAttrib::
|
||||
check_sorted() const {
|
||||
if (_sort_seq != TextureStage::get_sort_seq() && !_sort_seq.is_fresh()) {
|
||||
if (_sort_seq != TextureStage::get_sort_seq()) {
|
||||
((TextureAttrib *)this)->sort_on_stages();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -385,19 +385,9 @@ output(ostream &out) const {
|
|||
const StageNode &sn = *(*ri);
|
||||
TextureStage *stage = sn._stage;
|
||||
Texture *tex = sn._texture;
|
||||
out << " " << stage->get_name();
|
||||
if (tex != nullptr) {
|
||||
out << " " << stage->get_name() << ":" << tex->get_name();
|
||||
} else {
|
||||
out << " " << stage->get_name() << ":(" << sn._texture_type;
|
||||
if (sn._texture_affects_rgb) {
|
||||
out << " rgb";
|
||||
if (sn._texture_affects_alpha) {
|
||||
out << "a";
|
||||
}
|
||||
} else if (sn._texture_affects_alpha) {
|
||||
out << " alpha";
|
||||
}
|
||||
out << ")";
|
||||
out << ":" << tex->get_name();
|
||||
}
|
||||
if (sn._override != 0) {
|
||||
out << "^" << sn._override;
|
||||
|
|
@ -513,19 +503,6 @@ compare_to_impl(const RenderAttrib *other) const {
|
|||
}
|
||||
}
|
||||
|
||||
if (texture == nullptr) {
|
||||
// This is an attribute returned by get_auto_shader_attrib_impl.
|
||||
if ((*si)._texture_type != (*osi)._texture_type) {
|
||||
return (*si)._texture_type < (*osi)._texture_type ? -1 : 1;
|
||||
}
|
||||
if ((*si)._texture_affects_rgb != (*osi)._texture_affects_rgb) {
|
||||
return (*si)._texture_affects_rgb < (*osi)._texture_affects_rgb ? -1 : 1;
|
||||
}
|
||||
if ((*si)._texture_affects_alpha != (*osi)._texture_affects_alpha) {
|
||||
return (*si)._texture_affects_alpha < (*osi)._texture_affects_alpha ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
++si;
|
||||
++osi;
|
||||
}
|
||||
|
|
@ -589,13 +566,6 @@ get_hash_impl() const {
|
|||
hash = pointer_hash::add_hash(hash, sn._texture);
|
||||
hash = int_hash::add_hash(hash, (int)sn._implicit_sort);
|
||||
hash = int_hash::add_hash(hash, sn._override);
|
||||
|
||||
if (sn._texture == nullptr) {
|
||||
// This is an attribute returned by get_auto_shader_attrib_impl.
|
||||
hash = int_hash::add_hash(hash, (int)sn._texture_type);
|
||||
hash = int_hash::add_hash(hash, (int)sn._texture_affects_rgb);
|
||||
hash = int_hash::add_hash(hash, (int)sn._texture_affects_alpha);
|
||||
}
|
||||
}
|
||||
|
||||
// This bool value goes here, between the two lists, to differentiate
|
||||
|
|
@ -767,52 +737,6 @@ invert_compose_impl(const RenderAttrib *other) const {
|
|||
return other;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) TextureAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
if (_on_stages.empty()) {
|
||||
// Having no stages is the same as not applying a texture attribute.
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// We make a texture attribute that does not store the texture and sampler,
|
||||
// so that we don't have to generate a shader for every possible texture.
|
||||
// We do have to store the few texture properties that do affect the
|
||||
// generated shader.
|
||||
PT(TextureAttrib) attrib = new TextureAttrib;
|
||||
attrib->_on_stages = _on_stages;
|
||||
attrib->sort_on_stages();
|
||||
|
||||
Stages::iterator si;
|
||||
for (si = attrib->_on_stages.begin(); si != attrib->_on_stages.end(); ++si) {
|
||||
Texture::Format format = (*si)._texture->get_format();
|
||||
(*si)._texture_type = (*si)._texture->get_texture_type();
|
||||
(*si)._texture_affects_rgb = (format != Texture::F_alpha);
|
||||
(*si)._texture_affects_alpha = Texture::has_alpha(format);
|
||||
(*si)._texture = nullptr;
|
||||
(*si)._has_sampler = false;
|
||||
|
||||
// We will no longer be composing or sorting this state so we can get rid
|
||||
// of these values.
|
||||
(*si)._override = 0;
|
||||
(*si)._implicit_sort = 0;
|
||||
|
||||
// Exception to optimize a common case: if the first texture is an RGB
|
||||
// texture, we don't care about whether it affects the alpha channel.
|
||||
if (attrib->_render_stages[0] == &(*si) &&
|
||||
(*si)._texture_affects_rgb && !(*si)._texture_affects_alpha) {
|
||||
(*si)._texture_affects_alpha = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent check_sorted() from being called on this state.
|
||||
attrib->_sort_seq = UpdateSeq::fresh();
|
||||
|
||||
return return_new(attrib);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the BamReader how to create objects of type TextureAttrib.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ PUBLISHED:
|
|||
INLINE int get_ff_tc_index(int n) const;
|
||||
INLINE bool has_on_stage(TextureStage *stage) const;
|
||||
INLINE Texture *get_on_texture(TextureStage *stage) const;
|
||||
INLINE Texture::TextureType get_on_texture_type(TextureStage *stage) const;
|
||||
INLINE const SamplerState &get_on_sampler(TextureStage *stage) const;
|
||||
INLINE int get_on_stage_override(TextureStage *stage) const;
|
||||
|
||||
|
|
@ -82,8 +81,6 @@ PUBLISHED:
|
|||
CPT(RenderAttrib) unify_texture_stages(TextureStage *stage) const;
|
||||
|
||||
public:
|
||||
INLINE bool on_stage_affects_rgb(size_t n) const;
|
||||
INLINE bool on_stage_affects_alpha(size_t n) const;
|
||||
CPT(TextureAttrib) filter_to_max(int max_texture_stages) const;
|
||||
|
||||
virtual bool lower_attrib_can_override() const;
|
||||
|
|
@ -97,7 +94,6 @@ protected:
|
|||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
INLINE void check_sorted() const;
|
||||
|
|
@ -117,11 +113,6 @@ private:
|
|||
int _ff_tc_index;
|
||||
unsigned int _implicit_sort;
|
||||
int _override;
|
||||
|
||||
// These fields are used by the shader generator.
|
||||
Texture::TextureType _texture_type : 16;
|
||||
bool _texture_affects_rgb : 8;
|
||||
bool _texture_affects_alpha : 8;
|
||||
};
|
||||
|
||||
class CompareTextureStagePriorities {
|
||||
|
|
|
|||
|
|
@ -109,21 +109,6 @@ get_hash_impl() const {
|
|||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
CPT(RenderAttrib) TransparencyAttrib::
|
||||
get_auto_shader_attrib_impl(const RenderState *state) const {
|
||||
if (_mode == TransparencyAttrib::M_alpha) {
|
||||
return this;
|
||||
} else if (_mode == TransparencyAttrib::M_premultiplied_alpha ||
|
||||
_mode == TransparencyAttrib::M_dual) {
|
||||
return return_new(new TransparencyAttrib(M_alpha));
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells the BamReader how to create objects of type TransparencyAttrib.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ public:
|
|||
protected:
|
||||
virtual int compare_to_impl(const RenderAttrib *other) const;
|
||||
virtual size_t get_hash_impl() const;
|
||||
virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
|
||||
|
||||
private:
|
||||
Mode _mode;
|
||||
|
|
|
|||
|
|
@ -56,9 +56,7 @@ fillin(DatagramIterator &scan, BamReader *) {
|
|||
*/
|
||||
DirectionalLight::
|
||||
DirectionalLight(const string &name) :
|
||||
LightLensNode(name, new OrthographicLens()),
|
||||
_has_specular_color(false)
|
||||
{
|
||||
LightLensNode(name, new OrthographicLens()) {
|
||||
_lenses[0]._lens->set_interocular_distance(0);
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +67,6 @@ DirectionalLight(const string &name) :
|
|||
DirectionalLight::
|
||||
DirectionalLight(const DirectionalLight ©) :
|
||||
LightLensNode(copy),
|
||||
_has_specular_color(copy._has_specular_color),
|
||||
_cycler(copy._cycler)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,6 @@ public:
|
|||
int light_id);
|
||||
|
||||
private:
|
||||
bool _has_specular_color;
|
||||
|
||||
// This is the data that must be cycled between pipeline stages.
|
||||
class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -11,6 +11,15 @@
|
|||
* @date 2002-03-26
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns true if this light defines a specular color, false if the specular
|
||||
* color is derived automatically from the light color.
|
||||
*/
|
||||
INLINE bool LightLensNode::
|
||||
has_specular_color() const {
|
||||
return _has_specular_color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this light is configured to cast shadows or not.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ TypeHandle LightLensNode::_type_handle;
|
|||
LightLensNode::
|
||||
LightLensNode(const string &name, Lens *lens) :
|
||||
Camera(name, lens),
|
||||
_has_specular_color(false),
|
||||
_attrib_count(0)
|
||||
{
|
||||
set_active(false);
|
||||
|
|
@ -63,6 +64,7 @@ LightLensNode(const LightLensNode ©) :
|
|||
_shadow_caster(copy._shadow_caster),
|
||||
_sb_size(copy._sb_size),
|
||||
_sb_sort(-10),
|
||||
_has_specular_color(copy._has_specular_color),
|
||||
_attrib_count(0)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ PUBLISHED:
|
|||
LightLensNode(const string &name, Lens *lens = new PerspectiveLens());
|
||||
virtual ~LightLensNode();
|
||||
|
||||
INLINE bool has_specular_color() const;
|
||||
|
||||
INLINE bool is_shadow_caster() const;
|
||||
INLINE void set_shadow_caster(bool caster);
|
||||
INLINE void set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int sort = -10);
|
||||
|
|
@ -54,6 +56,7 @@ protected:
|
|||
|
||||
LVecBase2i _sb_size;
|
||||
bool _shadow_caster;
|
||||
bool _has_specular_color;
|
||||
int _sb_sort;
|
||||
|
||||
// This is really a map of GSG -> GraphicsOutput.
|
||||
|
|
|
|||
|
|
@ -61,9 +61,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
|||
*/
|
||||
PointLight::
|
||||
PointLight(const string &name) :
|
||||
LightLensNode(name),
|
||||
_has_specular_color(false)
|
||||
{
|
||||
LightLensNode(name) {
|
||||
PT(Lens) lens;
|
||||
lens = new PerspectiveLens(90, 90);
|
||||
lens->set_interocular_distance(0);
|
||||
|
|
@ -98,7 +96,6 @@ PointLight(const string &name) :
|
|||
PointLight::
|
||||
PointLight(const PointLight ©) :
|
||||
LightLensNode(copy),
|
||||
_has_specular_color(copy._has_specular_color),
|
||||
_cycler(copy._cycler)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,8 +63,6 @@ public:
|
|||
int light_id);
|
||||
|
||||
private:
|
||||
bool _has_specular_color;
|
||||
|
||||
// This is the data that must be cycled between pipeline stages.
|
||||
class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
|
||||
public:
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -28,6 +28,11 @@
|
|||
#include "renderState.h"
|
||||
#include "renderAttrib.h"
|
||||
|
||||
#include "colorAttrib.h"
|
||||
#include "lightRampAttrib.h"
|
||||
#include "texGenAttrib.h"
|
||||
#include "textureAttrib.h"
|
||||
|
||||
class AmbientLight;
|
||||
class DirectionalLight;
|
||||
class PointLight;
|
||||
|
|
@ -66,7 +71,6 @@ PUBLISHED:
|
|||
const GeomVertexAnimationSpec &anim);
|
||||
|
||||
protected:
|
||||
CPT(RenderAttrib) create_shader_attrib(const string &txt);
|
||||
static const string combine_mode_as_string(CPT(TextureStage) stage,
|
||||
TextureStage::CombineMode c_mode, bool alpha, short texindex);
|
||||
static const string combine_source_as_string(CPT(TextureStage) stage,
|
||||
|
|
@ -84,66 +88,76 @@ protected:
|
|||
const char *alloc_vreg();
|
||||
const char *alloc_freg();
|
||||
|
||||
bool _use_shadow_filter;
|
||||
|
||||
// RenderState analysis information. Created by analyze_renderstate:
|
||||
|
||||
CPT(RenderState) _state;
|
||||
int _material_flags;
|
||||
int _num_textures;
|
||||
struct ShaderKey {
|
||||
ShaderKey();
|
||||
bool operator < (const ShaderKey &other) const;
|
||||
bool operator == (const ShaderKey &other) const;
|
||||
bool operator != (const ShaderKey &other) const { return !operator ==(other); }
|
||||
|
||||
pvector<LightLensNode *> _lights;
|
||||
pvector<NodePath> _lights_np;
|
||||
GeomVertexAnimationSpec _anim_spec;
|
||||
enum TextureFlags {
|
||||
TF_has_rgb = 1,
|
||||
TF_has_alpha = 2,
|
||||
TF_has_texscale = 4,
|
||||
TF_has_texmat = 8,
|
||||
TF_saved_result = 16,
|
||||
TF_map_normal = 32,
|
||||
TF_map_height = 64,
|
||||
TF_map_glow = 128,
|
||||
TF_map_gloss = 256,
|
||||
};
|
||||
|
||||
bool _vertex_colors;
|
||||
bool _flat_colors;
|
||||
ColorAttrib::Type _color_type;
|
||||
int _material_flags;
|
||||
int _texture_flags;
|
||||
|
||||
bool _lighting;
|
||||
bool _shadows;
|
||||
bool _fog;
|
||||
struct TextureInfo {
|
||||
CPT_InternalName _texcoord_name;
|
||||
Texture::TextureType _type;
|
||||
TextureStage::Mode _mode;
|
||||
TexGenAttrib::Mode _gen_mode;
|
||||
int _flags;
|
||||
|
||||
bool _have_ambient;
|
||||
bool _have_diffuse;
|
||||
bool _have_emission;
|
||||
bool _have_specular;
|
||||
// Stored only if combine modes / blend color is used
|
||||
CPT(TextureStage) _stage;
|
||||
};
|
||||
pvector<TextureInfo> _textures;
|
||||
|
||||
bool _separate_ambient_diffuse;
|
||||
enum LightFlags {
|
||||
LF_has_shadows = 1,
|
||||
LF_has_specular_color = 2,
|
||||
};
|
||||
|
||||
int _map_index_normal;
|
||||
int _map_index_height;
|
||||
int _map_index_glow;
|
||||
int _map_index_gloss;
|
||||
bool _map_height_in_alpha;
|
||||
struct LightInfo {
|
||||
TypeHandle _type;
|
||||
int _flags;
|
||||
};
|
||||
pvector<LightInfo> _lights;
|
||||
bool _lighting;
|
||||
bool _have_separate_ambient;
|
||||
|
||||
bool _out_primary_glow;
|
||||
bool _out_aux_normal;
|
||||
bool _out_aux_glow;
|
||||
bool _out_aux_any;
|
||||
int _fog_mode;
|
||||
|
||||
bool _have_alpha_test;
|
||||
bool _have_alpha_blend;
|
||||
bool _calc_primary_alpha;
|
||||
bool _subsume_alpha_test;
|
||||
bool _disable_alpha_write;
|
||||
int _outputs;
|
||||
bool _calc_primary_alpha;
|
||||
bool _disable_alpha_write;
|
||||
RenderAttrib::PandaCompareFunc _alpha_test_mode;
|
||||
PN_stdfloat _alpha_test_ref;
|
||||
|
||||
int _num_clip_planes;
|
||||
bool _use_shadow_filter;
|
||||
int _num_clip_planes;
|
||||
|
||||
bool _need_material_props;
|
||||
bool _need_world_position;
|
||||
bool _need_world_normal;
|
||||
bool _need_eye_position;
|
||||
bool _need_eye_normal;
|
||||
bool _normalize_normals;
|
||||
bool _auto_normal_on;
|
||||
bool _auto_glow_on;
|
||||
bool _auto_gloss_on;
|
||||
bool _auto_ramp_on;
|
||||
bool _auto_shadow_on;
|
||||
CPT(LightRampAttrib) _light_ramp;
|
||||
};
|
||||
|
||||
void analyze_renderstate(const RenderState *rs);
|
||||
void clear_analysis();
|
||||
typedef phash_map<ShaderKey, CPT(ShaderAttrib)> GeneratedShaders;
|
||||
GeneratedShaders _generated_shaders;
|
||||
|
||||
// This is not a PT() to prevent a circular reference.
|
||||
GraphicsStateGuardianBase *_gsg;
|
||||
void analyze_renderstate(ShaderKey &key, const RenderState *rs);
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
|
|
|
|||
|
|
@ -65,9 +65,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
|||
*/
|
||||
Spotlight::
|
||||
Spotlight(const string &name) :
|
||||
LightLensNode(name),
|
||||
_has_specular_color(false)
|
||||
{
|
||||
LightLensNode(name) {
|
||||
_lenses[0]._lens->set_interocular_distance(0);
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +76,6 @@ Spotlight(const string &name) :
|
|||
Spotlight::
|
||||
Spotlight(const Spotlight ©) :
|
||||
LightLensNode(copy),
|
||||
_has_specular_color(copy._has_specular_color),
|
||||
_cycler(copy._cycler)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,8 +79,6 @@ private:
|
|||
CPT(RenderState) get_viz_state();
|
||||
|
||||
private:
|
||||
bool _has_specular_color;
|
||||
|
||||
// This is the data that must be cycled between pipeline stages.
|
||||
class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ static TimeCollectorProperties time_properties[] = {
|
|||
{ 1, "Cull:Sort", { 0.3, 0.3, 0.6 } },
|
||||
{ 1, "*", { 0.1, 0.1, 0.5 } },
|
||||
{ 1, "*:Show fps", { 0.5, 0.8, 1.0 } },
|
||||
{ 0, "*:Munge", { 0.3, 0.3, 0.9 } },
|
||||
{ 1, "*:Munge", { 0.3, 0.3, 0.9 } },
|
||||
{ 1, "*:Munge:Geom", { 0.4, 0.2, 0.8 } },
|
||||
{ 1, "*:Munge:Sprites", { 0.2, 0.8, 0.4 } },
|
||||
{ 0, "*:Munge:Data", { 0.7, 0.5, 0.2 } },
|
||||
|
|
|
|||
Loading…
Reference in New Issue