Skip to main content
gamedev.net
🔒 Locked 🎮 Unity

Shadows

Started by gnitsuk Feb 25, 2008 at 6:17 AM 1 replies 600+ views
Original Post
gnitsuk
gnitsuk
Hi, Just re-written this to try and make it clearer for anyone who might be able to help me - I'm confused! I have a VERY simple application - Visual Studio 2005 using C# I have two vertexbuffers. One is filled with the four corners of a sqaure. The square lays on the z = 0 plane and is of side length 40 - so vertices are (-40,-40,0),(40,-40,0),(40,40,0),(-40,40,0) - easy. The other is filled with the vertices of a cube. cube's centre is at (0,0,1) and is of side length 2. So it sits on the plane defined by the squre. All I want to do is render the shadow of the cube on the plane. My light source position is (13,0,3) I define the following: Plane m_shadowPlane = new Plane(0.0f, 0.0f, 1.0f, 0.0f); Matrix m_shadowMatrix; m_shadowMatrix.Shadow(new Vector4(13,0,3,0), m_shadowPlane); Then in my render code I have: m_device.Transform.World = Matrix.Identity; RenderCube(); RenderSquare(); m_device.Transform.World = m_shadowMatrix; RenderCube(); All works fine. Shadow is there. BUT if I change the cube so that is is NOT centred at the origin BUT centred directly under the light at (13,0,3) the the shaow stays at the origin and stays of the same shape as it was before. Now that the light is right above the cube the shadow should be a square, not the extented shape which is was previously when the cube was at the origin. Has anyone managed to use Matrix.Shadow correctly? Where am I wrong, this seems soooooooooo simple. Thanks, Mitch. [Edited by - gnitsuk on February 26, 2008 3:57:17 AM]
gnitsuk
gnitsuk
Thanks for any advice :)

Mitch.
gnitsuk
gnitsuk
Cool. One less to think about. I found my error. Fixed it.

Thanks,
Mitch,

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.