Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7407565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:44:39+00:00 2026-05-29T05:44:39+00:00

I am currently developing a Direct3D 11 rendering engine using C#. I have already

  • 0

I am currently developing a Direct3D 11 rendering engine using C#.

I have already succeded in drawing triangles, applying color and textures, etc.
The object I am trying to display now is a rotated cube with a side length of 1 placed at the origin of the world space.
But I am getting unsatisfying results when applying the view and especially the projection matrix. As it is difficult to explain, I just show you what result I get for different view/projection combinations:


HLSL snippet from my vertex shader:

float4x4 wvpMatrix = mul(World, mul(View, Projection));
output.Position = mul(input.Position, wvpMatrix);

The world matrix I use:

// Static rotation around all three axes
matrices.World = Matrix.Identity * Matrix.CreateFromYawPitchRoll(0.5f, 0.6f, 1.0f);

Test A

Simple view vector from origin in the positive z direction. No projection used.
You can see that the back of the cube is being clipped.

matrices.View = Matrix.CreateLookAt(new Vector3(0, 0, 0), new Vector3(0, 0, 1), Vector3.Up);
matrices.Projection = Matrix.Identity;

Cube with back corners clipped


Test B

View matrix stays the same, but now I am using an orthographic projection matrix.
This time the front of the cube vanishes. The parts you can see are those which were clipped in Test A.

matrices.View = Matrix.CreateLookAt(new Vector3(0, 0, 0), new Vector3(0, 0, 1), Vector3.Up);
matrices.Projection = Matrix.CreateOrthographic(2, 2, 0.01f, 100.0f);

Cube with front corner clipped


Test C

Again no projection, just like in Test A. This time the scene is being viewed from a point three units in the negative z direction.
The cube looks distorted when the camera position is not set to the origin of the system. I think there is also some clipping.

matrices.View = Matrix.CreateLookAt(new Vector3(0, 0, -3), new Vector3(0, 0, 1), Vector3.Up);
matrices.Projection = Matrix.Identity;

Distorted cube


Test D

Finally, I use a perspective projection. Up to now I have not found a camera position from which any part of the cube is visible. All I get is fullscreen cornflower blue.

matrices.View = Matrix.CreateLookAt(new Vector3(0, 0, -3), new Vector3(0, 0, 1), Vector3.Up);
matrices.Projection = Matrix.CreatePerspectiveFieldOfView(1, 1, 0.1f, 100);

No visible parts of the cube


First thing I want to do is drawing the full cube – no clipping. I tried different combinations of near/far plane values but I could not find an acceptable solution.
My final goal would be to have a perspective projection. But as you see I can’t even get a good orthagonal view of the scene.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:44:40+00:00Added an answer on May 29, 2026 at 5:44 am

    The matrices must be transposed at some point.

    Reason:

    The layout of the Microsoft.Xna.Framework.Matrix struct is row-based. Matrices in HLSL are column-based.

    From the XNA Documentation:

    Matrices use a row vector layout in the XNA Framework.

    From the Wikipedia article on matrix order:

    Column-major order is a similar method of flattening arrays onto
    linear memory, but the columns are listed in sequence. The […] shading languages
    GLSL and HLSL use column-major ordering.


    Solution A:

    Transpose all matrices before they are sent to the shader:

    var projection = Matrix.CreatePerspectiveFieldOfView(1, 1, 0.1f, 100);
    projection = Matrix.Transpose(projection);
    

    Solution B:

    Put this line in your shader code:

    #pragma pack_matrix( row_major )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently developing a 3d game using C#/SlimDX (The target is Direct3D 9).
Currently developing an application using the newest version of symfony, obtained through PEAR. This
Currently developing a PHP framework and have ran into my first problem. I need
I was currently developing a desktop application in C# using mono and testing in
I am currently developing a Rails application using a database that was designed before
I'm currently developing a PHP application that's using an Access database as a backend.
Currently developing a connector DLL to HP's Quality Center. I'm using their (insert expelative)
I'm currently developing a simple 2D game for Android. I have a stationary object
I am currently developing a simple Pong game for the iPhone. Currently using CGRectIntersectsRect
I´m currently developing a web site using Symfony2. On 'dev' environment everything works just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.