Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I expand the radius of a light bloom?
    primarykey
    data
    text
    <p>I am writing a software filter object and trying to implement a light bloom effect. I'm using a simple, two pass convolution approach which works fine except that the effect radius is tiny and I can't seem to control the radius. I've played with larger box filters and adjusted the weights of the various pixels, but none of that seems to have any effect. The effect seems to have a maximum size (which is not very big) and then all changes to the parameters just serve to make it smaller.</p> <p>I'd like to be able to create a light bloom with an arbitrary radius. After a LOT of experimentation and searching online, I'm starting to wonder if this just can't be done. I've been thinking about alternate approaches--plasmas, gradients, and various seeding schemes--but I'd like to hound this path into the ground first. Does anyone out there know how to create an arbitrarily sized light bloom (in software)?</p> <p>The javascript is as follows (this operates on an HTML5 canvas; I can add comments to the code if needed):</p> <pre><code>// the kernel functions are called via Array.map on this.backBuffer.data, a canvas surface color array this.kernelFirstPass = function(val, index, array) { if(index&lt;pitch || index&gt;=array.length-pitch || index%pitch&lt;4 || index%pitch&gt;pitch-5 || index%4==3) return; var c = 1, l1 = 1, l2 = 1, l3 = 1, r1 = 1, r2 = 1, r3 = 1; var avg = ( c*this.frontBuffer.data[index]+ l1*this.frontBuffer.data[index-4]+ l2*this.frontBuffer.data[index-8]+ l3*this.frontBuffer.data[index-12]+ l1*this.frontBuffer.data[index+4]+ l2*this.frontBuffer.data[index+8]+ l3*this.frontBuffer.data[index+12] )/(c+l1+l2+l3+l1+l2+l3); //this.frontBuffer.data[index] = avg; array[index] = avg; } this.kernelSecondPass = function(val, index, array) { if(index&lt;pitch || index&gt;=array.length-pitch || index%pitch&lt;4 || index%pitch&gt;=pitch-4 || index%4==3) return; var c = 1, l1 = 1, l2 = 1, l3 = 1, r1 = 1, r2 = 1, r3 = 1; var avg = ( c*array[index]+ l1*array[index-pitch]+ l2*array[index-(pitch*2)]+ l3*array[index-(pitch*3)]+ l1*array[index+pitch]+ l2*array[index+(pitch*2)]+ l3*array[index+(pitch*3)] )/(c+l1+l2+l3+l1+l2+l3); array[index] = avg; } </code></pre> <hr> <p>Perhaps an important point that I missed in my original question was to explain that I'm not trying to simulate any real or particular phenomenon (and it probably doesn't help that I call it a "light" bloom). It could be that, when dealing with real light phenomenon, in order to have a penumbra with arbitrary radius you need a source (ie. "completely saturated area") with arbitrary radius. If that were in fact the way a real light bloom behaved, then Jim's and tskuzzy's explanations would seem like reasonable approaches to simulating that. Regardless, that's not what I'm trying to accomplish. I want to control the radius of the "gradient" portion of the bloom independently from the size/intensity/etc. of the source. I'd like to be able to set a single, white (max value) pixel in the center of the screen and have the bloom grow out as far as I want it, to the edges of the screen or beyond if I feel like it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload