on 14-05-2012 01:10 AM
Hi.
I'm testing the basic model and found an strange behaviour: when the object is scaled the light is also scaled... but not in all objects.
A simple way to test it is with the BasicModelSample doing those changes:
On function Draw:
replace
Matrix4 view = Matrix4.LookAt(...
with
Matrix4 view = Matrix4.LookAt( new Vector3( 0.0f, 5.0f, 2500.0f ),
new Vector3( 0.0f, 5.0f, 0.0f ),
new Vector3( 0.0f, 1.0f, 0.0f ) ) ;
and
Matrix4 world = Matrix4.RotationY(...
with
Matrix4 world = Matrix4.RotationY( FMath.Radians( turn * 5 ) ) * Matrix4.Scale(100, 100, 100) ;
The main character illumination looks right but the sword is really bright, a lot more than without the scaling.
Is this normal behaviour or is a bug?
Is there any way to scale objects without corrupting illumination parameters?
Thanks.
on 18-05-2012 12:04 PM
on 07-06-2012 01:20 PM
Hi gusmanb,
Any reason why you are multiplying with the world matrix ? Also can I please ask why you are altering the view matrix.
In my understanding the scaling is done in the vertex shader and then the output is given by multiplying with the worldviewprojection matrix.
World Matrix = Object Space to World space
View Matrix = Camera Matrix
Projection matrix = Used for giving the scene perspective(Example Orthographic projection or a view Frustum)
Multiplying these 3 matrices gives the WorldViewProj matrix which is then multiplied with our final object.
Example
void main( float4 in a_Position : POSITION,
float4 out v_Position : POSITION,
uniform float4x4 WorldViewProj
)
{
a_Position.xyz = a_Position * 4.0f; (scaling the vertices by multiplying)
v_Position = mul( a_Position, WorldViewProj ); (transforming the object onto the screen)
}
This is my understanding but I am unsure of how you are performing scaling in the BasicModel Example.My above example will scale objects in the shader catalog example. It would be great if you could explain your ideas a little bit more.
Thanks
on 09-06-2012 09:19 PM
Not wanting to speak for gusmanb but there is no reason why you can't combine your world matrix with a scaling matrix. In fact doing it this way would be somewhat less expensive than doing the scaling in the shader.
If you perform the scaling in the shader you have an extra cost of 1 additional multiply per vertex while if you apply the scale by multiplying the world matrix with a scale matrix then the scaling will happen implicitly as part of the transform into screen space.
However, one side effect of applying a scaling to your world matrix is it will also scale the vertex normals used for lighting I suspect that gusmanb's problem is due to the normals being scaled by 100, whereas the lighting calculations expect normals that are unit vectors (length 1)
To solve this problem if you normalise the vertex normals after they have been transformed by the normalMatrix (Inverse Transpose of the ModelView matrix) then that will get them back to unit length.
Claire
on 09-06-2012 10:21 PM
Hmmm, I've just looked at the BasicModel sample and while it seems that lighting is performed, it doesn't seem to be occuring within the shaders?? Certainly the .vcg and .fcg files that are part of the SampleLib don't perform any lighting. Indeed the shaders don't seem to be being used at for this sample.as I modified Texture.fcg to return a single fixed colour and saw no changes.
It seems to me that the BasicModel class by default at least makes use of shaders that we don't have access too.
I've personally moved away from BasicModel and written my own model class as I had too many problems getting the supplied BasicModel class to behave as I require.
Claire
PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.
フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと
PSM DevPortalを一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870