Home
Products
Community
Manuals
Contact
Login or Signup

image processing with glsl shaders

BlitzMax Forums/OpenGL Module/image processing with glsl shaders

TWH(Posted 1+ years ago) #1


I've converted the image processing example from the OpenGL Superbible.
Chapter 23 in the 3. edition.
Chapter 17 in the 4. edition.

I removed the teapot from the scene and replaced it with a cone.

I began with Tom Speed / ChrisC's glsl.bmx, but I couldn't get the program to render to texture. So I converted the shaderloaders from the book. glsl.bmx would have worked. The problem was me not setting the texture size properly.. It appeared that I had a 0x512 texture ><

Here all the code is, copy-paste-n-run ;), with a freelook camera I got from this gamedev.net article:

http://www.gamedev.net/reference/articles/article2160.asp

OR. Download a zip file with the code and the 8 shaders
www.softswit.ch/bmaxprosjekter/imageprocessing.zip

Edit:
The code would not compile in release mode because of
?debug
code
?debug <- changed to "?" only
This error gave me "expecting expression but encountered end-of-file"

Also, I had commented out 'glClear(GL_COLOR_BUFFER_BIT); when doing the rendering passes for the filters. But this didn't seem to make a change.

Also. I've added an FPS counter




The fragment shader programs:
passthrough.frag
// pass through a single texel value
uniform sampler2D sampler0;

void main(void)
{
    gl_FragColor = texture2D(sampler0, gl_TexCoord[0].st);
}


blur.frag

sharphen.frag


dilation.frag


erosion.frag


laplacian.frag



sobel.frag



prewitt.frag


You can download the orignal source from the books website:
http://www.starstonesoftware.com/OpenGL/index.htm


ImaginaryHuman(Posted 1+ years ago) #2
Cool, thanks. The superbible is a great book.


TWH(Posted 1+ years ago) #3
It is!

I've now added a textured quad. "texture.jpg"



Press space (or 1) to toggle filter.



The shaders are the same as before.


Scienthsine(Posted 1+ years ago) #4
Are the OpenGL shader functions like glShaderSourceARB and glGetObjectParameterivARB a part of BMax now?

Been away awhile, and not at home atm.


plash(Posted 1+ years ago) #5
Are the OpenGL shader functions like glShaderSourceARB and glGetObjectParameterivARB a part of BMax now?
A part of pub.glew, so yes.


Scienthsine(Posted 1+ years ago) #6
w00t, yays


FreakForFreedom(Posted 1+ years ago) #7
very nice, thanks for sharing


Uncle(Posted 1+ years ago) #8
Hi,

Has anyone managed to get this working on a Mac? I've managed to get it rendering but its not working properly. All the shaders seem to do is colour everything blue? Also the program fails on the OpenGL 1.3 check. My Mac should be at least 1.4 compliant, but the check fails.

Cheers,


Unc

PS the graphics card is a GMA 950 I think.


RupeB(Posted 1+ years ago) #9
Yep got this working perfectly on a Mac. 6 years later I can confirm this, maybe changes to BlitzMAX through these years have happened to make it so. But it does works now.


Kimor(Posted 1+ years ago) #10
Maybe a VBO would work but Im trying to convert this now,
where GPU is used for the actual tiling in every possible way.

We'll see how that goes.

http://blog.tojicode.com/2012/07/sprite-tile-maps-on-gpu.html
http://media.tojicode.com/zelda/

The primary reason is that ever teeny weeny work is put onto the GPU here, and I kind of like that.


Frosty Beverage Fund