2011-10-10 09:38:02 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* 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
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/texture.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2008-10-01 03:35:53 +00:00
|
|
|
#include "BLI_kdopbvh.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2014-08-15 15:29:08 +10:00
|
|
|
#include "BLI_math_color.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "DNA_key_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_lamp_types.h"
|
|
|
|
#include "DNA_material_types.h"
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
#include "DNA_world_types.h"
|
2006-07-31 15:53:03 +00:00
|
|
|
#include "DNA_brush_types.h"
|
2008-03-14 18:08:27 +00:00
|
|
|
#include "DNA_node_types.h"
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
#include "DNA_color_types.h"
|
2011-02-12 14:38:34 +00:00
|
|
|
#include "DNA_particle_types.h"
|
2014-05-03 18:51:53 +09:00
|
|
|
#include "DNA_linestyle_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
|
|
|
#include "BKE_library.h"
|
2016-07-10 16:38:17 +02:00
|
|
|
#include "BKE_library_query.h"
|
|
|
|
#include "BKE_library_remap.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_image.h"
|
2004-07-26 21:44:55 +00:00
|
|
|
#include "BKE_material.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_texture.h"
|
|
|
|
#include "BKE_key.h"
|
2005-12-21 22:21:43 +00:00
|
|
|
#include "BKE_icons.h"
|
2008-03-14 18:08:27 +00:00
|
|
|
#include "BKE_node.h"
|
2009-01-18 10:41:45 +00:00
|
|
|
#include "BKE_animsys.h"
|
2011-05-01 03:57:53 +00:00
|
|
|
#include "BKE_colortools.h"
|
2013-10-20 13:01:07 +00:00
|
|
|
#include "BKE_scene.h"
|
|
|
|
|
|
|
|
#include "RE_shader_ext.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-01-04 12:13:13 +00:00
|
|
|
/* ****************** Mapping ******************* */
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
TexMapping *BKE_texture_mapping_add(int type)
|
2006-01-04 12:13:13 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
TexMapping *texmap = MEM_callocN(sizeof(TexMapping), "TexMapping");
|
2006-01-04 12:13:13 +00:00
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
BKE_texture_mapping_default(texmap, type);
|
2011-11-07 17:35:20 +00:00
|
|
|
|
|
|
|
return texmap;
|
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_mapping_default(TexMapping *texmap, int type)
|
2011-11-07 17:35:20 +00:00
|
|
|
{
|
|
|
|
memset(texmap, 0, sizeof(TexMapping));
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
texmap->size[0] = texmap->size[1] = texmap->size[2] = 1.0f;
|
|
|
|
texmap->max[0] = texmap->max[1] = texmap->max[2] = 1.0f;
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(texmap->mat);
|
2011-11-07 17:35:20 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
texmap->projx = PROJ_X;
|
|
|
|
texmap->projy = PROJ_Y;
|
|
|
|
texmap->projz = PROJ_Z;
|
|
|
|
texmap->mapping = MTEX_FLAT;
|
2013-09-25 20:28:49 +00:00
|
|
|
texmap->type = type;
|
2006-01-04 12:13:13 +00:00
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_mapping_init(TexMapping *texmap)
|
2006-01-04 12:13:13 +00:00
|
|
|
{
|
2013-09-25 20:28:49 +00:00
|
|
|
float smat[4][4], rmat[4][4], tmat[4][4], proj[4][4], size[3];
|
2011-11-07 17:35:20 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (texmap->projx == PROJ_X && texmap->projy == PROJ_Y && texmap->projz == PROJ_Z &&
|
2012-05-20 19:49:27 +00:00
|
|
|
is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size))
|
|
|
|
{
|
2011-11-07 17:35:20 +00:00
|
|
|
unit_m4(texmap->mat);
|
|
|
|
|
|
|
|
texmap->flag |= TEXMAP_UNIT_MATRIX;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* axis projection */
|
2013-09-25 20:28:49 +00:00
|
|
|
zero_m4(proj);
|
|
|
|
proj[3][3] = 1.0f;
|
2011-11-07 17:35:20 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (texmap->projx != PROJ_N)
|
2012-05-06 15:15:33 +00:00
|
|
|
proj[texmap->projx - 1][0] = 1.0f;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (texmap->projy != PROJ_N)
|
2012-05-06 15:15:33 +00:00
|
|
|
proj[texmap->projy - 1][1] = 1.0f;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (texmap->projz != PROJ_N)
|
2012-05-06 15:15:33 +00:00
|
|
|
proj[texmap->projz - 1][2] = 1.0f;
|
2011-11-07 17:35:20 +00:00
|
|
|
|
|
|
|
/* scale */
|
2013-09-25 20:28:49 +00:00
|
|
|
copy_v3_v3(size, texmap->size);
|
|
|
|
|
|
|
|
if (ELEM(texmap->type, TEXMAP_TYPE_TEXTURE, TEXMAP_TYPE_NORMAL)) {
|
|
|
|
/* keep matrix invertible */
|
2013-10-01 03:56:02 +00:00
|
|
|
if (fabsf(size[0]) < 1e-5f)
|
2013-10-01 16:40:11 +00:00
|
|
|
size[0] = signf(size[0]) * 1e-5f;
|
2013-10-01 03:56:02 +00:00
|
|
|
if (fabsf(size[1]) < 1e-5f)
|
2013-10-01 16:40:11 +00:00
|
|
|
size[1] = signf(size[1]) * 1e-5f;
|
2013-10-01 03:56:02 +00:00
|
|
|
if (fabsf(size[2]) < 1e-5f)
|
2013-10-01 16:40:11 +00:00
|
|
|
size[2] = signf(size[2]) * 1e-5f;
|
2013-09-25 20:28:49 +00:00
|
|
|
}
|
2011-11-07 17:35:20 +00:00
|
|
|
|
2013-09-25 20:28:49 +00:00
|
|
|
size_to_mat4(smat, texmap->size);
|
|
|
|
|
2011-11-07 17:35:20 +00:00
|
|
|
/* rotation */
|
2013-09-25 20:28:49 +00:00
|
|
|
eul_to_mat4(rmat, texmap->rot);
|
|
|
|
|
2011-11-07 17:35:20 +00:00
|
|
|
/* translation */
|
2013-09-25 20:28:49 +00:00
|
|
|
unit_m4(tmat);
|
|
|
|
copy_v3_v3(tmat[3], texmap->loc);
|
|
|
|
|
|
|
|
if (texmap->type == TEXMAP_TYPE_TEXTURE) {
|
|
|
|
/* to transform a texture, the inverse transform needs
|
|
|
|
* to be applied to the texture coordinate */
|
2014-07-21 18:55:12 +10:00
|
|
|
mul_m4_series(texmap->mat, tmat, rmat, smat);
|
2013-09-25 20:28:49 +00:00
|
|
|
invert_m4(texmap->mat);
|
|
|
|
}
|
|
|
|
else if (texmap->type == TEXMAP_TYPE_POINT) {
|
|
|
|
/* forward transform */
|
2014-07-21 18:55:12 +10:00
|
|
|
mul_m4_series(texmap->mat, tmat, rmat, smat);
|
2013-09-25 20:28:49 +00:00
|
|
|
}
|
|
|
|
else if (texmap->type == TEXMAP_TYPE_VECTOR) {
|
|
|
|
/* no translation for vectors */
|
|
|
|
mul_m4_m4m4(texmap->mat, rmat, smat);
|
|
|
|
}
|
|
|
|
else if (texmap->type == TEXMAP_TYPE_NORMAL) {
|
|
|
|
/* no translation for normals, and inverse transpose */
|
|
|
|
mul_m4_m4m4(texmap->mat, rmat, smat);
|
|
|
|
invert_m4(texmap->mat);
|
|
|
|
transpose_m4(texmap->mat);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* projection last */
|
|
|
|
mul_m4_m4m4(texmap->mat, texmap->mat, proj);
|
2011-11-07 17:35:20 +00:00
|
|
|
|
|
|
|
texmap->flag &= ~TEXMAP_UNIT_MATRIX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
ColorMapping *BKE_texture_colormapping_add(void)
|
2011-11-07 17:35:20 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
ColorMapping *colormap = MEM_callocN(sizeof(ColorMapping), "ColorMapping");
|
2006-01-04 12:13:13 +00:00
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
BKE_texture_colormapping_default(colormap);
|
2006-01-04 12:13:13 +00:00
|
|
|
|
2011-11-07 17:35:20 +00:00
|
|
|
return colormap;
|
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_colormapping_default(ColorMapping *colormap)
|
2011-11-07 17:35:20 +00:00
|
|
|
{
|
|
|
|
memset(colormap, 0, sizeof(ColorMapping));
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
init_colorband(&colormap->coba, true);
|
2011-11-07 17:35:20 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
colormap->bright = 1.0;
|
|
|
|
colormap->contrast = 1.0;
|
|
|
|
colormap->saturation = 1.0;
|
2006-01-04 12:13:13 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
colormap->blend_color[0] = 0.8f;
|
|
|
|
colormap->blend_color[1] = 0.8f;
|
|
|
|
colormap->blend_color[2] = 0.8f;
|
|
|
|
colormap->blend_type = MA_RAMP_BLEND;
|
|
|
|
colormap->blend_factor = 0.0f;
|
2006-01-04 12:13:13 +00:00
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* ****************** COLORBAND ******************* */
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
void init_colorband(ColorBand *coba, bool rangetype)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
int a;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
coba->data[0].pos = 0.0;
|
|
|
|
coba->data[1].pos = 1.0;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (rangetype == 0) {
|
|
|
|
coba->data[0].r = 0.0;
|
|
|
|
coba->data[0].g = 0.0;
|
|
|
|
coba->data[0].b = 0.0;
|
|
|
|
coba->data[0].a = 0.0;
|
|
|
|
|
|
|
|
coba->data[1].r = 1.0;
|
|
|
|
coba->data[1].g = 1.0;
|
|
|
|
coba->data[1].b = 1.0;
|
|
|
|
coba->data[1].a = 1.0;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
coba->data[0].r = 0.0;
|
|
|
|
coba->data[0].g = 0.0;
|
|
|
|
coba->data[0].b = 0.0;
|
|
|
|
coba->data[0].a = 1.0;
|
|
|
|
|
|
|
|
coba->data[1].r = 1.0;
|
|
|
|
coba->data[1].g = 1.0;
|
|
|
|
coba->data[1].b = 1.0;
|
|
|
|
coba->data[1].a = 1.0;
|
Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
2005-12-28 15:42:51 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
|
|
|
|
for (a = 2; a < MAXCOLORBAND; a++) {
|
|
|
|
coba->data[a].r = 0.5;
|
|
|
|
coba->data[a].g = 0.5;
|
|
|
|
coba->data[a].b = 0.5;
|
|
|
|
coba->data[a].a = 1.0;
|
|
|
|
coba->data[a].pos = 0.5;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
coba->tot = 2;
|
2014-08-15 15:29:08 +10:00
|
|
|
coba->color_mode = COLBAND_BLEND_RGB;
|
2007-10-31 13:56:07 +00:00
|
|
|
}
|
|
|
|
|
2013-03-18 18:25:05 +00:00
|
|
|
ColorBand *add_colorband(bool rangetype)
|
2007-10-31 13:56:07 +00:00
|
|
|
{
|
|
|
|
ColorBand *coba;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
coba = MEM_callocN(sizeof(ColorBand), "colorband");
|
2007-10-31 13:56:07 +00:00
|
|
|
init_colorband(coba, rangetype);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return coba;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2014-08-15 15:29:08 +10:00
|
|
|
static float colorband_hue_interp(
|
|
|
|
const int ipotype_hue,
|
|
|
|
const float mfac, const float fac,
|
|
|
|
float h1, float h2)
|
|
|
|
{
|
|
|
|
float h_interp;
|
|
|
|
int mode = 0;
|
|
|
|
|
|
|
|
#define HUE_INTERP(h_a, h_b) ((mfac * (h_a)) + (fac * (h_b)))
|
|
|
|
#define HUE_MOD(h) (((h) < 1.0f) ? (h) : (h) - 1.0f)
|
|
|
|
|
|
|
|
h1 = HUE_MOD(h1);
|
|
|
|
h2 = HUE_MOD(h2);
|
|
|
|
|
|
|
|
BLI_assert(h1 >= 0.0f && h1 < 1.0f);
|
|
|
|
BLI_assert(h2 >= 0.0f && h2 < 1.0f);
|
|
|
|
|
|
|
|
switch (ipotype_hue) {
|
|
|
|
case COLBAND_HUE_NEAR:
|
|
|
|
{
|
|
|
|
if ((h1 < h2) && (h2 - h1) > +0.5f) mode = 1;
|
|
|
|
else if ((h1 > h2) && (h2 - h1) < -0.5f) mode = 2;
|
|
|
|
else mode = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case COLBAND_HUE_FAR:
|
|
|
|
{
|
|
|
|
if ((h1 < h2) && (h2 - h1) < +0.5f) mode = 1;
|
|
|
|
else if ((h1 > h2) && (h2 - h1) > -0.5f) mode = 2;
|
|
|
|
else mode = 0;
|
|
|
|
break;
|
|
|
|
}
|
2014-08-22 09:47:10 +10:00
|
|
|
case COLBAND_HUE_CCW:
|
2014-08-15 15:29:08 +10:00
|
|
|
{
|
|
|
|
if (h1 > h2) mode = 2;
|
|
|
|
else mode = 0;
|
|
|
|
break;
|
|
|
|
}
|
2014-08-22 09:47:10 +10:00
|
|
|
case COLBAND_HUE_CW:
|
2014-08-15 15:29:08 +10:00
|
|
|
{
|
|
|
|
if (h1 < h2) mode = 1;
|
|
|
|
else mode = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case 0:
|
|
|
|
h_interp = HUE_INTERP(h1, h2);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
h_interp = HUE_INTERP(h1 + 1.0f, h2);
|
|
|
|
h_interp = HUE_MOD(h_interp);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
h_interp = HUE_INTERP(h1, h2 + 1.0f);
|
|
|
|
h_interp = HUE_MOD(h_interp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_assert(h_interp >= 0.0f && h_interp < 1.0f);
|
|
|
|
|
|
|
|
#undef HUE_INTERP
|
|
|
|
#undef HUE_MOD
|
|
|
|
|
|
|
|
return h_interp;
|
|
|
|
}
|
|
|
|
|
2014-02-03 18:55:59 +11:00
|
|
|
bool do_colorband(const ColorBand *coba, float in, float out[4])
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2011-12-19 22:55:04 +00:00
|
|
|
const CBData *cbd1, *cbd2, *cbd0, *cbd3;
|
2014-08-15 15:29:08 +10:00
|
|
|
float fac;
|
|
|
|
int ipotype;
|
2002-10-12 11:37:38 +00:00
|
|
|
int a;
|
|
|
|
|
2014-12-01 17:11:18 +01:00
|
|
|
if (coba == NULL || coba->tot == 0) return false;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
cbd1 = coba->data;
|
2014-08-15 15:29:08 +10:00
|
|
|
|
|
|
|
ipotype = (coba->color_mode == COLBAND_BLEND_RGB) ? coba->ipotype : COLBAND_INTERP_LINEAR;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (coba->tot == 1) {
|
|
|
|
out[0] = cbd1->r;
|
|
|
|
out[1] = cbd1->g;
|
|
|
|
out[2] = cbd1->b;
|
|
|
|
out[3] = cbd1->a;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2014-08-15 15:29:08 +10:00
|
|
|
else if ((in <= cbd1->pos) && ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE)) {
|
|
|
|
out[0] = cbd1->r;
|
|
|
|
out[1] = cbd1->g;
|
|
|
|
out[2] = cbd1->b;
|
|
|
|
out[3] = cbd1->a;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
else {
|
2014-08-15 15:29:08 +10:00
|
|
|
CBData left, right;
|
|
|
|
|
|
|
|
/* we're looking for first pos > in */
|
2015-01-24 03:10:23 +11:00
|
|
|
for (a = 0; a < coba->tot; a++, cbd1++) {
|
|
|
|
if (cbd1->pos > in) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-08-15 15:29:08 +10:00
|
|
|
|
|
|
|
if (a == coba->tot) {
|
|
|
|
cbd2 = cbd1 - 1;
|
|
|
|
right = *cbd2;
|
|
|
|
right.pos = 1.0f;
|
|
|
|
cbd1 = &right;
|
|
|
|
}
|
|
|
|
else if (a == 0) {
|
|
|
|
left = *cbd1;
|
|
|
|
left.pos = 0.0f;
|
|
|
|
cbd2 = &left;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cbd2 = cbd1 - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((in >= cbd1->pos) && ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE)) {
|
2012-05-06 15:15:33 +00:00
|
|
|
out[0] = cbd1->r;
|
|
|
|
out[1] = cbd1->g;
|
|
|
|
out[2] = cbd1->b;
|
|
|
|
out[3] = cbd1->a;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-08-15 15:29:08 +10:00
|
|
|
|
|
|
|
if (cbd2->pos != cbd1->pos) {
|
|
|
|
fac = (in - cbd1->pos) / (cbd2->pos - cbd1->pos);
|
2005-11-17 20:31:18 +00:00
|
|
|
}
|
2013-03-09 03:46:30 +00:00
|
|
|
else {
|
2014-08-15 15:29:08 +10:00
|
|
|
/* was setting to 0.0 in 2.56 & previous, but this
|
|
|
|
* is incorrect for the last element, see [#26732] */
|
|
|
|
fac = (a != coba->tot) ? 0.0f : 1.0f;
|
2013-03-09 03:46:30 +00:00
|
|
|
}
|
2014-08-15 15:29:08 +10:00
|
|
|
|
2014-08-20 14:46:10 +02:00
|
|
|
if (ipotype == COLBAND_INTERP_CONSTANT) {
|
2014-08-15 15:29:08 +10:00
|
|
|
/* constant */
|
|
|
|
out[0] = cbd2->r;
|
|
|
|
out[1] = cbd2->g;
|
|
|
|
out[2] = cbd2->b;
|
|
|
|
out[3] = cbd2->a;
|
2005-05-27 19:02:39 +00:00
|
|
|
}
|
2014-08-15 15:29:08 +10:00
|
|
|
else if (ipotype >= COLBAND_INTERP_B_SPLINE) {
|
|
|
|
/* ipo from right to left: 3 2 1 0 */
|
|
|
|
float t[4];
|
|
|
|
|
|
|
|
if (a >= coba->tot - 1) cbd0 = cbd1;
|
|
|
|
else cbd0 = cbd1 + 1;
|
|
|
|
if (a < 2) cbd3 = cbd2;
|
|
|
|
else cbd3 = cbd2 - 1;
|
|
|
|
|
|
|
|
CLAMP(fac, 0.0f, 1.0f);
|
|
|
|
|
|
|
|
if (ipotype == COLBAND_INTERP_CARDINAL) {
|
|
|
|
key_curve_position_weights(fac, t, KEY_CARDINAL);
|
|
|
|
}
|
2011-04-02 07:04:34 +00:00
|
|
|
else {
|
2014-08-15 15:29:08 +10:00
|
|
|
key_curve_position_weights(fac, t, KEY_BSPLINE);
|
2011-04-02 07:04:34 +00:00
|
|
|
}
|
2014-08-15 15:29:08 +10:00
|
|
|
|
|
|
|
out[0] = t[3] * cbd3->r + t[2] * cbd2->r + t[1] * cbd1->r + t[0] * cbd0->r;
|
|
|
|
out[1] = t[3] * cbd3->g + t[2] * cbd2->g + t[1] * cbd1->g + t[0] * cbd0->g;
|
|
|
|
out[2] = t[3] * cbd3->b + t[2] * cbd2->b + t[1] * cbd1->b + t[0] * cbd0->b;
|
|
|
|
out[3] = t[3] * cbd3->a + t[2] * cbd2->a + t[1] * cbd1->a + t[0] * cbd0->a;
|
|
|
|
CLAMP(out[0], 0.0f, 1.0f);
|
|
|
|
CLAMP(out[1], 0.0f, 1.0f);
|
|
|
|
CLAMP(out[2], 0.0f, 1.0f);
|
|
|
|
CLAMP(out[3], 0.0f, 1.0f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float mfac;
|
|
|
|
|
|
|
|
if (ipotype == COLBAND_INTERP_EASE) {
|
|
|
|
mfac = fac * fac;
|
|
|
|
fac = 3.0f * mfac - 2.0f * mfac * fac;
|
|
|
|
}
|
|
|
|
|
|
|
|
mfac = 1.0f - fac;
|
|
|
|
|
|
|
|
if (UNLIKELY(coba->color_mode == COLBAND_BLEND_HSV)) {
|
|
|
|
float col1[3], col2[3];
|
|
|
|
|
2014-08-24 12:56:34 +10:00
|
|
|
rgb_to_hsv_v(&cbd1->r, col1);
|
|
|
|
rgb_to_hsv_v(&cbd2->r, col2);
|
2014-08-22 09:50:10 +10:00
|
|
|
|
2014-08-15 15:29:08 +10:00
|
|
|
out[0] = colorband_hue_interp(coba->ipotype_hue, mfac, fac, col1[0], col2[0]);
|
|
|
|
out[1] = mfac * col1[1] + fac * col2[1];
|
|
|
|
out[2] = mfac * col1[2] + fac * col2[2];
|
|
|
|
out[3] = mfac * cbd1->a + fac * cbd2->a;
|
|
|
|
|
|
|
|
hsv_to_rgb_v(out, out);
|
2008-11-04 00:15:27 +00:00
|
|
|
}
|
2014-08-15 15:29:08 +10:00
|
|
|
else if (UNLIKELY(coba->color_mode == COLBAND_BLEND_HSL)) {
|
|
|
|
float col1[3], col2[3];
|
|
|
|
|
2014-08-24 12:56:34 +10:00
|
|
|
rgb_to_hsl_v(&cbd1->r, col1);
|
|
|
|
rgb_to_hsl_v(&cbd2->r, col2);
|
2014-08-15 15:29:08 +10:00
|
|
|
|
|
|
|
out[0] = colorband_hue_interp(coba->ipotype_hue, mfac, fac, col1[0], col2[0]);
|
|
|
|
out[1] = mfac * col1[1] + fac * col2[1];
|
|
|
|
out[2] = mfac * col1[2] + fac * col2[2];
|
|
|
|
out[3] = mfac * cbd1->a + fac * cbd2->a;
|
|
|
|
|
|
|
|
hsl_to_rgb_v(out, out);
|
2005-05-27 19:02:39 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-08-15 15:29:08 +10:00
|
|
|
/* COLBAND_BLEND_RGB */
|
2012-05-06 15:15:33 +00:00
|
|
|
out[0] = mfac * cbd1->r + fac * cbd2->r;
|
|
|
|
out[1] = mfac * cbd1->g + fac * cbd2->g;
|
|
|
|
out[2] = mfac * cbd1->b + fac * cbd2->b;
|
|
|
|
out[3] = mfac * cbd1->a + fac * cbd2->a;
|
2005-05-27 19:02:39 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-01 17:11:18 +01:00
|
|
|
return true; /* OK */
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
void colorband_table_RGBA(ColorBand *coba, float **array, int *size)
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
*size = CM_TABLE + 1;
|
|
|
|
*array = MEM_callocN(sizeof(float) * (*size) * 4, "ColorBand");
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (a = 0; a < *size; a++)
|
|
|
|
do_colorband(coba, (float)a / (float)CM_TABLE, &(*array)[a * 4]);
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
2012-09-15 01:52:28 +00:00
|
|
|
static int vergcband(const void *a1, const void *a2)
|
2010-07-30 00:20:05 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
const CBData *x1 = a1, *x2 = a2;
|
2010-07-30 00:20:05 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (x1->pos > x2->pos) return 1;
|
|
|
|
else if (x1->pos < x2->pos) return -1;
|
2010-07-30 00:20:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-02-02 14:07:24 +00:00
|
|
|
void colorband_update_sort(ColorBand *coba)
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (coba->tot < 2)
|
2012-02-02 14:07:24 +00:00
|
|
|
return;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (a = 0; a < coba->tot; a++)
|
|
|
|
coba->data[a].cur = a;
|
2012-02-02 14:07:24 +00:00
|
|
|
|
|
|
|
qsort(coba->data, coba->tot, sizeof(CBData), vergcband);
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (a = 0; a < coba->tot; a++) {
|
|
|
|
if (coba->data[a].cur == coba->cur) {
|
|
|
|
coba->cur = a;
|
2012-02-02 14:07:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-30 00:20:05 +00:00
|
|
|
CBData *colorband_element_add(struct ColorBand *coba, float position)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
if (coba->tot == MAXCOLORBAND) {
|
2010-07-30 00:20:05 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2014-08-29 16:56:19 +10:00
|
|
|
else {
|
2010-07-30 00:20:05 +00:00
|
|
|
CBData *xnew;
|
|
|
|
|
|
|
|
xnew = &coba->data[coba->tot];
|
|
|
|
xnew->pos = position;
|
|
|
|
|
2014-08-29 16:56:19 +10:00
|
|
|
if (coba->tot != 0) {
|
|
|
|
do_colorband(coba, position, &xnew->r);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
zero_v4(&xnew->r);
|
|
|
|
}
|
2010-07-30 00:20:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
coba->tot++;
|
2012-05-06 15:15:33 +00:00
|
|
|
coba->cur = coba->tot - 1;
|
2010-07-30 00:20:05 +00:00
|
|
|
|
2012-02-02 14:07:24 +00:00
|
|
|
colorband_update_sort(coba);
|
2010-07-30 00:20:05 +00:00
|
|
|
|
|
|
|
return coba->data + coba->cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
int colorband_element_remove(struct ColorBand *coba, int index)
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (coba->tot < 2)
|
2010-07-30 00:20:05 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (index < 0 || index >= coba->tot)
|
2010-07-30 00:20:05 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
for (a = index; a < coba->tot; a++) {
|
2010-07-30 00:20:05 +00:00
|
|
|
coba->data[a] = coba->data[a + 1];
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (coba->cur) coba->cur--;
|
2010-07-30 00:20:05 +00:00
|
|
|
coba->tot--;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* ******************* TEX ************************ */
|
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
/** Free (or release) any data used by this texture (does not free the texure itself). */
|
2012-05-05 14:03:12 +00:00
|
|
|
void BKE_texture_free(Tex *tex)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
BKE_animdata_free((ID *)tex, false);
|
|
|
|
|
|
|
|
/* is no lib link block, but texture extension */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tex->nodetree) {
|
2012-08-22 09:35:46 +00:00
|
|
|
ntreeFreeTree(tex->nodetree);
|
2008-11-12 22:03:11 +00:00
|
|
|
MEM_freeN(tex->nodetree);
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
tex->nodetree = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MEM_SAFE_FREE(tex->coba);
|
|
|
|
if (tex->env) {
|
|
|
|
BKE_texture_envmap_free(tex->env);
|
|
|
|
tex->env = NULL;
|
2008-11-12 22:03:11 +00:00
|
|
|
}
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
if (tex->pd) {
|
|
|
|
BKE_texture_pointdensity_free(tex->pd);
|
|
|
|
tex->pd = NULL;
|
|
|
|
}
|
|
|
|
if (tex->vd) {
|
|
|
|
BKE_texture_voxeldata_free(tex->vd);
|
|
|
|
tex->vd = NULL;
|
|
|
|
}
|
|
|
|
if (tex->ot) {
|
|
|
|
BKE_texture_ocean_free(tex->ot);
|
|
|
|
tex->ot = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
BKE_icon_id_delete((ID *)tex);
|
|
|
|
BKE_previewimg_free(&tex->preview);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_default(Tex *tex)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.
That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.
Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.
Future plans are also to be able to relocate missing libs and reload them at runtime.
Code notes:
- Placeholder ID is just a regular datablock of same type as expected linked one,
with 'default' data, and a LIB_MISSING bitflag set.
- To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
+ Allocation of memory itself.
+ Setting of all internal data to default values.
See also the design task (T43351).
Reviewed by @campbellbarton, thanks a bunch!
Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
|
|
|
/* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(tex, id)); */ /* Not here, can be called with some pointers set. :/ */
|
|
|
|
|
2014-07-21 12:02:05 +02:00
|
|
|
tex->type = TEX_IMAGE;
|
|
|
|
tex->ima = NULL;
|
2012-05-06 15:15:33 +00:00
|
|
|
tex->stype = 0;
|
|
|
|
tex->flag = TEX_CHECKER_ODD;
|
2013-03-04 13:18:14 +00:00
|
|
|
tex->imaflag = TEX_INTERPOL | TEX_MIPMAP | TEX_USEALPHA;
|
2012-05-06 15:15:33 +00:00
|
|
|
tex->extend = TEX_REPEAT;
|
|
|
|
tex->cropxmin = tex->cropymin = 0.0;
|
|
|
|
tex->cropxmax = tex->cropymax = 1.0;
|
2009-07-22 17:20:04 +00:00
|
|
|
tex->texfilter = TXF_EWA;
|
2009-07-21 13:20:35 +00:00
|
|
|
tex->afmax = 8;
|
2012-05-06 15:15:33 +00:00
|
|
|
tex->xrepeat = tex->yrepeat = 1;
|
|
|
|
tex->fie_ima = 2;
|
|
|
|
tex->sfra = 1;
|
|
|
|
tex->frames = 0;
|
|
|
|
tex->offset = 0;
|
|
|
|
tex->noisesize = 0.25;
|
|
|
|
tex->noisedepth = 2;
|
|
|
|
tex->turbul = 5.0;
|
|
|
|
tex->nabla = 0.025; // also in do_versions
|
|
|
|
tex->bright = 1.0;
|
|
|
|
tex->contrast = 1.0;
|
|
|
|
tex->saturation = 1.0;
|
|
|
|
tex->filtersize = 1.0;
|
|
|
|
tex->rfac = 1.0;
|
|
|
|
tex->gfac = 1.0;
|
|
|
|
tex->bfac = 1.0;
|
2004-04-03 13:59:27 +00:00
|
|
|
/* newnoise: init. */
|
|
|
|
tex->noisebasis = 0;
|
|
|
|
tex->noisebasis2 = 0;
|
|
|
|
/* musgrave */
|
|
|
|
tex->mg_H = 1.0;
|
|
|
|
tex->mg_lacunarity = 2.0;
|
|
|
|
tex->mg_octaves = 2.0;
|
|
|
|
tex->mg_offset = 1.0;
|
|
|
|
tex->mg_gain = 1.0;
|
|
|
|
tex->ns_outscale = 1.0;
|
|
|
|
/* distnoise */
|
|
|
|
tex->dist_amount = 1.0;
|
|
|
|
/* voronoi */
|
|
|
|
tex->vn_w1 = 1.0;
|
|
|
|
tex->vn_w2 = tex->vn_w3 = tex->vn_w4 = 0.0;
|
|
|
|
tex->vn_mexp = 2.5;
|
|
|
|
tex->vn_distm = 0;
|
|
|
|
tex->vn_coltype = 0;
|
|
|
|
|
|
|
|
if (tex->env) {
|
2012-05-06 15:15:33 +00:00
|
|
|
tex->env->stype = ENV_ANIM;
|
|
|
|
tex->env->clipsta = 0.1;
|
|
|
|
tex->env->clipend = 100;
|
2015-05-18 18:10:03 +02:00
|
|
|
tex->env->cuberes = 512;
|
2012-05-06 15:15:33 +00:00
|
|
|
tex->env->depth = 0;
|
2004-04-03 13:59:27 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
if (tex->pd) {
|
|
|
|
tex->pd->radius = 0.3f;
|
2008-10-01 03:35:53 +00:00
|
|
|
tex->pd->falloff_type = TEX_PD_FALLOFF_STD;
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
}
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
|
|
|
|
if (tex->vd) {
|
2009-08-13 05:21:25 +00:00
|
|
|
tex->vd->resol[0] = tex->vd->resol[1] = tex->vd->resol[2] = 0;
|
2012-05-06 15:15:33 +00:00
|
|
|
tex->vd->interp_type = TEX_VD_LINEAR;
|
|
|
|
tex->vd->file_format = TEX_VD_SMOKE;
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
}
|
2011-11-13 12:17:27 +00:00
|
|
|
|
|
|
|
if (tex->ot) {
|
|
|
|
tex->ot->output = TEX_OCN_DISPLACEMENT;
|
|
|
|
tex->ot->object = NULL;
|
|
|
|
}
|
2006-12-20 17:57:56 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
tex->iuser.fie_ima = 2;
|
|
|
|
tex->iuser.ok = 1;
|
|
|
|
tex->iuser.frames = 100;
|
|
|
|
tex->iuser.sfra = 1;
|
2007-09-02 17:25:03 +00:00
|
|
|
|
|
|
|
tex->preview = NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_type_set(Tex *tex, int type)
|
2010-06-22 09:13:30 +00:00
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (type) {
|
2010-06-22 09:13:30 +00:00
|
|
|
|
|
|
|
case TEX_VOXELDATA:
|
|
|
|
if (tex->vd == NULL)
|
2015-03-29 03:16:55 +11:00
|
|
|
tex->vd = BKE_texture_voxeldata_add();
|
2010-06-22 09:13:30 +00:00
|
|
|
break;
|
|
|
|
case TEX_POINTDENSITY:
|
|
|
|
if (tex->pd == NULL)
|
2015-03-29 03:16:55 +11:00
|
|
|
tex->pd = BKE_texture_pointdensity_add();
|
2010-06-22 09:13:30 +00:00
|
|
|
break;
|
|
|
|
case TEX_ENVMAP:
|
|
|
|
if (tex->env == NULL)
|
2015-03-29 03:16:55 +11:00
|
|
|
tex->env = BKE_texture_envmap_add();
|
2010-06-22 09:13:30 +00:00
|
|
|
break;
|
2011-11-13 12:17:27 +00:00
|
|
|
case TEX_OCEAN:
|
|
|
|
if (tex->ot == NULL)
|
2015-03-29 03:16:55 +11:00
|
|
|
tex->ot = BKE_texture_ocean_add();
|
2011-11-13 12:17:27 +00:00
|
|
|
break;
|
2010-06-22 09:13:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tex->type = type;
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
Tex *BKE_texture_add(Main *bmain, const char *name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
Tex *tex;
|
|
|
|
|
2014-01-15 16:37:03 +01:00
|
|
|
tex = BKE_libblock_alloc(bmain, ID_TE, name);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
BKE_texture_default(tex);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
return tex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_mtex_default(MTex *mtex)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2014-07-21 12:02:05 +02:00
|
|
|
mtex->texco = TEXCO_UV;
|
2012-05-06 15:15:33 +00:00
|
|
|
mtex->mapto = MAP_COL;
|
|
|
|
mtex->object = NULL;
|
|
|
|
mtex->projx = PROJ_X;
|
|
|
|
mtex->projy = PROJ_Y;
|
|
|
|
mtex->projz = PROJ_Z;
|
|
|
|
mtex->mapping = MTEX_FLAT;
|
|
|
|
mtex->ofs[0] = 0.0;
|
|
|
|
mtex->ofs[1] = 0.0;
|
|
|
|
mtex->ofs[2] = 0.0;
|
|
|
|
mtex->size[0] = 1.0;
|
|
|
|
mtex->size[1] = 1.0;
|
|
|
|
mtex->size[2] = 1.0;
|
|
|
|
mtex->tex = NULL;
|
2012-10-10 13:18:07 +00:00
|
|
|
mtex->texflag = MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE | MTEX_MAPTO_BOUNDS;
|
2012-05-06 15:15:33 +00:00
|
|
|
mtex->colormodel = 0;
|
|
|
|
mtex->r = 1.0;
|
|
|
|
mtex->g = 0.0;
|
|
|
|
mtex->b = 1.0;
|
|
|
|
mtex->k = 1.0;
|
|
|
|
mtex->def_var = 1.0;
|
|
|
|
mtex->blendtype = MTEX_BLEND;
|
|
|
|
mtex->colfac = 1.0;
|
|
|
|
mtex->norfac = 1.0;
|
|
|
|
mtex->varfac = 1.0;
|
|
|
|
mtex->dispfac = 0.2;
|
|
|
|
mtex->colspecfac = 1.0f;
|
|
|
|
mtex->mirrfac = 1.0f;
|
|
|
|
mtex->alphafac = 1.0f;
|
|
|
|
mtex->difffac = 1.0f;
|
|
|
|
mtex->specfac = 1.0f;
|
|
|
|
mtex->emitfac = 1.0f;
|
|
|
|
mtex->hardfac = 1.0f;
|
|
|
|
mtex->raymirrfac = 1.0f;
|
|
|
|
mtex->translfac = 1.0f;
|
|
|
|
mtex->ambfac = 1.0f;
|
|
|
|
mtex->colemitfac = 1.0f;
|
|
|
|
mtex->colreflfac = 1.0f;
|
|
|
|
mtex->coltransfac = 1.0f;
|
|
|
|
mtex->densfac = 1.0f;
|
|
|
|
mtex->scatterfac = 1.0f;
|
|
|
|
mtex->reflfac = 1.0f;
|
|
|
|
mtex->shadowfac = 1.0f;
|
|
|
|
mtex->zenupfac = 1.0f;
|
|
|
|
mtex->zendownfac = 1.0f;
|
|
|
|
mtex->blendfac = 1.0f;
|
|
|
|
mtex->timefac = 1.0f;
|
|
|
|
mtex->lengthfac = 1.0f;
|
|
|
|
mtex->clumpfac = 1.0f;
|
|
|
|
mtex->kinkfac = 1.0f;
|
2015-01-14 12:29:19 +01:00
|
|
|
mtex->kinkampfac = 1.0f;
|
2012-05-06 15:15:33 +00:00
|
|
|
mtex->roughfac = 1.0f;
|
|
|
|
mtex->padensfac = 1.0f;
|
|
|
|
mtex->lifefac = 1.0f;
|
|
|
|
mtex->sizefac = 1.0f;
|
|
|
|
mtex->ivelfac = 1.0f;
|
|
|
|
mtex->dampfac = 1.0f;
|
|
|
|
mtex->gravityfac = 1.0f;
|
|
|
|
mtex->fieldfac = 1.0f;
|
|
|
|
mtex->normapspace = MTEX_NSPACE_TANGENT;
|
2013-01-16 14:36:13 +00:00
|
|
|
mtex->brush_map_mode = MTEX_MAP_MODE_TILED;
|
2015-01-31 17:23:30 +11:00
|
|
|
mtex->random_angle = 2.0f * (float)M_PI;
|
2014-12-26 23:51:27 +01:00
|
|
|
mtex->brush_angle_mode = 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
MTex *BKE_texture_mtex_add(void)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
MTex *mtex;
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
mtex = MEM_callocN(sizeof(MTex), "BKE_texture_mtex_add");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
BKE_texture_mtex_default(mtex);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
return mtex;
|
|
|
|
}
|
|
|
|
|
2010-09-03 14:53:54 +00:00
|
|
|
/* slot -1 for first free ID */
|
2015-03-29 03:16:55 +11:00
|
|
|
MTex *BKE_texture_mtex_add_id(ID *id, int slot)
|
2010-09-03 14:53:54 +00:00
|
|
|
{
|
|
|
|
MTex **mtex_ar;
|
|
|
|
short act;
|
|
|
|
|
|
|
|
give_active_mtex(id, &mtex_ar, &act);
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (mtex_ar == NULL) {
|
2010-09-03 14:53:54 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (slot == -1) {
|
2010-09-03 14:53:54 +00:00
|
|
|
/* find first free */
|
2012-10-21 05:46:41 +00:00
|
|
|
int i;
|
2012-05-06 15:15:33 +00:00
|
|
|
for (i = 0; i < MAX_MTEX; i++) {
|
2010-09-03 14:53:54 +00:00
|
|
|
if (!mtex_ar[i]) {
|
2012-05-06 15:15:33 +00:00
|
|
|
slot = i;
|
2010-09-03 14:53:54 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (slot == -1) {
|
2010-09-03 14:53:54 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* make sure slot is valid */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (slot < 0 || slot >= MAX_MTEX) {
|
2010-09-03 14:53:54 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mtex_ar[slot]) {
|
|
|
|
id_us_min((ID *)mtex_ar[slot]->tex);
|
|
|
|
MEM_freeN(mtex_ar[slot]);
|
2012-05-06 15:15:33 +00:00
|
|
|
mtex_ar[slot] = NULL;
|
2010-09-03 14:53:54 +00:00
|
|
|
}
|
2014-05-28 08:19:41 +02:00
|
|
|
else if (GS(id->name) == ID_MA) {
|
|
|
|
/* Reset this slot's ON/OFF toggle, for materials, when slot was empty. */
|
|
|
|
((Material *)id)->septex &= ~(1 << slot);
|
|
|
|
}
|
2010-09-03 14:53:54 +00:00
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
mtex_ar[slot] = BKE_texture_mtex_add();
|
2010-09-03 14:53:54 +00:00
|
|
|
|
|
|
|
return mtex_ar[slot];
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2016-07-10 14:52:00 +02:00
|
|
|
Tex *BKE_texture_copy(Main *bmain, Tex *tex)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
Tex *texn;
|
|
|
|
|
2016-07-10 14:52:00 +02:00
|
|
|
texn = BKE_libblock_copy(bmain, &tex->id);
|
2015-02-23 18:22:09 +11:00
|
|
|
if (BKE_texture_is_image_user(tex)) {
|
|
|
|
id_us_plus((ID *)texn->ima);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
texn->ima = NULL;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (texn->coba) texn->coba = MEM_dupallocN(texn->coba);
|
2015-03-29 03:16:55 +11:00
|
|
|
if (texn->env) texn->env = BKE_texture_envmap_copy(texn->env);
|
|
|
|
if (texn->pd) texn->pd = BKE_texture_pointdensity_copy(texn->pd);
|
2012-05-06 15:15:33 +00:00
|
|
|
if (texn->vd) texn->vd = MEM_dupallocN(texn->vd);
|
2015-03-29 03:16:55 +11:00
|
|
|
if (texn->ot) texn->ot = BKE_texture_ocean_copy(texn->ot);
|
2007-09-02 17:25:03 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tex->nodetree) {
|
2011-09-05 21:01:50 +00:00
|
|
|
if (tex->nodetree->execdata) {
|
2013-03-18 16:34:57 +00:00
|
|
|
ntreeTexEndExecTree(tex->nodetree->execdata);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
2016-07-10 14:52:00 +02:00
|
|
|
texn->nodetree = ntreeCopyTree(bmain, tex->nodetree);
|
2008-11-12 22:03:11 +00:00
|
|
|
}
|
2016-07-19 16:27:40 +02:00
|
|
|
|
|
|
|
BKE_previewimg_id_copy(&texn->id, &tex->id);
|
2016-07-11 21:27:15 +02:00
|
|
|
|
2016-07-25 16:15:37 +02:00
|
|
|
BKE_id_copy_ensure_local(bmain, &tex->id, &texn->id);
|
2015-01-09 09:52:51 +01:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return texn;
|
|
|
|
}
|
|
|
|
|
2011-03-03 18:53:07 +00:00
|
|
|
/* texture copy without adding to main dbase */
|
2015-03-29 03:16:55 +11:00
|
|
|
Tex *BKE_texture_localize(Tex *tex)
|
2011-03-03 18:53:07 +00:00
|
|
|
{
|
|
|
|
Tex *texn;
|
|
|
|
|
2014-08-29 02:52:36 +06:00
|
|
|
texn = BKE_libblock_copy_nolib(&tex->id, false);
|
2011-03-03 18:53:07 +00:00
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
/* image texture: BKE_texture_free also doesn't decrease */
|
2011-03-03 18:53:07 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (texn->coba) texn->coba = MEM_dupallocN(texn->coba);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (texn->env) {
|
2015-03-29 03:16:55 +11:00
|
|
|
texn->env = BKE_texture_envmap_copy(texn->env);
|
2011-03-21 22:10:24 +00:00
|
|
|
id_us_min(&texn->env->ima->id);
|
2011-03-21 17:10:55 +00:00
|
|
|
}
|
2015-03-29 03:16:55 +11:00
|
|
|
if (texn->pd) texn->pd = BKE_texture_pointdensity_copy(texn->pd);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (texn->vd) {
|
2012-05-06 15:15:33 +00:00
|
|
|
texn->vd = MEM_dupallocN(texn->vd);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (texn->vd->dataset)
|
2012-05-06 15:15:33 +00:00
|
|
|
texn->vd->dataset = MEM_dupallocN(texn->vd->dataset);
|
2011-03-16 14:21:35 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (texn->ot) {
|
2015-03-29 03:16:55 +11:00
|
|
|
texn->ot = BKE_texture_ocean_copy(tex->ot);
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
2011-03-03 18:53:07 +00:00
|
|
|
|
|
|
|
texn->preview = NULL;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (tex->nodetree) {
|
2012-05-06 15:15:33 +00:00
|
|
|
texn->nodetree = ntreeLocalize(tex->nodetree);
|
2011-03-03 18:53:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return texn;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2016-07-20 19:49:45 +02:00
|
|
|
void BKE_texture_make_local(Main *bmain, Tex *tex, const bool lib_local)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2016-07-20 19:49:45 +02:00
|
|
|
BKE_id_make_local_generic(bmain, &tex->id, true, lib_local);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2009-10-09 09:50:49 +00:00
|
|
|
Tex *give_current_object_texture(Object *ob)
|
2004-07-26 21:44:55 +00:00
|
|
|
{
|
2011-08-15 13:17:39 +00:00
|
|
|
Material *ma, *node_ma;
|
2012-05-06 15:15:33 +00:00
|
|
|
Tex *tex = NULL;
|
2004-07-26 21:44:55 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ob == NULL) return NULL;
|
|
|
|
if (ob->totcol == 0 && !(ob->type == OB_LAMP)) return NULL;
|
2004-07-26 21:44:55 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (ob->type == OB_LAMP) {
|
|
|
|
tex = give_current_lamp_texture(ob->data);
|
2012-03-24 06:18:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
ma = give_current_material(ob, ob->actcol);
|
2011-08-15 13:17:39 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if ((node_ma = give_node_material(ma)))
|
|
|
|
ma = node_ma;
|
2011-08-15 13:17:39 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
tex = give_current_material_texture(ma);
|
2009-10-09 09:50:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tex;
|
|
|
|
}
|
2008-03-14 18:08:27 +00:00
|
|
|
|
2009-10-09 09:50:49 +00:00
|
|
|
Tex *give_current_lamp_texture(Lamp *la)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
MTex *mtex = NULL;
|
|
|
|
Tex *tex = NULL;
|
2008-03-14 18:08:27 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (la) {
|
2012-05-06 15:15:33 +00:00
|
|
|
mtex = la->mtex[(int)(la->texact)];
|
|
|
|
if (mtex) tex = mtex->tex;
|
2009-10-09 09:50:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tex;
|
|
|
|
}
|
|
|
|
|
2009-10-12 13:12:45 +00:00
|
|
|
void set_current_lamp_texture(Lamp *la, Tex *newtex)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
int act = la->texact;
|
2009-10-12 13:12:45 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (la->mtex[act] && la->mtex[act]->tex)
|
2009-10-12 13:12:45 +00:00
|
|
|
id_us_min(&la->mtex[act]->tex->id);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (newtex) {
|
|
|
|
if (!la->mtex[act]) {
|
2015-03-29 03:16:55 +11:00
|
|
|
la->mtex[act] = BKE_texture_mtex_add();
|
2012-05-06 15:15:33 +00:00
|
|
|
la->mtex[act]->texco = TEXCO_GLOB;
|
2009-10-12 13:12:45 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
la->mtex[act]->tex = newtex;
|
2009-10-12 13:12:45 +00:00
|
|
|
id_us_plus(&newtex->id);
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (la->mtex[act]) {
|
2009-10-12 13:12:45 +00:00
|
|
|
MEM_freeN(la->mtex[act]);
|
2012-05-06 15:15:33 +00:00
|
|
|
la->mtex[act] = NULL;
|
2009-10-12 13:12:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-03 18:51:53 +09:00
|
|
|
Tex *give_current_linestyle_texture(FreestyleLineStyle *linestyle)
|
|
|
|
{
|
|
|
|
MTex *mtex = NULL;
|
|
|
|
Tex *tex = NULL;
|
|
|
|
|
|
|
|
if (linestyle) {
|
|
|
|
mtex = linestyle->mtex[(int)(linestyle->texact)];
|
|
|
|
if (mtex) tex = mtex->tex;
|
|
|
|
}
|
|
|
|
|
|
|
|
return tex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_current_linestyle_texture(FreestyleLineStyle *linestyle, Tex *newtex)
|
|
|
|
{
|
|
|
|
int act = linestyle->texact;
|
|
|
|
|
|
|
|
if (linestyle->mtex[act] && linestyle->mtex[act]->tex)
|
|
|
|
id_us_min(&linestyle->mtex[act]->tex->id);
|
|
|
|
|
|
|
|
if (newtex) {
|
|
|
|
if (!linestyle->mtex[act]) {
|
2015-03-29 03:16:55 +11:00
|
|
|
linestyle->mtex[act] = BKE_texture_mtex_add();
|
2014-05-03 18:51:53 +09:00
|
|
|
linestyle->mtex[act]->texco = TEXCO_STROKE;
|
|
|
|
}
|
|
|
|
|
|
|
|
linestyle->mtex[act]->tex = newtex;
|
|
|
|
id_us_plus(&newtex->id);
|
|
|
|
}
|
|
|
|
else if (linestyle->mtex[act]) {
|
|
|
|
MEM_freeN(linestyle->mtex[act]);
|
|
|
|
linestyle->mtex[act] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-29 16:32:06 +00:00
|
|
|
bNode *give_current_material_texture_node(Material *ma)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ma && ma->use_nodes && ma->nodetree)
|
2010-01-29 16:32:06 +00:00
|
|
|
return nodeGetActiveID(ma->nodetree, ID_TE);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-10-09 09:50:49 +00:00
|
|
|
Tex *give_current_material_texture(Material *ma)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
MTex *mtex = NULL;
|
|
|
|
Tex *tex = NULL;
|
2009-10-09 09:50:49 +00:00
|
|
|
bNode *node;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ma && ma->use_nodes && ma->nodetree) {
|
2010-01-29 16:32:06 +00:00
|
|
|
/* first check texture, then material, this works together
|
2012-03-03 20:19:11 +00:00
|
|
|
* with a hack that clears the active ID flag for textures on
|
|
|
|
* making a material node active */
|
2012-05-06 15:15:33 +00:00
|
|
|
node = nodeGetActiveID(ma->nodetree, ID_TE);
|
2009-10-09 09:50:49 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node) {
|
2012-05-06 15:15:33 +00:00
|
|
|
tex = (Tex *)node->id;
|
|
|
|
ma = NULL;
|
2004-07-26 21:44:55 +00:00
|
|
|
}
|
|
|
|
}
|
2010-01-29 16:32:06 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ma) {
|
2012-05-06 15:15:33 +00:00
|
|
|
mtex = ma->mtex[(int)(ma->texact)];
|
|
|
|
if (mtex) tex = mtex->tex;
|
2009-10-09 09:50:49 +00:00
|
|
|
}
|
2004-07-26 21:44:55 +00:00
|
|
|
|
|
|
|
return tex;
|
|
|
|
}
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
bool give_active_mtex(ID *id, MTex ***mtex_ar, short *act)
|
2009-10-12 16:00:39 +00:00
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (GS(id->name)) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case ID_MA:
|
|
|
|
*mtex_ar = ((Material *)id)->mtex;
|
|
|
|
if (act) *act = (((Material *)id)->texact);
|
|
|
|
break;
|
|
|
|
case ID_WO:
|
|
|
|
*mtex_ar = ((World *)id)->mtex;
|
|
|
|
if (act) *act = (((World *)id)->texact);
|
|
|
|
break;
|
|
|
|
case ID_LA:
|
|
|
|
*mtex_ar = ((Lamp *)id)->mtex;
|
|
|
|
if (act) *act = (((Lamp *)id)->texact);
|
|
|
|
break;
|
2014-05-03 18:51:53 +09:00
|
|
|
case ID_LS:
|
|
|
|
*mtex_ar = ((FreestyleLineStyle *)id)->mtex;
|
|
|
|
if (act) *act = (((FreestyleLineStyle *)id)->texact);
|
|
|
|
break;
|
2012-05-06 15:15:33 +00:00
|
|
|
case ID_PA:
|
|
|
|
*mtex_ar = ((ParticleSettings *)id)->mtex;
|
|
|
|
if (act) *act = (((ParticleSettings *)id)->texact);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*mtex_ar = NULL;
|
|
|
|
if (act) *act = 0;
|
2014-04-01 11:34:00 +11:00
|
|
|
return false;
|
2009-10-12 16:00:39 +00:00
|
|
|
}
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
return true;
|
2009-10-12 16:00:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void set_active_mtex(ID *id, short act)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
if (act < 0) act = 0;
|
|
|
|
else if (act >= MAX_MTEX) act = MAX_MTEX - 1;
|
2009-10-12 16:00:39 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (GS(id->name)) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case ID_MA:
|
|
|
|
((Material *)id)->texact = act;
|
|
|
|
break;
|
|
|
|
case ID_WO:
|
|
|
|
((World *)id)->texact = act;
|
|
|
|
break;
|
|
|
|
case ID_LA:
|
|
|
|
((Lamp *)id)->texact = act;
|
|
|
|
break;
|
2014-05-03 18:51:53 +09:00
|
|
|
case ID_LS:
|
|
|
|
((FreestyleLineStyle *)id)->texact = act;
|
|
|
|
break;
|
2012-05-06 15:15:33 +00:00
|
|
|
case ID_PA:
|
|
|
|
((ParticleSettings *)id)->texact = act;
|
|
|
|
break;
|
2009-10-12 16:00:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-12 13:12:45 +00:00
|
|
|
void set_current_material_texture(Material *ma, Tex *newtex)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
Tex *tex = NULL;
|
2009-10-12 13:12:45 +00:00
|
|
|
bNode *node;
|
|
|
|
|
2012-10-04 09:43:27 +00:00
|
|
|
if ((ma->use_nodes && ma->nodetree) &&
|
|
|
|
(node = nodeGetActiveID(ma->nodetree, ID_TE)))
|
|
|
|
{
|
|
|
|
tex = (Tex *)node->id;
|
|
|
|
id_us_min(&tex->id);
|
|
|
|
if (newtex) {
|
2012-05-06 15:15:33 +00:00
|
|
|
node->id = &newtex->id;
|
2009-10-12 13:12:45 +00:00
|
|
|
id_us_plus(&newtex->id);
|
2012-10-04 09:43:27 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
node->id = NULL;
|
2009-10-12 13:12:45 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-04 09:43:27 +00:00
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
int act = (int)ma->texact;
|
2009-10-12 13:12:45 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
tex = (ma->mtex[act]) ? ma->mtex[act]->tex : NULL;
|
2009-10-12 13:12:45 +00:00
|
|
|
id_us_min(&tex->id);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (newtex) {
|
2014-05-28 08:19:41 +02:00
|
|
|
if (!ma->mtex[act]) {
|
2015-03-29 03:16:55 +11:00
|
|
|
ma->mtex[act] = BKE_texture_mtex_add();
|
2014-05-28 08:19:41 +02:00
|
|
|
/* Reset this slot's ON/OFF toggle, for materials, when slot was empty. */
|
|
|
|
ma->septex &= ~(1 << act);
|
|
|
|
}
|
2009-10-12 13:12:45 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ma->mtex[act]->tex = newtex;
|
2009-10-12 13:12:45 +00:00
|
|
|
id_us_plus(&newtex->id);
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (ma->mtex[act]) {
|
2009-10-12 13:12:45 +00:00
|
|
|
MEM_freeN(ma->mtex[act]);
|
2012-05-06 15:15:33 +00:00
|
|
|
ma->mtex[act] = NULL;
|
2009-10-12 13:12:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-28 03:52:21 +11:00
|
|
|
bool has_current_material_texture(Material *ma)
|
2011-06-01 16:17:38 +00:00
|
|
|
{
|
|
|
|
bNode *node;
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (ma && ma->use_nodes && ma->nodetree) {
|
2012-05-06 15:15:33 +00:00
|
|
|
node = nodeGetActiveID(ma->nodetree, ID_TE);
|
2011-06-01 16:17:38 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (node)
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2011-06-01 16:17:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (ma != NULL);
|
|
|
|
}
|
|
|
|
|
2009-10-09 09:50:49 +00:00
|
|
|
Tex *give_current_world_texture(World *world)
|
2008-08-01 12:56:29 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
MTex *mtex = NULL;
|
|
|
|
Tex *tex = NULL;
|
2008-08-01 12:56:29 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!world) return NULL;
|
2008-08-01 12:56:29 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
mtex = world->mtex[(int)(world->texact)];
|
|
|
|
if (mtex) tex = mtex->tex;
|
2008-08-01 12:56:29 +00:00
|
|
|
|
|
|
|
return tex;
|
|
|
|
}
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
2009-10-12 13:12:45 +00:00
|
|
|
void set_current_world_texture(World *wo, Tex *newtex)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
int act = wo->texact;
|
2009-10-12 13:12:45 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (wo->mtex[act] && wo->mtex[act]->tex)
|
2009-10-12 13:12:45 +00:00
|
|
|
id_us_min(&wo->mtex[act]->tex->id);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (newtex) {
|
|
|
|
if (!wo->mtex[act]) {
|
2015-03-29 03:16:55 +11:00
|
|
|
wo->mtex[act] = BKE_texture_mtex_add();
|
2012-05-06 15:15:33 +00:00
|
|
|
wo->mtex[act]->texco = TEXCO_VIEW;
|
2009-10-12 13:12:45 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
wo->mtex[act]->tex = newtex;
|
2009-10-12 13:12:45 +00:00
|
|
|
id_us_plus(&newtex->id);
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (wo->mtex[act]) {
|
2009-10-12 13:12:45 +00:00
|
|
|
MEM_freeN(wo->mtex[act]);
|
2012-05-06 15:15:33 +00:00
|
|
|
wo->mtex[act] = NULL;
|
2009-10-12 13:12:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-09 09:50:49 +00:00
|
|
|
Tex *give_current_brush_texture(Brush *br)
|
|
|
|
{
|
2010-01-03 08:37:18 +00:00
|
|
|
return br->mtex.tex;
|
2009-10-09 09:50:49 +00:00
|
|
|
}
|
|
|
|
|
2009-10-12 13:12:45 +00:00
|
|
|
void set_current_brush_texture(Brush *br, Tex *newtex)
|
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (br->mtex.tex)
|
2010-01-03 08:37:18 +00:00
|
|
|
id_us_min(&br->mtex.tex->id);
|
2009-10-12 13:12:45 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (newtex) {
|
2012-05-06 15:15:33 +00:00
|
|
|
br->mtex.tex = newtex;
|
2009-10-12 13:12:45 +00:00
|
|
|
id_us_plus(&newtex->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-12 14:38:34 +00:00
|
|
|
Tex *give_current_particle_texture(ParticleSettings *part)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
MTex *mtex = NULL;
|
|
|
|
Tex *tex = NULL;
|
2011-02-12 14:38:34 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!part) return NULL;
|
2011-02-12 14:38:34 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
mtex = part->mtex[(int)(part->texact)];
|
|
|
|
if (mtex) tex = mtex->tex;
|
2011-02-12 14:38:34 +00:00
|
|
|
|
|
|
|
return tex;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_current_particle_texture(ParticleSettings *part, Tex *newtex)
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
int act = part->texact;
|
2011-02-12 14:38:34 +00:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (part->mtex[act] && part->mtex[act]->tex)
|
2011-02-12 14:38:34 +00:00
|
|
|
id_us_min(&part->mtex[act]->tex->id);
|
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (newtex) {
|
|
|
|
if (!part->mtex[act]) {
|
2015-03-29 03:16:55 +11:00
|
|
|
part->mtex[act] = BKE_texture_mtex_add();
|
2012-05-06 15:15:33 +00:00
|
|
|
part->mtex[act]->texco = TEXCO_ORCO;
|
|
|
|
part->mtex[act]->blendtype = MTEX_MUL;
|
2011-02-12 14:38:34 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
part->mtex[act]->tex = newtex;
|
2011-02-12 14:38:34 +00:00
|
|
|
id_us_plus(&newtex->id);
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (part->mtex[act]) {
|
2011-02-12 14:38:34 +00:00
|
|
|
MEM_freeN(part->mtex[act]);
|
2012-05-06 15:15:33 +00:00
|
|
|
part->mtex[act] = NULL;
|
2011-02-12 14:38:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
EnvMap *BKE_texture_envmap_add(void)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
|
|
|
EnvMap *env;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
env = MEM_callocN(sizeof(EnvMap), "envmap");
|
|
|
|
env->type = ENV_CUBE;
|
|
|
|
env->stype = ENV_ANIM;
|
|
|
|
env->clipsta = 0.1;
|
|
|
|
env->clipend = 100.0;
|
2015-05-18 18:10:03 +02:00
|
|
|
env->cuberes = 512;
|
2010-03-11 07:43:49 +00:00
|
|
|
env->viewscale = 0.5;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
|
|
|
return env;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
EnvMap *BKE_texture_envmap_copy(EnvMap *env)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
|
|
|
EnvMap *envn;
|
|
|
|
int a;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
envn = MEM_dupallocN(env);
|
|
|
|
envn->ok = 0;
|
|
|
|
for (a = 0; a < 6; a++) envn->cube[a] = NULL;
|
2012-03-24 06:18:31 +00:00
|
|
|
if (envn->ima) id_us_plus((ID *)envn->ima);
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
|
|
|
return envn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_envmap_free_data(EnvMap *env)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
2006-12-20 17:57:56 +00:00
|
|
|
unsigned int part;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (part = 0; part < 6; part++) {
|
2012-03-24 06:18:31 +00:00
|
|
|
if (env->cube[part])
|
2006-12-20 17:57:56 +00:00
|
|
|
IMB_freeImBuf(env->cube[part]);
|
2012-05-06 15:15:33 +00:00
|
|
|
env->cube[part] = NULL;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
env->ok = 0;
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_envmap_free(EnvMap *env)
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
{
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
BKE_texture_envmap_free_data(env);
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
MEM_freeN(env);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2015-07-18 22:36:09 +02:00
|
|
|
void BKE_texture_pointdensity_init_data(PointDensity *pd)
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
{
|
2008-11-10 00:14:35 +00:00
|
|
|
pd->flag = 0;
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
pd->radius = 0.3f;
|
2008-10-01 03:35:53 +00:00
|
|
|
pd->falloff_type = TEX_PD_FALLOFF_STD;
|
2008-10-22 01:31:46 +00:00
|
|
|
pd->falloff_softness = 2.0;
|
Point Density texture
The Point Density texture now has some additional options for how
the point locations are cached. Previously it was all relative to
worldspace, but there are now some other options that make things
a lot more convenient for mapping the texture to Local (or Orco).
Thanks to theeth for helping with the space conversions!
The new Object space options allow this sort of thing to be possible
- a particle system, instanced on a transformed renderable object:
http://mke3.net/blender/devel/rendering/volumetrics/pd_objectspace.mov
It's also a lot easier to use multiple instances, just duplicate
the renderable objects and move them around.
The new particle cache options are:
* Emit Object space
This caches the particles relative to the emitter object's
coordinate space (i.e. relative to the emitter's object center).
This makes it possible to map the Texture to Local or Orco
easily, so you can easily move, rotate or scale the rendering
object that has the Point Density texture. It's relative to the
emitter's location, rotation and scale, so if the object you're
rendering the texture on is aligned differently to the emitter,
the results will be rotated etc.
* Emit Object Location
This offsets the particles to the emitter object's location in 3D
space. It's similar to Emit Object Space, however the emitter
object's rotation and scale are ignored. This is probably the
easiest to use, since you don't need to worry about the rotation
and scale of the emitter object (just the rendered object), so
it's the default.
* Global Space
This is the same as previously, the particles are cached in global space, so to use this effectively you'll need to map the texture to Global, and have the rendered object in the right global location.
2008-09-29 04:19:24 +00:00
|
|
|
pd->source = TEX_PD_PSYS;
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
pd->point_tree = NULL;
|
2008-10-02 01:38:12 +00:00
|
|
|
pd->point_data = NULL;
|
* New point density update: Turbulence
This addition allows you to perturb the point density with noise, to give
the impression of more resolution. It's a quick way to add detail, without
having to use large, complex, and slower to render particle systems.
Rather than just overlaying noise, like you might do by adding a secondary
clouds texture, it uses noise to perturb the actual coordinate looked up
in the density evaluation. This gives a much better looking result, as it
actually alters the original density.
Comparison of the particle cloud render without, and with added turbulence
(the render with turbulence only renders slightly more slowly):
http://mke3.net/blender/devel/rendering/volumetrics/pd_turbulence.jpg
Using the same constant noise function/spatial coordinates will give a
static appearance. This is fine (and quicker) if the particles aren't
moving, but on animated particle systems, it looks bad, as if the
particles are moving through a static noise field. To overcome this, there
are additional options for particle systems, to influence the turbulence
with the particles' average velocity, or average angular velocity. This
information is only available for particle systems at the present.
Here you can see the (dramatic) difference between no turbulence, static
turbulence, and turbulence influenced by particle velocity:
http://mke3.net/blender/devel/rendering/volumetrics/turbu_compare.mov
2008-10-06 12:25:22 +00:00
|
|
|
pd->noise_size = 0.5f;
|
|
|
|
pd->noise_depth = 1;
|
|
|
|
pd->noise_fac = 1.0f;
|
|
|
|
pd->noise_influence = TEX_PD_NOISE_STATIC;
|
2013-03-18 18:25:05 +00:00
|
|
|
pd->coba = add_colorband(true);
|
2008-11-09 01:16:12 +00:00
|
|
|
pd->speed_scale = 1.0f;
|
|
|
|
pd->totpoints = 0;
|
2009-08-17 22:09:36 +00:00
|
|
|
pd->object = NULL;
|
2009-11-04 08:44:42 +00:00
|
|
|
pd->psys = 0;
|
2012-05-06 15:15:33 +00:00
|
|
|
pd->psys_cache_space = TEX_PD_WORLDSPACE;
|
2011-05-01 03:57:53 +00:00
|
|
|
pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
pd->falloff_curve->preset = CURVE_PRESET_LINE;
|
|
|
|
pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE;
|
|
|
|
curvemap_reset(pd->falloff_curve->cm, &pd->falloff_curve->clipr, pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE);
|
2014-04-01 11:34:00 +11:00
|
|
|
curvemapping_changed(pd->falloff_curve, false);
|
2015-07-18 22:36:09 +02:00
|
|
|
}
|
2011-05-01 03:57:53 +00:00
|
|
|
|
2015-07-18 22:36:09 +02:00
|
|
|
PointDensity *BKE_texture_pointdensity_add(void)
|
|
|
|
{
|
|
|
|
PointDensity *pd = MEM_callocN(sizeof(PointDensity), "pointdensity");
|
|
|
|
BKE_texture_pointdensity_init_data(pd);
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
return pd;
|
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
PointDensity *BKE_texture_pointdensity_copy(PointDensity *pd)
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
{
|
|
|
|
PointDensity *pdn;
|
Point Density texture
The Point Density texture now has some additional options for how
the point locations are cached. Previously it was all relative to
worldspace, but there are now some other options that make things
a lot more convenient for mapping the texture to Local (or Orco).
Thanks to theeth for helping with the space conversions!
The new Object space options allow this sort of thing to be possible
- a particle system, instanced on a transformed renderable object:
http://mke3.net/blender/devel/rendering/volumetrics/pd_objectspace.mov
It's also a lot easier to use multiple instances, just duplicate
the renderable objects and move them around.
The new particle cache options are:
* Emit Object space
This caches the particles relative to the emitter object's
coordinate space (i.e. relative to the emitter's object center).
This makes it possible to map the Texture to Local or Orco
easily, so you can easily move, rotate or scale the rendering
object that has the Point Density texture. It's relative to the
emitter's location, rotation and scale, so if the object you're
rendering the texture on is aligned differently to the emitter,
the results will be rotated etc.
* Emit Object Location
This offsets the particles to the emitter object's location in 3D
space. It's similar to Emit Object Space, however the emitter
object's rotation and scale are ignored. This is probably the
easiest to use, since you don't need to worry about the rotation
and scale of the emitter object (just the rendered object), so
it's the default.
* Global Space
This is the same as previously, the particles are cached in global space, so to use this effectively you'll need to map the texture to Global, and have the rendered object in the right global location.
2008-09-29 04:19:24 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
pdn = MEM_dupallocN(pd);
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
pdn->point_tree = NULL;
|
2008-10-02 01:38:12 +00:00
|
|
|
pdn->point_data = NULL;
|
2012-05-06 15:15:33 +00:00
|
|
|
if (pdn->coba) pdn->coba = MEM_dupallocN(pdn->coba);
|
2011-05-01 05:51:21 +00:00
|
|
|
pdn->falloff_curve = curvemapping_copy(pdn->falloff_curve); /* can be NULL */
|
2008-10-22 06:10:16 +00:00
|
|
|
return pdn;
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_pointdensity_free_data(PointDensity *pd)
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
{
|
|
|
|
if (pd->point_tree) {
|
2008-10-01 03:35:53 +00:00
|
|
|
BLI_bvhtree_free(pd->point_tree);
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
pd->point_tree = NULL;
|
|
|
|
}
|
2008-10-01 03:35:53 +00:00
|
|
|
if (pd->point_data) {
|
|
|
|
MEM_freeN(pd->point_data);
|
|
|
|
pd->point_data = NULL;
|
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pd->coba) {
|
2011-03-16 18:21:31 +00:00
|
|
|
MEM_freeN(pd->coba);
|
|
|
|
pd->coba = NULL;
|
|
|
|
}
|
2011-05-01 05:51:21 +00:00
|
|
|
|
|
|
|
curvemapping_free(pd->falloff_curve); /* can be NULL */
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_pointdensity_free(PointDensity *pd)
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
{
|
2015-03-29 03:16:55 +11:00
|
|
|
BKE_texture_pointdensity_free_data(pd);
|
* Volumetrics
Removed all the old particle rendering code and options I had in there
before, in order to make way for...
A new procedural texture: 'Point Density'
Point Density is a 3d texture that find the density of a group of 'points'
in space and returns that in the texture as an intensity value. Right now,
its at an early stage and it's only enabled for particles, but it would be
cool to extend it later for things like object vertices, or point cache
files from disk - i.e. to import point cloud data into Blender for
rendering volumetrically.
Currently there are just options for an Object and its particle system
number, this is the particle system that will get cached before rendering,
and then used for the texture's density estimation.
It works totally consistent with as any other procedural texture, so
previously where I've mapped a clouds texture to volume density to make
some of those test renders, now I just map a point density texture to
volume density.
Here's a version of the same particle smoke test file from before, updated
to use the point density texture instead:
http://mke3.net/blender/devel/rendering/volumetrics/smoke_test02.blend
There are a few cool things about implementing this as a texture:
- The one texture (and cache) can be instanced across many different
materials:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_instanced.png
This means you can calculate and bake one particle system, but render it
multiple times across the scene, with different material settings, at no
extra memory cost.
Right now, the particles are cached in world space, so you have to map it
globally, and if you want it offset, you have to do it in the material (as
in the file above). I plan to add an option to bake in local space, so you
can just map the texture to local and it just works.
- It also works for solid surfaces too, it just gets the density at that
particular point on the surface, eg:
http://mke3.net/blender/devel/rendering/volumetrics/pointdensity_solid.mov
- You can map it to whatever you want, not only density but the various
emissions and colours as well. I'd like to investigate using the other
outputs in the texture too (like the RGB or normal outputs), perhaps with
options to colour by particle age, generating normals for making particle
'dents' in a surface, whatever!
2008-09-28 08:00:22 +00:00
|
|
|
MEM_freeN(pd);
|
|
|
|
}
|
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_voxeldata_free_data(VoxelData *vd)
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
{
|
|
|
|
if (vd->dataset) {
|
2010-11-11 17:03:09 +00:00
|
|
|
MEM_freeN(vd->dataset);
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
vd->dataset = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_voxeldata_free(VoxelData *vd)
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
{
|
2015-03-29 03:16:55 +11:00
|
|
|
BKE_texture_voxeldata_free_data(vd);
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
MEM_freeN(vd);
|
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
VoxelData *BKE_texture_voxeldata_add(void)
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
{
|
|
|
|
VoxelData *vd;
|
|
|
|
|
2012-05-06 17:22:54 +00:00
|
|
|
vd = MEM_callocN(sizeof(VoxelData), "voxeldata");
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
vd->dataset = NULL;
|
2009-08-13 05:21:25 +00:00
|
|
|
vd->resol[0] = vd->resol[1] = vd->resol[2] = 1;
|
2012-05-06 15:15:33 +00:00
|
|
|
vd->interp_type = TEX_VD_LINEAR;
|
|
|
|
vd->file_format = TEX_VD_SMOKE;
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
vd->int_multiplier = 1.0;
|
Rework of volume shading
After code review and experimentation, this commit makes some changes to the way that volumes are shaded. Previously, there were problems with the 'scattering' component, in that it wasn't physically correct - it didn't conserve energy and was just acting as a brightness multiplier. This has been changed to be more correct, so that as the light is scattered out of the volume, there is less remaining to penetrate through.
Since this behaviour is very similar to absorption but more useful, absorption has been removed and has been replaced by a 'transmission colour' - controlling the colour of light penetrating through the volume after it has been scattered/absorbed. As well as this, there's now 'reflection', a non-physically correct RGB multiplier for out-scattered light. This is handy for tweaking the overall colour of the volume, without having to worry about wavelength dependent absorption, and its effects on transmitted light. Now at least, even though there is the ability to tweak things non-physically, volume shading is physically based by default, and has a better combination of correctness and ease of use.
There's more detailed information and example images here:
http://wiki.blender.org/index.php/User:Broken/VolumeRendering
Also did some tweaks/optimisation:
* Removed shading step size (was a bit annoying, if it comes back, it will be in a different form)
* Removed phase function options, now just one asymmetry slider controls the range between back-scattering, isotropic scattering, and forward scattering. (note, more extreme values gives artifacts with light cache, will fix...)
* Disabled the extra 'bounce lights' from the preview render for volumes, speeds updates significantly
* Enabled voxeldata texture in preview render
* Fixed volume shadows (they were too dark, fixed by avoiding using the shadfac/AddAlphaLight stuff)
More revisions to come later...
2009-09-29 22:01:32 +00:00
|
|
|
vd->extend = TEX_CLIP;
|
2009-08-17 22:09:36 +00:00
|
|
|
vd->object = NULL;
|
2010-06-01 06:07:22 +00:00
|
|
|
vd->cachedframe = -1;
|
|
|
|
vd->ok = 0;
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
|
|
|
|
return vd;
|
2012-05-06 15:15:33 +00:00
|
|
|
}
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
VoxelData *BKE_texture_voxeldata_copy(VoxelData *vd)
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
{
|
|
|
|
VoxelData *vdn;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
vdn = MEM_dupallocN(vd);
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
vdn->dataset = NULL;
|
|
|
|
|
|
|
|
return vdn;
|
|
|
|
}
|
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
OceanTex *BKE_texture_ocean_add(void)
|
2011-11-13 12:17:27 +00:00
|
|
|
{
|
|
|
|
OceanTex *ot;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
ot = MEM_callocN(sizeof(struct OceanTex), "ocean texture");
|
2011-11-13 12:17:27 +00:00
|
|
|
ot->output = TEX_OCN_DISPLACEMENT;
|
|
|
|
ot->object = NULL;
|
|
|
|
|
|
|
|
return ot;
|
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
OceanTex *BKE_texture_ocean_copy(struct OceanTex *ot)
|
2011-11-13 12:17:27 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
OceanTex *otn = MEM_dupallocN(ot);
|
2011-11-13 12:17:27 +00:00
|
|
|
|
|
|
|
return otn;
|
|
|
|
}
|
|
|
|
|
2015-03-29 03:16:55 +11:00
|
|
|
void BKE_texture_ocean_free(struct OceanTex *ot)
|
2011-11-13 12:17:27 +00:00
|
|
|
{
|
|
|
|
MEM_freeN(ot);
|
|
|
|
}
|
|
|
|
|
2015-02-23 18:22:09 +11:00
|
|
|
/**
|
|
|
|
* \returns true if this texture can use its #Texture.ima (even if its NULL)
|
|
|
|
*/
|
|
|
|
bool BKE_texture_is_image_user(const struct Tex *tex)
|
|
|
|
{
|
|
|
|
switch (tex->type) {
|
|
|
|
case TEX_IMAGE:
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
case TEX_ENVMAP:
|
|
|
|
{
|
|
|
|
if (tex->env) {
|
|
|
|
if (tex->env->stype == ENV_LOAD) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
* Volume Rendering: Voxel data
This commit introduces a new texture ('Voxel Data'), used to load up saved voxel
data sets for rendering, contributed by Raúl 'farsthary' Fernández Hernández
with some additional tweaks. Thanks, Raúl!
The texture works similar to the existing point density texture, currently it
only provides intensity information, which can then be mapped (for example) to
density in a volume material. This is an early version, intended to read the
voxel format saved by Raúl's command line simulators, in future revisions
there's potential for making a more full-featured 'Blender voxel file format',
and also for supporting other formats too.
Note: Due to some subtleties in Raúl's existing released simulators, in order
to load them correctly the voxel data texture, you'll need to raise the
'resolution' value by 2. So if you baked out the simulation at resolution 50,
enter 52 for the resolution in the texture panel. This can possibly be fixed in
the simulator later on.
Right now, the way the texture is mapped is just in the space 0,0,0 <-> 1,1,1
and it can appear rotated 90 degrees incorrectly. This will be tackled, for now,
probably the easiest way to map it is with and empty, using Map Input -> Object.
Smoke test: http://www.vimeo.com/2449270
One more note, trilinear interpolation seems a bit slow at the moment, we'll
look into this.
For curiosity, while testing/debugging this, I made a script that exports a mesh
to voxel data. Here's a test of grogan (www.kajimba.com) converted to voxels,
rendered as a volume: http://www.vimeo.com/2512028
The script is available here: http://mke3.net/projects/bpython/export_object_voxeldata.py
* Another smaller thing, brought back early ray termination (was disabled
previously for debugging) and made it user configurable. It now appears as a new
value in the volume material: 'Depth Cutoff'. For some background info on what
this does, check:
http://farsthary.wordpress.com/2008/12/11/cutting-down-render-times/
* Also some disabled work-in-progess code for light cache
2008-12-13 05:41:34 +00:00
|
|
|
|
Giant commit!
A full detailed description of this will be done later... is several days
of work. Here's a summary:
Render:
- Full cleanup of render code, removing *all* globals and bad level calls
all over blender. Render module is now not called abusive anymore
- API-fied calls to rendering
- Full recode of internal render pipeline. Is now rendering tiles by
default, prepared for much smarter 'bucket' render later.
- Each thread now can render a full part
- Renders were tested with 4 threads, goes fine, apart from some lookup
tables in softshadow and AO still
- Rendering is prepared to do multiple layers and passes
- No single 32 bits trick in render code anymore, all 100% floats now.
Writing images/movies
- moved writing images to blender kernel (bye bye 'schrijfplaatje'!)
- made a new Movie handle system, also in kernel. This will enable much
easier use of movies in Blender
PreviewRender:
- Using new render API, previewrender (in buttons) now uses regular render
code to generate images.
- new datafile 'preview.blend.c' has the preview scenes in it
- previews get rendered in exact displayed size (1 pixel = 1 pixel)
3D Preview render
- new; press Pkey in 3d window, for a panel that continuously renders
(pkey is for games, i know... but we dont do that in orange now!)
- this render works nearly identical to buttons-preview render, so it stops
rendering on any event (mouse, keyboard, etc)
- on moving/scaling the panel, the render code doesn't recreate all geometry
- same for shifting/panning view
- all other operations (now) regenerate the full render database still.
- this is WIP... but big fun, especially for simple scenes!
Compositor
- Using same node system as now in use for shaders, you can composit images
- works pretty straightforward... needs much more options/tools and integration
with rendering still
- is not threaded yet, nor is so smart to only recalculate changes... will be
done soon!
- the "Render Result" node will get all layers/passes as output sockets
- The "Output" node renders to a builtin image, which you can view in the Image
window. (yes, output nodes to render-result, and to files, is on the list!)
The Bad News
- "Unified Render" is removed. It might come back in some stage, but this
system should be built from scratch. I can't really understand this code...
I expect it is not much needed, especially with advanced layer/passes
control
- Panorama render, Field render, Motion blur, is not coded yet... (I had to
recode every single feature in render, so...!)
- Lens Flare is also not back... needs total revision, might become composit
effect though (using zbuffer for visibility)
- Part render is gone! (well, thats obvious, its default now).
- The render window is only restored with limited functionality... I am going
to check first the option to render to a Image window, so Blender can become
a true single-window application. :)
For example, the 'Spare render buffer' (jkey) doesnt work.
- Render with border, now default creates a smaller image
- No zbuffers are written yet... on the todo!
- Scons files and MSVC will need work to get compiling again
OK... thats what I can quickly recall. Now go compiling!
2006-01-23 22:05:47 +00:00
|
|
|
/* ------------------------------------------------------------------------- */
|
2013-06-02 03:59:19 +00:00
|
|
|
bool BKE_texture_dependsOnTime(const struct Tex *texture)
|
2008-08-05 14:42:04 +00:00
|
|
|
{
|
2014-01-14 04:59:58 +11:00
|
|
|
if (texture->ima && BKE_image_is_animated(texture->ima)) {
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2010-10-19 10:26:53 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (texture->adt) {
|
2012-07-07 22:51:57 +00:00
|
|
|
/* assume anything in adt means the texture is animated */
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2008-08-05 14:42:04 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
else if (texture->type == TEX_NOISE) {
|
2012-07-07 22:51:57 +00:00
|
|
|
/* noise always varies with time */
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2011-07-10 17:04:56 +00:00
|
|
|
}
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2008-08-05 14:42:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
2013-10-20 13:01:07 +00:00
|
|
|
|
2015-03-21 22:10:43 +11:00
|
|
|
void BKE_texture_get_value(
|
|
|
|
const Scene *scene, Tex *texture,
|
|
|
|
float *tex_co, TexResult *texres, bool use_color_management)
|
2013-10-20 13:01:07 +00:00
|
|
|
{
|
|
|
|
int result_type;
|
|
|
|
bool do_color_manage = false;
|
|
|
|
|
|
|
|
if (scene && use_color_management) {
|
|
|
|
do_color_manage = BKE_scene_check_color_management_enabled(scene);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no node textures for now */
|
2015-01-27 16:14:53 +05:00
|
|
|
result_type = multitex_ext_safe(texture, tex_co, texres, NULL, do_color_manage, false);
|
2013-10-20 13:01:07 +00:00
|
|
|
|
|
|
|
/* if the texture gave an RGB value, we assume it didn't give a valid
|
|
|
|
* intensity, since this is in the context of modifiers don't use perceptual color conversion.
|
|
|
|
* if the texture didn't give an RGB value, copy the intensity across
|
|
|
|
*/
|
|
|
|
if (result_type & TEX_RGB) {
|
|
|
|
texres->tin = (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
copy_v3_fl(&texres->tr, texres->tin);
|
|
|
|
}
|
|
|
|
}
|