shater vert and frag example
BlitzMax Forums/OpenGL Module/shater vert and frag example
| ||
tom speed made a nice file to help with shaders so I had a twiddle with it, had to change a few bits because of how bmax has progressed recently heres the results of my experiments, I hope you find it useful. test.frag test.vert shadertest.bmx tom speeds modifield glsl.bmx |
| ||
Shaders are the future! :) |
| ||
lol that is *so* you! getting the effect you want with glsl can be quite the challenge sometimes tho! |
| ||
Yup, the language takes some getting used to, but is definately worth learning. It'll be interesting to see how much the max 3D module uses them, Mark's said it'll likely be 'shader centric'. |
| ||
This crashes for me in OSX 10.3.9. Is the integrated gaphics card (radeon 9200) too old for this? Edit: This is what I find in the "Output" tab: I also get an OSX crash window. |
| ||
hmm, not sure about radeons, try out test.frag and test.vert with some kind of mac shader editor could you? |
| ||
OSX xtools comes with a simple shader editor but it looks like it doesn't support glsl. And I cannot find any other shader editor for osx. :/ |
| ||
will this work http://www.macinit.com/mifx/index.html I'd like to get together a simple set of shaders that will work on craptastic (and common) cards like my fx5200 and for that matter your radeon 9200 I've added some animation to both the frag and vert shader, but theres not too much point if I cant get it to work can you increase the size of the compilers log Global clog:Byte[1024] to say 4096 bytes and change all the glGetInfoLogARB(Program,1023,Varptr slen, Varptr clog[0]) commands to glGetInfoLogARB(Program,4095,Varptr slen, Varptr clog[0]) just to see if we have all the output from your cards shader compiler... |
| ||
cannot compile mifx, it needs xtools 2 and I can only use 1.5 since I'm using osx 10.3.9. I did the changes to glsl.bmx but nothing new was printed in the output tab. And it still crashes. |
| ||
I thought xtools 2.2 was 10.4 only, but 2.1 was fine? |
| ||
well unless someone with a radeon 9200 and a *working* shader editor can give me a little more feedback, I have no clue as to whats wrong, I can send you a simpler shader if your interested... |
| ||
anyone got a screen shot of the above code in action? |
| ||
You all have OpenGL v1.5+ drivers? Pretty sure that's what's needed for GLSL |
| ||
Wasn't the Radeon 9200 a shader version 1 card, I suspect as Tom says it could be a driver problem or perhaps the shader up there using Version 2 functions ? |
| ||
Testing with a Radeon 9550. glCreateProgramObjectARB() fails. My guess is something in glew.mod is screwed up. |
| ||
I determined this happens because ATI cards actually return a long-ass negative number (an unsigned integer). Now I have to figure out how to convert this into something OpenGL can recognize as a UINT. |
| ||
I fixed it so it will work with ATI cards. -vPosition is declared as a vec2 then as a vec3. Change them both to vec3. -In glsl.bmx, change this: 'Create a new GL ProgramObject p.Program = glCreateProgramObjectARB() If p.Program<1 to this: 'Create a new GL ProgramObject p.Program = glCreateProgramObjectARB() If p.Program=0 |
| ||
. |
| ||
Just tried here on ATI x1300, which is shader model 3.0 - nothing happens when I click the left mouse, and on output window I get the following:Compiled: test.vert successfuly in 6ms Compiled: test.frag successfuly in 5ms VertexShader test.vert attached & linked ok! Failed to link FragShader 'test.frag' Fragment shader(s) failed to link, vertex shader(s) failed to link. Error getting Uniform Var Location 'color' in Method setUF4 Process terminated Edit: apparently this is the line that causes trouble in the frag. shader: vec2 fp=fract(4.0 * vPosition.xy); I don't know why, never did anything shader-related :P Having the frag shader as this, it works (I get an orange flashing mesh, deformed): uniform vec4 color; varying vec2 vPosition; varying vec3 vNormal; void main(void) { float diffuse = 0.3 + 0.5 * dot(vNormal.xy, vNormal.xy); gl_FragColor = color * diffuse; } Last edited 2010 |
| ||
varying vec2 vPosition; should be varying vec3 vPosition; the vertex program and fragment program varyings should be the same. ie Its declared as vec3 in the frag shader, so it should match in the vertex shader. This fix is actually in a previous post above :) |