2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2011 Blender Foundation. */
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
|
|
|
|
|
#include "COM_ScreenLensDistortionOperation.h"
|
2021-10-13 23:00:24 +02:00
|
|
|
|
2021-08-23 15:30:18 +02:00
|
|
|
#include "COM_ConstantOperation.h"
|
2012-08-13 16:03:48 +00:00
|
|
|
|
2013-12-22 14:11:10 +11:00
|
|
|
#include "BLI_rand.h"
|
2020-05-08 18:16:39 +02:00
|
|
|
|
2018-06-14 16:24:55 +02:00
|
|
|
#include "PIL_time.h"
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
namespace blender::compositor {
|
|
|
|
|
|
2020-08-07 15:58:58 +02:00
|
|
|
ScreenLensDistortionOperation::ScreenLensDistortionOperation()
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
this->add_input_socket(DataType::Color);
|
|
|
|
|
this->add_input_socket(DataType::Value);
|
|
|
|
|
this->add_input_socket(DataType::Value);
|
|
|
|
|
this->add_output_socket(DataType::Color);
|
2021-10-13 23:01:53 +02:00
|
|
|
flags_.complex = true;
|
2021-10-13 23:01:15 +02:00
|
|
|
input_program_ = nullptr;
|
2021-10-13 23:01:04 +02:00
|
|
|
distortion_ = 0.0f;
|
|
|
|
|
dispersion_ = 0.0f;
|
|
|
|
|
distortion_const_ = false;
|
|
|
|
|
dispersion_const_ = false;
|
|
|
|
|
variables_ready_ = false;
|
2014-01-22 14:32:21 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void ScreenLensDistortionOperation::set_distortion(float distortion)
|
2014-01-22 14:32:21 +01:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
distortion_ = distortion;
|
|
|
|
|
distortion_const_ = true;
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
2014-01-22 14:32:21 +01:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void ScreenLensDistortionOperation::set_dispersion(float dispersion)
|
2014-01-22 14:32:21 +01:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
dispersion_ = dispersion;
|
|
|
|
|
dispersion_const_ = true;
|
2014-01-22 14:32:21 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-23 15:30:18 +02:00
|
|
|
void ScreenLensDistortionOperation::init_data()
|
|
|
|
|
{
|
2022-09-25 18:33:28 +10:00
|
|
|
cx_ = 0.5f * float(get_width());
|
|
|
|
|
cy_ = 0.5f * float(get_height());
|
2021-08-23 15:30:18 +02:00
|
|
|
|
|
|
|
|
switch (execution_model_) {
|
|
|
|
|
case eExecutionModel::FullFrame: {
|
|
|
|
|
NodeOperation *distortion_op = get_input_operation(1);
|
|
|
|
|
NodeOperation *dispersion_op = get_input_operation(2);
|
2021-10-13 23:01:04 +02:00
|
|
|
if (!distortion_const_ && distortion_op->get_flags().is_constant_operation) {
|
|
|
|
|
distortion_ = static_cast<ConstantOperation *>(distortion_op)->get_constant_elem()[0];
|
2021-08-23 15:30:18 +02:00
|
|
|
}
|
2021-10-13 23:01:04 +02:00
|
|
|
if (!dispersion_const_ && distortion_op->get_flags().is_constant_operation) {
|
|
|
|
|
dispersion_ = static_cast<ConstantOperation *>(dispersion_op)->get_constant_elem()[0];
|
2021-08-23 15:30:18 +02:00
|
|
|
}
|
2021-10-13 23:01:15 +02:00
|
|
|
update_variables(distortion_, dispersion_);
|
2021-08-23 15:30:18 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case eExecutionModel::Tiled: {
|
|
|
|
|
/* If both are constant, init variables once. */
|
2021-10-13 23:01:04 +02:00
|
|
|
if (distortion_const_ && dispersion_const_) {
|
2021-10-13 23:01:15 +02:00
|
|
|
update_variables(distortion_, dispersion_);
|
2021-10-13 23:01:04 +02:00
|
|
|
variables_ready_ = true;
|
2021-08-23 15:30:18 +02:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void ScreenLensDistortionOperation::init_execution()
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
input_program_ = this->get_input_socket_reader(0);
|
|
|
|
|
this->init_mutex();
|
2018-06-14 16:24:55 +02:00
|
|
|
|
2022-09-25 18:33:28 +10:00
|
|
|
uint rng_seed = uint(PIL_check_seconds_timer_i() & UINT_MAX);
|
|
|
|
|
rng_seed ^= uint(POINTER_AS_INT(input_program_));
|
2021-10-13 23:01:04 +02:00
|
|
|
rng_ = BLI_rng_new(rng_seed);
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void *ScreenLensDistortionOperation::initialize_tile_data(rcti * /*rect*/)
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
void *buffer = input_program_->initialize_tile_data(nullptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
/* get distortion/dispersion values once, by reading inputs at (0,0)
|
|
|
|
|
* XXX this assumes invariable values (no image inputs),
|
|
|
|
|
* we don't have a nice generic system for that yet
|
|
|
|
|
*/
|
2021-10-13 23:01:04 +02:00
|
|
|
if (!variables_ready_) {
|
2021-10-13 23:01:15 +02:00
|
|
|
this->lock_mutex();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
if (!distortion_const_) {
|
2014-01-22 14:32:21 +01:00
|
|
|
float result[4];
|
2021-10-13 23:01:15 +02:00
|
|
|
get_input_socket_reader(1)->read_sampled(result, 0, 0, PixelSampler::Nearest);
|
2021-10-13 23:01:04 +02:00
|
|
|
distortion_ = result[0];
|
2014-01-22 14:32:21 +01:00
|
|
|
}
|
2021-10-13 23:01:04 +02:00
|
|
|
if (!dispersion_const_) {
|
2014-01-22 14:32:21 +01:00
|
|
|
float result[4];
|
2021-10-13 23:01:15 +02:00
|
|
|
get_input_socket_reader(2)->read_sampled(result, 0, 0, PixelSampler::Nearest);
|
2021-10-13 23:01:04 +02:00
|
|
|
dispersion_ = result[0];
|
2014-01-22 14:32:21 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
update_variables(distortion_, dispersion_);
|
2021-10-13 23:01:04 +02:00
|
|
|
variables_ready_ = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
this->unlock_mutex();
|
2014-01-22 14:32:21 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
return buffer;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
void ScreenLensDistortionOperation::get_uv(const float xy[2], float uv[2]) const
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
uv[0] = sc_ * ((xy[0] + 0.5f) - cx_) / cx_;
|
|
|
|
|
uv[1] = sc_ * ((xy[1] + 0.5f) - cy_) / cy_;
|
2014-01-22 14:32:21 +01:00
|
|
|
}
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
void ScreenLensDistortionOperation::distort_uv(const float uv[2], float t, float xy[2]) const
|
|
|
|
|
{
|
|
|
|
|
float d = 1.0f / (1.0f + sqrtf(t));
|
2021-10-13 23:01:15 +02:00
|
|
|
xy[0] = (uv[0] * d + 0.5f) * get_width() - 0.5f;
|
|
|
|
|
xy[1] = (uv[1] * d + 0.5f) * get_height() - 0.5f;
|
2014-01-22 14:32:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ScreenLensDistortionOperation::get_delta(float r_sq,
|
|
|
|
|
float k4,
|
|
|
|
|
const float uv[2],
|
|
|
|
|
float delta[2]) const
|
|
|
|
|
{
|
|
|
|
|
float t = 1.0f - k4 * r_sq;
|
|
|
|
|
if (t >= 0.0f) {
|
|
|
|
|
distort_uv(uv, t, delta);
|
|
|
|
|
return true;
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
2020-08-07 12:32:45 +02:00
|
|
|
|
|
|
|
|
return false;
|
2014-01-22 14:32:21 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-23 15:30:18 +02:00
|
|
|
void ScreenLensDistortionOperation::accumulate(const MemoryBuffer *buffer,
|
2014-01-22 14:32:21 +01:00
|
|
|
int a,
|
|
|
|
|
int b,
|
|
|
|
|
float r_sq,
|
|
|
|
|
const float uv[2],
|
|
|
|
|
const float delta[3][2],
|
|
|
|
|
float sum[4],
|
|
|
|
|
int count[3]) const
|
|
|
|
|
{
|
|
|
|
|
float color[4];
|
2018-06-17 17:05:29 +02:00
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
float dsf = len_v2v2(delta[a], delta[b]) + 1.0f;
|
2022-09-25 18:33:28 +10:00
|
|
|
int ds = jitter_ ? (dsf < 4.0f ? 2 : int(sqrtf(dsf))) : int(dsf);
|
|
|
|
|
float sd = 1.0f / float(ds);
|
2014-01-22 14:32:21 +01:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
float k4 = k4_[a];
|
|
|
|
|
float dk4 = dk4_[a];
|
2014-01-22 14:32:21 +01:00
|
|
|
|
2019-09-08 00:12:26 +10:00
|
|
|
for (float z = 0; z < ds; z++) {
|
2021-10-13 23:01:04 +02:00
|
|
|
float tz = (z + (jitter_ ? BLI_rng_get_float(rng_) : 0.5f)) * sd;
|
2014-01-22 14:32:21 +01:00
|
|
|
float t = 1.0f - (k4 + tz * dk4) * r_sq;
|
2018-06-17 17:05:29 +02:00
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
float xy[2];
|
|
|
|
|
distort_uv(uv, t, xy);
|
2021-08-23 15:30:18 +02:00
|
|
|
switch (execution_model_) {
|
|
|
|
|
case eExecutionModel::Tiled:
|
2021-10-13 23:01:15 +02:00
|
|
|
buffer->read_bilinear(color, xy[0], xy[1]);
|
2021-08-23 15:30:18 +02:00
|
|
|
break;
|
|
|
|
|
case eExecutionModel::FullFrame:
|
|
|
|
|
buffer->read_elem_bilinear(xy[0], xy[1], color);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-06-17 17:05:29 +02:00
|
|
|
|
2016-03-05 09:13:16 +11:00
|
|
|
sum[a] += (1.0f - tz) * color[a];
|
|
|
|
|
sum[b] += (tz)*color[b];
|
|
|
|
|
count[a]++;
|
|
|
|
|
count[b]++;
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
2014-01-22 14:32:21 +01:00
|
|
|
}
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void ScreenLensDistortionOperation::execute_pixel(float output[4], int x, int y, void *data)
|
2014-01-22 14:32:21 +01:00
|
|
|
{
|
|
|
|
|
MemoryBuffer *buffer = (MemoryBuffer *)data;
|
2022-09-25 18:33:28 +10:00
|
|
|
float xy[2] = {float(x), float(y)};
|
2014-01-22 14:32:21 +01:00
|
|
|
float uv[2];
|
|
|
|
|
get_uv(xy, uv);
|
|
|
|
|
float uv_dot = len_squared_v2(uv);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
int count[3] = {0, 0, 0};
|
|
|
|
|
float delta[3][2];
|
|
|
|
|
float sum[4] = {0, 0, 0, 0};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
bool valid_r = get_delta(uv_dot, k4_[0], uv, delta[0]);
|
|
|
|
|
bool valid_g = get_delta(uv_dot, k4_[1], uv, delta[1]);
|
|
|
|
|
bool valid_b = get_delta(uv_dot, k4_[2], uv, delta[2]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
if (valid_r && valid_g && valid_b) {
|
|
|
|
|
accumulate(buffer, 0, 1, uv_dot, uv, delta, sum, count);
|
|
|
|
|
accumulate(buffer, 1, 2, uv_dot, uv, delta, sum, count);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 11:21:22 +10:00
|
|
|
if (count[0]) {
|
2022-09-25 18:33:28 +10:00
|
|
|
output[0] = 2.0f * sum[0] / float(count[0]);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
|
|
|
|
if (count[1]) {
|
2022-09-25 18:33:28 +10:00
|
|
|
output[1] = 2.0f * sum[1] / float(count[1]);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
|
|
|
|
if (count[2]) {
|
2022-09-25 18:33:28 +10:00
|
|
|
output[2] = 2.0f * sum[2] / float(count[2]);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
/* set alpha */
|
2012-08-10 14:07:24 +00:00
|
|
|
output[3] = 1.0f;
|
2012-05-17 13:44:15 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-08-10 14:07:24 +00:00
|
|
|
zero_v4(output);
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void ScreenLensDistortionOperation::deinit_execution()
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
this->deinit_mutex();
|
|
|
|
|
input_program_ = nullptr;
|
2021-10-13 23:01:04 +02:00
|
|
|
BLI_rng_free(rng_);
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-15 18:14:34 +00:00
|
|
|
void ScreenLensDistortionOperation::determineUV(float result[6], float x, float y) const
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2014-01-26 22:17:01 +11:00
|
|
|
const float xy[2] = {x, y};
|
2014-01-22 14:32:21 +01:00
|
|
|
float uv[2];
|
|
|
|
|
get_uv(xy, uv);
|
|
|
|
|
float uv_dot = len_squared_v2(uv);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-26 22:17:01 +11:00
|
|
|
copy_v2_v2(result + 0, xy);
|
|
|
|
|
copy_v2_v2(result + 2, xy);
|
|
|
|
|
copy_v2_v2(result + 4, xy);
|
2021-10-13 23:01:04 +02:00
|
|
|
get_delta(uv_dot, k4_[0], uv, result + 0);
|
|
|
|
|
get_delta(uv_dot, k4_[1], uv, result + 2);
|
|
|
|
|
get_delta(uv_dot, k4_[2], uv, result + 4);
|
____
`````|````` | | | ..''''
| | | |______ .''
| | | | ..'
| | |_______ |___________ ....''
merge to TRUNK!
* The old compositor is still available (Debug Menu: 200)
This commit was brought to you by:
Developers:
* Monique Dewanchand
* Jeroen Bakker
* Dalai Felinto
* Lukas Tönne
Review:
* Brecht van Lommel
Testers:
* Nate Wiebe
* Wolfgang Faehnle
* Carlo Andreacchio
* Daniel Salazar
* Artur Mag
* Christian Krupa
* Francesco Siddi
* Dan McGrath
* Bassam Kurdali
But mostly by the community:
Gold:
Joshua Faulkner
Michael Tiemann
Francesco Paglia
Blender Guru
Blender Developers Fund
Silver:
Pablo Vazquez
Joel Heethaar
Amrein Olivier
Ilias Karasavvidis
Thomas Kumlehn
Sebastian Koenig
Hannu Hoffrén
Benjamin Dansie
Fred M'ule
Michel Vilain
Bradley Cathey
Gianmichele Mariani
Gottfried Hofmann
Bjørnar Frøyse
Valentijn Bruning
Paul Holmes
Clemens Rudolph
Juris Graphix
David Strebel
Ronan Zeegers
François Tarlier
Felipe Andres Esquivel Reed
Olaf Beckman
Jesus Alberto Olmos Linares
Kajimba
Maria Figueiredo
Alexandr Galperin
Francesco Siddi
Julio Iglesias Lopez
Kjartan Tysdal
Thomas Torfs
Film Works
Teruyuki Nakamura
Roger Luethi
Benoit Bolsee
Stefan Abrahamsen
Andreas Mattijat
Xavier Bouchoux
Blender 3D Graphics and Animation
Henk Vostermans
Daniel Blanco Delgado
BlenderDay/2011
Bradley Cathey
Matthieu Dupont de Dinechin
Gianmichele Mariani
Jérôme Scaillet
Bronze (Ivo Grigull, Dylan Urquidi, Philippe Derungs, Phil Beauchamp, Bruce Parrott, Mathieu Quiblier, Daniel Martinez, Leandro Inocencio, Lluc Romaní Brasó,
Jonathan Williamson, Michael Ehlen, Karlis Stigis, Dreamsteep, Martin Lindelöf, Filippo Saracino, Douwe van der Veen, Olli Äkräs, Bruno D'Arcangeli,
Francisco Sedrez Warmling, Watchmike.ca, peter lener, Matteo Novellino, Martin Kirsch, Austars Schnore, KC Elliott, Massimiliano Puliero, Karl Stein,
Wood Design Studios, Omer Khan, Jyrki Kanto, Michał Krupa, Lars Brubaker, Neil Richmond, Adam Kalisz, Robert Garlington, Ian Wilson, Carlo Andreacchio,
Jeremias Boos, Robert Holcomb, Gabriel Zöller, Robert Cude, Natibel de Leon, Nathan Turnage, Nicolas Vergnes, Philipp Kleinhenz, Norman Hartig, Louis Kreusel,
Christopher Taylor, Giovanni Remondini, Daniel Rentzsch, Nico Partipilo, Thomas Ventresco, Johannes Schwarz, Александр Коротеев, Brendon Harvey,
Marcelo G. Malheiros, Marius Giurgi, Richard Burns, Perttu Iso-Metsälä, Steve Bazin, Radoslav Borisov, Yoshiyuki Shida, Julien Guigner, Andrew Hunter,
Philipp Oeser, Daniel Thul, Thobias Johansson, Mauro Bonecchi, Georg Piorczynski, Sebastian Michailidis, L M Weedy, Gen X, Stefan Hinze, Nicolò Zubbini,
Erik Pusch, Rob Scott, Florian Koch, Charles Razack, Adrian Baker, Oliver Villar Diz, David Revoy, Julio Iglesias Lopez, Coen Spoor, Carlos Folch,
Joseph Christie, Victor Hernández García, David Mcsween, James Finnerty, Cory Kruckenberg, Giacomo Graziosi, Olivier Saraja, Lars Brubaker, Eric Hudson,
Johannes Schwarz, David Elguea, Marcus Schulderinsky, Karel De Bruijn, Lucas van Wijngaarden, Stefano Ciarrocchi, Mehmet Eribol, Thomas Berglund, Zuofei Song,
Dylan Urquidi )
2012-05-17 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
bool ScreenLensDistortionOperation::determine_depending_area_of_interest(
|
|
|
|
|
rcti * /*input*/, ReadBufferOperation *read_operation, rcti *output)
|
2012-05-17 22:55:28 +00:00
|
|
|
{
|
2021-10-13 23:01:15 +02:00
|
|
|
rcti new_input_value;
|
|
|
|
|
new_input_value.xmin = 0;
|
|
|
|
|
new_input_value.ymin = 0;
|
|
|
|
|
new_input_value.xmax = 2;
|
|
|
|
|
new_input_value.ymax = 2;
|
|
|
|
|
|
|
|
|
|
NodeOperation *operation = get_input_operation(1);
|
|
|
|
|
if (operation->determine_depending_area_of_interest(&new_input_value, read_operation, output)) {
|
2012-07-03 09:05:19 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
operation = get_input_operation(2);
|
|
|
|
|
if (operation->determine_depending_area_of_interest(&new_input_value, read_operation, output)) {
|
2012-07-03 09:05:19 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
/* XXX the original method of estimating the area-of-interest does not work
|
|
|
|
|
* it assumes a linear increase/decrease of mapped coordinates, which does not
|
|
|
|
|
* yield correct results for the area and leaves uninitialized buffer areas.
|
|
|
|
|
* So now just use the full image area, which may not be as efficient but works at least ...
|
|
|
|
|
*/
|
|
|
|
|
#if 1
|
2021-10-13 23:01:15 +02:00
|
|
|
rcti image_input;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
operation = get_input_operation(0);
|
|
|
|
|
image_input.xmax = operation->get_width();
|
|
|
|
|
image_input.xmin = 0;
|
|
|
|
|
image_input.ymax = operation->get_height();
|
|
|
|
|
image_input.ymin = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
if (operation->determine_depending_area_of_interest(&image_input, read_operation, output)) {
|
2014-01-22 14:32:21 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
#else
|
2021-10-13 23:01:15 +02:00
|
|
|
rcti new_input;
|
2012-08-15 18:14:34 +00:00
|
|
|
const float margin = 2;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
BLI_rcti_init_minmax(&new_input);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
if (dispersion_const_ && distortion_const_) {
|
2014-01-22 14:32:21 +01:00
|
|
|
/* update from fixed distortion/dispersion */
|
|
|
|
|
# define UPDATE_INPUT(x, y) \
|
|
|
|
|
{ \
|
|
|
|
|
float coords[6]; \
|
|
|
|
|
determineUV(coords, x, y); \
|
2021-10-13 23:01:15 +02:00
|
|
|
new_input.xmin = min_ffff(new_input.xmin, coords[0], coords[2], coords[4]); \
|
|
|
|
|
new_input.ymin = min_ffff(new_input.ymin, coords[1], coords[3], coords[5]); \
|
|
|
|
|
new_input.xmax = max_ffff(new_input.xmax, coords[0], coords[2], coords[4]); \
|
|
|
|
|
new_input.ymax = max_ffff(new_input.ymax, coords[1], coords[3], coords[5]); \
|
2014-01-22 14:32:21 +01:00
|
|
|
} \
|
|
|
|
|
(void)0
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
UPDATE_INPUT(input->xmin, input->xmax);
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->ymax);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymax);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymin);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
# undef UPDATE_INPUT
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-08-13 16:03:48 +00:00
|
|
|
else {
|
2014-01-22 14:32:21 +01:00
|
|
|
/* use maximum dispersion 1.0 if not const */
|
2021-10-13 23:01:04 +02:00
|
|
|
float dispersion = dispersion_const_ ? dispersion_ : 1.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
# define UPDATE_INPUT(x, y, distortion) \
|
|
|
|
|
{ \
|
|
|
|
|
float coords[6]; \
|
2021-10-13 23:01:15 +02:00
|
|
|
update_variables(distortion, dispersion); \
|
2014-01-22 14:32:21 +01:00
|
|
|
determineUV(coords, x, y); \
|
2021-10-13 23:01:15 +02:00
|
|
|
new_input.xmin = min_ffff(new_input.xmin, coords[0], coords[2], coords[4]); \
|
|
|
|
|
new_input.ymin = min_ffff(new_input.ymin, coords[1], coords[3], coords[5]); \
|
|
|
|
|
new_input.xmax = max_ffff(new_input.xmax, coords[0], coords[2], coords[4]); \
|
|
|
|
|
new_input.ymax = max_ffff(new_input.ymax, coords[1], coords[3], coords[5]); \
|
2014-01-22 14:32:21 +01:00
|
|
|
} \
|
|
|
|
|
(void)0
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
if (distortion_const_) {
|
2014-01-22 14:32:21 +01:00
|
|
|
/* update from fixed distortion */
|
2021-10-13 23:01:04 +02:00
|
|
|
UPDATE_INPUT(input->xmin, input->xmax, distortion_);
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->ymax, distortion_);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymax, distortion_);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymin, distortion_);
|
2014-01-22 14:32:21 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* update from min/max distortion (-1..1) */
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->xmax, -1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->ymax, -1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymax, -1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymin, -1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-22 14:32:21 +01:00
|
|
|
UPDATE_INPUT(input->xmin, input->xmax, 1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->ymax, 1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymax, 1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymin, 1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-07-03 09:05:19 +00:00
|
|
|
# undef UPDATE_INPUT
|
2014-01-22 14:32:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
new_input.xmin -= margin;
|
|
|
|
|
new_input.ymin -= margin;
|
|
|
|
|
new_input.xmax += margin;
|
|
|
|
|
new_input.ymax += margin;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
operation = get_input_operation(0);
|
|
|
|
|
if (operation->determine_depending_area_of_interest(&new_input, read_operation, output)) {
|
2012-07-03 09:05:19 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2014-01-22 14:32:21 +01:00
|
|
|
#endif
|
2012-07-03 09:05:19 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
void ScreenLensDistortionOperation::update_variables(float distortion, float dispersion)
|
2012-07-03 09:05:19 +00:00
|
|
|
{
|
2021-10-13 23:01:04 +02:00
|
|
|
k_[1] = max_ff(min_ff(distortion, 1.0f), -0.999f);
|
2021-08-31 13:36:28 +10:00
|
|
|
/* Smaller dispersion range for somewhat more control. */
|
2014-01-22 14:32:21 +01:00
|
|
|
float d = 0.25f * max_ff(min_ff(dispersion, 1.0f), 0.0f);
|
2021-10-13 23:01:04 +02:00
|
|
|
k_[0] = max_ff(min_ff((k_[1] + d), 1.0f), -0.999f);
|
|
|
|
|
k_[2] = max_ff(min_ff((k_[1] - d), 1.0f), -0.999f);
|
|
|
|
|
maxk_ = max_fff(k_[0], k_[1], k_[2]);
|
|
|
|
|
sc_ = (fit_ && (maxk_ > 0.0f)) ? (1.0f / (1.0f + 2.0f * maxk_)) : (1.0f / (1.0f + maxk_));
|
|
|
|
|
dk4_[0] = 4.0f * (k_[1] - k_[0]);
|
|
|
|
|
dk4_[1] = 4.0f * (k_[2] - k_[1]);
|
|
|
|
|
dk4_[2] = 0.0f; /* unused */
|
|
|
|
|
|
|
|
|
|
mul_v3_v3fl(k4_, k_, 4.0f);
|
2012-06-22 14:43:25 +00:00
|
|
|
}
|
2021-03-23 17:12:27 +01:00
|
|
|
|
2021-09-28 19:33:06 +02:00
|
|
|
void ScreenLensDistortionOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
|
|
|
|
{
|
|
|
|
|
switch (execution_model_) {
|
|
|
|
|
case eExecutionModel::FullFrame: {
|
|
|
|
|
set_determined_canvas_modifier([=](rcti &canvas) {
|
|
|
|
|
/* Ensure screen space. */
|
|
|
|
|
BLI_rcti_translate(&canvas, -canvas.xmin, -canvas.ymin);
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NodeOperation::determine_canvas(preferred_area, r_area);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-23 15:30:18 +02:00
|
|
|
void ScreenLensDistortionOperation::get_area_of_interest(const int input_idx,
|
2022-10-03 17:37:25 -05:00
|
|
|
const rcti & /*output_area*/,
|
2021-08-23 15:30:18 +02:00
|
|
|
rcti &r_input_area)
|
|
|
|
|
{
|
|
|
|
|
if (input_idx != 0) {
|
2021-08-24 12:49:00 +10:00
|
|
|
/* Dispersion and distortion inputs are used as constants only. */
|
2021-09-28 19:32:49 +02:00
|
|
|
r_input_area = COM_CONSTANT_INPUT_AREA_OF_INTEREST;
|
2021-08-23 15:30:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* XXX the original method of estimating the area-of-interest does not work
|
|
|
|
|
* it assumes a linear increase/decrease of mapped coordinates, which does not
|
|
|
|
|
* yield correct results for the area and leaves uninitialized buffer areas.
|
|
|
|
|
* So now just use the full image area, which may not be as efficient but works at least ...
|
|
|
|
|
*/
|
|
|
|
|
#if 1
|
2021-10-13 23:01:15 +02:00
|
|
|
NodeOperation *image = get_input_operation(0);
|
2021-09-28 19:32:49 +02:00
|
|
|
r_input_area = image->get_canvas();
|
2021-08-23 15:30:18 +02:00
|
|
|
|
|
|
|
|
#else /* Original method in tiled implementation. */
|
2021-10-13 23:01:15 +02:00
|
|
|
rcti new_input;
|
2021-08-23 15:30:18 +02:00
|
|
|
const float margin = 2;
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
BLI_rcti_init_minmax(&new_input);
|
2021-08-23 15:30:18 +02:00
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
if (dispersion_const_ && distortion_const_) {
|
2021-08-23 15:30:18 +02:00
|
|
|
/* update from fixed distortion/dispersion */
|
|
|
|
|
# define UPDATE_INPUT(x, y) \
|
|
|
|
|
{ \
|
|
|
|
|
float coords[6]; \
|
|
|
|
|
determineUV(coords, x, y); \
|
2021-10-13 23:01:15 +02:00
|
|
|
new_input.xmin = min_ffff(new_input.xmin, coords[0], coords[2], coords[4]); \
|
|
|
|
|
new_input.ymin = min_ffff(new_input.ymin, coords[1], coords[3], coords[5]); \
|
|
|
|
|
new_input.xmax = max_ffff(new_input.xmax, coords[0], coords[2], coords[4]); \
|
|
|
|
|
new_input.ymax = max_ffff(new_input.ymax, coords[1], coords[3], coords[5]); \
|
2021-08-23 15:30:18 +02:00
|
|
|
} \
|
|
|
|
|
(void)0
|
|
|
|
|
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->xmax);
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->ymax);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymax);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymin);
|
|
|
|
|
|
|
|
|
|
# undef UPDATE_INPUT
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* use maximum dispersion 1.0 if not const */
|
2021-10-13 23:01:04 +02:00
|
|
|
float dispersion = dispersion_const_ ? dispersion_ : 1.0f;
|
2021-08-23 15:30:18 +02:00
|
|
|
|
|
|
|
|
# define UPDATE_INPUT(x, y, distortion) \
|
|
|
|
|
{ \
|
|
|
|
|
float coords[6]; \
|
2021-10-13 23:01:15 +02:00
|
|
|
update_variables(distortion, dispersion); \
|
2021-08-23 15:30:18 +02:00
|
|
|
determineUV(coords, x, y); \
|
2021-10-13 23:01:15 +02:00
|
|
|
new_input.xmin = min_ffff(new_input.xmin, coords[0], coords[2], coords[4]); \
|
|
|
|
|
new_input.ymin = min_ffff(new_input.ymin, coords[1], coords[3], coords[5]); \
|
|
|
|
|
new_input.xmax = max_ffff(new_input.xmax, coords[0], coords[2], coords[4]); \
|
|
|
|
|
new_input.ymax = max_ffff(new_input.ymax, coords[1], coords[3], coords[5]); \
|
2021-08-23 15:30:18 +02:00
|
|
|
} \
|
|
|
|
|
(void)0
|
|
|
|
|
|
2021-10-13 23:01:04 +02:00
|
|
|
if (distortion_const_) {
|
2021-08-23 15:30:18 +02:00
|
|
|
/* update from fixed distortion */
|
2021-10-13 23:01:04 +02:00
|
|
|
UPDATE_INPUT(input->xmin, input->xmax, distortion_);
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->ymax, distortion_);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymax, distortion_);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymin, distortion_);
|
2021-08-23 15:30:18 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* update from min/max distortion (-1..1) */
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->xmax, -1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->ymax, -1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymax, -1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymin, -1.0f);
|
|
|
|
|
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->xmax, 1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmin, input->ymax, 1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymax, 1.0f);
|
|
|
|
|
UPDATE_INPUT(input->xmax, input->ymin, 1.0f);
|
|
|
|
|
|
|
|
|
|
# undef UPDATE_INPUT
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
new_input.xmin -= margin;
|
|
|
|
|
new_input.ymin -= margin;
|
|
|
|
|
new_input.xmax += margin;
|
|
|
|
|
new_input.ymax += margin;
|
2021-08-23 15:30:18 +02:00
|
|
|
|
2021-10-13 23:01:15 +02:00
|
|
|
operation = get_input_operation(0);
|
|
|
|
|
if (operation->determine_depending_area_of_interest(&new_input, read_operation, output)) {
|
2021-08-23 15:30:18 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScreenLensDistortionOperation::update_memory_buffer_partial(MemoryBuffer *output,
|
|
|
|
|
const rcti &area,
|
|
|
|
|
Span<MemoryBuffer *> inputs)
|
|
|
|
|
{
|
|
|
|
|
const MemoryBuffer *input_image = inputs[0];
|
|
|
|
|
for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) {
|
2022-09-25 18:33:28 +10:00
|
|
|
float xy[2] = {float(it.x), float(it.y)};
|
2021-08-23 15:30:18 +02:00
|
|
|
float uv[2];
|
|
|
|
|
get_uv(xy, uv);
|
|
|
|
|
const float uv_dot = len_squared_v2(uv);
|
|
|
|
|
|
|
|
|
|
float delta[3][2];
|
2021-10-13 23:01:04 +02:00
|
|
|
const bool valid_r = get_delta(uv_dot, k4_[0], uv, delta[0]);
|
|
|
|
|
const bool valid_g = get_delta(uv_dot, k4_[1], uv, delta[1]);
|
|
|
|
|
const bool valid_b = get_delta(uv_dot, k4_[2], uv, delta[2]);
|
2021-08-23 15:30:18 +02:00
|
|
|
if (!(valid_r && valid_g && valid_b)) {
|
|
|
|
|
zero_v4(it.out);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int count[3] = {0, 0, 0};
|
|
|
|
|
float sum[4] = {0, 0, 0, 0};
|
|
|
|
|
accumulate(input_image, 0, 1, uv_dot, uv, delta, sum, count);
|
|
|
|
|
accumulate(input_image, 1, 2, uv_dot, uv, delta, sum, count);
|
|
|
|
|
|
|
|
|
|
if (count[0]) {
|
2022-09-25 18:33:28 +10:00
|
|
|
it.out[0] = 2.0f * sum[0] / float(count[0]);
|
2021-08-23 15:30:18 +02:00
|
|
|
}
|
|
|
|
|
if (count[1]) {
|
2022-09-25 18:33:28 +10:00
|
|
|
it.out[1] = 2.0f * sum[1] / float(count[1]);
|
2021-08-23 15:30:18 +02:00
|
|
|
}
|
|
|
|
|
if (count[2]) {
|
2022-09-25 18:33:28 +10:00
|
|
|
it.out[2] = 2.0f * sum[2] / float(count[2]);
|
2021-08-23 15:30:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set alpha. */
|
|
|
|
|
it.out[3] = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
} // namespace blender::compositor
|