# Questions tagged [projection-matrix]

The tag has no usage guidance.

58 questions
Filter by
Sorted by
Tagged with
4k views

### Why do we need a fourth coordinate to divide by z?

I read the response here: What does the graphics card do with the fourth element of a vector as the final position? "The fourth component is a trick to keep track of perspective projection. When ...
4k views

### How do I correctly project a point behind the camera?

I am making a 3D game in which I put an exclamation marker above points of interest. In order to find out where in the 2D screen should I put my marker, I am manually projecting the 3D point where ...
• 13.2k
123 views

### How to clip cut-off using different frustrum than that of original camera? How to cut plane by pyramid shape?

SOURCE : http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Mitchell_LightShafts.pdf This process is part of creating light draft effect. And I am suggested to do the described process in ...
• 1,102
334 views

### How do I create a half-ortho half-perspective projection matrix

I've been trying to make a formula for the projection matrix where your vertical axis is projected orthographically but your horizontal axis will have perspective to it. So the view frustum would look ...
470 views

### How to set the camera projection matrix so that its 4 rays always exactly hit the corners of a defined rectangle?

I have a camera, and I have a rectangle drawn in an arbitrary plane. I need to change the projection matrix of the camera so that the rays along the edges of the camera's frustum always hit the ...
• 1,412
2k views

### How does a game like Enter the Gungeon handle forward and backwards movement with their orthographic set up?

So I've been scratching my head at this problem for over a week now, and would love some insight from anyone who might know a bit more. In my game I have the floor flat on the X/Z plane with walls/...
• 131
2k views

### 360 degree video of my OpenGL game

I want to make a 360 degree video of my OpenGL game. Concerning the rendering: Is it enough to render it in OpenGL with a specific projection matrix? If yes, which one? Or can I render it into a cube ...
• 91
479 views

### OpenGL: How to map point inside frustrum to normal device coordinates (NDC)?

I read this article http://www.songho.ca/opengl/gl_projectionmatrix.html. It's explain how calculate projection matrix coefficients. But I completely can't understand how author perform mapping from ...
• 151
1k views

### Offset a camera/render without changing perspective

I need to offset a render so that the perspective / vanishing point doesn't change. Or another way to look at it is that I need to adjust the vanishing point in my view so that instead of being at 0,...
• 1,941
115 views

### OpenGL Perspective Issue

I'm trying to troubleshoot a problem with my simple OpenGL test program, which I've written in C. I've written some math routines to do the matrix manipulation, but even after copying known working ...
• 51
4k views

### libGDX - Why do I have to use camera.setToOrtho what does it do?

I am very confused about camera matrices and I don't know where to start my studying. Maybe I have to study OpenGL, but I don't know C++ ... Ok so I have a camera, Box2d world and a Box2d body. <...
• 183
4k views

### Deproject Screen To World Coordinates (Unreal Engine 4.15)

I am working on a small game in Unreal Engine 4.15 using blueprints only and encountered a behaviour I don't understand. The game is based on the Top Down Example. As I'd like to teleport an actor ...
• 31
575 views

### Control frustum near and far clip plane sizes in a Projection Matrix

I'm trying to achieve a dolly zoom effect. My first try was the obvious one, the original "zoom in & dolly out" technique, which works nicely. Except that there are cases which this is not ...
• 389
10k views

### How can I set up an intuitive perspective projection/view matrix combination in OpenGL, using GLM?

Could anyone help me set up an intuitive perspective camera matrix using OpenGL and the GLM library? By "intuitive" I mean that I want the camera to be looking at the middle of the screen down the -Z ...
• 187
1k views

### OpenGL: Is it efficient ok to glPushMatrix, plMultMatrix, plPopMatrix for every object in my scene?

I'm very new to opengl, and I might not fully understand the openGL matrix projection stack thing. So, I have about 300 'objects' in my scene, each with their own position/rotation, and I want to ...
• 547
3k views

...
• 209
153 views

### What are some standard mathematical tests for projection matrices?

I'm trying to double check my math in my projection matrices. I'm thinking about "unit tests" when I ask this. I'm looking for 4 or 5 unit tests that would be appropriate to give one confidence that ...
• 179
140 views

### Shaders wont bind to the uniform block

I'm having an issue with interface block binding. Example shader: ...
• 31
751 views

### Why does the projection matrix transform object points into a unit cube in computer graphics?

This semester I both took a computer vision and a computer graphics seminar. But only now before the exams I realize that there seems to be a fundamental difference between projection in both topics. ...
• 123
1k views

### How to achieve the top-down (oblique) projection of textures using an OrthographicCamera?

This question is related to (How to calculate the initial velocity of projectile motion by a given distance and angle from point A to B) question. Details In the below image is the graphical ...
• 491
1 vote
54 views

### Can I get world-space z-near-plane vertices from projection matrix + z-near distance?

I'm trying to port ShaderToy VR shaders to WebXR (the new browser API for AR/VR devices). ShaderToy VR shaders expect two extra parameters: ray origin (view translation) and ray direction (unit vector ...
• 1,935
1 vote
543 views

### OpenGL frustum extraction

I'm trying to extract frustum planes from the camera. The algorithm is simple: create clip to world space matrix (inversed projection * inversed view) multiply clip point by clip to world matrix ...
• 108
1 vote
2k views

### libGDX - orthographic camera and world units

I've followed the advice in this post to handle world/screen coordinates, but I'm getting results I don't quite understand, as I'm not terribly good in math. So, when I use this code: ...
• 125
1 vote
316 views

