Home
Products
Community
Manuals
Contact
Login or Signup

image processing with glsl shaders

BlitzMax Forums/BlitzMax OpenGL Programming/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.