my modification of HDRish
the following will create a less-intense and tightly-spread glow that doesn't spill everywhere like the original did.
shader samplePixelShader =
"!!ARBfp1.0
TEMP Temp;
TEX result.color, fragment.texcoord[0], texture[0], 2D;
END";
shader gaussianXPixelShader =
"!!ARBfp1.0
PARAM Offset[11]={ program.local[0..10] };
PARAM Weight[3]=
{
{ 0.182008, 0.116053, 0.073999, 0.047184 },
{ 0.030086, 0.019183, 0.012232, 0.007799 },
{ 0.004973, 0.003171, 0.002022, 0.001289 }
};
TEMP s0, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10;
ADD r0, -Offset[10], fragment.texcoord[0];
ADD r1, -Offset[ 9], fragment.texcoord[0];
ADD r2, -Offset[ 8], fragment.texcoord[0];
ADD r3, -Offset[ 7], fragment.texcoord[0];
ADD r4, -Offset[ 6], fragment.texcoord[0];
ADD r5, -Offset[ 5], fragment.texcoord[0];
ADD r6, -Offset[ 4], fragment.texcoord[0];
ADD r7, -Offset[ 3], fragment.texcoord[0];
ADD r8, -Offset[ 2], fragment.texcoord[0];
ADD r9, -Offset[ 1], fragment.texcoord[0];
ADD r10, -Offset[ 0], fragment.texcoord[0];
MOV s0, fragment.texcoord[0];
TEX r0, r0, texture[0], 2D;
TEX r1, r1, texture[0], 2D;
TEX r2, r2, texture[0], 2D;
TEX r3, r3, texture[0], 2D;
TEX r4, r4, texture[0], 2D;
TEX r5, r5, texture[0], 2D;
TEX r6, r6, texture[0], 2D;
TEX r7, r7, texture[0], 2D;
TEX r8, r8, texture[0], 2D;
TEX r9, r9, texture[0], 2D;
TEX r10, r10, texture[0], 2D;
TEX s0, s0, texture[0], 2D;
MUL s0, s0, Weight[0].x;
MAD s0, r0, Weight[2].w, s0;
MAD s0, r1, Weight[2].z, s0;
MAD s0, r2, Weight[2].y, s0;
MAD s0, r3, Weight[2].x, s0;
MAD s0, r4, Weight[1].w, s0;
MAD s0, r5, Weight[1].z, s0;
MAD s0, r6, Weight[1].y, s0;
MAD s0, r7, Weight[1].x, s0;
MAD s0, r8, Weight[0].w, s0;
MAD s0, r9, Weight[0].z, s0;
MAD s0, r10, Weight[0].y, s0;
ADD r0, Offset[ 0], fragment.texcoord[0];
ADD r1, Offset[ 1], fragment.texcoord[0];
ADD r2, Offset[ 2], fragment.texcoord[0];
ADD r3, Offset[ 3], fragment.texcoord[0];
ADD r4, Offset[ 4], fragment.texcoord[0];
ADD r5, Offset[ 5], fragment.texcoord[0];
ADD r6, Offset[ 6], fragment.texcoord[0];
ADD r7, Offset[ 7], fragment.texcoord[0];
ADD r8, Offset[ 8], fragment.texcoord[0];
ADD r9, Offset[ 9], fragment.texcoord[0];
ADD r10, Offset[10], fragment.texcoord[0];
TEX r0, r0, texture[0], 2D;
TEX r1, r1, texture[0], 2D;
TEX r2, r2, texture[0], 2D;
TEX r3, r3, texture[0], 2D;
TEX r4, r4, texture[0], 2D;
TEX r5, r5, texture[0], 2D;
TEX r6, r6, texture[0], 2D;
TEX r7, r7, texture[0], 2D;
TEX r8, r8, texture[0], 2D;
TEX r9, r9, texture[0], 2D;
TEX r10, r10, texture[0], 2D;
MAD s0, r0, Weight[0].y, s0;
MAD s0, r1, Weight[0].z, s0;
MAD s0, r2, Weight[0].w, s0;
MAD s0, r3, Weight[1].x, s0;
MAD s0, r4, Weight[1].y, s0;
MAD s0, r5, Weight[1].z, s0;
MAD s0, r6, Weight[1].w, s0;
MAD s0, r7, Weight[2].x, s0;
MAD s0, r8, Weight[2].y, s0;
MAD s0, r9, Weight[2].z, s0;
MAD s0, r10, Weight[2].w, s0;
MOV result.color, s0;
END";
shader gaussianYPixelShader =
"!!ARBfp1.0
PARAM Offset[11]={ program.local[0..10] };
PARAM Weight[3]=
{
{ 0.182008, 0.116053, 0.073999, 0.047184 },
{ 0.030086, 0.019183, 0.012232, 0.007799 },
{ 0.004973, 0.003171, 0.002022, 0.001289 }
};
TEMP s0, r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10;
ADD r0, -Offset[10], fragment.texcoord[0];
ADD r1, -Offset[ 9], fragment.texcoord[0];
ADD r2, -Offset[ 8], fragment.texcoord[0];
ADD r3, -Offset[ 7], fragment.texcoord[0];
ADD r4, -Offset[ 6], fragment.texcoord[0];
ADD r5, -Offset[ 5], fragment.texcoord[0];
ADD r6, -Offset[ 4], fragment.texcoord[0];
ADD r7, -Offset[ 3], fragment.texcoord[0];
ADD r8, -Offset[ 2], fragment.texcoord[0];
ADD r9, -Offset[ 1], fragment.texcoord[0];
ADD r10, -Offset[ 0], fragment.texcoord[0];
MOV s0, fragment.texcoord[0];
TEX r0, r0, texture[0], 2D;
TEX r1, r1, texture[0], 2D;
TEX r2, r2, texture[0], 2D;
TEX r3, r3, texture[0], 2D;
TEX r4, r4, texture[0], 2D;
TEX r5, r5, texture[0], 2D;
TEX r6, r6, texture[0], 2D;
TEX r7, r7, texture[0], 2D;
TEX r8, r8, texture[0], 2D;
TEX r9, r9, texture[0], 2D;
TEX r10, r10, texture[0], 2D;
TEX s0, s0, texture[0], 2D;
MUL s0, s0, Weight[0].x;
MAD s0, r0, Weight[2].w, s0;
MAD s0, r1, Weight[2].z, s0;
MAD s0, r2, Weight[2].y, s0;
MAD s0, r3, Weight[2].x, s0;
MAD s0, r4, Weight[1].w, s0;
MAD s0, r5, Weight[1].z, s0;
MAD s0, r6, Weight[1].y, s0;
MAD s0, r7, Weight[1].x, s0;
MAD s0, r8, Weight[0].w, s0;
MAD s0, r9, Weight[0].z, s0;
MAD s0, r10, Weight[0].y, s0;
ADD r0, Offset[ 0], fragment.texcoord[0];
ADD r1, Offset[ 1], fragment.texcoord[0];
ADD r2, Offset[ 2], fragment.texcoord[0];
ADD r3, Offset[ 3], fragment.texcoord[0];
ADD r4, Offset[ 4], fragment.texcoord[0];
ADD r5, Offset[ 5], fragment.texcoord[0];
ADD r6, Offset[ 6], fragment.texcoord[0];
ADD r7, Offset[ 7], fragment.texcoord[0];
ADD r8, Offset[ 8], fragment.texcoord[0];
ADD r9, Offset[ 9], fragment.texcoord[0];
ADD r10, Offset[10], fragment.texcoord[0];
TEX r0, r0, texture[0], 2D;
TEX r1, r1, texture[0], 2D;
TEX r2, r2, texture[0], 2D;
TEX r3, r3, texture[0], 2D;
TEX r4, r4, texture[0], 2D;
TEX r5, r5, texture[0], 2D;
TEX r6, r6, texture[0], 2D;
TEX r7, r7, texture[0], 2D;
TEX r8, r8, texture[0], 2D;
TEX r9, r9, texture[0], 2D;
TEX r10, r10, texture[0], 2D;
MAD s0, r0, Weight[0].y, s0;
MAD s0, r1, Weight[0].z, s0;
MAD s0, r2, Weight[0].w, s0;
MAD s0, r3, Weight[1].x, s0;
MAD s0, r4, Weight[1].y, s0;
MAD s0, r5, Weight[1].z, s0;
MAD s0, r6, Weight[1].w, s0;
MAD s0, r7, Weight[2].x, s0;
MAD s0, r8, Weight[2].y, s0;
MAD s0, r9, Weight[2].z, s0;
MAD s0, r10, Weight[2].w, s0;
MOV result.color, s0;
END";
shader outputPixelShader =
"!!ARBfp1.0
TEMP back, blur;
TEX blur, fragment.texcoord[0], texture[0], 2D;
TEX back, fragment.texcoord[0], texture[1], 2D;
ADD blur, blur, blur;
MAD result.color, blur, 0.75, back;
END";
surface blur0 = allocsurf(width/4, height/4);
surface blur1 = allocsurf(width/4, height/4);
gaussianXPixelShader.constant[ 0] = { (2.0*ds_dx)* 1.45, 0, 0, 0 };
gaussianXPixelShader.constant[ 1] = { (2.0*ds_dx)* 3.45, 0, 0, 0 };
gaussianXPixelShader.constant[ 2] = { (2.0*ds_dx)* 5.45, 0, 0, 0 };
gaussianXPixelShader.constant[ 3] = { (2.0*ds_dx)* 7.45, 0, 0, 0 };
gaussianXPixelShader.constant[ 4] = { (2.0*ds_dx)* 9.45, 0, 0, 0 };
gaussianXPixelShader.constant[ 5] = { (2.0*ds_dx)*11.45, 0, 0, 0 };
gaussianXPixelShader.constant[ 6] = { (2.0*ds_dx)*13.45, 0, 0, 0 };
gaussianXPixelShader.constant[ 7] = { (2.0*ds_dx)*15.45, 0, 0, 0 };
gaussianXPixelShader.constant[ 8] = { (2.0*ds_dx)*17.45, 0, 0, 0 };
gaussianXPixelShader.constant[ 9] = { (2.0*ds_dx)*19.45, 0, 0, 0 };
gaussianXPixelShader.constant[10] = { (2.0*ds_dx)*21.45, 0, 0, 0 };
gaussianYPixelShader.constant[ 0] = { 0, (2.0*dt_dy)* 1.45, 0, 0 };
gaussianYPixelShader.constant[ 1] = { 0, (2.0*dt_dy)* 3.45, 0, 0 };
gaussianYPixelShader.constant[ 2] = { 0, (2.0*dt_dy)* 5.45, 0, 0 };
gaussianYPixelShader.constant[ 3] = { 0, (2.0*dt_dy)* 7.45, 0, 0 };
gaussianYPixelShader.constant[ 4] = { 0, (2.0*dt_dy)* 9.45, 0, 0 };
gaussianYPixelShader.constant[ 5] = { 0, (2.0*dt_dy)*11.45, 0, 0 };
gaussianYPixelShader.constant[ 6] = { 0, (2.0*dt_dy)*13.45, 0, 0 };
gaussianYPixelShader.constant[ 7] = { 0, (2.0*dt_dy)*15.45, 0, 0 };
gaussianYPixelShader.constant[ 8] = { 0, (2.0*dt_dy)*17.45, 0, 0 };
gaussianYPixelShader.constant[ 9] = { 0, (2.0*dt_dy)*19.45, 0, 0 };
gaussianYPixelShader.constant[10] = { 0, (2.0*dt_dy)*21.45, 0, 0 };
texture[0].magfilter = "linear";
texture[0].source = backbuffer;
destination blur0;
apply samplePixelShader;
texture[0].source = blur0;
destination blur1;
apply gaussianXPixelShader;
texture[0].source = blur1;
destination blur0;
apply gaussianYPixelShader;
texture[0].source = blur0;
texture[1].source = backbuffer;
destination backbuffer;
apply outputPixelShader;
My version...I took a few suggestions from other places...such as the line
MAD result.color, blur, 0.75, back;
that line came from elsewhere on the same forum that referred the original files...it tones down the glow. i also did a little logical checking around and figured "oh look at these 4.0 values in here, I bet they deal with the size of the glow!" so I did a Find and Replace on all the "dt_dy"'s and "ds_dx"'s that were in the thing. The Ds_DX ones control the width of the glows, the dt_dy ones control the height (so you can make glows that are vertical or horizontal only if you want, but why you'd want to is beyond me).
Result: A soft glow that spreads over a smaller area around what it is glowing up. Looks MUCH better imho and is very fast -- note however that this does not include any of the dark pixel optimizations DaBrain's version has.
UPDATE: For strange results, do a Find and Replace on "2.0*" in the above code, or "4.0*" in the original HDRish, without the quotes, and replace it with numbers lower than 1.0 (0.5 is fine) --- causes VERY strange effects on the lighting...the menus get all funky for one thing...
UPDATE 2: Eliminating Shimmering Once and For All Has a Nasty Price
surface blur0 = allocsurf(width/4, height/4);
surface blur1 = allocsurf(width/4, height/4);
Those lines...the number 4 determines how much less resolution the gaussian has. In other words, /4 samples only every four pixels for the blur.
/1 : samples EVERY SINGLE DAMN PIXEL, at a severe severe severe SEVERE cost to your video card's framerate.
/2 : samples 2x2 pixels at a time...which means every 2 pixels that exist are treated as ONE pixel with ONE color (arbitrarily, it appears).
/4: samples 4x4 pixels at a time. 4 pixels are recognized as one.
/6: samples 6x6 pixel region at a time. 6 pixels are treated and displayed as one single pixel enlarged to fit your resolution.
and so on...
...What we need is a code to make it take the AVERAGE of four pixels or six pixels or eight pixels and use that average for the blur effect, rather than a straight resolution chopping which is what is currently having.
The bigger that number, the more mosaic-y your HDRishnish effects are going to be. The only way to cut back on this is if it is somehow made to be the average RGB and brightness of four or more pixels together rather than just using one of them to represent the whole region of four or more pixels/unit.
That would be the best tradeoff between performace and quality. Right now, the larger the number after that divide sign, the less resolution and the faster the HDR effect, but the worse it looks and the more it shimmers.