Forum
Contact





DirectX using C#
DirectX using C++
DirectX using Visual Basic



Latest Forum posts

 No download link for 2d series: shooter
  Posted by: zaboleq
  When: 07/05/2013 at 15:46:28

 Collision Class?
  Posted by: Anonymous
  When: 05/05/2013 at 19:03:59

 stack overflow
  Posted by: cityguy
  When: 07/04/2013 at 01:58:38

 Meshes looks strange.
  Posted by: ab_saratov
  When: 01/04/2013 at 04:31:08

 Lamppost Not loaded
  Posted by: Anonymous
  When: 22/03/2013 at 06:43:52

 Collision Class?
  Posted by: Da_Boom
  When: 21/03/2013 at 01:23:09

 Math boggles me
  Posted by: cityguy
  When: 17/03/2013 at 03:44:48

 Collision Class?
  Posted by: Da_Boom
  When: 16/03/2013 at 03:44:42

 Tree update
  Posted by: Anonymous
  When: 15/03/2013 at 21:11:22

 XNA 4.0
  Posted by: Anonymous
  When: 15/03/2013 at 19:43:57

 Error when I try to run.
  Posted by: Anonymous
  When: 15/03/2013 at 19:21:06

 Error With the Effect File
  Posted by: Anonymous
  When: 15/03/2013 at 18:21:01

 Can only get shadowmap
  Posted by: Anonymous
  When: 15/03/2013 at 15:48:52

 Vertex and Pixel Shader Versions?
  Posted by: Anonymous
  When: 15/03/2013 at 15:07:16

 Unsupported properties
  Posted by: Anonymous
  When: 15/03/2013 at 14:23:00

 Problem Loading Skybox
  Posted by: Rana
  When: 15/03/2013 at 10:34:45

 Black Screen Of Death - Help!
  Posted by: Anonymous
  When: 15/03/2013 at 03:43:43

 2.0 anyone?
  Posted by: Anonymous
  When: 15/03/2013 at 02:19:48

 Defitinition of tha rotation axis
  Posted by: Anonymous
  When: 15/03/2013 at 00:55:14

 Typo / Inconsistancy for 360 deployment.
  Posted by: Anonymous
  When: 14/03/2013 at 19:48:23




Topic: questiong regarding shadowed scene



  
Goto parent category
  
Create a new user account


   questiong regarding shadowed scene
 Poster : reyjexter
 Posts: 21
 Country : philippines
 City: legazpi city

  
Posted by reyjexter on 22/02/2007 at 12:48:08
hi riemer!


i'm i bit lost on the tutorial that cast shadows specifically on the hlsl part:


SScenePixelToFrame ShadowedScenePixelShader(SSceneVertexToPixel vs)
{
    SScenePixelToFrame output = (SScenePixelToFrame) 0;
    
    float2 projectedTextureCoords;
    projectedTextureCoords.x = vs.shadowMapSamplingPos.x / vs.shadowMapSamplingPos.w / 2.0f + 0.5f;
    projectedTextureCoords.y = -vs.shadowMapSamplingPos.y / vs.shadowMapSamplingPos.w / 2.0f + 0.5f;
    
    output.color = tex2D(shadowMapSampler, projectedTextureCoords);
    
    return output;
}


i cant understand why you needed to negate the projectedTextureCoords.y


thanks


rey
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 23/02/2007 at 02:45:01
For a reason I forgot, the result of multiplying the vertices with the view and projection matrix, the image you get is flipped upside down. To correct for this, we need to negate the Y coord
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 17/08/2009 at 16:51:32
Could someone please elborate on this?
 Poster : radulph
 Posts: 225
 Country : germany
 City: hamburg

  
Posted by radulph on 18/08/2009 at 04:44:04
XNA uses a right hand coordinate system. Thus, the x axis points to the right, the y axis to the top and the z axis towards the viewer. Further the origin of the 3d space is at the center of the screen.
The last thing to note is that (given an identity matrix as the projection matrix) both x and y axis range from -1 to 1 (from left side of the screen to the right side of the screen, top to bottom as well)

On the other hand, texture coordinates range from (0,0) to (1,1) (top left to bottom right corner where u = horizontal pos. and v = vertical pos.).
What happens in the code snippet above is to transform view space coordinates to texture coordinates. the division by 2 and addition of 0.5 shifts the origin to the top left corner and scales the axis. The -sign inverts the y axis since it originally points up, whereas the v coordinate of a texture points downwards.

  
Post a new reply
 





Google
 
Web www.riemers.net
If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !
- Website design & DirectX code : Riemer Grootjans -
©2006 Riemer Grootjans


News
Home
Forum
XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Downloads
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
XNA 4.0 using C# (89)
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Series 3: HLSL (19)
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
DirectX using VB (2)