Vertex program / shaders
BlitzMax Forums/OpenGL Module/Vertex program / shaders
| ||
Has anyone had any success using vertex programs/shaders??? Regards |
| ||
Yup The parallax one is gorgous to look at, but pounds my GF FX5600s frame rate (something like 40 - 50fps) at the scale shown, though Noel Cowers spangly XT800 got about 600fps I think Not all shaders are slow, the toon one is quite fast, alone and full screen I get abotu 1100 fps, the lattice (cage looking) one is slow. Fill rate is a big factor on performance, the more the geometry fills the screen, the slower it gets. Shaders can be loaded & used with about 4 function calls in my (bunch of functions & types I call an 'engine' :) ), and you can turn them on/off per entity surface. I've currently got a few problems that aint been answered yet though :S Maybe if MArk reads this thread he'll have an idea what's going on here? http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=11;t=000613 Cya! Tom |
| ||
Looks amazing, and thats done in BMAX? Is it difficult to code? |
| ||
All in max yeah. Difficult?.... Implementing a Shader system wasn't too hard, the actual shader language is another matter, GL Shader Language (GLSL) specs & manual are here: http://www.opengl.org/documentation/oglsl.html You can use programs like www.typhoonlabs.com Shader Designer or ATIs RenderMonkey http://www.ati.com/developer/rendermonkey/index.html to aid in designing Shaders (both currently free programs!) |
| ||
I see, so you have to code the shaders seperatly in other languages, not as easy as doing it all in BMAX. Thanks for the info mate, and Welldone to you Tom, it's an excellent achievement. |
| ||
Thanks for your reply. I've now got em working with vertex arrays and vertex indices. But I just learned the VERY hard that the shader file is case sensitive. tut tut. Just wasted about 4 hours before I just realised I have a temp and was accessing it as Temp !!!! I was getting an error after the 'glProgramStringARB............' command! Although the error didn't stop the program, OPenGl just generated the error internally ( retrieved by glGetError() ) and just ignored the command, hence i got a blank screen! A lesson learned here is always do ERROR CHECKING. What a nightmare! At least I know now, and I won't make that mistake again! Keep a look out for some spankingly cool demos effects! :) @Tom: You dont have to program the shader in another app (although the apps do offer immediate visuals as to what you will get!). The shader program is just a normal ascii file. Then you load that file into your program and store it in a string, then load the string up to your graphics card! You can infact ( and I did ) just have a text string in your bmax program that contains all the right shader commands! then upload that to the graphics card. Cool stuff with unbelievable possibilties! :D Thanks again |
| ||
yeah, Anyone know if theres a way to load of convert D3D .FX files in GL? most 3D apps support .FX as do most shader tools, and 3dsmax even lets you create shaders from within the standard 3dsmax material editor. so you can model with bump, specular and masked materials etc, see it in realtime in your viewports and save out he .FX material. 2.4mb WMV file http://mtlstream02.discreet.com/streaming/ms/showdx_200k.wmv 2.4mb QUICKTIME file http://mtlstream02.discreet.com/streaming/qt/showdx_300k.mov Just need to find a uility that can load or convert the FX files. |
| ||
Yippee! :) Could someone please do a tutorial on this please? As it sounds so unbelievable. And would love to be able to do it!!! :) Thanks, THUMBZ |
| ||
For those fortunate souls that are on OSX, there's a shader creation utility in the dev tools folder.....it's pretty neat. |
| ||
Please please do a tutorial, as I really want to understand BMAX and all things OPENGL. |
| ||
I'd love to. Damn I gotta get me self some webspace!! |
| ||
@Tom. Could you kind enough to show me a little bit of shader initialisation code please. The only bits I'm interested in are: glShaderSourceARB( vertexshader,1,Varptr vertexShaderStrings,Null) glCompileShaderARB(vertexShader) and how you have setup the 'vertexshader' variable and 'vertexshaderstrings' variable. I'm having a spot of trouble getting the pointers right and although my code will run it generates an internal GL_ERROR and the shader won't do its thing. Many thanks |
| ||
Hi, Sure thing.... Important: BACKUP YOUR WORK BEFORE USING OTHER PEOPLES CODE!! Note: I use 2 space TAB size when coding (just warning you! :) Here's my 'ongoing' GLSL Module. http://www.tomspeed.com/glsl.bmx GLSL Shaders come in 2 flavours, Low level & High Level. Low level shader source kinda looks like ASM, where as High level looks more like C (more readable!). My GLSL system relies on shaders being High level and won't (untested but pretty sure) work if you give it Low level shader source, because the 2 are applied differently in GL. Here's a brief explanation on how I implement it 'Each surface in my Mesh entitys 'can have their own 'tShaderObject' 'i.e: myMesh.surfShader 'cubeSurf is a surface on a mesh (a cluster of Tris) cubeSurf.surfShader = tProgramObject.Create() Local vertShader:tShaderObject = CreateVertShader("Lattice.vert") Local fragShader:tShaderObject = CreateFragShader("Lattice.frag") cubeSurf.surfShader.AttachVertShader(vertShader) cubeSurf.surfShader.AttachFragShader(fragShader) 'Yes, we want to use the shader when rendering cubeSurf.useShader = True cubeSurf.setShaderVars = ToonShaderVars '^^ 'A cool feature in blitzmax, setShaderVars is a Function Pointer 'In this case, I use them to point the surface shader to a user 'defined 'callback' Function to change variable settings within 'the shader! ' 'example, in my surface process I do something like this ' ' If surf.useShader 'use the shader? ' surf.EnableShader() ' enable this surfaces shader ' surf.setShaderVars(surf.surfShader) ' set the shader Variables (call LatticeShaderVars()) ' End If ' ' DrawSurfaceGeometry() ' ' disable shader e.t.c ' 'So the function below would be called automaticaly, and the user 'can tweak shader variables easily this way! Function LatticeShaderVars(s:tProgramObject) 'Here's how you tweak shader variables! s.SetUF3("LightPosition",1.0,4.0,3.0) s.SetUF3("LightColor",1.0,0.8,0.9) s.SetUF3("EyePosition",myCam.GetX(3), myCam.GetY(3), myCam.GetZ(3)) s.SetUF3("AmbientColor",0.2,0.2,0.2) s.SetUF3("Specular",0.2,0.2,0.2) s.SetUF1("Kd",0.8) s.SetUF2("Scale",10.0,10.0) s.SetUF2("Threshold",0.13, 0.13) s.SetUF3("SurfaceColor",1.0,0.0,1.0) End Function Any Q's ? :) Tom |
| ||
Thanks for your help Tom. I really appreciate it. |
| ||
The problem I had was I was loading the shader file as text, where as it should have been loading it in as bytes. Thanks again for your help. Nice module btw :) |