@@ -584,7 +584,7 @@ void ParticleSystem2D::render() {
584584 continue ;
585585 // generate RGB values for particle
586586 if (fireIntesity) { // fire mode
587- brightness = (uint32_t )particles[i].ttl * (3 + (fireIntesity >> 5 )) + 20 ;
587+ brightness = (uint32_t )particles[i].ttl * (3 + (fireIntesity >> 5 )) + 5 ;
588588 brightness = min (brightness, (uint32_t )255 );
589589 baseRGB = ColorFromPaletteWLED (SEGPALETTE, brightness, 255 , LINEARBLEND_NOWRAP);
590590 }
@@ -600,6 +600,7 @@ void ParticleSystem2D::render() {
600600 baseRGB = (CRGB)tempcolor;
601601 }
602602 }
603+ brightness = gamma8 (brightness); // apply gamma correction, used for gamma-inverted brightness distribution
603604 renderParticle (i, brightness, baseRGB, particlesettings.wrapX , particlesettings.wrapY );
604605 }
605606
@@ -676,6 +677,14 @@ __attribute__((optimize("O2"))) void ParticleSystem2D::renderParticle(const uint
676677 pxlbrightness[1 ] = (dx * precal2) >> PS_P_SURFACE; // bottom right value equal to (dx * (PS_P_RADIUS-dy) * brightness) >> PS_P_SURFACE
677678 pxlbrightness[2 ] = (dx * precal3) >> PS_P_SURFACE; // top right value equal to (dx * dy * brightness) >> PS_P_SURFACE
678679 pxlbrightness[3 ] = (precal1 * precal3) >> PS_P_SURFACE; // top left value equal to ((PS_P_RADIUS-dx) * dy * brightness) >> PS_P_SURFACE
680+ // adjust brightness such that distribution is linear after gamma correction:
681+ // - scale brigthness with gamma correction (done in render())
682+ // - apply inverse gamma correction to brightness values
683+ // - gamma is applied again in show() -> the resulting brightness distribution is linear but gamma corrected in total
684+ pxlbrightness[0 ] = gamma8inv (pxlbrightness[0 ]); // use look-up-table for invers gamma
685+ pxlbrightness[1 ] = gamma8inv (pxlbrightness[1 ]);
686+ pxlbrightness[2 ] = gamma8inv (pxlbrightness[2 ]);
687+ pxlbrightness[3 ] = gamma8inv (pxlbrightness[3 ]);
679688
680689 if (advPartProps && advPartProps[particleindex].size > 1 ) { // render particle to a bigger size
681690 CRGB renderbuffer[100 ]; // 10x10 pixel buffer
@@ -1467,6 +1476,7 @@ void ParticleSystem1D::render() {
14671476 baseRGB = (CRGB)tempcolor;
14681477 }
14691478 }
1479+ brightness = gamma8 (brightness); // apply gamma correction, used for gamma-inverted brightness distribution
14701480 renderParticle (i, brightness, baseRGB, particlesettings.wrap );
14711481 }
14721482 // apply smear-blur to rendered frame
@@ -1534,6 +1544,12 @@ __attribute__((optimize("O2"))) void ParticleSystem1D::renderParticle(const uint
15341544 // calculate the brightness values for both pixels using linear interpolation (note: in standard rendering out of frame pixels could be skipped but if checks add more clock cycles over all)
15351545 pxlbrightness[0 ] = (((int32_t )PS_P_RADIUS_1D - dx) * brightness) >> PS_P_SURFACE_1D;
15361546 pxlbrightness[1 ] = (dx * brightness) >> PS_P_SURFACE_1D;
1547+ // adjust brightness such that distribution is linear after gamma correction:
1548+ // - scale brigthness with gamma correction (done in render())
1549+ // - apply inverse gamma correction to brightness values
1550+ // - gamma is applied again in show() -> the resulting brightness distribution is linear but gamma corrected in total
1551+ pxlbrightness[0 ] = gamma8inv (pxlbrightness[0 ]); // use look-up-table for invers gamma
1552+ pxlbrightness[1 ] = gamma8inv (pxlbrightness[1 ]);
15371553
15381554 // check if particle has advanced size properties and buffer is available
15391555 if (advPartProps && advPartProps[particleindex].size > 1 ) {
0 commit comments