TGEA MS4.2 Bug : Fogging of scaled static shapes not working
by Stephane Conde · in Torque Game Engine Advanced · 02/13/2007 (1:00 pm) · 6 replies
TSStatics and StaticShapes that are placed inside a fog layer in TSEA MS4.2 do not function properly if their scale is anything different than (1, 1, 1).
If the scale is increased (i.e. (3, 3, 3)) then the shape will not be fogged as much as it should be and it will pop out of view before it should. The opposite happens when the scale is decreased (i.e. (0.5, 0.5, 0.5)).
At a scale of (1, 1, 1) everything works perfectly...
The higher the scale, the more obvious the issue... which leads me to be believe it is some kind of normalization issue (something not being normalized).
I have already tried looking into this, but haven't been able to fix the issue. Does anyone have any insight as to why this issue might be happening?
Thanks,
Stephane
P.S. I have tested this issue in a clean version of MS4.2, so I don't think it's user error...
If the scale is increased (i.e. (3, 3, 3)) then the shape will not be fogged as much as it should be and it will pop out of view before it should. The opposite happens when the scale is decreased (i.e. (0.5, 0.5, 0.5)).
At a scale of (1, 1, 1) everything works perfectly...
The higher the scale, the more obvious the issue... which leads me to be believe it is some kind of normalization issue (something not being normalized).
I have already tried looking into this, but haven't been able to fix the issue. Does anyone have any insight as to why this issue might be happening?
Thanks,
Stephane
P.S. I have tested this issue in a clean version of MS4.2, so I don't think it's user error...
About the author
Recent Threads
#2
04/01/2007 (1:23 pm)
I experience this issue, makes scenes look pretty ugly.
#3
Stephane
04/01/2007 (2:58 pm)
Thank you very much Chris for posting. Very good to know that at least one other person is experiencing this issue.Stephane
#4
A simple fix would be to just move the scaling of the world matrix to the TSMesh render function after we have given the fog shader the un-scaled object transform... Unfortunately this will not work because matrix transformations are non-communative (i.e. changing the order of the transformations changes the actual transformations performed).
A quick and dirty fix for this is to implement a new matrix stack (called something like 'object') and apply exactly the same transforms, pushes and pops as the world matrix, except don't apply the scale in the TSStatic/ShapeBase rendering functions. This has fixed the problem for me, but there has got to be a better way.
Would someone with more knowledge of rendering pipelines be able to answer the following questions:
Why does the fog shader seem to care that the mesh has been scaled? It would seem to me that the fact that the mesh has been scale would be GOOD for the fog shader, but in fact it is the opposite...
What would be a better way of fixing this issue?
Thank you very much in advance for any help you can offer!
Stephane
04/06/2007 (2:40 am)
Alright, well, I've definitely confirmed this issue... The problem seems to be that the scale is applied to the world matrix in the TSStatic and ShapeBase rendering functions (mat.scale( mObjScale );). The world matrix is then also used in the TSMesh rendering function to pass the object transform to the Fog shader...A simple fix would be to just move the scaling of the world matrix to the TSMesh render function after we have given the fog shader the un-scaled object transform... Unfortunately this will not work because matrix transformations are non-communative (i.e. changing the order of the transformations changes the actual transformations performed).
A quick and dirty fix for this is to implement a new matrix stack (called something like 'object') and apply exactly the same transforms, pushes and pops as the world matrix, except don't apply the scale in the TSStatic/ShapeBase rendering functions. This has fixed the problem for me, but there has got to be a better way.
Would someone with more knowledge of rendering pipelines be able to answer the following questions:
Why does the fog shader seem to care that the mesh has been scaled? It would seem to me that the fact that the mesh has been scale would be GOOD for the fog shader, but in fact it is the opposite...
What would be a better way of fixing this issue?
Thank you very much in advance for any help you can offer!
Stephane
#5
10/24/2007 (1:33 pm)
Any solutions for this issue? None have been introduced in any of the TGEA releases as of yet.
Torque 3D Owner Stephane Conde
Does anyone have any ideas at all about what might be causing this/how to resolve this?
Cheers,
Stephane