The Shader example...
BlitzMax Forums/MiniB3D Module/The Shader example...
| ||
It does not appear to be working correctly. Has anyone else noticed this? The light in the scene does not appear to be affecting the model at all... |
| ||
Except if you click, then it's affecting the model. I believe if you would want to have an effect on shader rendering then it should be transmitted to the shader program (and the shader program would have to be programmed to compute lights from passed data). That seems normal to me. |
| ||
I know ;) Replace with original Shader.bmx and this with bump.vert. |
| ||
Hmm, better, but still not correct. It seems to work close up, but not as I pull the camera further away. :( |
| ||
Aaaaargh! I don't understand why the light has an effect on the shader, but when I hold the mouse button down so the shader is turned off, the moving light no longer affects the object. I decided to experiment. I commented out the lines that set the angle and update the light position based on that, and instead parented the light to a pivot point in the middle which is continuously turning. Now that I've made these changes, it is the shader that is unaffected and the object that is so when shaders are turned off. What the...? |
| ||
Okay, I have learned that simply passing the entity x, y, and z values is resulting in the wrong position for the light. Using gl_LightSource[0].position does work, but I'd like to understand what the difference is. The built in light source position value is a vec4 instead of a vec3, for instance. Does anyone know how this stuff works or where I can find a good GLSL tutorial? The ones I've found so far have been lacking... |
| ||
I'm not exactly a shaders person, but I wrote a little article linking together a whole bunch of other resources here. (Scroll down for the more useful external resources). |
| ||
Thanks, but all I can find are specs. Does anyone know WHY gl_LightSource[0].position is a vec4? Aside from x, y, and z, what is there? I know that passing x, y, and z in order doesn't work for MiniB3D because the axes are not the same, but I don't know how to transform the values properly. The shader example that was supplied by Klepto is not working correctly and I'd like to know if anyone has already solved this problem. ??? |
| ||
In OpenGL and DX anything is a Vec4 For the reason that all matrices are 4x4 matrices. the forth is w and normally 1 unless you use the position to save quaternions in there instead of vectors. as you seem to lack the 3d programming basics, understanding them before trying to do shader (higher end math) might be a usefull idea. |
| ||
@Dreamora - Actually, that is an assumption on your part. I have written 3dsMax .fx shaders and work professionally in the game biz as a technical artist. Knowing what the FOURTH value contains is not a 3d programming basic. :P |