svn merge ^/trunk/blender -r48188:48195

This commit is contained in:
Campbell Barton
2012-06-22 15:08:33 +00:00
30 changed files with 180 additions and 98 deletions

View File

@@ -26,7 +26,7 @@
CompositorContext::CompositorContext()
{
this->scene = NULL;
this->rd = NULL;
this->quality = COM_QUALITY_HIGH;
this->hasActiveOpenCLDevices = false;
this->activegNode = NULL;
@@ -34,8 +34,8 @@ CompositorContext::CompositorContext()
const int CompositorContext::getFramenumber() const
{
if (this->scene) {
return this->scene->r.cfra;
if (this->rd) {
return this->rd->cfra;
}
else {
return -1; /* this should never happen */
@@ -44,8 +44,8 @@ const int CompositorContext::getFramenumber() const
const int CompositorContext::isColorManaged() const
{
if (this->scene) {
return this->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT;
if (this->rd) {
return this->rd->color_mgt_flag & R_COLOR_MANAGEMENT;
}
else {
return 0; /* this should never happen */

View File

@@ -51,11 +51,11 @@ private:
CompositorQuality quality;
/**
* @brief Reference to the scene that is being composited.
* @brief Reference to the render data that is being composited.
* This field is initialized in ExecutionSystem and must only be read from that point on.
* @see ExecutionSystem
*/
Scene *scene;
RenderData *rd;
/**
* @brief reference to the bNodeTree
@@ -93,7 +93,7 @@ public:
/**
* @brief set the scene of the context
*/
void setScene(Scene *scene) { this->scene = scene; }
void setRenderData(RenderData *rd) { this->rd = rd; }
/**
* @brief set the bnodetree of the context
@@ -118,7 +118,7 @@ public:
/**
* @brief get the scene of the context
*/
const Scene *getScene() const { return this->scene; }
const RenderData *getRenderData() const { return this->rd; }
/**
* @brief set the quality

View File

@@ -41,7 +41,7 @@
#include "BKE_global.h"
ExecutionSystem::ExecutionSystem(Scene *scene, bNodeTree *editingtree, bool rendering)
ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering)
{
context.setbNodeTree(editingtree);
bNode *gnode;
@@ -64,7 +64,7 @@ ExecutionSystem::ExecutionSystem(Scene *scene, bNodeTree *editingtree, bool rend
ExecutionSystemHelper::addbNodeTree(*this, 0, editingtree, NULL);
context.setScene(scene);
context.setRenderData(rd);
this->convertToOperations();
this->groupOperations(); /* group operations in ExecutionGroups */
unsigned int index;

View File

@@ -156,7 +156,7 @@ public:
* @param editingtree [bNodeTree*]
* @param rendering [true false]
*/
ExecutionSystem(Scene *scene, bNodeTree *editingtree, bool rendering);
ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering);
/**
* Destructor

View File

@@ -56,15 +56,9 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
editingtree->progress(editingtree->prh, 0.0);
/* initialize execution system */
Scene *scene;
for (scene = (Scene*)G.main->scene.first; scene != NULL ; scene = (Scene*)scene->id.next) {
if (&scene->r == rd) {
ExecutionSystem *system = new ExecutionSystem(scene, editingtree, rendering);
system->execute();
delete system;
break;
}
}
ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering);
system->execute();
delete system;
BLI_mutex_unlock(compositorMutex);
}

View File

@@ -35,7 +35,7 @@ void CompositorNode::convertToOperations(ExecutionSystem *graph, CompositorConte
InputSocket *alphaSocket = this->getInputSocket(1);
if (imageSocket->isConnected()) {
CompositorOperation *colourAlphaProg = new CompositorOperation();
colourAlphaProg->setScene(context->getScene());
colourAlphaProg->setRenderData(context->getRenderData());
colourAlphaProg->setbNodeTree(context->getbNodeTree());
imageSocket->relinkConnections(colourAlphaProg->getInputSocket(0));
alphaSocket->relinkConnections(colourAlphaProg->getInputSocket(1));

View File

@@ -38,7 +38,7 @@ void IDMaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
operation->setObjectIndex(bnode->custom1);
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
if (bnode->custom2 == 0 || context->getScene()->r.scemode & R_FULL_SAMPLE) {
if (bnode->custom2 == 0 || context->getRenderData()->scemode & R_FULL_SAMPLE) {
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
}
else {

View File

@@ -39,7 +39,7 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC
ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation();
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]);
this->getInputSocket(2)->relinkConnections(operation->getInputSocket(1), 2, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
operation->setData(data);
@@ -50,8 +50,8 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC
ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation();
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
operation->setDistortion(this->getInputSocket(1)->getStaticValues()[0]);
operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
operation->setData(data);

View File

@@ -36,7 +36,7 @@ MaskNode::MaskNode(bNode *editorNode) : Node(editorNode)
void MaskNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
const RenderData *data = &context->getScene()->r;
const RenderData *data = context->getRenderData();
OutputSocket *outputMask = this->getOutputSocket(0);

View File

@@ -47,7 +47,7 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte
if (storage->format.imtype == R_IMF_IMTYPE_MULTILAYER) {
/* single output operation for the multilayer file */
OutputOpenExrMultiLayerOperation *outputOperation = new OutputOpenExrMultiLayerOperation(
context->getScene(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec);
context->getRenderData(), context->getbNodeTree(), storage->base_path, storage->format.exr_codec);
int num_inputs = getNumberOfInputSockets();
bool hasConnections = false;
@@ -80,7 +80,7 @@ void OutputFileNode::convertToOperations(ExecutionSystem *graph, CompositorConte
BLI_join_dirfile(path, FILE_MAX, storage->base_path, sockdata->path);
OutputSingleLayerOperation *outputOperation = new OutputSingleLayerOperation(
context->getScene(), context->getbNodeTree(), input->getDataType(), format, path);
context->getRenderData(), context->getbNodeTree(), input->getDataType(), format, path);
input->relinkConnections(outputOperation->getInputSocket(0));
graph->addOperation(outputOperation);
if (!previewAdded) {

View File

@@ -52,7 +52,7 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
break;
case CMP_SCALE_SCENEPERCENT: {
SetValueOperation *scaleFactorOperation = new SetValueOperation();
scaleFactorOperation->setValue(context->getScene()->r.size / 100.0f);
scaleFactorOperation->setValue(context->getRenderData()->size / 100.0f);
ScaleOperation *operation = new ScaleOperation();
inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph);
addLink(graph, scaleFactorOperation->getOutputSocket(), operation->getInputSocket(1));
@@ -64,7 +64,7 @@ void ScaleNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c
break;
case CMP_SCALE_RENDERPERCENT: {
const RenderData *data = &context->getScene()->r;
const RenderData *data = context->getRenderData();
ScaleFixedSizeOperation *operation = new ScaleFixedSizeOperation();
/* framing options */

View File

@@ -39,8 +39,8 @@ void SplitViewerNode::convertToOperations(ExecutionSystem *graph, CompositorCont
ImageUser *imageUser = (ImageUser *) this->getbNode()->storage;
if (image1Socket->isConnected() && image2Socket->isConnected()) {
SplitViewerOperation *splitViewerOperation = new SplitViewerOperation();
splitViewerOperation->setColorManagement(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT);
splitViewerOperation->setColorPredivide(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
splitViewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT);
splitViewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
splitViewerOperation->setImage(image);
splitViewerOperation->setImageUser(imageUser);
splitViewerOperation->setActive((this->getbNode()->flag & NODE_DO_OUTPUT) && this->isInActiveGroup());

View File

@@ -38,7 +38,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, system);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, system);
operation->setTexture(texture);
operation->setScene(context->getScene());
operation->setRenderData(context->getRenderData());
system->addOperation(operation);
addPreviewOperation(system, operation->getOutputSocket());
@@ -48,7 +48,7 @@ void TextureNode::convertToOperations(ExecutionSystem *system, CompositorContext
addLink(system, operation->getInputSocket(0)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(0));
addLink(system, operation->getInputSocket(1)->getConnection()->getFromSocket(), alphaOperation->getInputSocket(1));
alphaOperation->setTexture(texture);
alphaOperation->setScene(context->getScene());
alphaOperation->setRenderData(context->getRenderData());
system->addOperation(alphaOperation);
}
}

View File

@@ -40,8 +40,8 @@ void ViewerNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
bNode *editorNode = this->getbNode();
if (imageSocket->isConnected()) {
ViewerOperation *viewerOperation = new ViewerOperation();
viewerOperation->setColorManagement(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT);
viewerOperation->setColorPredivide(context->getScene()->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
viewerOperation->setColorManagement(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT);
viewerOperation->setColorPredivide(context->getRenderData()->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE);
viewerOperation->setbNodeTree(context->getbNodeTree());
viewerOperation->setImage(image);
viewerOperation->setImageUser(imageUser);

View File

@@ -21,7 +21,7 @@
*/
#include "COM_CombineChannelsOperation.h"
#include <stdio.h>
#include "BLI_utildefines.h"
CombineChannelsOperation::CombineChannelsOperation() : NodeOperation()
{
@@ -36,6 +36,31 @@ CombineChannelsOperation::CombineChannelsOperation() : NodeOperation()
this->inputChannel3Operation = NULL;
this->inputChannel4Operation = NULL;
}
bool CombineChannelsOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti tempOutput;
bool first = true;
for (int i = 0 ; i < 4 ; i ++) {
NodeOperation * inputOperation = this->getInputOperation(i);
if (inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) {
if (first) {
output->xmin = tempOutput.xmin;
output->ymin = tempOutput.ymin;
output->xmax = tempOutput.xmax;
output->ymax = tempOutput.ymax;
first = false;
} else {
output->xmin = MIN2(output->xmin, tempOutput.xmin);
output->ymin = MIN2(output->ymin, tempOutput.ymin);
output->xmax = MAX2(output->xmax, tempOutput.xmax);
output->ymax = MAX2(output->ymax, tempOutput.ymax);
}
}
}
return !first;
}
void CombineChannelsOperation::initExecution()
{
this->inputChannel1Operation = this->getInputSocketReader(0);

View File

@@ -37,6 +37,8 @@ public:
void initExecution();
void deinitExecution();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
};
#endif

View File

@@ -41,7 +41,7 @@ CompositorOperation::CompositorOperation() : NodeOperation()
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->setScene(NULL);
this->setRenderData(NULL);
this->outputBuffer = NULL;
this->imageInput = NULL;
this->alphaInput = NULL;
@@ -60,8 +60,8 @@ void CompositorOperation::initExecution()
void CompositorOperation::deinitExecution()
{
if (!isBreaked()) {
const Scene *scene = this->scene;
Render *re = RE_GetRender(scene->id.name);
const RenderData *rd = this->rd;
Render *re = RE_GetRender_FromData(rd);
RenderResult *rr = RE_AcquireResultWrite(re);
if (rr) {
if (rr->rectf != NULL) {
@@ -127,12 +127,12 @@ void CompositorOperation::executeRegion(rcti *rect, unsigned int tileNumber, Mem
void CompositorOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{
int width = this->scene->r.xsch * this->scene->r.size / 100;
int height = this->scene->r.ysch * this->scene->r.size / 100;
int width = this->rd->xsch * this->rd->size / 100;
int height = this->rd->ysch * this->rd->size / 100;
// check actual render resolution with cropping it may differ with cropped border.rendering
// FIX for: [31777] Border Crop gives black (easy)
Render *re = RE_GetRender(this->scene->id.name);
Render *re = RE_GetRender_FromData(this->rd);
if (re) {
RenderResult *rr = RE_AcquireResultRead(re);
if (rr) {

View File

@@ -34,7 +34,7 @@ private:
/**
* @brief local reference to the scene
*/
const Scene *scene;
const RenderData *rd;
/**
* @brief reference to the output float buffer
@@ -53,7 +53,7 @@ private:
public:
CompositorOperation();
void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers);
void setScene(const Scene *scene) { this->scene = scene; }
void setRenderData(const RenderData *rd) { this->rd = rd; }
bool isOutputOperation(bool rendering) const { return true; }
void initExecution();
void deinitExecution();

View File

@@ -92,9 +92,9 @@ static void write_buffer_rect(rcti *rect, MemoryBuffer **memoryBuffers, const bN
OutputSingleLayerOperation::OutputSingleLayerOperation(
const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path)
const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path)
{
this->scene = scene;
this->rd = rd;
this->tree = tree;
this->addInputSocket(datatype);
@@ -130,13 +130,13 @@ void OutputSingleLayerOperation::deinitExecution()
ibuf->channels = size;
ibuf->rect_float = this->outputBuffer;
ibuf->mall |= IB_rectfloat;
ibuf->dither = scene->r.dither_intensity;
ibuf->dither = this->rd->dither_intensity;
if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
if (this->rd->color_mgt_flag & R_COLOR_MANAGEMENT)
ibuf->profile = IB_PROFILE_LINEAR_RGB;
BKE_makepicstring(filename, this->path, bmain->name, this->scene->r.cfra, this->format->imtype,
(this->scene->r.scemode & R_EXTENSION), true);
BKE_makepicstring(filename, this->path, bmain->name, this->rd->cfra, this->format->imtype,
(this->rd->scemode & R_EXTENSION), true);
if (0 == BKE_imbuf_write(ibuf, filename, this->format))
printf("Cannot save Node File Output to %s\n", filename);
@@ -160,9 +160,9 @@ OutputOpenExrLayer::OutputOpenExrLayer(const char *name, DataType datatype)
}
OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(
const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec)
const RenderData *rd, const bNodeTree *tree, const char *path, char exr_codec)
{
this->scene = scene;
this->rd = rd;
this->tree = tree;
BLI_strncpy(this->path, path, sizeof(this->path));
@@ -199,8 +199,8 @@ void OutputOpenExrMultiLayerOperation::deinitExecution()
char filename[FILE_MAX];
void *exrhandle = IMB_exr_get_handle();
BKE_makepicstring(filename, this->path, bmain->name, this->scene->r.cfra, R_IMF_IMTYPE_MULTILAYER,
(this->scene->r.scemode & R_EXTENSION), true);
BKE_makepicstring(filename, this->path, bmain->name, this->rd->cfra, R_IMF_IMTYPE_MULTILAYER,
(this->rd->scemode & R_EXTENSION), true);
BLI_make_existing_file(filename);
for (unsigned int i = 0; i < layers.size(); ++i) {

View File

@@ -32,7 +32,7 @@
/* Writes the image to a single-layer file. */
class OutputSingleLayerOperation : public NodeOperation {
private:
const Scene *scene;
const RenderData *rd;
const bNodeTree *tree;
ImageFormatData *format;
@@ -43,7 +43,7 @@ private:
SocketReader *imageInput;
public:
OutputSingleLayerOperation(const Scene *scene, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path);
OutputSingleLayerOperation(const RenderData *rd, const bNodeTree *tree, DataType datatype, ImageFormatData *format, const char *path);
void executeRegion(rcti *rect, unsigned int tileNumber, MemoryBuffer **memoryBuffers);
bool isOutputOperation(bool rendering) const { return true; }
@@ -67,7 +67,7 @@ class OutputOpenExrMultiLayerOperation : public NodeOperation {
private:
typedef std::vector<OutputOpenExrLayer> LayerList;
const Scene *scene;
const RenderData *rd;
const bNodeTree *tree;
char path[FILE_MAX];
@@ -75,7 +75,7 @@ private:
LayerList layers;
public:
OutputOpenExrMultiLayerOperation(const Scene *scene, const bNodeTree *tree, const char *path, char exr_codec);
OutputOpenExrMultiLayerOperation(const RenderData *rd, const bNodeTree *tree, const char *path, char exr_codec);
void add_layer(const char *name, DataType datatype);

View File

@@ -27,19 +27,21 @@
ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
this->inputProgram = NULL;
this->dispersionAvailable = false;
this->dispersion = 0.0f;
}
void ProjectorLensDistortionOperation::initExecution()
{
this->inputProgram = this->getInputSocketReader(0);
kr = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f);
kr2 = kr * 20;
}
void *ProjectorLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
updateDispersion(memoryBuffers);
void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers);
return buffer;
}
@@ -69,9 +71,28 @@ void ProjectorLensDistortionOperation::deinitExecution()
bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
newInput.ymax = input->ymax;
newInput.ymin = input->ymin;
newInput.xmin = input->xmin - kr2 - 2;
newInput.xmax = input->xmax + kr2 + 2;
if (dispersionAvailable) {
newInput.ymax = input->ymax;
newInput.ymin = input->ymin;
newInput.xmin = input->xmin - kr2 - 2;
newInput.xmax = input->xmax + kr2 + 2;
} else {
newInput.xmin = 0;
newInput.ymin = input->ymin;
newInput.ymax = input->ymax;
newInput.xmax = inputProgram->getWidth();
}
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void ProjectorLensDistortionOperation::updateDispersion(MemoryBuffer **inputBuffers)
{
if (!dispersionAvailable) {
float result[4];
this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers);
dispersion = result[0];
kr = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f);
kr2 = kr * 20;
dispersionAvailable = true;
}
}

View File

@@ -35,6 +35,8 @@ private:
NodeLensDist *data;
float dispersion;
bool dispersionAvailable;
float kr, kr2;
public:
ProjectorLensDistortionOperation();
@@ -56,9 +58,10 @@ public:
void deinitExecution();
void setData(NodeLensDist *data) { this->data = data; }
void setDispertion(float dispersion) { this->dispersion = dispersion; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
void updateDispersion(MemoryBuffer** inputBuffers);
};
#endif

View File

@@ -48,14 +48,21 @@ void ReadBufferOperation::determineResolution(unsigned int resolution[], unsigne
}
void ReadBufferOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
MemoryBuffer *inputBuffer = inputBuffers[this->offset];
if (inputBuffer) {
if (sampler == COM_PS_NEAREST) {
inputBuffer->read(color, x, y);
}
else {
inputBuffer->readCubic(color, x, y);
if (inputBuffers) {
MemoryBuffer *inputBuffer = inputBuffers[this->offset];
if (inputBuffer) {
if (sampler == COM_PS_NEAREST) {
inputBuffer->read(color, x, y);
}
else {
inputBuffer->readCubic(color, x, y);
}
}
} else {
color[0] = 0.0f;
color[1] = 0.0f;
color[2] = 0.0f;
color[3] = 0.0f;
}
}

View File

@@ -30,34 +30,24 @@ extern "C" {
ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
this->inputProgram = NULL;
this->valuesAvailable = false;
this->dispersion = 0.0f;
this->distortion = 0.0f;
}
void ScreenLensDistortionOperation::initExecution()
{
this->inputProgram = this->getInputSocketReader(0);
kg = MAX2(MIN2(this->distortion, 1.f), -0.999f);
// smaller dispersion range for somewhat more control
const float d = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f);
kr = MAX2(MIN2((kg + d), 1.f), -0.999f);
kb = MAX2(MIN2((kg - d), 1.f), -0.999f);
maxk = MAX3(kr, kg, kb);
sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk));
drg = 4.f * (kg - kr);
dgb = 4.f * (kb - kg);
kr4 = kr * 4.f;
kg4 = kg * 4.f;
kb4 = kb * 4.f;
cx = 0.5f * (float)getWidth();
cy = 0.5f * (float)getHeight();
}
void *ScreenLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers);
updateDispersionAndDistortion(memoryBuffers);
return buffer;
}
@@ -171,3 +161,30 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input
newInput.xmax = inputProgram->getWidth();
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void ScreenLensDistortionOperation::updateDispersionAndDistortion(MemoryBuffer **inputBuffers)
{
if (!valuesAvailable) {
float result[4];
this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers);
this->distortion = result[0];
this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers);
this->dispersion = result[0];
kg = MAX2(MIN2(this->distortion, 1.f), -0.999f);
// smaller dispersion range for somewhat more control
const float d = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f);
kr = MAX2(MIN2((kg + d), 1.f), -0.999f);
kb = MAX2(MIN2((kg - d), 1.f), -0.999f);
maxk = MAX3(kr, kg, kb);
sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk));
drg = 4.f * (kg - kr);
dgb = 4.f * (kb - kg);
kr4 = kr * 4.f;
kg4 = kg * 4.f;
kb4 = kb * 4.f;
cx = 0.5f * (float)getWidth();
cy = 0.5f * (float)getHeight();
valuesAvailable = true;
}
}

View File

@@ -36,6 +36,7 @@ private:
float dispersion;
float distortion;
bool valuesAvailable;
float kr, kg, kb;
float kr4, kg4, kb4;
float maxk;
@@ -62,13 +63,12 @@ public:
void deinitExecution();
void setData(NodeLensDist *data) { this->data = data; }
void setDispertion(float dispersion) { this->dispersion = dispersion; }
void setDistortion(float distortion) { this->distortion = distortion; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
private:
void determineUV(float *result, float x, float y) const;
void updateDispersionAndDistortion(MemoryBuffer** inputBuffers);
};
#endif

View File

@@ -32,7 +32,7 @@ TextureBaseOperation::TextureBaseOperation() : NodeOperation()
this->texture = NULL;
this->inputSize = NULL;
this->inputOffset = NULL;
this->scene = NULL;
this->rd = NULL;
}
TextureOperation::TextureOperation() : TextureBaseOperation()
{
@@ -57,8 +57,8 @@ void TextureBaseOperation::deinitExecution()
void TextureBaseOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[])
{
if (preferredResolution[0] == 0 || preferredResolution[1] == 0) {
int width = this->scene->r.xsch * this->scene->r.size / 100;
int height = this->scene->r.ysch * this->scene->r.size / 100;
int width = this->rd->xsch * this->rd->size / 100;
int height = this->rd->ysch * this->rd->size / 100;
resolution[0] = width;
resolution[1] = height;
}

View File

@@ -43,7 +43,7 @@ extern "C" {
class TextureBaseOperation : public NodeOperation {
private:
Tex *texture;
const Scene *scene;
const RenderData *rd;
SocketReader *inputSize;
SocketReader *inputOffset;
@@ -65,7 +65,7 @@ public:
void setTexture(Tex *texture) { this->texture = texture; }
void initExecution();
void deinitExecution();
void setScene(const Scene *scene) { this->scene = scene; }
void setRenderData(const RenderData *rd) { this->rd = rd; }
};
class TextureOperation : public TextureBaseOperation {

View File

@@ -467,7 +467,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit)
/* draw other uvs */
if (sima->flag & SI_DRAW_OTHER) {
Image *curimage = (activetf) ? activetf->tpage : NULL;
Image *curimage = (activetf) ? activetf->tpage : ima;
draw_uvs_other(scene, obedit, curimage);
}

View File

@@ -154,6 +154,7 @@ typedef struct RenderStats {
/* calling a new render with same name, frees automatic existing render */
struct Render *RE_NewRender (const char *name);
struct Render *RE_GetRender(const char *name);
struct Render *RE_GetRender_FromData(const struct RenderData *rd);
/* returns 1 while render is working (or renders called from within render) */
int RE_RenderInProgress(struct Render *re);

View File

@@ -245,6 +245,18 @@ Render *RE_GetRender(const char *name)
return re;
}
Render *RE_GetRender_FromData(const RenderData *rd)
{
Render *re;
/* search for existing renders */
for (re = RenderGlobal.renderlist.first; re; re = re->next)
if (&re->r == rd)
break;
return re;
}
/* if you want to know exactly what has been done */
RenderResult *RE_AcquireResultRead(Render *re)
{