2011-08-28 23:24:34 +00:00
|
|
|
/*
|
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2012-03-18 09:27:36 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2011-08-28 23:24:34 +00:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Tom Edwards
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** \file blender/makesrna/intern/rna_texture_api.c
|
|
|
|
|
* \ingroup RNA
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2013-03-04 18:36:37 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2012-09-03 22:04:14 +00:00
|
|
|
#include "BLI_path_util.h"
|
2011-08-28 23:24:34 +00:00
|
|
|
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
2012-09-22 14:07:55 +00:00
|
|
|
#include "rna_internal.h" /* own include */
|
|
|
|
|
|
2011-08-28 23:24:34 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
|
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
|
#include "RE_pipeline.h"
|
2011-09-06 10:49:55 +00:00
|
|
|
#include "RE_shader_ext.h"
|
2011-08-28 23:24:34 +00:00
|
|
|
|
2012-09-22 14:07:55 +00:00
|
|
|
static void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const char *filepath,
|
|
|
|
|
struct Scene *scene, float layout[12])
|
2011-08-28 23:24:34 +00:00
|
|
|
{
|
|
|
|
|
if (scene == NULL) {
|
|
|
|
|
scene = CTX_data_scene(C);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-21 20:19:58 +00:00
|
|
|
RE_WriteEnvmapResult(reports, scene, env, filepath, scene->r.im_format.imtype, layout);
|
2011-08-28 23:24:34 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-22 14:07:55 +00:00
|
|
|
static void clear_envmap(struct EnvMap *env, bContext *C)
|
2011-08-28 23:24:34 +00:00
|
|
|
{
|
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
Tex *tex;
|
|
|
|
|
|
|
|
|
|
BKE_free_envmapdata(env);
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
for (tex = bmain->tex.first; tex; tex = tex->id.next)
|
2011-08-28 23:24:34 +00:00
|
|
|
if (tex->env == env) {
|
2012-05-12 11:01:29 +00:00
|
|
|
WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex);
|
2011-08-28 23:24:34 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-22 14:07:55 +00:00
|
|
|
static void texture_evaluate(struct Tex *tex, float value[3], float color_r[4])
|
2011-09-06 10:49:55 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
TexResult texres = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
|
Fix #36058: Displace Modifier errors using a baked Image and displace baking inconsistency between 2.67/2.68RC and previous versions
This was in fact really nasty bug, caused by multitex_nodes
function using global variable R (which is a copy of current
renderer). this variable is not initialized to anything
meaningful for until first rendering (preview or final)
happened.
Since multitex_nodes might be used outside of render pipeline,
made it so whether CM is on or off as an argument to functions
multitex_ext_safe and multitex_ext. Now multitex_nodes() is
only shall be used for stuff happening from render pipeline!
Also needed to make some changes to other places, so all the
usages of texture sampling knows for the fact whether CM is
on or off.
And one more change is related on behavior of dispalcement,
wave, warp, weightvg modifiers and smoke. They'll be always
using CM off since texture is used for influence, not for
color.
It's rather bigger patch, but it's mostly straightforward
changes, which we really need to be done.
Reviewed by Brecht, thanks!
2013-07-15 14:47:58 +00:00
|
|
|
|
|
|
|
|
/* TODO(sergey): always use color management now. */
|
|
|
|
|
multitex_ext(tex, value, NULL, NULL, 1, &texres, NULL, true);
|
2011-09-06 10:49:55 +00:00
|
|
|
|
|
|
|
|
color_r[0] = texres.tr;
|
|
|
|
|
color_r[1] = texres.tg;
|
|
|
|
|
color_r[2] = texres.tb;
|
|
|
|
|
color_r[3] = texres.tin;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-28 23:24:34 +00:00
|
|
|
#else
|
|
|
|
|
|
2011-09-06 10:49:55 +00:00
|
|
|
void RNA_api_texture(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "evaluate", "texture_evaluate");
|
2011-09-06 10:49:55 +00:00
|
|
|
RNA_def_function_ui_description(func, "Evaluate the texture at the coordinates given");
|
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_float_vector(func, "value", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
|
2011-09-06 10:49:55 +00:00
|
|
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
|
|
|
|
|
|
|
|
|
/* return location and normal */
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_float_vector(func, "result", 4, NULL, -FLT_MAX, FLT_MAX, "Result", NULL, -1e4, 1e4);
|
2011-09-06 10:49:55 +00:00
|
|
|
RNA_def_property_flag(parm, PROP_THICK_WRAP);
|
|
|
|
|
RNA_def_function_output(func, parm);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-28 23:24:34 +00:00
|
|
|
void RNA_api_environment_map(StructRNA *srna)
|
|
|
|
|
{
|
|
|
|
|
FunctionRNA *func;
|
|
|
|
|
PropertyRNA *parm;
|
2011-09-06 10:49:55 +00:00
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
static const float default_layout[] = {0, 0, 1, 0, 2, 0, 0, 1, 1, 1, 2, 1};
|
2011-09-06 10:49:55 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "clear", "clear_envmap");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Discard the environment map and free it from memory");
|
2011-09-06 10:49:55 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
|
2011-08-28 23:24:34 +00:00
|
|
|
|
|
|
|
|
|
2012-04-29 15:47:02 +00:00
|
|
|
func = RNA_def_function(srna, "save", "save_envmap");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Save the environment map to disc using the scene render settings");
|
2012-05-12 11:01:29 +00:00
|
|
|
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
|
2011-09-06 10:49:55 +00:00
|
|
|
|
2014-01-16 21:43:22 +11:00
|
|
|
parm = RNA_def_string_file_name(func, "filepath", NULL, FILE_MAX, "File path", "Location of the output file");
|
2011-09-06 10:49:55 +00:00
|
|
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
|
|
|
|
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_pointer(func, "scene", "Scene", "", "Overrides the scene from which image parameters are taken");
|
2011-08-28 23:24:34 +00:00
|
|
|
|
2012-10-11 23:46:12 +00:00
|
|
|
RNA_def_float_array(func, "layout", 12, default_layout, 0.0f, 1000.0f, "File layout",
|
2011-11-07 15:19:26 +00:00
|
|
|
"Flat array describing the X,Y position of each cube face in the "
|
|
|
|
|
"output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] "
|
2012-10-11 23:46:12 +00:00
|
|
|
"(use -1 to skip a face)", 0.0f, 1000.0f);
|
2011-08-28 23:24:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|