This repository has been archived on 2023-10-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-archive/source/blender/render/intern/texture_image.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

2027 lines
55 KiB
C
Raw Normal View History

/*
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +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
* of the License, or (at your option) any later version.
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +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.
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
/** \file
* \ingroup render
2011-02-27 19:31:27 +00:00
*/
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
#include <fcntl.h>
#include <float.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#ifndef WIN32
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
# include <unistd.h>
#else
# include <io.h>
#endif
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
#include "DNA_image_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
#include "BKE_image.h"
#include "RE_texture.h"
2011-02-14 18:20:10 +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
#include "render_types.h"
#include "texture_common.h"
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
static void boxsample(ImBuf *ibuf,
float minx,
float miny,
float maxx,
float maxy,
TexResult *texres,
const short imaprepeat,
const short imapextend);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
/* *********** IMAGEWRAPPING ****************** */
/* x and y have to be checked for image size */
static void ibuf_get_color(float col[4], struct ImBuf *ibuf, int x, int y)
{
int ofs = y * ibuf->x + x;
if (ibuf->rect_float) {
2019-03-25 11:55:36 +11:00
if (ibuf->channels == 4) {
const float *fp = ibuf->rect_float + 4 * ofs;
copy_v4_v4(col, fp);
}
2019-03-25 11:55:36 +11:00
else if (ibuf->channels == 3) {
const float *fp = ibuf->rect_float + 3 * ofs;
copy_v3_v3(col, fp);
2019-03-25 11:55:36 +11:00
col[3] = 1.0f;
}
else {
2019-03-25 11:55:36 +11:00
const float *fp = ibuf->rect_float + ofs;
col[0] = col[1] = col[2] = col[3] = *fp;
}
}
else {
2019-03-25 11:55:36 +11:00
const char *rect = (char *)(ibuf->rect + ofs);
2019-03-25 11:55:36 +11:00
col[0] = ((float)rect[0]) * (1.0f / 255.0f);
col[1] = ((float)rect[1]) * (1.0f / 255.0f);
col[2] = ((float)rect[2]) * (1.0f / 255.0f);
col[3] = ((float)rect[3]) * (1.0f / 255.0f);
Alpha premul pipeline cleanup This assumptions are now made: - Internally float buffers are always linear alpha-premul colors - Readers should worry about delivering float buffers with that assumptions. - There's an input image setting to say whether it's stored with straight/premul alpha on the disk. - Byte buffers are now assumed have straight alpha, readers should deliver straight alpha. Some implementation details: - Removed scene's color unpremultiply setting, which was very much confusing and was wrong for default settings. Now all renderers assumes to deliver premultiplied alpha. - IMB_buffer_byte_from_float will now linearize alpha when converting from buffer. - Sequencer's effects were changed to assume bytes have got straight alpha. Most of effects will work with bytes still, however for glow it was more tricky to avoid data loss, so there's a commented out glow implementation which converts byte buffer to floats first, operates on floats and returns bytes back. It's slower and not sure if it should actually be used -- who're using glow on alpha anyway? - Sequencer modifiers should also be working nice with straight bytes now. - GLSL preview will predivide float textures to make nice shading, shading with byte textures worked nice (GLSL was assuming straight alpha). - Blender Internal will set alpha=1 to the whole sky. The same happens in Cycles and there's no way to avoid this -- sky is neither straight nor premul and doesn't fit color pipeline well. - Straight alpha mode for render result was also eliminated. - Conversion to correct alpha need to be done before linearizing float buffer. - TIFF will now load and save files with proper alpha mode setting in file meta data header. - Remove Use Alpha from texture mapping and replaced with image datablock setting. Behaves much more predictable and clear from code point of view and solves possible regressions when non-premultiplied images were used as textures with ignoring alpha channel.
2012-12-31 13:52:13 +00:00
/* bytes are internally straight, however render pipeline seems to expect premul */
col[0] *= col[3];
col[1] *= col[3];
col[2] *= col[3];
}
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
int imagewrap(Tex *tex,
Image *ima,
const float texvec[3],
TexResult *texres,
struct ImagePool *pool,
const bool skip_load_image)
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
{
float fx, fy, val1, val2, val3;
int x, y, retval;
int xi, yi; /* original values */
2019-03-25 11:55:36 +11:00
texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.0f;
/* we need to set retval OK, otherwise texture code generates normals itself... */
retval = texres->nor ? (TEX_RGB | TEX_NOR) : TEX_RGB;
/* quick tests */
if (ima == NULL) {
return retval;
2019-04-22 09:08:06 +10:00
}
/* hack for icon render */
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) {
return retval;
}
ImageUser *iuser = &tex->iuser;
ImageUser local_iuser;
if (ima->source == IMA_SRC_TILED) {
/* tex->iuser might be shared by threads, so create a local copy. */
local_iuser = tex->iuser;
iuser = &local_iuser;
float new_uv[2];
iuser->tile = BKE_image_get_tile_from_pos(ima, texvec, new_uv, NULL);
fx = new_uv[0];
fy = new_uv[1];
}
else {
fx = texvec[0];
fy = texvec[1];
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
ImBuf *ibuf = BKE_image_pool_acquire_ibuf(ima, iuser, pool);
ima->flag |= IMA_USED_FOR_RENDER;
2019-03-25 11:55:36 +11:00
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
return retval;
}
/* setup mapping */
if (tex->imaflag & TEX_IMAROT) {
SWAP(float, fx, fy);
}
if (tex->extend == TEX_CHECKER) {
int xs, ys;
2019-03-25 11:55:36 +11:00
xs = (int)floor(fx);
ys = (int)floor(fy);
fx -= xs;
fy -= ys;
2012-10-07 09:48:59 +00:00
if ((tex->flag & TEX_CHECKER_ODD) == 0) {
if ((xs + ys) & 1) {
/* pass */
}
else {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
2012-10-07 09:48:59 +00:00
return retval;
}
2012-10-07 09:48:59 +00:00
}
2019-03-25 11:55:36 +11:00
if ((tex->flag & TEX_CHECKER_EVEN) == 0) {
if ((xs + ys) & 1) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
}
/* scale around center, (0.5, 0.5) */
2019-03-25 11:55:36 +11:00
if (tex->checkerdist < 1.0f) {
fx = (fx - 0.5f) / (1.0f - tex->checkerdist) + 0.5f;
fy = (fy - 0.5f) / (1.0f - tex->checkerdist) + 0.5f;
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2019-03-25 11:55:36 +11:00
x = xi = (int)floorf(fx * ibuf->x);
y = yi = (int)floorf(fy * ibuf->y);
if (tex->extend == TEX_CLIPCUBE) {
2019-03-25 11:55:36 +11:00
if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y || texvec[2] < -1.0f || texvec[2] > 1.0f) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2020-11-06 12:30:59 +11:00
else if (ELEM(tex->extend, TEX_CLIP, TEX_CHECKER)) {
2019-03-25 11:55:36 +11:00
if (x < 0 || y < 0 || x >= ibuf->x || y >= ibuf->y) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-03-25 11:55:36 +11:00
if (tex->extend == TEX_EXTEND) {
2019-04-22 09:08:06 +10:00
if (x >= ibuf->x) {
2019-03-25 11:55:36 +11:00
x = ibuf->x - 1;
2019-04-22 09:08:06 +10:00
}
else if (x < 0) {
2019-03-25 11:55:36 +11:00
x = 0;
2019-04-22 09:08:06 +10:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-03-25 11:55:36 +11:00
x = x % ibuf->x;
2019-04-22 09:08:06 +10:00
if (x < 0) {
2019-03-25 11:55:36 +11:00
x += ibuf->x;
2019-04-22 09:08:06 +10:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2019-03-25 11:55:36 +11:00
if (tex->extend == TEX_EXTEND) {
2019-04-22 09:08:06 +10:00
if (y >= ibuf->y) {
2019-03-25 11:55:36 +11:00
y = ibuf->y - 1;
2019-04-22 09:08:06 +10:00
}
else if (y < 0) {
2019-03-25 11:55:36 +11:00
y = 0;
2019-04-22 09:08:06 +10:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-03-25 11:55:36 +11:00
y = y % ibuf->y;
2019-04-22 09:08:06 +10:00
if (y < 0) {
2019-03-25 11:55:36 +11:00
y += ibuf->y;
2019-04-22 09:08:06 +10:00
}
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
/* Keep this before interpolation T29761. */
if (ima) {
if ((tex->imaflag & TEX_USEALPHA) && (ima->alpha_mode != IMA_ALPHA_IGNORE)) {
if ((tex->imaflag & TEX_CALCALPHA) == 0) {
texres->talpha = true;
}
}
}
/* interpolate */
if (tex->imaflag & TEX_INTERPOL) {
float filterx, filtery;
filterx = (0.5f * tex->filtersize) / ibuf->x;
filtery = (0.5f * tex->filtersize) / ibuf->y;
/* Important that this value is wrapped T27782.
* this applies the modifications made by the checks above,
* back to the floating point values */
fx -= (float)(xi - x) / (float)ibuf->x;
fy -= (float)(yi - y) / (float)ibuf->y;
2019-03-25 11:55:36 +11:00
boxsample(ibuf,
fx - filterx,
fy - filtery,
fx + filterx,
fy + filtery,
texres,
(tex->extend == TEX_REPEAT),
(tex->extend == TEX_EXTEND));
}
else { /* no filtering */
ibuf_get_color(&texres->tr, ibuf, x, y);
}
if (texres->nor) {
if (tex->imaflag & TEX_NORMALMAP) {
2019-08-18 04:11:50 +10:00
/* Normal from color:
2012-07-07 22:51:57 +00:00
* The invert of the red channel is to make
* the normal map compliant with the outside world.
* It needs to be done because in Blender
* the normal used in the renderer points inward. It is generated
* this way in calc_vertexnormals(). Should this ever change
* this negate must be removed. */
texres->nor[0] = -2.0f * (texres->tr - 0.5f);
texres->nor[1] = 2.0f * (texres->tg - 0.5f);
texres->nor[2] = 2.0f * (texres->tb - 0.5f);
}
else {
/* bump: take three samples */
2019-03-25 11:55:36 +11:00
val1 = texres->tr + texres->tg + texres->tb;
2019-03-25 11:55:36 +11:00
if (x < ibuf->x - 1) {
float col[4];
2019-03-25 11:55:36 +11:00
ibuf_get_color(col, ibuf, x + 1, y);
val2 = (col[0] + col[1] + col[2]);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-03-25 11:55:36 +11:00
val2 = val1;
}
2019-03-25 11:55:36 +11:00
if (y < ibuf->y - 1) {
float col[4];
2019-03-25 11:55:36 +11:00
ibuf_get_color(col, ibuf, x, y + 1);
val3 = (col[0] + col[1] + col[2]);
}
else {
val3 = val1;
}
/* do not mix up x and y here! */
2019-03-25 11:55:36 +11:00
texres->nor[0] = (val1 - val2);
texres->nor[1] = (val1 - val3);
}
}
if (texres->talpha) {
texres->tin = texres->ta;
}
else if (tex->imaflag & TEX_CALCALPHA) {
texres->ta = texres->tin = max_fff(texres->tr, texres->tg, texres->tb);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
texres->ta = texres->tin = 1.0;
}
if (tex->flag & TEX_NEGALPHA) {
texres->ta = 1.0f - texres->ta;
}
2020-11-16 16:48:41 +11:00
/* de-premul, this is being pre-multiplied in shade_input_do_shade()
* do not de-premul for generated alpha, it is already in straight */
2019-03-25 11:55:36 +11:00
if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
fx = 1.0f / texres->ta;
texres->tr *= fx;
texres->tg *= fx;
texres->tb *= fx;
}
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
BRICONTRGB;
return retval;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
{
rctf *rf, *newrct;
short a;
2019-03-25 11:55:36 +11:00
a = *count;
rf = stack;
for (; a > 0; a--) {
if (rf->xmin < x1) {
if (rf->xmax < x1) {
rf->xmin += (x2 - x1);
rf->xmax += (x2 - x1);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-04-22 09:08:06 +10:00
if (rf->xmax > x2) {
2019-03-25 11:55:36 +11:00
rf->xmax = x2;
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
newrct = stack + *count;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
(*count)++;
newrct->xmax = x2;
2019-03-25 11:55:36 +11:00
newrct->xmin = rf->xmin + (x2 - x1);
newrct->ymin = rf->ymin;
newrct->ymax = rf->ymax;
2019-04-22 09:08:06 +10:00
if (newrct->xmin == newrct->xmax) {
2019-03-25 11:55:36 +11:00
(*count)--;
2019-04-22 09:08:06 +10:00
}
rf->xmin = x1;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
}
2019-03-25 11:55:36 +11:00
else if (rf->xmax > x2) {
if (rf->xmin > x2) {
rf->xmin -= (x2 - x1);
rf->xmax -= (x2 - x1);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-04-22 09:08:06 +10:00
if (rf->xmin < x1) {
2019-03-25 11:55:36 +11:00
rf->xmin = x1;
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
newrct = stack + *count;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
(*count)++;
newrct->xmin = x1;
2019-03-25 11:55:36 +11:00
newrct->xmax = rf->xmax - (x2 - x1);
newrct->ymin = rf->ymin;
newrct->ymax = rf->ymax;
2019-04-22 09:08:06 +10:00
if (newrct->xmin == newrct->xmax) {
2019-03-25 11:55:36 +11:00
(*count)--;
2019-04-22 09:08:06 +10:00
}
rf->xmax = x2;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
rf++;
}
}
static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
{
rctf *rf, *newrct;
short a;
2019-03-25 11:55:36 +11:00
a = *count;
rf = stack;
for (; a > 0; a--) {
if (rf->ymin < y1) {
if (rf->ymax < y1) {
rf->ymin += (y2 - y1);
rf->ymax += (y2 - y1);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-04-22 09:08:06 +10:00
if (rf->ymax > y2) {
2019-03-25 11:55:36 +11:00
rf->ymax = y2;
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
newrct = stack + *count;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
(*count)++;
newrct->ymax = y2;
2019-03-25 11:55:36 +11:00
newrct->ymin = rf->ymin + (y2 - y1);
newrct->xmin = rf->xmin;
newrct->xmax = rf->xmax;
2019-04-22 09:08:06 +10:00
if (newrct->ymin == newrct->ymax) {
2019-03-25 11:55:36 +11:00
(*count)--;
2019-04-22 09:08:06 +10:00
}
rf->ymin = y1;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
}
2019-03-25 11:55:36 +11:00
else if (rf->ymax > y2) {
if (rf->ymin > y2) {
rf->ymin -= (y2 - y1);
rf->ymax -= (y2 - y1);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-04-22 09:08:06 +10:00
if (rf->ymin < y1) {
2019-03-25 11:55:36 +11:00
rf->ymin = y1;
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
newrct = stack + *count;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
(*count)++;
newrct->ymin = y1;
2019-03-25 11:55:36 +11:00
newrct->ymax = rf->ymax - (y2 - y1);
newrct->xmin = rf->xmin;
newrct->xmax = rf->xmax;
2019-04-22 09:08:06 +10:00
if (newrct->ymin == newrct->ymax) {
2019-03-25 11:55:36 +11:00
(*count)--;
2019-04-22 09:08:06 +10:00
}
rf->ymax = y2;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
}
rf++;
}
}
static float square_rctf(rctf *rf)
{
float x, y;
x = BLI_rctf_size_x(rf);
y = BLI_rctf_size_y(rf);
2012-08-21 20:34:05 +00:00
return x * y;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
static float clipx_rctf(rctf *rf, float x1, float x2)
{
float size;
size = BLI_rctf_size_x(rf);
2019-03-25 11:55:36 +11:00
if (rf->xmin < x1) {
rf->xmin = x1;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2019-03-25 11:55:36 +11:00
if (rf->xmax > x2) {
rf->xmax = x2;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
if (rf->xmin > rf->xmax) {
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
rf->xmin = rf->xmax;
return 0.0;
}
if (size != 0.0f) {
return BLI_rctf_size_x(rf) / size;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
return 1.0;
}
static float clipy_rctf(rctf *rf, float y1, float y2)
{
float size;
size = BLI_rctf_size_y(rf);
2019-03-25 11:55:36 +11:00
if (rf->ymin < y1) {
rf->ymin = y1;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2019-03-25 11:55:36 +11:00
if (rf->ymax > y2) {
rf->ymax = y2;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
if (rf->ymin > rf->ymax) {
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
rf->ymin = rf->ymax;
return 0.0;
}
if (size != 0.0f) {
return BLI_rctf_size_y(rf) / size;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
return 1.0;
}
static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
{
2019-06-15 09:24:38 +10:00
/* Sample box, is clipped already, and minx etc. have been set at ibuf size.
* Enlarge with anti-aliased edges of the pixels. */
float muly, mulx, div, col[4];
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
int x, y, startx, endx, starty, endy;
2019-03-25 11:55:36 +11:00
startx = (int)floor(rf->xmin);
endx = (int)floor(rf->xmax);
starty = (int)floor(rf->ymin);
endy = (int)floor(rf->ymax);
2019-04-22 09:08:06 +10:00
if (startx < 0) {
2019-03-25 11:55:36 +11:00
startx = 0;
2019-04-22 09:08:06 +10:00
}
if (starty < 0) {
2019-03-25 11:55:36 +11:00
starty = 0;
2019-04-22 09:08:06 +10:00
}
if (endx >= ibuf->x) {
2019-03-25 11:55:36 +11:00
endx = ibuf->x - 1;
2019-04-22 09:08:06 +10:00
}
if (endy >= ibuf->y) {
2019-03-25 11:55:36 +11:00
endy = ibuf->y - 1;
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
if (starty == endy && startx == endx) {
ibuf_get_color(&texres->tr, ibuf, startx, starty);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-03-25 11:55:36 +11:00
div = texres->tr = texres->tg = texres->tb = texres->ta = 0.0;
for (y = starty; y <= endy; y++) {
2019-03-25 11:55:36 +11:00
muly = 1.0;
2019-03-25 11:55:36 +11:00
if (starty == endy) {
2012-10-07 09:48:59 +00:00
/* pass */
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
else {
2019-04-22 09:08:06 +10:00
if (y == starty) {
2019-03-25 11:55:36 +11:00
muly = 1.0f - (rf->ymin - y);
2019-04-22 09:08:06 +10:00
}
if (y == endy) {
2019-03-25 11:55:36 +11:00
muly = (rf->ymax - y);
2019-04-22 09:08:06 +10:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2019-03-25 11:55:36 +11:00
if (startx == endx) {
mulx = muly;
ibuf_get_color(col, ibuf, startx, y);
2019-03-25 11:55:36 +11:00
texres->ta += mulx * col[3];
texres->tr += mulx * col[0];
texres->tg += mulx * col[1];
texres->tb += mulx * col[2];
div += mulx;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-03-25 11:55:36 +11:00
for (x = startx; x <= endx; x++) {
mulx = muly;
2019-04-22 09:08:06 +10:00
if (x == startx) {
2019-03-25 11:55:36 +11:00
mulx *= 1.0f - (rf->xmin - x);
2019-04-22 09:08:06 +10:00
}
if (x == endx) {
2019-03-25 11:55:36 +11:00
mulx *= (rf->xmax - x);
2019-04-22 09:08:06 +10:00
}
ibuf_get_color(col, ibuf, x, y);
2019-03-25 11:55:36 +11:00
if (mulx == 1.0f) {
texres->ta += col[3];
texres->tr += col[0];
texres->tg += col[1];
texres->tb += col[2];
div += 1.0f;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-03-25 11:55:36 +11:00
texres->ta += mulx * col[3];
texres->tr += mulx * col[0];
texres->tg += mulx * col[1];
texres->tb += mulx * col[2];
div += mulx;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
}
}
}
2019-03-25 11:55:36 +11:00
if (div != 0.0f) {
div = 1.0f / div;
texres->tb *= div;
texres->tg *= div;
texres->tr *= div;
texres->ta *= div;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-03-25 11:55:36 +11:00
texres->tr = texres->tg = texres->tb = texres->ta = 0.0f;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
}
}
static void boxsample(ImBuf *ibuf,
float minx,
float miny,
float maxx,
float maxy,
TexResult *texres,
const short imaprepeat,
const short imapextend)
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
{
/* Sample box, performs clip. minx etc are in range 0.0 - 1.0 .
2021-02-09 10:42:00 +11:00
* Enlarge with anti-aliased edges of pixels.
* If variable 'imaprepeat' has been set, the
* clipped-away parts are sampled as well.
*/
/* note: actually minx etc isn't in the proper range...
* this due to filter size and offset vectors for bump */
/* note: talpha must be initialized */
2012-07-16 23:23:33 +00:00
/* note: even when 'imaprepeat' is set, this can only repeat once in any direction.
* the point which min/max is derived from is assumed to be wrapped */
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
TexResult texr;
rctf *rf, stack[8];
2019-03-25 11:55:36 +11:00
float opp, tot, alphaclip = 1.0;
short count = 1;
2019-03-25 11:55:36 +11:00
rf = stack;
rf->xmin = minx * (ibuf->x);
rf->xmax = maxx * (ibuf->x);
rf->ymin = miny * (ibuf->y);
rf->ymax = maxy * (ibuf->y);
2019-03-25 11:55:36 +11:00
texr.talpha = texres->talpha; /* is read by boxsample_clip */
if (imapextend) {
2019-03-25 11:55:36 +11:00
CLAMP(rf->xmin, 0.0f, ibuf->x - 1);
CLAMP(rf->xmax, 0.0f, ibuf->x - 1);
}
2019-04-22 09:08:06 +10:00
else if (imaprepeat) {
clipx_rctf_swap(stack, &count, 0.0, (float)(ibuf->x));
2019-04-22 09:08:06 +10:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
else {
2019-03-25 11:55:36 +11:00
alphaclip = clipx_rctf(rf, 0.0, (float)(ibuf->x));
2019-03-25 11:55:36 +11:00
if (alphaclip <= 0.0f) {
texres->tr = texres->tb = texres->tg = texres->ta = 0.0;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
return;
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
if (imapextend) {
2019-03-25 11:55:36 +11:00
CLAMP(rf->ymin, 0.0f, ibuf->y - 1);
CLAMP(rf->ymax, 0.0f, ibuf->y - 1);
}
2019-04-22 09:08:06 +10:00
else if (imaprepeat) {
clipy_rctf_swap(stack, &count, 0.0, (float)(ibuf->y));
2019-04-22 09:08:06 +10:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
else {
2019-03-25 11:55:36 +11:00
alphaclip *= clipy_rctf(rf, 0.0, (float)(ibuf->y));
2019-03-25 11:55:36 +11:00
if (alphaclip <= 0.0f) {
texres->tr = texres->tb = texres->tg = texres->ta = 0.0;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
return;
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2019-03-25 11:55:36 +11:00
if (count > 1) {
tot = texres->tr = texres->tb = texres->tg = texres->ta = 0.0;
while (count--) {
boxsampleclip(ibuf, rf, &texr);
2019-03-25 11:55:36 +11:00
opp = square_rctf(rf);
tot += opp;
2019-03-25 11:55:36 +11:00
texres->tr += opp * texr.tr;
texres->tg += opp * texr.tg;
texres->tb += opp * texr.tb;
2019-04-22 09:08:06 +10:00
if (texres->talpha) {
2019-03-25 11:55:36 +11:00
texres->ta += opp * texr.ta;
2019-04-22 09:08:06 +10:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
rf++;
}
2019-03-25 11:55:36 +11:00
if (tot != 0.0f) {
texres->tr /= tot;
texres->tg /= tot;
texres->tb /= tot;
2019-04-22 09:08:06 +10:00
if (texres->talpha) {
2019-03-25 11:55:36 +11:00
texres->ta /= tot;
2019-04-22 09:08:06 +10:00
}
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2019-04-22 09:08:06 +10:00
else {
boxsampleclip(ibuf, rf, texres);
2019-04-22 09:08:06 +10:00
}
2019-04-22 09:08:06 +10:00
if (texres->talpha == 0) {
2019-03-25 11:55:36 +11:00
texres->ta = 1.0;
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
if (alphaclip != 1.0f) {
/* premul it all */
2019-03-25 11:55:36 +11:00
texres->tr *= alphaclip;
texres->tg *= alphaclip;
texres->tb *= alphaclip;
texres->ta *= alphaclip;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
/* -------------------------------------------------------------------- */
/* from here, some functions only used for the new filtering */
2012-07-07 22:51:57 +00:00
/* anisotropic filters, data struct used instead of long line of (possibly unused) func args */
typedef struct afdata_t {
float dxt[2], dyt[2];
int intpol, extflag;
2012-07-07 22:51:57 +00:00
/* feline only */
float majrad, minrad, theta;
int iProbes;
float dusc, dvsc;
} afdata_t;
2012-07-07 22:51:57 +00:00
/* this only used here to make it easier to pass extend flags as single int */
enum { TXC_XMIR = 1, TXC_YMIR, TXC_REPT, TXC_EXTD };
2020-11-12 11:35:31 +11:00
/**
* Similar to `ibuf_get_color()` but clips/wraps coords according to repeat/extend flags
* returns true if out of range in clip-mode.
*/
static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extflag)
{
int clip = 0;
switch (extflag) {
2019-03-25 11:55:36 +11:00
case TXC_XMIR: /* y rep */
x %= 2 * ibuf->x;
x += x < 0 ? 2 * ibuf->x : 0;
x = x >= ibuf->x ? 2 * ibuf->x - x - 1 : x;
y %= ibuf->y;
y += y < 0 ? ibuf->y : 0;
break;
2019-03-25 11:55:36 +11:00
case TXC_YMIR: /* x rep */
x %= ibuf->x;
x += x < 0 ? ibuf->x : 0;
2019-03-25 11:55:36 +11:00
y %= 2 * ibuf->y;
y += y < 0 ? 2 * ibuf->y : 0;
y = y >= ibuf->y ? 2 * ibuf->y - y - 1 : y;
break;
case TXC_EXTD:
x = (x < 0) ? 0 : ((x >= ibuf->x) ? (ibuf->x - 1) : x);
y = (y < 0) ? 0 : ((y >= ibuf->y) ? (ibuf->y - 1) : y);
break;
case TXC_REPT:
x %= ibuf->x;
x += (x < 0) ? ibuf->x : 0;
y %= ibuf->y;
y += (y < 0) ? ibuf->y : 0;
break;
2019-03-25 11:55:36 +11:00
default: { /* as extend, if clipped, set alpha to 0.0 */
2012-07-07 22:51:57 +00:00
if (x < 0) {
x = 0;
} /* TXF alpha: clip = 1; } */
if (x >= ibuf->x) {
x = ibuf->x - 1;
} /* TXF alpha: clip = 1; } */
if (y < 0) {
y = 0;
} /* TXF alpha: clip = 1; } */
if (y >= ibuf->y) {
y = ibuf->y - 1;
} /* TXF alpha: clip = 1; } */
}
}
if (ibuf->rect_float) {
2019-03-25 11:42:28 +11:00
const float *fp = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels;
2019-04-22 09:08:06 +10:00
if (ibuf->channels == 1) {
col[0] = col[1] = col[2] = col[3] = *fp;
2019-04-22 09:08:06 +10:00
}
else {
col[0] = fp[0];
col[1] = fp[1];
col[2] = fp[2];
col[3] = clip ? 0.0f : (ibuf->channels == 4 ? fp[3] : 1.0f);
}
}
else {
2019-03-25 11:55:36 +11:00
const char *rect = (char *)(ibuf->rect + x + y * ibuf->x);
Alpha premul pipeline cleanup This assumptions are now made: - Internally float buffers are always linear alpha-premul colors - Readers should worry about delivering float buffers with that assumptions. - There's an input image setting to say whether it's stored with straight/premul alpha on the disk. - Byte buffers are now assumed have straight alpha, readers should deliver straight alpha. Some implementation details: - Removed scene's color unpremultiply setting, which was very much confusing and was wrong for default settings. Now all renderers assumes to deliver premultiplied alpha. - IMB_buffer_byte_from_float will now linearize alpha when converting from buffer. - Sequencer's effects were changed to assume bytes have got straight alpha. Most of effects will work with bytes still, however for glow it was more tricky to avoid data loss, so there's a commented out glow implementation which converts byte buffer to floats first, operates on floats and returns bytes back. It's slower and not sure if it should actually be used -- who're using glow on alpha anyway? - Sequencer modifiers should also be working nice with straight bytes now. - GLSL preview will predivide float textures to make nice shading, shading with byte textures worked nice (GLSL was assuming straight alpha). - Blender Internal will set alpha=1 to the whole sky. The same happens in Cycles and there's no way to avoid this -- sky is neither straight nor premul and doesn't fit color pipeline well. - Straight alpha mode for render result was also eliminated. - Conversion to correct alpha need to be done before linearizing float buffer. - TIFF will now load and save files with proper alpha mode setting in file meta data header. - Remove Use Alpha from texture mapping and replaced with image datablock setting. Behaves much more predictable and clear from code point of view and solves possible regressions when non-premultiplied images were used as textures with ignoring alpha channel.
2012-12-31 13:52:13 +00:00
float inv_alpha_fac = (1.0f / 255.0f) * rect[3] * (1.0f / 255.0f);
col[0] = rect[0] * inv_alpha_fac;
col[1] = rect[1] * inv_alpha_fac;
col[2] = rect[2] * inv_alpha_fac;
col[3] = clip ? 0.0f : rect[3] * (1.0f / 255.0f);
}
return clip;
}
2012-07-07 22:51:57 +00:00
/* as above + bilerp */
static int ibuf_get_color_clip_bilerp(
float col[4], ImBuf *ibuf, float u, float v, int intpol, int extflag)
{
if (intpol) {
float c00[4], c01[4], c10[4], c11[4];
const float ufl = floorf(u -= 0.5f), vfl = floorf(v -= 0.5f);
const float uf = u - ufl, vf = v - vfl;
const float w00 = (1.0f - uf) * (1.0f - vf), w10 = uf * (1.0f - vf), w01 = (1.0f - uf) * vf,
2019-03-25 11:55:36 +11:00
w11 = uf * vf;
const int x1 = (int)ufl, y1 = (int)vfl, x2 = x1 + 1, y2 = y1 + 1;
int clip = ibuf_get_color_clip(c00, ibuf, x1, y1, extflag);
clip |= ibuf_get_color_clip(c10, ibuf, x2, y1, extflag);
clip |= ibuf_get_color_clip(c01, ibuf, x1, y2, extflag);
clip |= ibuf_get_color_clip(c11, ibuf, x2, y2, extflag);
2019-03-25 11:55:36 +11:00
col[0] = w00 * c00[0] + w10 * c10[0] + w01 * c01[0] + w11 * c11[0];
col[1] = w00 * c00[1] + w10 * c10[1] + w01 * c01[1] + w11 * c11[1];
col[2] = w00 * c00[2] + w10 * c10[2] + w01 * c01[2] + w11 * c11[2];
col[3] = clip ? 0.0f : w00 * c00[3] + w10 * c10[3] + w01 * c01[3] + w11 * c11[3];
return clip;
}
return ibuf_get_color_clip(col, ibuf, (int)u, (int)v, extflag);
}
2012-08-23 07:10:48 +00:00
static void area_sample(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD)
{
int xs, ys, clip = 0;
float tc[4], xsd, ysd, cw = 0.0f;
2019-03-25 11:55:36 +11:00
const float ux = ibuf->x * AFD->dxt[0], uy = ibuf->y * AFD->dxt[1];
const float vx = ibuf->x * AFD->dyt[0], vy = ibuf->y * AFD->dyt[1];
int xsam = (int)(0.5f * sqrtf(ux * ux + uy * uy) + 0.5f);
int ysam = (int)(0.5f * sqrtf(vx * vx + vy * vy) + 0.5f);
const int minsam = AFD->intpol ? 2 : 4;
2019-03-25 11:55:36 +11:00
xsam = CLAMPIS(xsam, minsam, ibuf->x * 2);
ysam = CLAMPIS(ysam, minsam, ibuf->y * 2);
xsd = 1.0f / xsam;
ysd = 1.0f / ysam;
texr->tr = texr->tg = texr->tb = texr->ta = 0.0f;
for (ys = 0; ys < ysam; ys++) {
for (xs = 0; xs < xsam; xs++) {
2019-03-25 11:55:36 +11:00
const float su = (xs + ((ys & 1) + 0.5f) * 0.5f) * xsd - 0.5f;
const float sv = (ys + ((xs & 1) + 0.5f) * 0.5f) * ysd - 0.5f;
const float pu = fx + su * AFD->dxt[0] + sv * AFD->dyt[0];
const float pv = fy + su * AFD->dxt[1] + sv * AFD->dyt[1];
const int out = ibuf_get_color_clip_bilerp(
tc, ibuf, pu * ibuf->x, pv * ibuf->y, AFD->intpol, AFD->extflag);
clip |= out;
cw += out ? 0.0f : 1.0f;
texr->tr += tc[0];
texr->tg += tc[1];
texr->tb += tc[2];
texr->ta += texr->talpha ? tc[3] : 0.0f;
}
}
xsd *= ysd;
texr->tr *= xsd;
texr->tg *= xsd;
texr->tb *= xsd;
2012-07-07 22:51:57 +00:00
/* clipping can be ignored if alpha used, texr->ta already includes filtered edge */
texr->ta = texr->talpha ? texr->ta * xsd : (clip ? cw * xsd : 1.0f);
}
typedef struct ReadEWAData {
ImBuf *ibuf;
afdata_t *AFD;
} ReadEWAData;
static void ewa_read_pixel_cb(void *userdata, int x, int y, float result[4])
{
2019-03-25 11:55:36 +11:00
ReadEWAData *data = (ReadEWAData *)userdata;
ibuf_get_color_clip(result, data->ibuf, x, y, data->AFD->extflag);
}
2012-08-23 07:10:48 +00:00
static void ewa_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD)
{
ReadEWAData data;
const float uv[2] = {fx, fy};
data.ibuf = ibuf;
data.AFD = AFD;
BLI_ewa_filter(ibuf->x,
ibuf->y,
AFD->intpol != 0,
texr->talpha,
uv,
AFD->dxt,
AFD->dyt,
ewa_read_pixel_cb,
&data,
&texr->tr);
}
2012-08-23 07:10:48 +00:00
static void feline_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD)
{
const int maxn = AFD->iProbes - 1;
const float ll = ((AFD->majrad == AFD->minrad) ? 2.0f * AFD->majrad :
2.0f * (AFD->majrad - AFD->minrad)) /
(maxn ? (float)maxn : 1.0f);
float du = maxn ? cosf(AFD->theta) * ll : 0.0f;
float dv = maxn ? sinf(AFD->theta) * ll : 0.0f;
2012-07-07 22:51:57 +00:00
/* const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); */
2019-03-25 11:55:36 +11:00
const float D = (EWA_MAXIDX + 1) * 0.25f * (du * du + dv * dv) / (AFD->majrad * AFD->majrad);
float d; /* TXF alpha: cw = 0.0f; */
2012-07-07 22:51:57 +00:00
int n; /* TXF alpha: clip = 0; */
/* have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.) */
du *= AFD->dusc;
dv *= AFD->dvsc;
d = texr->tr = texr->tb = texr->tg = texr->ta = 0.0f;
2019-03-25 11:55:36 +11:00
for (n = -maxn; n <= maxn; n += 2) {
float tc[4];
2019-03-25 11:55:36 +11:00
const float hn = n * 0.5f;
const float u = fx + hn * du, v = fy + hn * dv;
2019-04-18 07:21:26 +02:00
/* Can use ewa table here too. */
#if 0
const float wt = expf(n * n * D);
#else
2019-03-25 11:55:36 +11:00
const float wt = EWA_WTS[(int)(n * n * D)];
2019-04-18 07:21:26 +02:00
#endif
2019-03-25 11:55:36 +11:00
/*const int out =*/ibuf_get_color_clip_bilerp(
tc, ibuf, ibuf->x * u, ibuf->y * v, AFD->intpol, AFD->extflag);
2012-07-07 22:51:57 +00:00
/* TXF alpha: clip |= out;
* TXF alpha: cw += out ? 0.0f : wt; */
2019-03-25 11:55:36 +11:00
texr->tr += tc[0] * wt;
texr->tg += tc[1] * wt;
texr->tb += tc[2] * wt;
texr->ta += texr->talpha ? tc[3] * wt : 0.0f;
d += wt;
}
d = 1.0f / d;
texr->tr *= d;
texr->tg *= d;
texr->tb *= d;
2012-07-07 22:51:57 +00:00
/* clipping can be ignored if alpha used, texr->ta already includes filtered edge */
texr->ta = texr->talpha ? texr->ta * d : 1.0f; // TXF alpha: (clip ? cw*d : 1.0f);
}
#undef EWA_MAXIDX
static void alpha_clip_aniso(
ImBuf *ibuf, float minx, float miny, float maxx, float maxy, int extflag, TexResult *texres)
{
float alphaclip;
rctf rf;
2019-08-04 12:51:44 +10:00
/* TXF alpha: we're doing the same alpha-clip here as box-sample, but I'm doubting
2012-07-07 22:51:57 +00:00
* if this is actually correct for the all the filtering algorithms .. */
if (!(extflag == TXC_REPT || extflag == TXC_EXTD)) {
2019-03-25 11:55:36 +11:00
rf.xmin = minx * (ibuf->x);
rf.xmax = maxx * (ibuf->x);
rf.ymin = miny * (ibuf->y);
rf.ymax = maxy * (ibuf->y);
alphaclip = clipx_rctf(&rf, 0.0, (float)(ibuf->x));
alphaclip *= clipy_rctf(&rf, 0.0, (float)(ibuf->y));
alphaclip = max_ff(alphaclip, 0.0f);
2019-03-25 11:55:36 +11:00
if (alphaclip != 1.0f) {
/* premul it all */
2019-03-25 11:55:36 +11:00
texres->tr *= alphaclip;
texres->tg *= alphaclip;
texres->tb *= alphaclip;
texres->ta *= alphaclip;
}
}
}
static void image_mipmap_test(Tex *tex, ImBuf *ibuf)
{
if (tex->imaflag & TEX_MIPMAP) {
if (ibuf->mipmap[0] && (ibuf->userflags & IB_MIPMAP_INVALID)) {
BLI_thread_lock(LOCK_IMAGE);
if (ibuf->userflags & IB_MIPMAP_INVALID) {
IMB_remakemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
ibuf->userflags &= ~IB_MIPMAP_INVALID;
2013-02-13 05:07:46 +00:00
}
BLI_thread_unlock(LOCK_IMAGE);
}
if (ibuf->mipmap[0] == NULL) {
BLI_thread_lock(LOCK_IMAGE);
2019-04-22 09:08:06 +10:00
if (ibuf->mipmap[0] == NULL) {
IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
2019-04-22 09:08:06 +10:00
}
BLI_thread_unlock(LOCK_IMAGE);
}
/* if no mipmap could be made, fall back on non-mipmap render */
if (ibuf->mipmap[0] == NULL) {
tex->imaflag &= ~TEX_MIPMAP;
}
}
}
static int imagewraposa_aniso(Tex *tex,
Image *ima,
ImBuf *ibuf,
const float texvec[3],
float dxt[2],
float dyt[2],
TexResult *texres,
struct ImagePool *pool,
const bool skip_load_image)
{
TexResult texr;
float fx, fy, minx, maxx, miny, maxy;
float maxd, val1, val2, val3;
int curmap, retval, intpol, extflag = 0;
afdata_t AFD;
2019-03-25 11:55:36 +11:00
void (*filterfunc)(TexResult *, ImBuf *, float, float, afdata_t *);
switch (tex->texfilter) {
case TXF_EWA:
filterfunc = ewa_eval;
break;
case TXF_FELINE:
filterfunc = feline_eval;
break;
case TXF_AREA:
default:
filterfunc = area_sample;
}
texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.0f;
2012-07-07 22:51:57 +00:00
/* we need to set retval OK, otherwise texture code generates normals itself... */
retval = texres->nor ? (TEX_RGB | TEX_NOR) : TEX_RGB;
2012-07-07 22:51:57 +00:00
/* quick tests */
2019-04-22 09:08:06 +10:00
if (ibuf == NULL && ima == NULL) {
2019-03-25 11:55:36 +11:00
return retval;
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
if (ima) { /* hack for icon render */
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) {
Image cache rewrite to using generic movie cache Summary: Behaves very much the same as cache for Movie Clip datablock: - Image now have `MovieCache *cache` field which replaced legacy `ListBase ibufs`. This allows image datablock to easily keep of image buffers which are owned by itself. This field isn't saved to the file and getting restored on undo steps. However, cache limit is global for movies, sequences and image datablocks now. So overall cached image buffers size will not go above cache limit size in user preferences. - Image buffers which are marked as BITMAPDIRTY will never be freed from the cache. - Added utility function to iterate over image buffers saved in movie cache. - Movie cache cleanup check callback now have ImBuf argument which can be used in a condition of cleanup. - Added some utility functions which replaces legacy ibufs iterations with image cache iteration which happens from inside a lock. - Fixed `image_mem_size()` which was only counting one of the buffers if both float and byte buffer present. Additional notes: - `BKE_image_get_first_ibuf()` is rather stupid, but direct access to ibufs->first was also the same stupid idea. Would consider avoid this function is another project. - There are some places which doesn't look threadsafe, but they already were not so much threadsafe anyway before. So think not a big deal with solving this later. Finally solves infinite memory usage by image sequences! :) Reviewers: brecht, campbellbarton Reviewed By: brecht CC: sebastian_k Differential Revision: http://developer.blender.org/D95
2013-12-13 16:22:08 +06:00
return retval;
}
ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, pool);
}
if ((ibuf == NULL) || ((ibuf->rect == NULL) && (ibuf->rect_float == NULL))) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
if (ima) {
ima->flag |= IMA_USED_FOR_RENDER;
}
/* mipmap test */
image_mipmap_test(tex, ibuf);
if (ima) {
if ((tex->imaflag & TEX_USEALPHA) && (ima->alpha_mode != IMA_ALPHA_IGNORE)) {
if ((tex->imaflag & TEX_CALCALPHA) == 0) {
texres->talpha = 1;
}
}
}
texr.talpha = texres->talpha;
if (tex->imaflag & TEX_IMAROT) {
fy = texvec[0];
fx = texvec[1];
}
else {
fx = texvec[0];
fy = texvec[1];
}
2012-07-07 22:51:57 +00:00
/* pixel coordinates */
minx = min_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
maxx = max_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
miny = min_fff(dxt[1], dyt[1], dxt[1] + dyt[1]);
maxy = max_fff(dxt[1], dyt[1], dxt[1] + dyt[1]);
2012-07-07 22:51:57 +00:00
/* tex_sharper has been removed */
2019-03-25 11:55:36 +11:00
minx = (maxx - minx) * 0.5f;
miny = (maxy - miny) * 0.5f;
if (tex->imaflag & TEX_FILTER_MIN) {
/* Make sure the filtersize is minimal in pixels
* (normal, ref map can have miniature pixel dx/dy). */
const float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y);
2019-04-22 09:08:06 +10:00
if (addval > minx) {
minx = addval;
2019-04-22 09:08:06 +10:00
}
if (addval > miny) {
miny = addval;
2019-04-22 09:08:06 +10:00
}
}
else if (tex->filtersize != 1.0f) {
minx *= tex->filtersize;
miny *= tex->filtersize;
dxt[0] *= tex->filtersize;
dxt[1] *= tex->filtersize;
dyt[0] *= tex->filtersize;
dyt[1] *= tex->filtersize;
}
if (tex->imaflag & TEX_IMAROT) {
float t;
SWAP(float, minx, miny);
2012-07-07 22:51:57 +00:00
/* must rotate dxt/dyt 90 deg
2020-11-12 11:35:31 +11:00
* yet another blender problem is that swapping X/Y axes (or any tex projection switches)
* should do something similar, but it doesn't, it only swaps coords,
* so filter area will be incorrect in those cases. */
t = dxt[0];
dxt[0] = dxt[1];
dxt[1] = -t;
t = dyt[0];
dyt[0] = dyt[1];
dyt[1] = -t;
}
2012-07-07 22:51:57 +00:00
/* side faces of unit-cube */
minx = (minx > 0.25f) ? 0.25f : ((minx < 1e-5f) ? 1e-5f : minx);
miny = (miny > 0.25f) ? 0.25f : ((miny < 1e-5f) ? 1e-5f : miny);
2012-07-07 22:51:57 +00:00
/* repeat and clip */
if (tex->extend == TEX_REPEAT) {
2019-04-22 09:08:06 +10:00
if ((tex->flag & (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) == (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) {
extflag = TXC_EXTD;
2019-04-22 09:08:06 +10:00
}
else if (tex->flag & TEX_REPEAT_XMIR) {
extflag = TXC_XMIR;
2019-04-22 09:08:06 +10:00
}
else if (tex->flag & TEX_REPEAT_YMIR) {
extflag = TXC_YMIR;
2019-04-22 09:08:06 +10:00
}
else {
extflag = TXC_REPT;
2019-04-22 09:08:06 +10:00
}
}
2019-04-22 09:08:06 +10:00
else if (tex->extend == TEX_EXTEND) {
extflag = TXC_EXTD;
2019-04-22 09:08:06 +10:00
}
if (tex->extend == TEX_CHECKER) {
int xs = (int)floorf(fx), ys = (int)floorf(fy);
2012-07-07 22:51:57 +00:00
/* both checkers available, no boundary exceptions, checkerdist will eat aliasing */
if ((tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN)) {
fx -= xs;
fy -= ys;
}
else if ((tex->flag & TEX_CHECKER_ODD) == 0 && (tex->flag & TEX_CHECKER_EVEN) == 0) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
else {
int xs1 = (int)floorf(fx - minx);
int ys1 = (int)floorf(fy - miny);
int xs2 = (int)floorf(fx + minx);
int ys2 = (int)floorf(fy + miny);
if ((xs1 != xs2) || (ys1 != ys2)) {
if (tex->flag & TEX_CHECKER_ODD) {
fx -= ((xs1 + ys) & 1) ? xs2 : xs1;
fy -= ((ys1 + xs) & 1) ? ys2 : ys1;
}
if (tex->flag & TEX_CHECKER_EVEN) {
fx -= ((xs1 + ys) & 1) ? xs1 : xs2;
fy -= ((ys1 + xs) & 1) ? ys1 : ys2;
}
}
else {
if ((tex->flag & TEX_CHECKER_ODD) == 0 && ((xs + ys) & 1) == 0) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
if ((tex->flag & TEX_CHECKER_EVEN) == 0 && (xs + ys) & 1) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
fx -= xs;
fy -= ys;
}
}
2012-07-07 22:51:57 +00:00
/* scale around center, (0.5, 0.5) */
if (tex->checkerdist < 1.0f) {
const float omcd = 1.0f / (1.0f - tex->checkerdist);
2019-03-25 11:55:36 +11:00
fx = (fx - 0.5f) * omcd + 0.5f;
fy = (fy - 0.5f) * omcd + 0.5f;
minx *= omcd;
miny *= omcd;
}
}
if (tex->extend == TEX_CLIPCUBE) {
if ((fx + minx) < 0.0f || (fy + miny) < 0.0f || (fx - minx) > 1.0f || (fy - miny) > 1.0f ||
texvec[2] < -1.0f || texvec[2] > 1.0f) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
}
2020-11-06 12:30:59 +11:00
else if (ELEM(tex->extend, TEX_CLIP, TEX_CHECKER)) {
if ((fx + minx) < 0.0f || (fy + miny) < 0.0f || (fx - minx) > 1.0f || (fy - miny) > 1.0f) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
}
else {
if (tex->extend == TEX_EXTEND) {
fx = (fx > 1.0f) ? 1.0f : ((fx < 0.0f) ? 0.0f : fx);
fy = (fy > 1.0f) ? 1.0f : ((fy < 0.0f) ? 0.0f : fy);
}
else {
fx -= floorf(fx);
fy -= floorf(fy);
}
}
intpol = tex->imaflag & TEX_INTERPOL;
2012-07-07 22:51:57 +00:00
/* struct common data */
copy_v2_v2(AFD.dxt, dxt);
copy_v2_v2(AFD.dyt, dyt);
AFD.intpol = intpol;
AFD.extflag = extflag;
2012-07-07 22:51:57 +00:00
/* brecht: added stupid clamping here, large dx/dy can give very large
* filter sizes which take ages to render, it may be better to do this
* more intelligently later in the code .. probably it's not noticeable */
2019-04-22 09:08:06 +10:00
if (AFD.dxt[0] * AFD.dxt[0] + AFD.dxt[1] * AFD.dxt[1] > 2.0f * 2.0f) {
2019-03-25 11:55:36 +11:00
mul_v2_fl(AFD.dxt, 2.0f / len_v2(AFD.dxt));
2019-04-22 09:08:06 +10:00
}
if (AFD.dyt[0] * AFD.dyt[0] + AFD.dyt[1] * AFD.dyt[1] > 2.0f * 2.0f) {
2019-03-25 11:55:36 +11:00
mul_v2_fl(AFD.dyt, 2.0f / len_v2(AFD.dyt));
2019-04-22 09:08:06 +10:00
}
2012-07-07 22:51:57 +00:00
/* choice: */
if (tex->imaflag & TEX_MIPMAP) {
ImBuf *previbuf, *curibuf;
float levf;
int maxlev;
2015-07-13 22:00:07 +10:00
ImBuf *mipmaps[IMB_MIPMAP_LEVELS + 1];
2020-11-12 11:35:31 +11:00
/* Modify ellipse minor axis if too eccentric, use for area sampling as well
* scaling `dxt/dyt` as done in PBRT is not the same
* (as in `ewa_eval()`, scale by `sqrt(ibuf->x)` to maximize precision). */
2019-03-25 11:55:36 +11:00
const float ff = sqrtf(ibuf->x), q = ibuf->y / ff;
const float Ux = dxt[0] * ff, Vx = dxt[1] * q, Uy = dyt[0] * ff, Vy = dyt[1] * q;
const float A = Vx * Vx + Vy * Vy;
const float B = -2.0f * (Ux * Vx + Uy * Vy);
2019-03-25 11:55:36 +11:00
const float C = Ux * Ux + Uy * Uy;
const float F = A * C - B * B * 0.25f;
float a, b, th, ecc;
BLI_ewa_imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
if (tex->texfilter == TXF_FELINE) {
float fProbes;
a *= ff;
b *= ff;
a = max_ff(a, 1.0f);
b = max_ff(b, 1.0f);
fProbes = 2.0f * (a / b) - 1.0f;
AFD.iProbes = round_fl_to_int(fProbes);
AFD.iProbes = MIN2(AFD.iProbes, tex->afmax);
2019-04-22 09:08:06 +10:00
if (AFD.iProbes < fProbes) {
b = 2.0f * a / (float)(AFD.iProbes + 1);
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
AFD.majrad = a / ff;
AFD.minrad = b / ff;
AFD.theta = th;
AFD.dusc = 1.0f / ff;
AFD.dvsc = ff / (float)ibuf->y;
}
2019-03-25 11:55:36 +11:00
else { /* EWA & area */
2019-04-22 09:08:06 +10:00
if (ecc > (float)tex->afmax) {
b = a / (float)tex->afmax;
2019-04-22 09:08:06 +10:00
}
b *= ff;
}
maxd = max_ff(b, 1e-8f);
levf = ((float)M_LOG2E) * logf(maxd);
curmap = 0;
maxlev = 1;
mipmaps[0] = ibuf;
2015-07-13 22:00:07 +10:00
while (curmap < IMB_MIPMAP_LEVELS) {
mipmaps[curmap + 1] = ibuf->mipmap[curmap];
2019-04-22 09:08:06 +10:00
if (ibuf->mipmap[curmap]) {
maxlev++;
2019-04-22 09:08:06 +10:00
}
curmap++;
}
2012-07-07 22:51:57 +00:00
/* mipmap level */
if (levf < 0.0f) { /* original image only */
previbuf = curibuf = mipmaps[0];
levf = 0.0f;
}
else if (levf >= maxlev - 1) {
previbuf = curibuf = mipmaps[maxlev - 1];
levf = 0.0f;
2019-04-22 09:08:06 +10:00
if (tex->texfilter == TXF_FELINE) {
AFD.iProbes = 1;
2019-04-22 09:08:06 +10:00
}
}
else {
const int lev = isnan(levf) ? 0 : (int)levf;
curibuf = mipmaps[lev];
previbuf = mipmaps[lev + 1];
levf -= floorf(levf);
}
2012-07-07 22:51:57 +00:00
/* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */
if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) {
2012-07-07 22:51:57 +00:00
/* color & normal */
filterfunc(texres, curibuf, fx, fy, &AFD);
val1 = texres->tr + texres->tg + texres->tb;
filterfunc(&texr, curibuf, fx + dxt[0], fy + dxt[1], &AFD);
val2 = texr.tr + texr.tg + texr.tb;
filterfunc(&texr, curibuf, fx + dyt[0], fy + dyt[1], &AFD);
val3 = texr.tr + texr.tg + texr.tb;
2012-07-07 22:51:57 +00:00
/* don't switch x or y! */
texres->nor[0] = val1 - val2;
texres->nor[1] = val1 - val3;
2012-07-07 22:51:57 +00:00
if (previbuf != curibuf) { /* interpolate */
filterfunc(&texr, previbuf, fx, fy, &AFD);
2012-07-07 22:51:57 +00:00
/* rgb */
2019-03-25 11:55:36 +11:00
texres->tr += levf * (texr.tr - texres->tr);
texres->tg += levf * (texr.tg - texres->tg);
texres->tb += levf * (texr.tb - texres->tb);
texres->ta += levf * (texr.ta - texres->ta);
2012-07-07 22:51:57 +00:00
/* normal */
2019-03-25 11:55:36 +11:00
val1 += levf * ((texr.tr + texr.tg + texr.tb) - val1);
filterfunc(&texr, previbuf, fx + dxt[0], fy + dxt[1], &AFD);
2019-03-25 11:55:36 +11:00
val2 += levf * ((texr.tr + texr.tg + texr.tb) - val2);
filterfunc(&texr, previbuf, fx + dyt[0], fy + dyt[1], &AFD);
2019-03-25 11:55:36 +11:00
val3 += levf * ((texr.tr + texr.tg + texr.tb) - val3);
2012-07-07 22:51:57 +00:00
texres->nor[0] = val1 - val2; /* vals have been interpolated above! */
texres->nor[1] = val1 - val3;
}
}
2012-07-07 22:51:57 +00:00
else { /* color */
filterfunc(texres, curibuf, fx, fy, &AFD);
2012-07-07 22:51:57 +00:00
if (previbuf != curibuf) { /* interpolate */
filterfunc(&texr, previbuf, fx, fy, &AFD);
2019-03-25 11:55:36 +11:00
texres->tr += levf * (texr.tr - texres->tr);
texres->tg += levf * (texr.tg - texres->tg);
texres->tb += levf * (texr.tb - texres->tb);
texres->ta += levf * (texr.ta - texres->ta);
}
if (tex->texfilter != TXF_EWA) {
2019-03-25 11:55:36 +11:00
alpha_clip_aniso(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, extflag, texres);
}
}
}
2019-03-25 11:55:36 +11:00
else { /* no mipmap */
2012-07-07 22:51:57 +00:00
/* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */
if (tex->texfilter == TXF_FELINE) {
2019-03-25 11:55:36 +11:00
const float ff = sqrtf(ibuf->x), q = ibuf->y / ff;
const float Ux = dxt[0] * ff, Vx = dxt[1] * q, Uy = dyt[0] * ff, Vy = dyt[1] * q;
const float A = Vx * Vx + Vy * Vy;
const float B = -2.0f * (Ux * Vx + Uy * Vy);
2019-03-25 11:55:36 +11:00
const float C = Ux * Ux + Uy * Uy;
const float F = A * C - B * B * 0.25f;
float a, b, th, ecc, fProbes;
BLI_ewa_imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
a *= ff;
b *= ff;
a = max_ff(a, 1.0f);
b = max_ff(b, 1.0f);
fProbes = 2.0f * (a / b) - 1.0f;
2012-07-07 22:51:57 +00:00
/* no limit to number of Probes here */
AFD.iProbes = round_fl_to_int(fProbes);
2019-04-22 09:08:06 +10:00
if (AFD.iProbes < fProbes) {
b = 2.0f * a / (float)(AFD.iProbes + 1);
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
AFD.majrad = a / ff;
AFD.minrad = b / ff;
AFD.theta = th;
AFD.dusc = 1.0f / ff;
AFD.dvsc = ff / (float)ibuf->y;
}
if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) {
2012-07-07 22:51:57 +00:00
/* color & normal */
filterfunc(texres, ibuf, fx, fy, &AFD);
val1 = texres->tr + texres->tg + texres->tb;
filterfunc(&texr, ibuf, fx + dxt[0], fy + dxt[1], &AFD);
val2 = texr.tr + texr.tg + texr.tb;
filterfunc(&texr, ibuf, fx + dyt[0], fy + dyt[1], &AFD);
val3 = texr.tr + texr.tg + texr.tb;
2012-07-07 22:51:57 +00:00
/* don't switch x or y! */
texres->nor[0] = val1 - val2;
texres->nor[1] = val1 - val3;
}
else {
filterfunc(texres, ibuf, fx, fy, &AFD);
if (tex->texfilter != TXF_EWA) {
2019-03-25 11:55:36 +11:00
alpha_clip_aniso(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, extflag, texres);
}
}
}
2019-04-22 09:08:06 +10:00
if (tex->imaflag & TEX_CALCALPHA) {
texres->ta = texres->tin = texres->ta * max_fff(texres->tr, texres->tg, texres->tb);
2019-04-22 09:08:06 +10:00
}
else {
texres->tin = texres->ta;
2019-04-22 09:08:06 +10:00
}
if (tex->flag & TEX_NEGALPHA) {
texres->ta = 1.0f - texres->ta;
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */
2012-07-07 22:51:57 +00:00
/* The invert of the red channel is to make
* the normal map compliant with the outside world.
* It needs to be done because in Blender
* the normal used in the renderer points inward. It is generated
* this way in calc_vertexnormals(). Should this ever change
* this negate must be removed. */
texres->nor[0] = -2.0f * (texres->tr - 0.5f);
texres->nor[1] = 2.0f * (texres->tg - 0.5f);
texres->nor[2] = 2.0f * (texres->tb - 0.5f);
}
2020-11-16 16:48:41 +11:00
/* de-premul, this is being pre-multiplied in shade_input_do_shade()
* TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode,
* so for now commented out also disabled in imagewraposa()
* to be able to compare results with blender's default texture filtering */
2012-07-07 22:51:57 +00:00
/* brecht: tried to fix this, see "TXF alpha" comments */
/* do not de-premul for generated alpha, it is already in straight */
2019-03-25 11:55:36 +11:00
if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
fx = 1.0f / texres->ta;
texres->tr *= fx;
texres->tg *= fx;
texres->tb *= fx;
}
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
BRICONTRGB;
return retval;
}
int imagewraposa(Tex *tex,
Image *ima,
ImBuf *ibuf,
const float texvec[3],
const float DXT[2],
const float DYT[2],
TexResult *texres,
struct ImagePool *pool,
const bool skip_load_image)
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
{
TexResult texr;
float fx, fy, minx, maxx, miny, maxy, dx, dy, dxt[2], dyt[2];
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
float maxd, pixsize, val1, val2, val3;
int curmap, retval, imaprepeat, imapextend;
/* TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa()
* call, make a local copy here so that original vecs remain untouched. */
copy_v2_v2(dxt, DXT);
copy_v2_v2(dyt, DYT);
2012-07-07 22:51:57 +00:00
/* anisotropic filtering */
2019-04-22 09:08:06 +10:00
if (tex->texfilter != TXF_BOX) {
return imagewraposa_aniso(tex, ima, ibuf, texvec, dxt, dyt, texres, pool, skip_load_image);
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.0f;
/* we need to set retval OK, otherwise texture code generates normals itself... */
retval = texres->nor ? (TEX_RGB | TEX_NOR) : TEX_RGB;
/* quick tests */
2019-04-22 09:08:06 +10:00
if (ibuf == NULL && ima == NULL) {
return retval;
2019-04-22 09:08:06 +10:00
}
if (ima) {
/* hack for icon render */
2019-04-22 09:08:06 +10:00
if (skip_load_image && !BKE_image_has_loaded_ibuf(ima)) {
return retval;
2019-04-22 09:08:06 +10:00
}
ibuf = BKE_image_pool_acquire_ibuf(ima, &tex->iuser, pool);
2019-03-25 11:55:36 +11:00
ima->flag |= IMA_USED_FOR_RENDER;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2019-03-25 11:55:36 +11:00
if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
/* mipmap test */
image_mipmap_test(tex, ibuf);
if (ima) {
if ((tex->imaflag & TEX_USEALPHA) && (ima->alpha_mode != IMA_ALPHA_IGNORE)) {
if ((tex->imaflag & TEX_CALCALPHA) == 0) {
texres->talpha = true;
}
}
}
2019-03-25 11:55:36 +11:00
texr.talpha = texres->talpha;
if (tex->imaflag & TEX_IMAROT) {
2019-03-25 11:55:36 +11:00
fy = texvec[0];
fx = texvec[1];
}
else {
2019-03-25 11:55:36 +11:00
fx = texvec[0];
fy = texvec[1];
}
/* pixel coordinates */
minx = min_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
maxx = max_fff(dxt[0], dyt[0], dxt[0] + dyt[0]);
miny = min_fff(dxt[1], dyt[1], dxt[1] + dyt[1]);
maxy = max_fff(dxt[1], dyt[1], dxt[1] + dyt[1]);
/* tex_sharper has been removed */
minx = (maxx - minx) / 2.0f;
2019-03-25 11:55:36 +11:00
miny = (maxy - miny) / 2.0f;
if (tex->imaflag & TEX_FILTER_MIN) {
/* Make sure the filtersize is minimal in pixels
* (normal, ref map can have miniature pixel dx/dy). */
2019-03-25 11:55:36 +11:00
float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y);
2019-04-22 09:08:06 +10:00
if (addval > minx) {
2019-03-25 11:55:36 +11:00
minx = addval;
2019-04-22 09:08:06 +10:00
}
if (addval > miny) {
2019-03-25 11:55:36 +11:00
miny = addval;
2019-04-22 09:08:06 +10:00
}
}
2019-03-25 11:55:36 +11:00
else if (tex->filtersize != 1.0f) {
minx *= tex->filtersize;
2019-03-25 11:55:36 +11:00
miny *= tex->filtersize;
2019-03-25 11:55:36 +11:00
dxt[0] *= tex->filtersize;
dxt[1] *= tex->filtersize;
dyt[0] *= tex->filtersize;
dyt[1] *= tex->filtersize;
}
2019-04-22 09:08:06 +10:00
if (tex->imaflag & TEX_IMAROT) {
SWAP(float, minx, miny);
2019-04-22 09:08:06 +10:00
}
2019-04-22 09:08:06 +10:00
if (minx > 0.25f) {
minx = 0.25f;
2019-04-22 09:08:06 +10:00
}
else if (minx < 0.00001f) {
minx = 0.00001f; /* side faces of unit-cube */
2019-04-22 09:08:06 +10:00
}
if (miny > 0.25f) {
2019-03-25 11:55:36 +11:00
miny = 0.25f;
2019-04-22 09:08:06 +10:00
}
else if (miny < 0.00001f) {
2019-03-25 11:55:36 +11:00
miny = 0.00001f;
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
/* repeat and clip */
imaprepeat = (tex->extend == TEX_REPEAT);
imapextend = (tex->extend == TEX_EXTEND);
2019-03-25 11:55:36 +11:00
if (tex->extend == TEX_REPEAT) {
if (tex->flag & (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) {
2019-03-25 11:55:36 +11:00
imaprepeat = 0;
imapextend = 1;
}
}
if (tex->extend == TEX_CHECKER) {
2019-03-25 11:55:36 +11:00
int xs, ys, xs1, ys1, xs2, ys2, boundary;
2019-03-25 11:55:36 +11:00
xs = (int)floor(fx);
ys = (int)floor(fy);
/* both checkers available, no boundary exceptions, checkerdist will eat aliasing */
2019-03-25 11:55:36 +11:00
if ((tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN)) {
fx -= xs;
fy -= ys;
}
else if ((tex->flag & TEX_CHECKER_ODD) == 0 && (tex->flag & TEX_CHECKER_EVEN) == 0) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
else {
xs1 = (int)floor(fx - minx);
ys1 = (int)floor(fy - miny);
xs2 = (int)floor(fx + minx);
ys2 = (int)floor(fy + miny);
boundary = (xs1 != xs2) || (ys1 != ys2);
2012-07-07 22:51:57 +00:00
if (boundary == 0) {
if ((tex->flag & TEX_CHECKER_ODD) == 0) {
if ((xs + ys) & 1) {
2012-10-07 09:48:59 +00:00
/* pass */
}
else {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
}
if ((tex->flag & TEX_CHECKER_EVEN) == 0) {
if ((xs + ys) & 1) {
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
}
}
2019-03-25 11:55:36 +11:00
fx -= xs;
fy -= ys;
}
else {
2019-03-25 11:55:36 +11:00
if (tex->flag & TEX_CHECKER_ODD) {
2019-04-22 09:08:06 +10:00
if ((xs1 + ys) & 1) {
2019-03-25 11:55:36 +11:00
fx -= xs2;
2019-04-22 09:08:06 +10:00
}
else {
2019-03-25 11:55:36 +11:00
fx -= xs1;
2019-04-22 09:08:06 +10:00
}
2019-04-22 09:08:06 +10:00
if ((ys1 + xs) & 1) {
2019-03-25 11:55:36 +11:00
fy -= ys2;
2019-04-22 09:08:06 +10:00
}
else {
fy -= ys1;
2019-04-22 09:08:06 +10:00
}
2012-10-07 09:48:59 +00:00
}
2019-03-25 11:55:36 +11:00
if (tex->flag & TEX_CHECKER_EVEN) {
2019-04-22 09:08:06 +10:00
if ((xs1 + ys) & 1) {
fx -= xs1;
2019-04-22 09:08:06 +10:00
}
else {
2019-03-25 11:55:36 +11:00
fx -= xs2;
2019-04-22 09:08:06 +10:00
}
2019-04-22 09:08:06 +10:00
if ((ys1 + xs) & 1) {
2019-03-25 11:55:36 +11:00
fy -= ys1;
2019-04-22 09:08:06 +10:00
}
else {
2019-03-25 11:55:36 +11:00
fy -= ys2;
2019-04-22 09:08:06 +10:00
}
}
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
/* scale around center, (0.5, 0.5) */
if (tex->checkerdist < 1.0f) {
2019-03-25 11:55:36 +11:00
fx = (fx - 0.5f) / (1.0f - tex->checkerdist) + 0.5f;
fy = (fy - 0.5f) / (1.0f - tex->checkerdist) + 0.5f;
minx /= (1.0f - tex->checkerdist);
miny /= (1.0f - tex->checkerdist);
}
}
2019-03-25 11:55:36 +11:00
if (tex->extend == TEX_CLIPCUBE) {
if (fx + minx < 0.0f || fy + miny < 0.0f || fx - minx > 1.0f || fy - miny > 1.0f ||
texvec[2] < -1.0f || texvec[2] > 1.0f) {
2019-04-22 09:08:06 +10:00
if (ima) {
2019-03-25 11:55:36 +11:00
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
return retval;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
}
2020-11-06 12:30:59 +11:00
else if (ELEM(tex->extend, TEX_CLIP, TEX_CHECKER)) {
2019-03-25 11:55:36 +11:00
if (fx + minx < 0.0f || fy + miny < 0.0f || fx - minx > 1.0f || fy - miny > 1.0f) {
2019-04-22 09:08:06 +10:00
if (ima) {
2019-03-25 11:55:36 +11:00
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
return retval;
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
if (imapextend) {
2019-04-22 09:08:06 +10:00
if (fx > 1.0f) {
2019-03-25 11:55:36 +11:00
fx = 1.0f;
2019-04-22 09:08:06 +10:00
}
else if (fx < 0.0f) {
2019-03-25 11:55:36 +11:00
fx = 0.0f;
2019-04-22 09:08:06 +10:00
}
}
2019-03-25 11:55:36 +11:00
else {
2019-04-22 09:08:06 +10:00
if (fx > 1.0f) {
2019-03-25 11:55:36 +11:00
fx -= (int)(fx);
2019-04-22 09:08:06 +10:00
}
else if (fx < 0.0f) {
2019-03-25 11:55:36 +11:00
fx += 1 - (int)(fx);
2019-04-22 09:08:06 +10:00
}
}
2019-03-25 11:55:36 +11:00
if (imapextend) {
2019-04-22 09:08:06 +10:00
if (fy > 1.0f) {
2019-03-25 11:55:36 +11:00
fy = 1.0f;
2019-04-22 09:08:06 +10:00
}
else if (fy < 0.0f) {
2019-03-25 11:55:36 +11:00
fy = 0.0f;
2019-04-22 09:08:06 +10:00
}
}
else {
2019-04-22 09:08:06 +10:00
if (fy > 1.0f) {
2019-03-25 11:55:36 +11:00
fy -= (int)(fy);
2019-04-22 09:08:06 +10:00
}
else if (fy < 0.0f) {
2019-03-25 11:55:36 +11:00
fy += 1 - (int)(fy);
2019-04-22 09:08:06 +10:00
}
}
}
2019-03-25 11:55:36 +11:00
/* choice: */
if (tex->imaflag & TEX_MIPMAP) {
ImBuf *previbuf, *curibuf;
float bumpscale;
dx = minx;
dy = miny;
maxd = max_ff(dx, dy);
2019-04-22 09:08:06 +10:00
if (maxd > 0.5f) {
2019-03-25 11:55:36 +11:00
maxd = 0.5f;
2019-04-22 09:08:06 +10:00
}
2019-03-25 11:55:36 +11:00
pixsize = 1.0f / (float)MIN2(ibuf->x, ibuf->y);
2019-03-25 11:55:36 +11:00
bumpscale = pixsize / maxd;
2019-04-22 09:08:06 +10:00
if (bumpscale > 1.0f) {
2019-03-25 11:55:36 +11:00
bumpscale = 1.0f;
2019-04-22 09:08:06 +10:00
}
else {
bumpscale *= bumpscale;
2019-04-22 09:08:06 +10:00
}
curmap = 0;
previbuf = curibuf = ibuf;
while (curmap < IMB_MIPMAP_LEVELS && ibuf->mipmap[curmap]) {
2019-04-22 09:08:06 +10:00
if (maxd < pixsize) {
break;
2019-04-22 09:08:06 +10:00
}
previbuf = curibuf;
curibuf = ibuf->mipmap[curmap];
2019-03-25 11:55:36 +11:00
pixsize = 1.0f / (float)MIN2(curibuf->x, curibuf->y);
curmap++;
}
2019-03-25 11:55:36 +11:00
if (previbuf != curibuf || (tex->imaflag & TEX_INTERPOL)) {
/* sample at least 1 pixel */
2019-04-22 09:08:06 +10:00
if (minx < 0.5f / ibuf->x) {
2019-03-25 11:55:36 +11:00
minx = 0.5f / ibuf->x;
2019-04-22 09:08:06 +10:00
}
if (miny < 0.5f / ibuf->y) {
2015-07-13 22:00:07 +10:00
miny = 0.5f / ibuf->y;
2019-04-22 09:08:06 +10:00
}
}
2015-07-13 22:00:07 +10:00
if (texres->nor && (tex->imaflag & TEX_NORMALMAP) == 0) {
/* a bit extra filter */
// minx*= 1.35f;
// miny*= 1.35f;
2019-03-25 11:55:36 +11:00
boxsample(
curibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend);
val1 = texres->tr + texres->tg + texres->tb;
boxsample(curibuf,
fx - minx + dxt[0],
2019-03-25 11:55:36 +11:00
fy - miny + dxt[1],
fx + minx + dxt[0],
fy + miny + dxt[1],
2019-03-25 11:55:36 +11:00
&texr,
imaprepeat,
imapextend);
val2 = texr.tr + texr.tg + texr.tb;
boxsample(curibuf,
2019-03-25 11:55:36 +11:00
fx - minx + dyt[0],
fy - miny + dyt[1],
fx + minx + dyt[0],
fy + miny + dyt[1],
&texr,
imaprepeat,
imapextend);
val3 = texr.tr + texr.tg + texr.tb;
/* don't switch x or y! */
2019-03-25 11:55:36 +11:00
texres->nor[0] = (val1 - val2);
texres->nor[1] = (val1 - val3);
2019-03-25 11:55:36 +11:00
if (previbuf != curibuf) { /* interpolate */
2019-03-25 11:55:36 +11:00
boxsample(
previbuf, fx - minx, fy - miny, fx + minx, fy + miny, &texr, imaprepeat, imapextend);
/* calc rgb */
2019-03-25 11:55:36 +11:00
dx = 2.0f * (pixsize - maxd) / pixsize;
if (dx >= 1.0f) {
texres->ta = texr.ta;
texres->tb = texr.tb;
texres->tg = texr.tg;
texres->tr = texr.tr;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-03-25 11:55:36 +11:00
dy = 1.0f - dx;
texres->tb = dy * texres->tb + dx * texr.tb;
texres->tg = dy * texres->tg + dx * texr.tg;
texres->tr = dy * texres->tr + dx * texr.tr;
texres->ta = dy * texres->ta + dx * texr.ta;
}
2019-03-25 11:55:36 +11:00
val1 = dy * val1 + dx * (texr.tr + texr.tg + texr.tb);
boxsample(previbuf,
fx - minx + dxt[0],
fy - miny + dxt[1],
fx + minx + dxt[0],
fy + miny + dxt[1],
&texr,
imaprepeat,
imapextend);
val2 = dy * val2 + dx * (texr.tr + texr.tg + texr.tb);
boxsample(previbuf,
fx - minx + dyt[0],
fy - miny + dyt[1],
fx + minx + dyt[0],
fy + miny + dyt[1],
&texr,
imaprepeat,
imapextend);
val3 = dy * val3 + dx * (texr.tr + texr.tg + texr.tb);
2019-03-25 11:55:36 +11:00
texres->nor[0] = (val1 - val2); /* vals have been interpolated above! */
texres->nor[1] = (val1 - val3);
2019-03-25 11:55:36 +11:00
if (dx < 1.0f) {
dy = 1.0f - dx;
texres->tb = dy * texres->tb + dx * texr.tb;
texres->tg = dy * texres->tg + dx * texr.tg;
texres->tr = dy * texres->tr + dx * texr.tr;
texres->ta = dy * texres->ta + dx * texr.ta;
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2019-03-25 11:55:36 +11:00
texres->nor[0] *= bumpscale;
texres->nor[1] *= bumpscale;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
2019-03-25 11:55:36 +11:00
maxx = fx + minx;
minx = fx - minx;
maxy = fy + miny;
miny = fy - miny;
boxsample(curibuf, minx, miny, maxx, maxy, texres, imaprepeat, imapextend);
2019-03-25 11:55:36 +11:00
if (previbuf != curibuf) { /* interpolate */
boxsample(previbuf, minx, miny, maxx, maxy, &texr, imaprepeat, imapextend);
2019-03-25 11:55:36 +11:00
fx = 2.0f * (pixsize - maxd) / pixsize;
2019-03-25 11:55:36 +11:00
if (fx >= 1.0f) {
texres->ta = texr.ta;
texres->tb = texr.tb;
texres->tg = texr.tg;
texres->tr = texr.tr;
}
else {
2019-03-25 11:55:36 +11:00
fy = 1.0f - fx;
texres->tb = fy * texres->tb + fx * texr.tb;
texres->tg = fy * texres->tg + fx * texr.tg;
texres->tr = fy * texres->tr + fx * texr.tr;
texres->ta = fy * texres->ta + fx * texr.ta;
}
}
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
else {
const int intpol = tex->imaflag & TEX_INTERPOL;
if (intpol) {
/* sample 1 pixel minimum */
2019-04-22 09:08:06 +10:00
if (minx < 0.5f / ibuf->x) {
minx = 0.5f / ibuf->x;
2019-04-22 09:08:06 +10:00
}
if (miny < 0.5f / ibuf->y) {
miny = 0.5f / ibuf->y;
2019-04-22 09:08:06 +10:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2019-03-25 11:55:36 +11:00
if (texres->nor && (tex->imaflag & TEX_NORMALMAP) == 0) {
boxsample(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend);
val1 = texres->tr + texres->tg + texres->tb;
boxsample(ibuf,
fx - minx + dxt[0],
fy - miny + dxt[1],
fx + minx + dxt[0],
fy + miny + dxt[1],
&texr,
imaprepeat,
imapextend);
val2 = texr.tr + texr.tg + texr.tb;
boxsample(ibuf,
fx - minx + dyt[0],
fy - miny + dyt[1],
fx + minx + dyt[0],
fy + miny + dyt[1],
&texr,
imaprepeat,
imapextend);
val3 = texr.tr + texr.tg + texr.tb;
/* don't switch x or y! */
2019-03-25 11:55:36 +11:00
texres->nor[0] = (val1 - val2);
texres->nor[1] = (val1 - val3);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2019-04-22 09:08:06 +10:00
else {
2019-03-25 11:55:36 +11:00
boxsample(ibuf, fx - minx, fy - miny, fx + minx, fy + miny, texres, imaprepeat, imapextend);
2019-04-22 09:08:06 +10:00
}
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
if (tex->imaflag & TEX_CALCALPHA) {
texres->ta = texres->tin = texres->ta * max_fff(texres->tr, texres->tg, texres->tb);
}
else {
texres->tin = texres->ta;
}
2019-04-22 09:08:06 +10:00
if (tex->flag & TEX_NEGALPHA) {
2019-03-25 11:55:36 +11:00
texres->ta = 1.0f - texres->ta;
2019-04-22 09:08:06 +10:00
}
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) {
2012-07-07 22:51:57 +00:00
/* qdn: normal from color
* The invert of the red channel is to make
* the normal map compliant with the outside world.
* It needs to be done because in Blender
* the normal used in the renderer points inward. It is generated
* this way in calc_vertexnormals(). Should this ever change
* this negate must be removed. */
texres->nor[0] = -2.0f * (texres->tr - 0.5f);
texres->nor[1] = 2.0f * (texres->tg - 0.5f);
texres->nor[2] = 2.0f * (texres->tb - 0.5f);
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
2020-11-16 16:48:41 +11:00
/* de-premul, this is being pre-multiplied in shade_input_do_shade() */
/* do not de-premul for generated alpha, it is already in straight */
2019-03-25 11:55:36 +11:00
if (texres->ta != 1.0f && texres->ta > 1e-4f && !(tex->imaflag & TEX_CALCALPHA)) {
mul_v3_fl(&texres->tr, 1.0f / texres->ta);
}
2019-04-22 09:08:06 +10:00
if (ima) {
BKE_image_pool_release_ibuf(ima, ibuf, pool);
2019-04-22 09:08:06 +10:00
}
BRICONTRGB;
return retval;
Biiig commit! Thanks to 2-3 weeks of cvs freeze... Render: - New; support for dual CPU render (SDL thread) Currently only works with alternating scanlines, but gives excellent performance. For both normal render as unified implemented. Note the "mutex" locks on z-transp buffer render and imbuf loads. - This has been made possible by major cleanups in render code, especially getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct OSA or using Materials or Texture data to write to. - Made normal render fully 4x32 floats too, and removed all old optimizes with chars or shorts. - Made normal render and unified render use same code for sky and halo render, giving equal (and better) results for halo render. Old render now also uses PostProcess options (brightness, mul, gamma) - Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer after render. Using PostProcess menu you will note an immediate re- display of image too (32 bits RGBA) - Added "Hue" and "Saturation" sliders to PostProcess options - Render module is still not having a "nice" API, but amount of dependencies went down a lot. Next todo: remove abusive "previewrender" code. The last main global in Render (struct Render) now can be re-used for fully controlling a render, to allow multiple "instances" of render to open. - Renderwindow now displays a smal bar on top with the stats, and keeps the stats after render too. Including "spare" page support. Not only easier visible that way, but also to remove the awkward code that was drawing stats in the Info header (extreme slow on some ATIs too) - Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping defines. - I might have forgotten stuff... and will write a nice doc on the architecture!
2004-12-27 19:28:52 +00:00
}
void image_sample(
Image *ima, float fx, float fy, float dx, float dy, float result[4], struct ImagePool *pool)
{
TexResult texres;
ImBuf *ibuf = BKE_image_pool_acquire_ibuf(ima, NULL, pool);
if (UNLIKELY(ibuf == NULL)) {
zero_v4(result);
return;
}
texres.talpha = true; /* boxsample expects to be initialized */
boxsample(ibuf, fx, fy, fx + dx, fy + dy, &texres, 0, 1);
copy_v4_v4(result, &texres.tr);
2019-03-25 11:55:36 +11:00
ima->flag |= IMA_USED_FOR_RENDER;
BKE_image_pool_release_ibuf(ima, ibuf, pool);
}
void ibuf_sample(ImBuf *ibuf, float fx, float fy, float dx, float dy, float result[4])
{
TexResult texres = {0};
afdata_t AFD;
AFD.dxt[0] = dx;
AFD.dxt[1] = dx;
AFD.dyt[0] = dy;
AFD.dyt[1] = dy;
// copy_v2_v2(AFD.dxt, dx);
// copy_v2_v2(AFD.dyt, dy);
AFD.intpol = 1;
AFD.extflag = TXC_EXTD;
ewa_eval(&texres, ibuf, fx, fy, &AFD);
copy_v4_v4(result, &texres.tr);
2010-09-03 03:30:20 +00:00
}