Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 02, 2012
@julik Ensure vertex UV attributes also get distorted
We were previously only affecting the point attributes, which prevented SyUV from working with Nuke Sphere's. Fixes issue #10.
3957fb0
@julik Style and formatting fixes adbbd9e
Showing with 31 additions and 19 deletions.
  1. +4 −7 src/SyDistorter.cpp
  2. +1 −2  src/SyLens.cpp
  3. +26 −10 src/SyUV.cpp
View
11 src/SyDistorter.cpp
@@ -50,9 +50,6 @@ void SyDistorter::set_aspect(double a)
void SyDistorter::set_coefficients(double k, double k_cube, double aspect)
{
- // Do not reconfigure the object unless it's really needed
- if (k == k_ && k_cube == k_cube_ && aspect == aspect_) return;
-
k_ = k;
k_cube_ = k_cube;
aspect_ = aspect;
@@ -71,7 +68,7 @@ SyDistorter::~SyDistorter()
// Clear out the LUT
std::vector<LutTuple*>::iterator tuple_it;
for(tuple_it = lut.begin(); tuple_it != lut.end(); tuple_it++) {
- delete (*tuple_it);
+ delete(*tuple_it);
}
// Then the LUT gets deleted
}
@@ -245,10 +242,10 @@ void SyDistorter::distort_uv(Vector4& uv)
// Call the SY algo
apply_disto(syntheyes_uv);
- syntheyes_uv.x = ((syntheyes_uv.x / factor) + centerpoint_shift_in_uv_space) * uv.w;
- syntheyes_uv.y = ((syntheyes_uv.y / factor) + centerpoint_shift_in_uv_space) * uv.w;
+ syntheyes_uv.x = (syntheyes_uv.x / factor) + centerpoint_shift_in_uv_space;
+ syntheyes_uv.y = (syntheyes_uv.y / factor) + centerpoint_shift_in_uv_space;
- uv.set(syntheyes_uv.x, syntheyes_uv.y, uv.z, uv.w);
+ uv.set(syntheyes_uv.x * uv.w, syntheyes_uv.y * uv.w, uv.z, uv.w);
}
double SyDistorter::aspect()
View
3  src/SyLens.cpp
@@ -46,8 +46,7 @@ static const char* const HELP = "This plugin undistorts footage according "
#include "VERSION.h"
-static const char* const output_mode_names[] = { "undistorted", "redistorted", 0 };
-
+static const char* const output_mode_names[] = { "remove disto", "apply disto", 0 };
class SyLens : public Iop
{
View
36 src/SyUV.cpp
@@ -30,6 +30,9 @@ class SyUV : public ModifyGeo
// The distortion engine
SyDistorter distorter;
+ // Group type ptr detected in keep_uvs()
+ DD::Image::GroupType t_group_type;
+
public:
static const Description description;
@@ -97,26 +100,25 @@ class SyUV : public ModifyGeo
// get the original uv attribute used to restore untouched uv coordinate
const AttribContext* context = info.get_attribcontext(uv_attrib_name);
AttributePtr uv_original = context ? context->attribute : AttributePtr();
-
+
if(!uv_original){
Op::error( "Missing \"%s\" channel from geometry", uv_attrib_name );
return;
}
- DD::Image::GroupType t_group_type = context->group; // texture coordinate group type
+ t_group_type = context->group; // texture coordinate group type
// we have two possibilities:
// the uv coordinate are stored in Group_Points or in Group_Vertices way
// sanity check
assert(t_group_type == Group_Points || t_group_type == Group_Vertices);
-
+
// create a buffer to write on it
Attribute* uv = out.writable_attribute(index, t_group_type, uv_attrib_name, VECTOR4_ATTRIB);
assert(uv);
// copy all original texture coordinate if available
if (uv_original){
-
// sanity check
assert(uv->size() == uv_original->size());
@@ -128,7 +130,6 @@ class SyUV : public ModifyGeo
void modify_geometry(int obj, Scene& scene, GeometryList& out)
{
- const char* uv_attrib_name = "uv";
// Call the engine on all the caches:
for (unsigned i = 0; i < out.objects(); i++) {
GeoInfo& info = out[i];
@@ -136,12 +137,27 @@ class SyUV : public ModifyGeo
// Copy over old UV attributes
keep_uvs(i, info, out);
- // Create a point attribute
- Attribute* uv = out.writable_attribute(i, Group_Points, uv_attrib_name, VECTOR4_ATTRIB);
- if(!uv) return;
+ // Write vertex attribs
+ Attribute* uv;
+
+ // Copy over pt attributes
+ uv = out.writable_attribute(i, Group_Points, uv_attrib_name, VECTOR4_ATTRIB);
+ if(uv) {
+ for (unsigned point_idx = 0; point_idx < info.points(); point_idx++) {
+ distorter.distort_uv(uv->vector4(point_idx));
+ }
+ }
- for (unsigned p = 0; p < info.points(); p++) {
- distorter.distort_uv(uv->vector4(p));
+ // If the previously detected group type is vertex attribute we need to distort it as well
+ // since vertex attribs take precedence and say a Sphere in Nuke has vertex attribs
+ // as opposed to point attribs :-( so justified double work here
+ if(t_group_type == Group_Vertices) {
+ // Copy over vertex attributes
+ uv = out.writable_attribute(i, Group_Vertices, uv_attrib_name, VECTOR4_ATTRIB);
+ if(!uv) return;
+ for (unsigned vtx_idx = 0; vtx_idx < info.vertices(); vtx_idx++) {
+ distorter.distort_uv(uv->vector4(vtx_idx));
+ }
}
}
}

No commit comments for this range

Something went wrong with that request. Please try again.