New option to specify the angular threshold for detecting crease edges.
An entry "Crease Angle" has been added to the Layers tab of the Render buttons, to allow users to specify an angle (between 0 and 180) used for crease edge detection. An edge is considered a crease edge if the angle between two faces sharing the edge is smaller than the threshold. The default value is 134.43 degrees (for backward compatibility). Be aware that a larger threshold leads to a larger number of feature edges and thus a larger memory consumption.
This commit is contained in:
@@ -182,6 +182,7 @@ class RENDER_PT_layers(RenderButtonsPanel):
|
||||
col = split.column()
|
||||
col.label(text="Freestyle:")
|
||||
freestyle = rl.freestyle_settings
|
||||
col.prop(freestyle, "crease_angle", text="Crease Angle")
|
||||
col.prop(freestyle, "sphere_radius", text="Sphere Radius")
|
||||
col.prop(freestyle, "ridges_and_valleys", text="Ridges and Valleys")
|
||||
col.prop(freestyle, "suggestive_contours", text="Suggestive Contours")
|
||||
|
||||
@@ -116,6 +116,7 @@ Controller::Controller()
|
||||
_ComputeSuggestive = true;
|
||||
_ComputeMaterialBoundaries = true;
|
||||
_sphereRadius = 1.0;
|
||||
_creaseAngle = 134.43;
|
||||
|
||||
init_options();
|
||||
}
|
||||
@@ -468,6 +469,7 @@ void Controller::ComputeViewMap()
|
||||
edgeDetector.enableRidgesAndValleysFlag(_ComputeRidges);
|
||||
edgeDetector.enableSuggestiveContours(_ComputeSuggestive);
|
||||
edgeDetector.enableMaterialBoundaries(_ComputeMaterialBoundaries);
|
||||
edgeDetector.setCreaseAngle(_creaseAngle);
|
||||
edgeDetector.setSphereRadius(_sphereRadius);
|
||||
edgeDetector.setSuggestiveContourKrDerivativeEpsilon(_suggestiveContourKrDerivativeEpsilon);
|
||||
edgeDetector.processShapes(*_winged_edge);
|
||||
|
||||
@@ -124,6 +124,8 @@ public:
|
||||
|
||||
void setComputeSteerableViewMapFlag(bool iBool);
|
||||
bool getComputeSteerableViewMapFlag() const;
|
||||
void setCreaseAngle(real angle){_creaseAngle=angle;}
|
||||
real getCreaseAngle() const {return _creaseAngle;}
|
||||
void setSphereRadius(real s){_sphereRadius=s;}
|
||||
real getSphereRadius() const {return _sphereRadius;}
|
||||
void setSuggestiveContourKrDerivativeEpsilon(real dkr){_suggestiveContourKrDerivativeEpsilon=dkr;}
|
||||
@@ -225,6 +227,7 @@ private:
|
||||
bool _ComputeRidges;
|
||||
bool _ComputeSuggestive;
|
||||
bool _ComputeMaterialBoundaries;
|
||||
real _creaseAngle;
|
||||
real _sphereRadius;
|
||||
real _suggestiveContourKrDerivativeEpsilon;
|
||||
|
||||
|
||||
@@ -159,12 +159,14 @@ extern "C" {
|
||||
cout << endl;
|
||||
|
||||
// set parameters
|
||||
controller->setCreaseAngle( config->crease_angle );
|
||||
controller->setSphereRadius( config->sphere_radius );
|
||||
controller->setComputeRidgesAndValleysFlag( (config->flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false);
|
||||
controller->setComputeSuggestiveContoursFlag( (config->flags & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false);
|
||||
controller->setComputeMaterialBoundariesFlag( (config->flags & FREESTYLE_MATERIAL_BOUNDARIES_FLAG) ? true : false);
|
||||
controller->setSuggestiveContourKrDerivativeEpsilon( config->dkr_epsilon ) ;
|
||||
|
||||
cout << "Crease angle : " << controller->getCreaseAngle() << endl;
|
||||
cout << "Sphere radius : " << controller->getSphereRadius() << endl;
|
||||
cout << "Redges and valleys : " << (controller->getComputeRidgesAndValleysFlag() ? "enabled" : "disabled") << endl;
|
||||
cout << "Suggestive contours : " << (controller->getComputeSuggestiveContoursFlag() ? "enabled" : "disabled") << endl;
|
||||
@@ -312,6 +314,7 @@ extern "C" {
|
||||
config->flags = 0;
|
||||
config->sphere_radius = 1.0;
|
||||
config->dkr_epsilon = 0.001;
|
||||
config->crease_angle = 134.43;
|
||||
}
|
||||
|
||||
void FRS_free_freestyle_config( SceneRenderLayer* srl )
|
||||
|
||||
@@ -370,7 +370,7 @@ void FEdgeXDetector::ProcessCreaseEdge(WXEdge *iEdge)
|
||||
WXFace * fB = (WXFace *)iEdge->GetaOEdge()->GetbFace();
|
||||
|
||||
WVertex * aVertex = iEdge->GetaVertex();
|
||||
if((fA->GetVertexNormal(aVertex) * fB->GetVertexNormal(aVertex)) <= 0.7) // angle of 140 degrees
|
||||
if((fA->GetVertexNormal(aVertex) * fB->GetVertexNormal(aVertex)) <= _creaseAngle)
|
||||
iEdge->AddNature(Nature::CREASE);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
_orthographicProjection = false;
|
||||
_changes = false;
|
||||
_kr_derivative_epsilon = 0.0;
|
||||
_creaseAngle = 0.7; // angle of 134.43 degrees
|
||||
}
|
||||
virtual ~FEdgeXDetector() {}
|
||||
|
||||
@@ -79,6 +80,23 @@ public:
|
||||
// CREASE
|
||||
virtual void processCreaseShape(WXShape* iShape);
|
||||
virtual void ProcessCreaseEdge(WXEdge *iEdge);
|
||||
/*! Sets the minimum angle for detecting crease edges
|
||||
* \param angle
|
||||
* The angular threshold in degrees (between 0 and 180) for detecting crease
|
||||
* edges. An edge is considered a crease edge if the angle between two faces
|
||||
* sharing the edge is smaller than the given threshold.
|
||||
*/
|
||||
inline void setCreaseAngle(real angle) {
|
||||
if (angle < 0.0)
|
||||
angle = 0.0;
|
||||
else if (angle > 180.0)
|
||||
angle = 180.0;
|
||||
angle = cos(M_PI * (180.0 - angle) / 180.0);
|
||||
if (angle != _creaseAngle){
|
||||
_creaseAngle = angle;
|
||||
_changes = true;
|
||||
}
|
||||
}
|
||||
|
||||
// BORDER
|
||||
virtual void processBorderShape(WXShape* iShape);
|
||||
@@ -150,6 +168,7 @@ protected:
|
||||
bool _computeSuggestiveContours;
|
||||
bool _computeMaterialBoundaries;
|
||||
real _sphereRadius; // expressed as a ratio of the mean edge size
|
||||
real _creaseAngle; // [-1, 1] compared with the inner product of face normals
|
||||
bool _changes;
|
||||
|
||||
real _kr_derivative_epsilon;
|
||||
|
||||
@@ -22,7 +22,7 @@ typedef struct FreestyleConfig {
|
||||
int flags;
|
||||
float sphere_radius;
|
||||
float dkr_epsilon;
|
||||
int pad;
|
||||
float crease_angle;
|
||||
|
||||
} FreestyleConfig;
|
||||
|
||||
|
||||
@@ -1527,6 +1527,12 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
|
||||
RNA_def_property_range(prop, 0.0, 1000.0);
|
||||
RNA_def_property_ui_text(prop, "Dkr Epsilon", "*TBD*");
|
||||
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "crease_angle", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "crease_angle");
|
||||
RNA_def_property_range(prop, 0.0, 180.0);
|
||||
RNA_def_property_ui_text(prop, "Crease Angle", "Angular threshold in degrees (between 0 and 180) for detecting crease edges.");
|
||||
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||
}
|
||||
|
||||
static void rna_def_scene_game_data(BlenderRNA *brna)
|
||||
|
||||
Reference in New Issue
Block a user