[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

I have never been able to find an explanation of transformation

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 9
Thread images: 1

File: Capture.png (8KB, 599x217px)
Capture.png
8KB, 599x217px
I have never been able to find an explanation of transformation matrices in 3D graphics that doesn't use specialised libraries and doesn't use coding practices of questionable efficiency.

So I tried making my own, but it makes no sense, yet it almost works.
Anyone on /g/ thinks it's redeemable?

Every frame:
>create camera matrix, starting with a translation matrix
>multiply by z rotation matrix, then x, then y
>translate by (0, 0, -1) (so that when the camera rotates, it doesn't rotate around a point in front of the camera)
>multiply by projection matrix, which is as shown

Every frame, per object:
>create object matrix, starting with a scale matrix
>multiply by x rotation matrix, then y, then z
>multiply by translation matrix
>multiply with camera matrix to get the transformation matrix

In vertex shader:
>create vec4 "position" by multiplying the transformation matrix with the vertex position (since it's a vec3, 1.0 is tacked on the end)
>define gl_Position in either of the following ways
>gl_Position = vec4(position.xy/position.w, position.z, 1.0) (causes layering issues and vertices behave weirdly as they go offscreen)
>gl_Position = position (cutoffs are no longer the near and far defined by the camera)
>>
It sounds pretty close. It's been a while since I've touched graphics so this is mostly just a bump but I wonder how much of that per frame per object stuff can be cached and how good time/space savings would be.
>>
>>58858968
If I get this fully working, I could test that.
>>
By the way, I should add that "questionable efficiency" includes stuff like passing three matrices into the vertex shader.
That's promoting a per-frame multiplication (camera x projection) to per-vertex, and a per-object multiplication (object x whatever) to per-vertex.
>>
Maybe I should look up Vulkan tutorials, since it's rather new it shouldn't be full of bad practices that have been passed from person to person.
>>
>>58857102
Everything you posted sounds fine. What are you having trouble with? The projection?

Projection isn't a linear transform so the 4x4 matrix thing is a bit of a hack to make it work. You don't actually have to do it with a matrix, the simplest projection is just to divide x and y by z at the end.

The w coordinate is called the homogeneous vertex coordinate. It's kind of a hack to be able to put translation and projection in, which are both not linear transforms on Euclidean geometry.

You're using 4x4 matrices everywhere, right?

Also, the correct normalization for a vec4 is to divide all components by w, including z. This might explain your layering issues.
>>
Aren't you supposed to use quaternions for rotation?
>>
>>58864824
Yes, but you can't compose them with translation, scale, and projection like you can with a 4x4 matrix.
>>
lol, low level 3d coding, good luck doing the work for anything that matters unless you have a team of 200,000 people.
Thread posts: 9
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.