### Last Row of the perspective projection matrix

Could you explain to me what is the purpose of -1 in the last row of the gl_projection matrix? And how it affects the perspective division step ?
• 189
1 vote
9k views

### How can I pass a std::vector<Vector3f> to my shader?

I have a Vector3f type which has x, y, and z properties. ...
1 vote
238 views

### Combining cylindrical Billboarding and aligning with velocity (unity)

I'm trying to make a custom GPU particle solution on Unity to fullfill some needs on my project, using compute shaders and custom shader + Graphics.DrawProceduralNow() to draw them. While I managed ...
1 vote
369 views

### set zfar/znear in openGL using shaders (QT env)

I have a QT canvas and I'm using shaders to build my scence. I've set the camera image plane at some position, and would like to view object from the image plane to infinity. How do I set the zfar and ...
• 111
1 vote
92 views

### 2D World Mouse Coordinates - Matrices

I'm trying to get the world coordinates out of a mouse click. Currently I'm doing the following: ...
1 vote
100 views

### What are projection independent ways of determining whether a normal is facing the viewer?

A position v and normal n are given in world coordinates. Also there is a view matrix V for ...
1 vote
194 views

I'm figuring out shadowmapping in HLSL (see also this question). I understand that I need projection matrices for each cascading shadowmap. I use this code to create the projections: ...
• 3,989
1 vote
116 views

### How to get world coordinates from a 4X4 camera matrix

I have Intel T265 camera which has a camera coordinates system like following diagram: The camera system has two cameras and the center of the two cameras is the position of the camera system. The ...
• 111
1 vote
47 views

### My triangle disappears when multiplaying by my perspective projection matrix

Whenever I multiply my transformation matrix, which is passed to the shader via constant buffer, my triangle disappears. Here is the code for the passed matrix: ...
1 vote
69 views

### Why projection window is between -1 and 1

Is it a convetion ? What we achieve with this ? I am reading about how the perspective and orthographic matrix is getting calculated and everyone is trying to normalize the homogenous coordinates to [...
• 11
1 vote
81 views

### How and where to transform a Camera Frustum onto a tilted screen?

In rendering tutorials for perspective projection the assumption is that the rendering surface is perpendicular to the sight line. As shown here: How to accommodate for a screen that is tilted ...
• 185
1 vote
3k views

### From screen space to world space for a 2D game

I'm making a 2D game and I want the user to be able to position an object in the world using mouse input. After a while I found an answer to 'OpenGL Math - Projecting Screen space to World space ...
• 113
1 vote
54 views

### Convert box to matrix

I have a box (non-rectangular cuboid?) and would like to convert it to a matrix such that when a point inside the box is multiplied by the matrix, a vector is returned that describes the relative ...
1 vote
779 views

### Converting normalized device coordinates to world space coordinates flipping my sprites

I'm trying to convert my game's camera system to use world space coordinates rather than OpenGL's default normalized device coordinates, however in doing so my sprites are being rendered improperly as ...
1 vote
1k views

### How can I get shadows to appear correctly when using a custom projection matrix?

EDIT: This has been officially marked as a bug in Unity. If anyone else has this issue, you can vote here for Unity to fix it. As mentioned in this thread, I'm using a custom projection matrix in ...
• 396
1 vote
357 views

### How to position a Weapons model in a first person shooter with XNA

I am building a first person shooter and positioning the weapons is hard. I am trying to get the bat to look like you are holding it but I keep trying things and they don't appear in the positions I ...
92 views

### Does a Standard Exist for Game Entity View Frustums

I was just recently adding the ability for my in-game entities to have their own Frustums, with the intentions of making them able to see enemies later down the road of my development cycle. My custom ...
• 800
172 views

### Projection Matrix Breaks My Rectangle

This is my vertex shader, shown below. ...
• 1,116
80 views

### When moving the "camera" should one move the projection matrix or move the world?

I'm making my own game engine as an exercise and I've gotten really confused with what I've read so far. When I want to move my camera do I simply just move the world or move the position of the ...
• 101
128 views

### How to visualize angle of projection in Oblique Parallel Projection?

We know that in Oblique Parallel Projection Point (x,y,z) is projected to position (x_p,y_p) on the view plane.Projector (oblique) from (x,y,z) to (x_p,y_p) makes an angle alpha. with the line (L) on ...
• 117
74 views

### Texture flipping behaviour

I was having this problem with OpenGL where I'd have all my textures being rendered upside down. I did the most logical thing I could think of and tried reversing the order of the mapping and that ...
833 views

### What exactly does XMMatrixPerspective{L,R}H do?

There are generally three functions to create a perspective matrix in DirectXMath, XMMatrixPerspective{L,R}H, ...
• 1,840
1k views

### Z-Value of clip-space position is always 1.0

I render a lot of quads on the screen into z direction (20 x 2000). I want to get the depth value in a final render target. But it looks like z is always 1.0f. I checked the result with the OpenGL ...
• 111
2k views

### How does glm::lookAt produce a View Matrix?

Say we do this: glm::mat4 View = glm::lookAt(glm::vec3(4,3,-3), glm::vec3(0,0,0),glm::vec3(0,1,0)); And after printing to the console with glm tostring (column ...
• 11
67 views

### Confused about why my projection matrix works

My projection matrix was buggy, I'm not great at mathematics, but I checked it against the the songho tutorial, and the broken one seems correct to me but switching nearplane to farplane seems to ...
• 301