Code: Select all
// transform normal
float3 normal = mul(float4(vNormal,0.0), mInvWorld);
Which one is correct? I am very confused.
Code: Select all
// transform normal
float3 normal = mul(float4(vNormal,0.0), mInvWorld);
Thanks for reply! In mul(vector, matrix) form just like the one in the example shader, the matrix I think should be the transpose of inverted world matrix.CuteAlien wrote:Could be because it's mul(vector, matrix) instead of mul(matrix, vector). But just guessing, one of those simple questions which would take me a few hours to answer until I figure it all out again.
Yes, mul(invWorld, normal) should be correct.devsh wrote:Should be correct if mul(matrix, vector) means a transpose of front multiply (since A^T.B^T = (AB)^T )
LOL. I think I can probably write a shader example of Blinn shading model with very basic normal mapping or Screen Quad for post processing if required.CuteAlien wrote:Uh... looking at shaders. Nothing makes sense?
- mLightPos is actually the camera position (maybe deliberate - but then still bad naming...)
- worldpos is calculated using the transpose world matrix instead of just world-matrix.
- normal should use either world-matrix (without non-uniform scaling that works I think?) Or invers-transpose world matrix as you said.
Well, shader says "Please note that these example shaders don't do anything really useful." I guess I'll just add a few more comments.
edit: Added comments now as I don't really know much about the idea behind it. Probably should write a different shader-example some day. Actually at least one more shader-example will be added soon (for cubemap, already working, just want to do some more cleanup before adding the example to the engine).
I think it may fit into some new kind of namespace such as utils, in order not to couple tightly with the engine.CuteAlien wrote:I think we even have some light shaders in OGL branch already.
Doing something with a ScreenQuad is also a good idea. Still considering if I should adding a screenquad class or struct to Irrlicht, thought not quite sure where it fits. So just adding it as example for now is maybe a way to do that.
I wrote a simple post processing example recently and hosted it on Github at https://github.com/BoshenGuan/Irrlicht- ... ng-Example. Hope this helps.CuteAlien wrote:OpenGL indeed flips the texture matrix (I think this is going back to some image format, TGA probably, which was used in the OpenGL predecessor IRIS GL)...
It's OK with no problem. You can certainly use it and modify it.CuteAlien wrote:Oh that's cool! I'll check it once more next week, but on first view looks pretty good - I think we can use it like that. That's if you are OK, with us putting it into the engine?
Tiny details I'm thinking about (but probably don't matter)...
Not sure about mipmap filter... it's likely not doing anything in that case (should only be active in combination with trilinear filter and we have no depth here), but then again also won't hurt to disable it.
Not sure if we should use MeshBuffer instead of directly using indices, vertices, maybe I'll switch to that (works better on WebGL which needs buffers for everything, but I also haven't switched rest of Irrlicht yet completely to that). I guess I can do that also once I support WebGL officially.
Okay. I will check for that on Github.CuteAlien wrote:Is there any chance you could change the license to zlib license for this? Then it'll fit into Irrlicht.