I'm slowly learning GLSL language, today I've finished a bloom/glow effect test, the shader code itself it's not mine (can't remember the autor :P) but I can fully understand how it works on the glsl pipeline and how I can use it with my framework. I just not sure if it will work on other graphics card.
Requirements:
d3dx9_32.dll -> to load png files (Thx Jim for that).
Pixel Shader 2.0
Use keys "1 to 6" to change texture and key "S" to enable/disable shader program.
Rbraz,
I have d3dx9_32.dll but all I get is a black screen. I guess the shader is Nvidia specific right now as Im running on a x600 ati, drivers from feb 2008.
Tried it on x1950 too - still just a black screen, no images or shader.
Taj
It works fine with nvidia 8800gt cards.
About 6fps on my 8600GT, with or without the shader!
Jim
The only thing that did anything here was 6 and that displayed an orange cube, S key didnt change anything.
I have an ATI card (X1650)
Quote from: Jim on March 07, 2008
About 6fps on my 8600GT, with or without the shader!
Jim
OMG Jim :o, only 6 fps, it run at fixed 60fps here on my old 6600GT, and I just use a trivial "glCopyTexImage2D" to copy textures, apply shader prog to texture and display it ???
Quote from: Shockwave on March 08, 2008
The only thing that did anything here was 6 and that displayed an orange cube, S key didnt change anything.
I have an ATI card (X1650)
There's bug for ATI cards in that shader code...
Quote from: taj on March 07, 2008
...
Tried it on x1950 too - still just a black screen, no images or shader.
Taj
Can you help me to fix it for ATI, check the code below.
char *vert="\
void main()\
{\
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\
gl_TexCoord[0] = gl_MultiTexCoord0;\
}";
char *frag="\
uniform sampler2D bgl_RenderedTexture;\
float samples[] ={\
0.0222244,0.0378346,0.0755906,0.1309775,0.1756663,\
0.1974126,\
0.1756663,0.1309775,0.0755906,0.0378346,0.0222244\
};\
void main()\
{\
vec4 sum = vec4(0);\
vec2 texcoord = vec2(gl_TexCoord[0]);\
int j;\
int i;\
for( i= -5 ;i < 5; i++)\
{\
for( j= -5 ;j < 5; j++)\
{\
sum += texture2D(bgl_RenderedTexture, texcoord + vec2(j, i)*0.004) * samples[j+5];\
}\
}\
gl_FragColor = clamp(sum*sum*0.04 + texture2D(bgl_RenderedTexture, texcoord),0.0,1.0);\
}";
Rbraz,
in order to help fix this the whole code would be much easier, otherwsie I have to go and write quite a bit of c code around it.
Taj
On second thoughts, debugging by eye - so highly unlikely to be right but the line
gl_FragColor = clamp(sum*sum*0.04 + texture2D(bgl_RenderedTexture, texcoord),0.0,1.0);\
looks unlikely to be right to me. How many components does your texture have? I guess 4 as you are loading PNGs, so this line would try to stuff 6 components into into a vec4 and fail I guess.
ATi drivers have always been less forgiving of type conversions than Nvidia ones.
I have updated the archive, I was passing a non power of two texture to the shader program, it might fix slowdown for Jim.
@Taj: I did some changes in the shader code too, not sure if it will work, anyway I will send all code for you to check. Thanks for your help.
It's still incredibly slow, even on the orange cube.
Jim
Hmm ??? Anyway, I will try to convert the "copy2texture" part using frame buffer object method and check if there's any performance change...
Can you send an image of what it should look like - I just get a red (pink) circle. The shader doesnt seem to work so Im trying things but an image for final goal would be good.
Ok, here one screenshot of that example test I sent to you.
Hey rbraz,
Firstly, I love the bloom effect. IMO the best looking one is number 4 (the granite-like texture).
On my NV GeForce 7300 GS, (full screen version), I get 30 FPS on all 6 with the shader active, and 45 FPS without.
Thx Voltage
Due to my lack of experience using shader language and make it compatible everywhere, I took another direction and made this effect using only software, looks much nicer and more like what I was looking for.
The idea is to draw main scene, copy to an image buffer, blur that image buffer (vertically and horizontally), apply luminance, and display all scene.
Still, I need some tests :skint:
(Run at fixed 60 fps here)
full 60 fps here, nvidia 8800gt in sli setup.
What would you say if I told you that this one (software) is actually showing what I think is a bloom effect - which the other isn't showing properly - I get no halo on the PS one - but that it is still 6fps? ???
Jim
Thx zawran
Quote from: Jim on March 10, 2008
What would you say if I told you that this one (software) is actually showing what I think is a bloom effect - which the other isn't showing properly - I get no halo on the PS one - but that it is still 6fps? ???
Jim
I agree, the PS version isn't working like I want, the software version is exactly what I need.
About speed, are you saying that this software version runs only at 6 fps on your PC ??? You will give me a heart attack!
I've tested it on a notebook with bad ATI 915gm something and it run at 53 fps...
I'll wait for more feedback about speed :) ....
tested the software one on my old ti4600 rig and it runs smooth i would guess 50 - 60 fps,
looks really cool and gives the texture a prince of persia style of look.
The software version does look lots better (more pronounced halo).
I get 47 FPS. (P4 3.00Ghz)
Looking really nice RbRaz.
Rbraz,
works fine here (xp, sp2, laptop x600). My only comment is the glow "flickers" like a candle, usually caused by rendering your scene at too low a resolution. However, we might also call it an effect :-)
Taj
Sorry rbraz mate, it's 6pfs on Vista, software or PS. I'd like to help you fix it if I can...
Jim
Rbraz,
I press s... but when I do the fps counter disappears and the glow is drawn, but I cant get both on screen at the same time ... without glow its 50 fps.
Taj
In the software version, each one seems to run at 60fps P4 2.8ghz :)
Looks mighty fine too!
Quote from: Jim on March 11, 2008
Sorry rbraz mate, it's 6pfs on Vista, software or PS. I'd like to help you fix it if I can...
Jim
Jim, I'll send code for you to test, IMHO the problem is with Vista drivers ;)
Quote from: taj on March 11, 2008
Rbraz,
I press s... but when I do the fps counter disappears and the glow is drawn, but I cant get both on screen at the same time ... without glow its 50 fps.
Taj
Fixed, weird bug with depth test...
@Nino, @Voltage, @Shockwave: Thanks :)