Compare commits

...

2 Commits
4.3.0 ... 4.4.0

Author SHA1 Message Date
semantic-release-bot
3fac6e4773 chore(release): 4.4.0 [skip ci]
# [4.4.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.3.0...4.4.0) (2023-11-08)

### Features

* support 'Active Apply Color Space' for linear color space ([45c56bb](45c56bbd85))
2023-11-08 11:31:04 +00:00
mob-sakai
45c56bbd85 feat: support 'Active Apply Color Space' for linear color space 2023-11-08 20:24:38 +09:00
5 changed files with 46 additions and 13 deletions

View File

@@ -1,3 +1,10 @@
# [4.4.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.3.0...4.4.0) (2023-11-08)
### Features
* support 'Active Apply Color Space' for linear color space ([45c56bb](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/45c56bbd850202365751ea019baf5131b2eb9fbe))
# [4.3.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.2.2...4.3.0) (2023-11-08) # [4.3.0](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/4.2.2...4.3.0) (2023-11-08)

View File

@@ -332,8 +332,6 @@ namespace Coffee.UIExtensions
DestroyUIParticle(current); DestroyUIParticle(current);
} }
// #203: When using linear color space, the particle colors are not output correctly.
// To fix, set 'Apply Active Color Space' in renderer module to false.
var allPsRenderers = targets.OfType<UIParticle>() var allPsRenderers = targets.OfType<UIParticle>()
.SelectMany(x => x.particles) .SelectMany(x => x.particles)
.Where(x => x) .Where(x => x)
@@ -341,16 +339,6 @@ namespace Coffee.UIExtensions
.ToArray(); .ToArray();
if (0 < allPsRenderers.Length) if (0 < allPsRenderers.Length)
{ {
var so = new SerializedObject(allPsRenderers);
var sp = so.FindProperty("m_ApplyActiveColorSpace");
label = "When using linear color space, the particle colors are not output correctly.\n" +
"To fix, set 'Apply Active Color Space' in renderer module to false.";
if (FixButton(sp.boolValue || sp.hasMultipleDifferentValues, label))
{
sp.boolValue = false;
so.ApplyModifiedProperties();
}
// Check to use 'TEXCOORD*.zw' components as custom vertex stream. // Check to use 'TEXCOORD*.zw' components as custom vertex stream.
foreach (var psr in allPsRenderers) foreach (var psr in allPsRenderers)
{ {

View File

@@ -18,6 +18,7 @@ namespace Coffee.UIExtensions
private static readonly List<Material> s_Materials = new List<Material>(2); private static readonly List<Material> s_Materials = new List<Material>(2);
private static MaterialPropertyBlock s_Mpb; private static MaterialPropertyBlock s_Mpb;
private static readonly List<UIParticleRenderer> s_Renderers = new List<UIParticleRenderer>(); private static readonly List<UIParticleRenderer> s_Renderers = new List<UIParticleRenderer>();
private static readonly List<Color32> s_Colors = new List<Color32>();
private static readonly Vector3[] s_Corners = new Vector3[4]; private static readonly Vector3[] s_Corners = new Vector3[4];
private Material _currentMaterialForRendering; private Material _currentMaterialForRendering;
private bool _delay; private bool _delay;
@@ -380,6 +381,24 @@ namespace Coffee.UIExtensions
bounds.extents = extents; bounds.extents = extents;
workerMesh.bounds = bounds; workerMesh.bounds = bounds;
_lastBounds = bounds; _lastBounds = bounds;
// Convert linear color to gamma color.
if (QualitySettings.activeColorSpace == ColorSpace.Linear)
{
Profiler.BeginSample("[UIParticleRenderer] Convert Linear to Gamma");
workerMesh.GetColors(s_Colors);
var count_c = s_Colors.Count;
for (var i = 0; i < count_c; i++)
{
var c = s_Colors[i];
c.r = c.r.LinearToGamma();
c.g = c.g.LinearToGamma();
c.b = c.b.LinearToGamma();
s_Colors[i] = c;
}
workerMesh.SetColors(s_Colors);
Profiler.EndSample();
}
} }
Profiler.EndSample(); Profiler.EndSample();

View File

@@ -6,6 +6,25 @@ using Object = UnityEngine.Object;
namespace Coffee.UIParticleExtensions namespace Coffee.UIParticleExtensions
{ {
public static class Color32Extensions
{
private static byte[] s_LinearToGammaLut;
public static byte LinearToGamma(this byte self)
{
if (s_LinearToGammaLut == null)
{
s_LinearToGammaLut = new byte[256];
for (var i = 0; i < 256; i++)
{
s_LinearToGammaLut[i] = (byte)(Mathf.LinearToGammaSpace(i / 255f) * 255f);
}
}
return s_LinearToGammaLut[self];
}
}
public static class Vector3Extensions public static class Vector3Extensions
{ {
public static Vector3 Inverse(this Vector3 self) public static Vector3 Inverse(this Vector3 self)

View File

@@ -2,7 +2,7 @@
"name": "com.coffee.ui-particle", "name": "com.coffee.ui-particle",
"displayName": "UI Particle", "displayName": "UI Particle",
"description": "This plugin provide a component to render particle effect for uGUI.\nThe particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.", "description": "This plugin provide a component to render particle effect for uGUI.\nThe particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.",
"version": "4.3.0", "version": "4.4.0",
"unity": "2018.2", "unity": "2018.2",
"license": "MIT", "license": "MIT",
"repository": { "repository": {