[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: 21
Thread images: 1

File: Capture.png (8KB, 599x217px) Image search: [Google]
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)

Sorry for recreating this thread, I got some responses that would have been useful with some elaboration last time, but my laptop briefly died and so did the thread.
>>
bump, i want a nice 3D programming thread too
>>
>>58918327
Canonical 3D graphics code seems to use projective geometry, which is no longer taught as a working subject. I believe this is done so as to enable translations to be performed as matrix rotations, but it feels like a bit of a hack.

I'm sure someone in the 1970s thought this was a good idea, but the rest of us are stuck with no real theory as to why we must do things this way.
>>
Read up on linear algebra, affine geometry and projective geometry, in this order.

You should be able to understand most stuff afterwards
>>
>>58918327
What's wrong with glm?
>>
>>58920362
So that's why no one seems to know how it's supposed to work?

>>58920522
It's a bad habit to apply something without learning it.
If things like GLM didn't exist then the knowledge for how to do all this without libraries would be abundant, and GLM wouldn't be necessary.
Really, whoever made GLM should have just made a tutorial instead, it's not like so much code goes into matrix transformations that a library is necessary. It's just that it's very hard to learn what to do.
>>
So what's what you don't understand, OP?
>>
>>58921461
Largely, what the vertex shader should look like if there is only one matrix passed into it (most people pass in three, which makes no sense performance-wise)
>>
>>58921989
If the question is about performance, then passing more uniform parameters is not too bad

If the question is about why three matrices, then it's because that's the way the model works. You have your projection, your view and your model. Passing in three matrices allows you to operate at the appropriate coordinate system (if you need to)
>>
I could definitely help but I don't want to do your homework. I took courses in uni that touched on this issue 100% hence how I know it's homework.
>>
>>58922050
The question isn't about either, it's about how to do it with only one matrix passed into the vertex shader.
Like, I'm pretty sure my way of setting gl_Position is wrong.
>>
>>58922084
That looks like an old shader variable...

Anyway, gl_Position = position.xyz/position.w should do it if your matrix is ok
>>
>>58922139
Do you mean (position.xyz/position.w, 1.0)?
And am I mistaken if I think that simply doing (position) is identical? Because I thought that gl_Position.xyz was divided by gl_Position.w, though that may be wrong.
>>
>>58922209
oh I can't remember if gl_Position is a vec3 or a vec4

If it's a vec4, then simply doing
gl_Position = YourMatrix * vec4(position, 1.0f);
should do it
>>
>>58922248
It's a vec4.
And position is a vec4 too, a 1.0 is tacked onto the vertex position so it can be multiplied by the matrix since you can't multiply a mat4 with a vec3.
>>
STOP HELPING OP WITH HIS HOMEWORK! OMG GUYS, HOW THE FUCK ARE WE SUPPOSED TO GET SMARTER IF YOU KEEP HELPING US?
>>
>>58920561
It's only really rotations and length that can be tricky. And it's not that tricky if you passed high school math.
>>
>>58922082
If I was taking this in university, I would have study notes available that would solve all my problems.
>>
>>58918327
Just understand conceptually how a vector in 3d space can be rotated by multiplying the individual Cartesian components,

Then realise that an object in 3d space can be represented by multiple points as vectors,

The same individual rotation of a vector applies to all vectors in total rotating the object
>>
>>58925147
>let me explain to you the most basic details of the thing you have almost fully implemented
Please consider deleting your 4chan account
>>
>>58922336
I really don't know what this is supposed to mean, even as sarcasm.
Thread posts: 21
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.