What a couple of *minor* patches can do :)
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
I'm currently very short on time, so I just read through this patch really quickly - but I did not get the sense of all changes. Could you please explain some parts in detail?
The affector matrix is for temporary view changes, right? Shouldn't be too much of a problem to add it.
The clipping planes are used for what? You are enabling the clip planes each cycle, this seems to be quite expensive?
And finally the culling mode. Why would one want to switch the culling of all faces at once? There are many things that don't work for incorrectly oriented faces, so this would not help to overcome wrong mesh orientations. What is wrong with the material attribute?
The affector matrix is for temporary view changes, right? Shouldn't be too much of a problem to add it.
The clipping planes are used for what? You are enabling the clip planes each cycle, this seems to be quite expensive?
And finally the culling mode. Why would one want to switch the culling of all faces at once? There are many things that don't work for incorrectly oriented faces, so this would not help to overcome wrong mesh orientations. What is wrong with the material attribute?
Errm, ok. These patches gives the programmer flexibility to do things that are not possible to do otherwise in Irrlicht. Let's visit them one by one:hybrid wrote:I'm currently very short on time, so I just read through this patch really quickly - but I did not get the sense of all changes. Could you please explain some parts in detail?
Temporary or not, it is up to the programmer. Basically the camera has a new member called ViewMatrixAffector (which defaults to identity). Each time the camera's view matrix is recalculated, it is then post-multiplied with this affector matrix. This allows the programmer to actually control the view in any way imaginable.hybrid wrote: The affector matrix is for temporary view changes, right? Shouldn't be too much of a problem to add it.
In the effect presented in this topic, this affector is used to flip the screen upside-down by using an affector matrix equivalent to what a call to glScalef(0, -1, 0) would do.
hybrid wrote: The clipping planes are used for what? You are enabling the clip planes each cycle, this seems to be quite expensive?
Clipping planes, err, clip the view that is in the back of each of these planes. They are not updated each frame. You could see that if you 'd take a look at the code. They are enabled/disabled only when the programmer enables/disables them.
In the presented effect, they 're used to render only parts of the scene, which are then used as the reflection and refraction on the water.
What's wrong with the material attribute?!?hybrid wrote: And finally the culling mode. Why would one want to switch the culling of all faces at once? There are many things that don't work for incorrectly oriented faces, so this would not help to overcome wrong mesh orientations. What is wrong with the material attribute?
a) the material attribute works only for one material
b) the material attribute does not do the same thing. It decides if backface culling should be enabled or not. This patch instead allows you to set which faces you want culled: the front-facing or the back-facing ones. It's clearly not the same thing...
There are many cases this is needed, especially for special effects like the one in this topic...
Nice work madrav
@hybrid clipping planes are used since underwater polygons viewed from below shouldnt appear on the reflection.
For a pic of the bug look at this thread:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=16079
Edit: he removed the picture of the bug. Anyway the clamping shader should be done on a per vertex basis(remove the comparision from the pixel shader put it in he pixel sahder and pass the transparency float to the ps), i just used the per pixel method when i wrote that thread because i thought it may still show artifacts.
@hybrid clipping planes are used since underwater polygons viewed from below shouldnt appear on the reflection.
For a pic of the bug look at this thread:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=16079
Edit: he removed the picture of the bug. Anyway the clamping shader should be done on a per vertex basis(remove the comparision from the pixel shader put it in he pixel sahder and pass the transparency float to the ps), i just used the per pixel method when i wrote that thread because i thought it may still show artifacts.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
In many cases I know what the technique would do, but it depends on the typical usage of the technique where in the Irrlicht architecture it should be added. That's why I asked - I know what clipping is
I asked for temporary effect of affector because you could change the view matrix otherwise - which might require more cpu/gfx power, though. We should also consider a boolean flag "isIdentityMatrix" inside matrix4 to reduce the number of multiplications applied (or avoid uploading of matrices such as the texture matrix).
I had a (quick) look at the code and I thought that it would call the enable each cycle. If this is not the case it is perfect
Where in the underwater effect do you use "cull front face but not back face"? And what is the effect of setting "global cull front face, material cull back face" or "global cull back face, material don't cull back face"? This addition is really not clear to me. But I've never programmed any fancy effects, yet, so I'm just wondering here.
BTW: I've moved the thread because it's some major code addition
I asked for temporary effect of affector because you could change the view matrix otherwise - which might require more cpu/gfx power, though. We should also consider a boolean flag "isIdentityMatrix" inside matrix4 to reduce the number of multiplications applied (or avoid uploading of matrices such as the texture matrix).
I had a (quick) look at the code and I thought that it would call the enable each cycle. If this is not the case it is perfect
Where in the underwater effect do you use "cull front face but not back face"? And what is the effect of setting "global cull front face, material cull back face" or "global cull back face, material don't cull back face"? This addition is really not clear to me. But I've never programmed any fancy effects, yet, so I'm just wondering here.
BTW: I've moved the thread because it's some major code addition
This is used to render the environment's reflection. To do this, you need to alter the view matrix (see affector) so that it renders the scene upside down. But by altering the view matrix like that (like glScalef(1,-1,1)), you have actually reversed the front and back faces (the -1 scale is responsible for that). So you have to change the culling mode in opengl so it culls the correct faces again.hybrid wrote: Where in the underwater effect do you use "cull front face but not back face"? And what is the effect of setting "global cull front face, material cull back face" or "global cull back face, material don't cull back face"? This addition is really not clear to me. But I've never programmed any fancy effects, yet, so I'm just wondering here.
The material's setting still affects each mesh. This patch just allows you to alter the definition of what is considered a front-face and what a back-face. That's all.
Last edited by mandrav on Sat Oct 28, 2006 6:49 pm, edited 1 time in total.
I'd stay with CullMode, but change ECM_BACK_FACES / ECM_FRONT_FACES to ECM_CLOCKWISE / ECM_COUNTER_CLOCKWISE. Because this is what it is about. In the sample, not the front faces are to be culled, but the back faces, which just happen to have their orientation flipped.
This would also fit well with DirectX/OpenGL, which have the options D3DCULL_CCW, D3DCULL_CW, GL_CCW, GL_CW. And the affected RenderState in DirectX is D3DRS_CULLMODE.
This would also fit well with DirectX/OpenGL, which have the options D3DCULL_CCW, D3DCULL_CW, GL_CCW, GL_CW. And the affected RenderState in DirectX is D3DRS_CULLMODE.