Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 66ec4d2

Browse files
author
haruto.watanabe
committed
Avoid GC allocate
1 parent 969f10c commit 66ec4d2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

PostProcessing/Runtime/Components/ColorGradingComponent.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ static class Uniforms
3434

3535
Texture2D m_GradingCurves;
3636

37+
38+
Color[] m_pixels = new Color[k_CurvePrecision * 2];
39+
3740
public override bool active
3841
{
3942
get
@@ -236,9 +239,7 @@ Texture2D GetCurveTexture()
236239
};
237240
}
238241

239-
var pixels = new Color[k_CurvePrecision * 2];
240242
var curves = model.settings.curves;
241-
242243
curves.hueVShue.Cache();
243244
curves.hueVSsat.Cache();
244245

@@ -251,17 +252,17 @@ Texture2D GetCurveTexture()
251252
float y = curves.hueVSsat.Evaluate(t);
252253
float z = curves.satVSsat.Evaluate(t);
253254
float w = curves.lumVSsat.Evaluate(t);
254-
pixels[i] = new Color(x, y, z, w);
255+
m_pixels[i] = new Color(x, y, z, w);
255256

256257
// YRGB
257258
float m = curves.master.Evaluate(t);
258259
float r = curves.red.Evaluate(t);
259260
float g = curves.green.Evaluate(t);
260261
float b = curves.blue.Evaluate(t);
261-
pixels[i + k_CurvePrecision] = new Color(r, g, b, m);
262+
m_pixels[i + k_CurvePrecision] = new Color(r, g, b, m);
262263
}
263264

264-
m_GradingCurves.SetPixels(pixels);
265+
m_GradingCurves.SetPixels(m_pixels);
265266
m_GradingCurves.Apply(false, false);
266267

267268
return m_GradingCurves;

0 commit comments

Comments
 (0)