Fragment shader demo!

BlitzMax Forums/BlitzMax Beginners Area/Fragment shader demo!

Tom(Posted 2004) [#1]
Hi all,

Just a little test showing a fragment shader in action (it's the first thing I dived into after getting max!)

Source:
http://www.tomspeed.com/frag_shader1.zip

It's a very simple demo, but it's nice to see shaders working in B'Max! :)

Shaders can be loaded from a file or from a string$ internaly, change 'FileShaderSource' to False to load from a string.


Happy holidays everyone!
And Thanks to BRL for an exciting program!!!

Tom Speed
'Scouse' @ irc.blitzed.org #blitzbasic

p.s
Some useful links:
http://developer.3dlabs.com/openGL2/specs/index.htm
http://www.typhoonlabs.com (cool shader editor!)
http://www.clockworkcoders.com/oglsl/tutorials.html


Kanati(Posted 2004) [#2]
Nice...

I find it very odd that I get 1580fps average with a debug build. And 1200-1300 variable average on a non-debug build.


FlameDuck(Posted 2004) [#3]
So you got it working? Nice!


Who was John Galt?(Posted 2004) [#4]
@Kanati - if you haven't done it already - stick this as a bug report.


Panno(Posted 2004) [#5]
shader not supportet here !
i need a better gfx card ;)

hmm tom shaders ;)


Damien Sturdy(Posted 2004) [#6]
my gf4ti4200 claims to support vertex/pixel shaders- but nothing that uses them works... any ideas peeps!? :S


Tom(Posted 2004) [#7]
Hi,

Damien: try this

fo:TStream=WriteFile("c:\GL_EXTENSIONS.txt")
bglCreateContext ScreenWidth,ScreenHeight,ScreenDepth,0
r:string= String.FromCString$(Byte Ptr(glGetString( GL_EXTENSIONS )))
WriteString(fo,r)
CloseFile(fo)


Can you paste the text file it writes out online for me to see, thanks.

Tom

While GotBeer=True
Drink(Beer)
Wend
Weeeeeeeeeeeeee()


Damien Sturdy(Posted 2004) [#8]
Checking the extensions shows i have shader support (i think)

GL_ARB_depth_texture GL_ARB_imaging GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_shadow GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_mirrored_repeat GL_ARB_transpose_matrix GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_S3_s3tc GL_EXT_texture_env_add GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_Cg_shader GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_multi_draw_arrays GL_EXT_packed_pixels GL_EXT_paletted_texture GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_shared_texture_palette GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_object GL_EXT_vertex_array GL_HP_occlusion_test GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KTX_buffer_region GL_NV_blend_square GL_NV_copy_depth_to_color GL_NV_depth_clamp GL_NV_fence GL_NV_fog_distance GL_NV_light_max_exponent GL_NV_multisample_filter_hint GL_NV_occlusion_query GL_NV_packed_depth_stencil GL_NV_pixel_data_range GL_NV_point_sprite GL_NV_register_combiners GL_NV_register_combiners2 GL_NV_texgen_reflection GL_NV_texture_compression_vtc GL_NV_texture_env_combine4 GL_NV_texture_rectangle GL_NV_texture_shader GL_NV_texture_shader2 GL_NV_texture_shader3 GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_program GL_NV_vertex_program1_1 GL_SGIS_generate_mipmap GL_SGIS_multitexture GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow GL_SUN_slice_accum GL_WIN_swap_hint WGL_EXT_swap_control


whatever it is ive never been able to use shaders. and my box says both vertex and pixel shaders supported...

i thought ti4200s didnt do them to begin with!? :S


Dreamora(Posted 2004) [#9]
depends on the shader version used ...
Your card only supports the low end Shaders, while most actual games need Shader 2


Tom(Posted 2004) [#10]
There's Vertex shader suport, but no Fragment/Pixel extension. What drivers you using?

Here's an old Creative GF4ti4200 review:
http://www.ocworkbench.com/2002/creative/GF4Ti4200/3dblasterti4200pg1.htm

It says the card supports Pixel Shaders
Hardware Features
NVIDIA® nfiniteFX™ II Engine
Programmable Vertex Shaders
Programmable Pixel Shaders
Lightspeed Memory Architecture™ II
Accuview Antialiasing™
nView™ Display Technology
Transform and Lighting (T&L) engines


I wonder if it's an OpenGL thing? Maybe pixel shaders are only supported in GL1.4+ ?

Try this:
Print String.FromCString$(Byte Ptr(glGetString( GL_VERSION )))
Print String.FromCString$(Byte Ptr(glGetString( GL_RENDERER )))


Tom


Extron(Posted 2004) [#11]
GeForce4 Ti4600 report :
"GL_ARB_fragment_shader not supported!"
GeForce6 6800 Ultra report OK.

Geforce4 Ti 4600 have no "GL_ARB_fragment_program", no "GL_ARB_fragment_shader" and no "GL_ARB_shader_objects", result don't pass test.

GeForce6 have "GL_ARB_fragment_shader, GL_ARB_fragment_program and GL_ARB_shader_objects", result pass all tests.

Beware whith vertex and shader program, recent card have this, but old card none.

And Tom tested whith Geforce FX. ;)


Extron(Posted 2004) [#12]
And to respond to Tom :
GeForce4 Ti 4600 report "1.4.0" "GeForce4 Ti 4600/AGP/SSE2"
GeForce6 6800 Ultra "1.5.1" "GeForce 6800 Ultra/AGP/SSE2"

And after driver upgrade 66.93
GeForce4 Ti 4600 "1.5.2"
GeForce 6800 Ultra "1.5.2"
And same result : GeForce4 out, GeForce 6800 Ultra ok.


Difference(Posted 2004) [#13]
Cool. Works like a charm on my Asus Radeon 9600XT.


ashmantle(Posted 2004) [#14]
ok.. its doing 'something' to the quad, but Im not sure its the desired effect..? you call it fragment shader, but to me it looks like an ordinary gradient with anti-alias on the edges..

Ati Radeon 9800 XT


Tom(Posted 2004) [#15]
It's a 'very' simple shader, it changes the pixel color based on it's screen Y coordinate :)

Support for pixel shaders does look bad, I thought at least GF4 cards could do them :S


Damien Sturdy(Posted 2004) [#16]
IM using the newest drivers- whatever they are (im usually one step ahead of the official releases but when bugs appear i revert and play)


Drago(Posted 2004) [#17]
gf4 can do pixel shaders below version 2, so if you are using a shader that says FX_20 then gf4 can't use it.


ashmantle(Posted 2004) [#18]
It's a 'very' simple shader, it changes the pixel color based on it's screen Y coordinate :)

Support for pixel shaders does look bad, I thought at least GF4 cards could do them :S


ok, then its working just fine ^^


ImaginaryHuman(Posted 2004) [#19]
The shader programs are not supported on my humble iBook. I know that the shader commands are part of an extension which is not a standard part of OpenGL 1.2. Do we need to be installing some kind of opengl extension modules?


AntonyWells(Posted 2004) [#20]
glsl requires 60+ drivers. i.e gl1.4/1.5


AdrianT(Posted 2004) [#21]
Doesn't work on the Geforce3 either, tried the latest 7x.xx drivers so I guess it's not a 1.1 shader.

get the error: Unhandled Exception: GL_ARB_fragment_shader not supported!

GL doesn't seem to be that great for shaders really compared to DX since there isn't much 3rd party support for them. Hopefully we will eventually end up with a nice basic set of features like masking 2 textures, 2 textures and specular, reflectin maps etc.

since most shader cards should be able to do most of what the xbox has been doing the last 3 years.