Skip to content

Commit

Permalink
Bug fixes on graph drawing
Browse files Browse the repository at this point in the history
- Added upper limit for the intensity parameter to prevent sampling errors in
  graph drawing.
- Added lower bound for the threshold parameter.
- Slightly increased the resolution of the graph.
  • Loading branch information
Keijiro Takahashi authored and Keijiro Takahashi committed Mar 23, 2016
1 parent 7ff33cb commit ed6bd70
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Assets/Kino/Bloom/Bloom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public float thresholdGamma {
/// Prefilter threshold (linearly-encoded)
/// Filters out pixels under this level of brightness.
public float thresholdLinear {
get { return GammaToLinear(_threshold); }
get { return GammaToLinear(thresholdGamma); }
set { _threshold = LinearToGamma(value); }
}

Expand Down
26 changes: 17 additions & 9 deletions Assets/Kino/Bloom/Editor/BloomGraphDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public void Prepare(Bloom bloom)

_threshold = bloom.thresholdLinear;
_knee = bloom.softKnee * _threshold + 1e-5f;
_intensity = bloom.intensity;

// Intensity is capped to prevent sampling errors.
_intensity = Mathf.Min(bloom.intensity, 10);
}

// Draw the graph at the current position.
Expand Down Expand Up @@ -90,17 +92,23 @@ public void DrawGraph()
}
else
{
// Extend the last segment up to the top edge of the rect.
var v1 = _curveVertices[vcount - 2];
var v2 = _curveVertices[vcount - 1];
var clip = (_rectGraph.y - v1.y) / (v2.y - v1.y);
_curveVertices[vcount - 1] = v1 + (v2 - v1) * clip;
if (vcount > 1)
{
// Extend the last segment to the top edge of the rect.
var v1 = _curveVertices[vcount - 2];
var v2 = _curveVertices[vcount - 1];
var clip = (_rectGraph.y - v1.y) / (v2.y - v1.y);
_curveVertices[vcount - 1] = v1 + (v2 - v1) * clip;
}
break;
}
}

Handles.color = Color.white * 0.9f;
Handles.DrawAAPolyLine(2.0f, vcount, _curveVertices);
if (vcount > 1)
{
Handles.color = Color.white * 0.9f;
Handles.DrawAAPolyLine(2.0f, vcount, _curveVertices);
}
}

#endregion
Expand All @@ -123,7 +131,7 @@ float ResponseFunction(float x)
#region Graph Functions

// Number of vertices in curve
const int _curveResolution = 64;
const int _curveResolution = 96;

// Vertex buffers
Vector3[] _rectVertices = new Vector3[4];
Expand Down

0 comments on commit ed6bd70

Please sign in to comment.