12#include "COLLADAFWColorOrTexture.h"
13#include "COLLADASWEffectProfile.h"
43 BCExportSettings &export_settings,
45 : COLLADASW::LibraryEffects(sw), export_settings(export_settings), key_image_map(key_image_map)
49bool EffectsExporter::hasEffects(
Scene *sce)
54 for (a = 0; a < ob->totcol; a++) {
72 if (hasEffects(sce)) {
78 sce, *
this, this->export_settings.get_export_set());
84void EffectsExporter::set_shader_type(COLLADASW::EffectProfile &ep,
Material *ma)
87 ep.setShaderType(COLLADASW::EffectProfile::LAMBERT);
90void EffectsExporter::set_transparency(COLLADASW::EffectProfile &ep,
Material *ma)
95 COLLADASW::ColorOrTexture cot =
bc_get_cot(0, 0, 0, alpha);
96 ep.setTransparent(cot,
false,
"alpha");
97 ep.setOpaque(COLLADASW::EffectProfile::A_ONE);
101void EffectsExporter::set_diffuse_color(COLLADASW::EffectProfile &ep,
Material *ma)
104 ep.setDiffuse(cot,
false,
"diffuse");
107void EffectsExporter::set_ambient(COLLADASW::EffectProfile &ep,
Material *ma)
110 ep.setAmbient(cot,
false,
"ambient");
112void EffectsExporter::set_specular(COLLADASW::EffectProfile &ep,
Material *ma)
115 ep.setSpecular(cot,
false,
"specular");
117void EffectsExporter::set_reflective(COLLADASW::EffectProfile &ep,
Material *ma)
120 ep.setReflective(cot,
false,
"reflective");
123void EffectsExporter::set_reflectivity(COLLADASW::EffectProfile &ep,
Material *ma)
126 if (reflectivity > 0.0) {
127 ep.setReflectivity(reflectivity,
false,
"specular");
131void EffectsExporter::set_emission(COLLADASW::EffectProfile &ep,
Material *ma)
134 ep.setEmission(cot,
false,
"emission");
137void EffectsExporter::set_ior(COLLADASW::EffectProfile &ep,
Material *ma)
140 ep.setIndexOfRefraction(alpha,
false,
"ior");
143void EffectsExporter::set_shininess(COLLADASW::EffectProfile &ep,
Material *ma)
146 ep.setShininess(shininess,
false,
"shininess");
156 Image *image = material.get_diffuse_image();
157 if (image ==
nullptr) {
161 std::string uid(
id_name(image));
164 if (material_image_map.find(key) == material_image_map.end()) {
165 material_image_map[key] =
image;
166 key_image_map[key] =
image;
170void EffectsExporter::create_image_samplers(COLLADASW::EffectProfile &ep,
172 std::string &active_uv)
174 KeyImageMap::iterator iter;
176 for (iter = material_image_map.begin(); iter != material_image_map.end(); iter++) {
178 Image *image = iter->second;
179 std::string uid(
id_name(image));
182 COLLADASW::Sampler *
sampler =
new COLLADASW::Sampler(
183 COLLADASW::Sampler::SAMPLER_TYPE_2D,
184 key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
185 key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
199 COLLADASW::EffectProfile ep(mSW);
200 ep.setProfileType(COLLADASW::EffectProfile::COMMON);
202 set_shader_type(ep, ma);
204 COLLADASW::ColorOrTexture cot;
206 set_diffuse_color(ep, ma);
207 set_emission(ep, ma);
209 set_reflectivity(ep, ma);
210 set_transparency(ep, ma);
214 set_shininess(ep, ma);
216 set_specular(ep, ma);
219 get_images(ma, material_image_map);
221 create_image_samplers(ep, material_image_map, active_uv);
225 for (a = 0,
b = 0; a < tex_indices.size(); a++) {
226 MTex *t = ma->mtex[tex_indices[a]];
238 if (im_samp_map.find(key) == im_samp_map.end()) {
240 COLLADASW::Sampler
sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D,
241 key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
242 key + COLLADASW::Sampler::SURFACE_SID_SUFFIX);
248 samp_surf[
b] = &samplers[a];
251 im_samp_map[key] =
b;
256 for (a = 0; a < tex_indices.size(); a++) {
257 MTex *t = ma->mtex[tex_indices[a]];
266 int i = im_samp_map[key];
267 std::string uvname = strlen(t->
uvname) ? t->
uvname : active_uv;
268 COLLADASW::Sampler *
sampler = (COLLADASW::Sampler *)
270 writeTextures(ep, key,
sampler, t, ima, uvname);
275 ep.addProfileElements();
276 ep.addExtraTechniques(mSW);
283 std::string &uv_layer_name,
289 texture.setTexcoord(uv_layer_name);
293 COLLADASW::ColorOrTexture cot(texture);
299 COLLADASW::Color
color(r, g,
b, a);
300 COLLADASW::ColorOrTexture cot(color);
#define FOREACH_SCENE_OBJECT_END
#define FOREACH_SCENE_OBJECT_BEGIN(scene, _instance)
CustomData interface, see also DNA_customdata_types.h.
int CustomData_number_of_layers(const CustomData *data, eCustomDataType type)
General operations, lookup, etc. for materials.
struct Material * BKE_object_material_get(struct Object *ob, short act)
static std::string getActiveUVLayerName(Object *ob)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
EffectsExporter(COLLADASW::StreamWriter *sw, BCExportSettings &export_settings, KeyImageMap &key_image_map)
COLLADASW::ColorOrTexture createTexture(Image *ima, std::string &uv_layer_name, COLLADASW::Sampler *sampler)
COLLADASW::ColorOrTexture getcol(float r, float g, float b, float a)
void operator()(Material *ma, Object *ob)
void exportEffects(bContext *C, Scene *sce)
std::string translate_id(const char *idString)
std::string get_effect_id(Material *mat)
std::string id_name(void *id)
COLLADASW::ColorOrTexture bc_get_specular(Material *ma)
COLLADASW::ColorOrTexture bc_get_ambient(Material *ma)
double bc_get_alpha(Material *ma)
COLLADASW::ColorOrTexture bc_get_cot(float r, float g, float b, float a)
COLLADASW::ColorOrTexture bc_get_emission(Material *ma)
COLLADASW::ColorOrTexture bc_get_reflective(Material *ma)
double bc_get_reflectivity(Material *ma)
double bc_get_shininess(Material *ma)
COLLADASW::ColorOrTexture bc_get_base_color(Material *ma)
double bc_get_ior(Material *ma)
const char * bc_CustomData_get_active_layer_name(const CustomData *data, eCustomDataType type)
std::map< std::string, Image * > KeyImageMap
input_tx image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "preview_img") .compute_source("compositor_compute_preview.glsl") .do_static_compilation(true)
local_group_size(16, 16) .push_constant(Type local_group_size(16, 16) .push_constant(Type input_tx sampler(1, ImageType::FLOAT_2D, "matte_tx") .image(0
local_group_size(16, 16) .push_constant(Type b
local_group_size(16, 16) .push_constant(Type texture
void forEachMaterialInExportSet(Scene *sce, Functor &f, LinkNode *export_set)