16 #ifndef SHADERGENERATOR_H
17 #define SHADERGENERATOR_H
73 void rehash_generated_shaders();
74 void clear_generated_shaders();
79 bool _use_generic_attr;
84 void reset_register_allocator();
85 const char *alloc_vreg();
86 const char *alloc_freg();
88 bool _use_shadow_filter;
95 bool operator < (
const ShaderKey &other)
const;
96 bool operator == (
const ShaderKey &other)
const;
97 bool operator != (
const ShaderKey &other)
const {
return !operator ==(other); }
102 TF_has_alpha = 0x002,
103 TF_has_texscale = 0x004,
104 TF_has_texmat = 0x008,
105 TF_saved_result = 0x010,
106 TF_map_normal = 0x020,
107 TF_map_height = 0x040,
109 TF_map_gloss = 0x100,
110 TF_map_emission = 0x001000000,
111 TF_uses_color = 0x200,
112 TF_uses_primary_color = 0x400,
113 TF_uses_last_saved_result = 0x800,
115 TF_rgb_scale_2 = 0x1000,
116 TF_rgb_scale_4 = 0x2000,
117 TF_alpha_scale_2 = 0x4000,
118 TF_alpha_scale_4 = 0x8000,
120 TF_COMBINE_RGB_MODE_SHIFT = 16,
121 TF_COMBINE_RGB_MODE_MASK = 0x0000f0000,
122 TF_COMBINE_ALPHA_MODE_SHIFT = 20,
123 TF_COMBINE_ALPHA_MODE_MASK = 0x000f00000,
126 ColorAttrib::Type _color_type;
132 Texture::TextureType _type;
133 TextureStage::Mode _mode;
134 TexGenAttrib::Mode _gen_mode;
136 uint16_t _combine_rgb;
137 uint16_t _combine_alpha;
143 LF_has_specular_color = 2,
152 bool _have_separate_ambient;
157 bool _calc_primary_alpha;
158 bool _disable_alpha_write;
159 RenderAttrib::PandaCompareFunc _alpha_test_mode;
160 PN_stdfloat _alpha_test_ref;
162 int _num_clip_planes;
167 typedef phash_map<ShaderKey, CPT(
ShaderAttrib)> GeneratedShaders;
168 GeneratedShaders _generated_shaders;
170 void analyze_renderstate(ShaderKey &key,
const RenderState *rs);
172 static std::string combine_mode_as_string(
const ShaderKey::TextureInfo &info,
173 TextureStage::CombineMode c_mode,
bool alpha,
short texindex);
174 static std::string combine_source_as_string(
const ShaderKey::TextureInfo &info,
175 short num,
bool alpha,
short texindex);
176 static const char *texture_type_as_string(Texture::TextureType ttype);
182 static void init_type() {
183 TypedReferenceCount::init_type();
185 TypedReferenceCount::get_class_type());
188 return get_class_type();
190 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
207 void rehash_generated_shaders();
208 void clear_generated_shaders();
214 static void init_type() {
215 TypedReferenceCount::init_type();
217 TypedReferenceCount::get_class_type());
220 return get_class_type();
222 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
232 #endif // SHADERGENERATOR_H