Hot answers tagged

23 votes

Get vector length with GLM

Sorry folks for posting such a trivial issue! The issue is solved. I was using the wrong function. Here goes the correct one: ...
sajis997's user avatar
  • 1,229
9 votes

What is the difference between a point transformation and a vector transformation?

Here's the simple answer. In 4D, to be able to multiply them by a 4x4 matrix, vectors are represented as (x,y,z,0) and points are represented as (x,y,z,1). Since the 4th row of a 4x4 matrix ...
Alan Wolfe's user avatar
  • 7,751
6 votes
Accepted

Graphics Pipeline: Viewspace & Back face culling incorrectly

I (believe) I've solved this (even if it has taken 2 days). My problem was essentially I wanted to take the dot product of the face normal, and line-of-sight vector like below And determine the angle ...
davidhood2's user avatar
6 votes

Ray tracing with thin lens camera

In a traditional camera, the photons from the scene travel through the lens of the camera, then hit the sensor at the focal length. A consequence of the lens is that the image is upside down and ...
RichieSams's user avatar
  • 3,732
5 votes

Test if a point is on a line segment

Let's say you have your two points that define the line segment: $A$ and $B$, and a point $P$ that you are testing to see if it is on the line segment. Firstly, you get a normalized vector from $A$ ...
Alan Wolfe's user avatar
  • 7,751
5 votes
Accepted

Interpolating vectors on a grid

I did some research and found the answer I was looking for. The three most common ways to interpolate vectors are: Slerp - short for "spherical interpolation", this is the most correct way, but is ...
Alan Wolfe's user avatar
  • 7,751
4 votes
Accepted

Calculating the angle between two polygons

I suggest computing the normal vector for each polygon and compute the angle between the normal vector of one triangle and the normal vector of a plane perpendicular to the other surface that passes ...
Wyck's user avatar
  • 410
4 votes

Correct view-space transform

I've done some small changes to how I usually construct my view matrix, here is what I've modified: ...
alariq's user avatar
  • 141
4 votes
Accepted

Normal vector in Phong Illumination Model should be normalized?

Short answer: yes. Longer answer: yes, because the vectors you’re using are meant to represent directions, not directions-and-distances. Think of it in terms of light: it doesn’t matter how far a ...
Noah Witherspoon's user avatar
4 votes
Accepted

Video-games; Rendering textures on scope zoom-in. Texture compression problem?

Well there's no way to know for sure unless you look at the source code but my guess is that they do zooming by lowering the FOV (field of view) of the camera. This is easy to implement and actually ...
Chuck's user avatar
  • 296
3 votes
Accepted

Vector Math for Raytracer

I think there might be a misprinting in the book. I am getting this $((A-C) + tB)\cdot((A-C) + tB) = R\cdot R$ Let A-C = Y $(Y + tB)\cdot(Y + tB) = R\cdot R$ $...
gallickgunner's user avatar
3 votes
Accepted

Perlin Noise with Smooth function vs Lerp

It looks like the way you're using smoothstep isn't quite right. With lerp, the first two parameters are the endpoints of the output range, and the third is a 0–1 value specifying how far to ...
Nathan Reed's user avatar
  • 24.8k
3 votes

Can somebody explain this Ray Tracing Function?

Good answer above. (I like that the book adds in p then subtracts it.) This is a hard-coded grey world as a "hello world" kind of ray tracer. The 0.5 is the hard-coded reflectance. Keep ...
Peter Shirley's user avatar
3 votes

Creating vector shapes using only C++

What you are looking for is a way to get access to individual pixels in an image, in a way that you can modify those pixels with CPU code. Once you have that you'll want to find software rendering / ...
Alan Wolfe's user avatar
  • 7,751
2 votes
Accepted

Can somebody explain this Ray Tracing Function?

vec3 target = rec.p + rec.normal + random_in_unit_sphere(); return 0.5*color(ray(rec.p, target-rec.p), world); this is the exact same as ...
ratchet freak's user avatar
2 votes

What is the difference between a point transformation and a vector transformation?

If you would look up the definition of a vector and a point, then a vector is: A quantity, such as velocity, completely specified by a magnitude and a direction. http://www.thefreedictionary.com/...
bram0101's user avatar
  • 1,595
2 votes

Where should I project a polygon corner when it is behind me?

Trying to explain a problem seems to help the thought process. This is what eventually worked for me: I realized that I can easily find the point (in 3D space) where a line between two of the corners ...
SE - stop firing the good guys's user avatar
2 votes
Accepted

Finding the normals of a tileable 2D surface extracted from 4D space

Since the question was somewhat clarified I will formalize both the question and the answer for future readers. Having a differentiable scalar field $f : \mathbb{R}^4 \rightarrow \mathbb{R}$ we want ...
lightxbulb's user avatar
  • 2,083
2 votes
Accepted

Refraction: given an incoming and transmitted direction, can I deduce the normal?

See equation (16) in Microfacet Models for Refraction through Rough Surfaces : $-(\eta_i w_i + \eta_o w_o)$ which you'll probably want to normalize. $\eta$ are the two indices of refraction and $w$ ...
Olivier's user avatar
  • 1,585
2 votes
Accepted

Plotting points along a 3D line segment

You shouldn’t need to use any trigonometry here at all. If you get the vector from v1 to v2 and divide it by the number of points you want along the line, each subsequent point is v1 + (that vector) × ...
Noah Witherspoon's user avatar
2 votes

Help understanding tangent from dot product and max distance from component wise vector multiplication

There is very little geometrical meaning to the multiplication of two vectors and there are no well defined identities describing the result. But that doesn't make it illegal, and is an important part ...
pmw1234's user avatar
  • 3,030
2 votes
Accepted

Trouble transforming vectors from view space to screen space using a perspective projection matrix

The way to do the projection is the following: ...
Thomas's user avatar
  • 1,136
1 vote

Extending an orthogonal set of vectors (graphics application?)

The most common use is almost certainly computing normal vectors for a surface, using a cross product. Although strictly speaking, this does not quite qualify as the two initial vectors are usually ...
Olivier's user avatar
  • 1,585
1 vote

3d Math Primer book equation derivation - Projecting One vector onto another

Since we have: $$\pmb{v}_{\parallel} \parallel \pmb{n},$$ then: $$\pmb{v}_{\parallel} = k\pmb{n}$$ We want that the length of $\pmb{v}_{\parallel}$ is $\|\pmb{v}_{\parallel}\|$, then: $$\|\pmb{v}...
lightxbulb's user avatar
  • 2,083
1 vote
Accepted

3d Math Primer book equation derivation - Projecting One vector onto another

Since v∥ is parallel to n, it can be expressed as some multiple of n. The multiple is the ...
Noah Witherspoon's user avatar
1 vote

Morph Targets Normal adding math

It would seem that, in the second example, the morphNormals are targets while in in the first they are deltas. This explains the difference in math used between the two pieces of code.
Sebastián Mestre's user avatar
1 vote

How do I derive this transformation

I'm not going to dive into much details about affine transformations and such, you are better off reading up on these concepts from good graphics books. I think The matrix you need is this. $\begin{...
gallickgunner's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible