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_uses_color = 0x200,
111 TF_uses_primary_color = 0x400,
112 TF_uses_last_saved_result = 0x800,
114 TF_rgb_scale_2 = 0x1000,
115 TF_rgb_scale_4 = 0x2000,
116 TF_alpha_scale_2 = 0x4000,
117 TF_alpha_scale_4 = 0x8000,
119 TF_COMBINE_RGB_MODE_SHIFT = 16,
120 TF_COMBINE_RGB_MODE_MASK = 0x0000f0000,
121 TF_COMBINE_ALPHA_MODE_SHIFT = 20,
122 TF_COMBINE_ALPHA_MODE_MASK = 0x000f00000,
125 ColorAttrib::Type _color_type;
131 Texture::TextureType _type;
132 TextureStage::Mode _mode;
133 TexGenAttrib::Mode _gen_mode;
135 uint16_t _combine_rgb;
136 uint16_t _combine_alpha;
142 LF_has_specular_color = 2,
151 bool _have_separate_ambient;
156 bool _calc_primary_alpha;
157 bool _disable_alpha_write;
158 RenderAttrib::PandaCompareFunc _alpha_test_mode;
159 PN_stdfloat _alpha_test_ref;
161 int _num_clip_planes;
166 typedef phash_map<ShaderKey, CPT(
ShaderAttrib)> GeneratedShaders;
167 GeneratedShaders _generated_shaders;
169 void analyze_renderstate(ShaderKey &key,
const RenderState *rs);
171 static std::string combine_mode_as_string(
const ShaderKey::TextureInfo &info,
172 TextureStage::CombineMode c_mode,
bool alpha,
short texindex);
173 static std::string combine_source_as_string(
const ShaderKey::TextureInfo &info,
174 short num,
bool alpha,
short texindex);
175 static const char *texture_type_as_string(Texture::TextureType ttype);
181 static void init_type() {
182 TypedReferenceCount::init_type();
184 TypedReferenceCount::get_class_type());
187 return get_class_type();
189 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
203 static void init_type() {
204 TypedReferenceCount::init_type();
206 TypedReferenceCount::get_class_type());
209 return get_class_type();
211 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
221 #endif // SHADERGENERATOR_H