Rename camera matrix terminology #127806
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#127806
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Blender terminology for camera matrices doesn't follow the usual naming conventions and can be quite counterintuitive.
We have:
viewmat
for the view matrix (this one is fine)winmat
for the projection matrix (window matrix?🤔)persmat
forwinmat*viewmat
(perspective matrix, which can be easily mistaken as the projection matrix)I propose to just follow the usual naming conventions, so it would become:
view_mat
projection_mat
view_projection_mat
I don't know where this terminology originated from. The only good thing about it is that names are quite short. But that can also be cryptic.
I would like to mention that there are also
viewinv
,wininv
andpersinv
. I propose:view_mat_inv
orview_mat_inverse
projection_mat_inv
orprojection_mat_inverse
view_projection_mat_inv
orview_projection_mat_inverse
Would like to know the feeling of some core contributors as this touches pretty much all 3D modules. There is over 1000 references of these over the whole codebase. Some of them are inside DNA and some exposed in the RNA through
window_matrix
,view_matrix
,view_perspective
. Obviously I don't think renaming RNA is worth it. But it would creates a discrepancy between python and C.Tagging @JacquesLucke @ideasman42 @Sergey @mont29 @filedescriptor to know their opinions.
Just mentioning one other way of specifying an inverse matrix that I've seen (mainly in sculpt / paint code) is
imat
. I don't have particularly strong thoughts on how we name things here, but I wanted to bring it up in case people really liked it as a third option.It was mentioned in the chat that
projection
could be shortened toproj
.Another option is to use the same convention as for objects matrices (i.e.
object_to_world
).I believe Cycles uses
raster
for the post projection space but I am not sure it maps 1:1 to projection matrices. For now I propose to usehomogeneous
as it is what we decided to use for the draw module inside the shaders. But we could also just useprojection
here too.So we would have:
world_to_view
view_to_homogeneous
world_to_homogeneous
EDIT: However, we also have
RE_GetCameraWindow
. And renaming it toRE_get_camera_view_to_homogeneous
might not be to everyone's liking.I like the
x_to_y
naming generally for matrices. It makes it obvious what they do and how to compose them, especially in more complex situations. But I'm also totally fine with using industry standard terms for these matrices here. What these are, you'd know better than me.For the inverse, I think we commonly follow
_inv
suffix. Theimat
is kinda historical, and should be renamed toworld_to_object
(that is whatimat
used to be, and for other cases usingi
prefix is kinda easily missable).Surely
x_to_y
is helping in general case, I am not sure it really helps here. There are well-established terms in the computer graphics for these matrices.The issue with Cycles's is that it is not that obvious what
raster
orscreen
actually is. And there is alsondc
. Every time i use them i need to check how exactly they are calculated.And
homogenous
sounds a bit vague.But also any of the proposals here are better than the current state :)
It looks like
projmat
is already used in some places.BTW,
BLI_math_geom.h
functions are a perfect example of the issues with this terminology.We have "perspective" used for both perspective projection matrices and for view+projection matrices. And "projection" and "window" is used interchangeably.
About
raster
, I have not checked it, but I would assume these are for pixel coordinates (the equivalent ofFragCoord
).I like the
x_to_y
for functions (IMO thedraw_view_lib
API is as good as it gets), but for the matrices themselves it can get confusing.RE_get_camera_view_to_homogeneous
is kind of bad, but something likeview_to_homogeneous_dimensions
is even worse and would need more thoughtful renaming.Also, the concept of a projection matrix probably sounds much more familiar to non-graphics devs than the concept of homogeneous or NDC coordinates.
BTW, when using that terminology for the matrices themselves, I'd say
x_from_y
is probably a better fit for Blender. So we have:homogeneous = homogeneous_from_view * view_from_world * world_from_local * vert_position
instead of:
homogeneous = view_to_homogeneous * world_to_view * local_to_world * vert_position
In any case, I personally would go for the least invasive changes that solve the most glaring issues.
There might be better style options, but if that's going to require a massive API redesign instead of a simple batch rename I'd say it's not worth it.
Regarding renaming RNA, currently we lack a proper way to handle this, so better to avoid it indeed, and live with the difference between C++ code and RNA/Python names. See alos discussion in !126796
Agreed!
The issue is that this touches a lot of areas as I pointed out. And having yet another convention that is not enforced or applied over the whole codebase will increase friction.
I would also avoid doing batch rename on the whole codebase in one commit. It is easy to change something else by mistake. Cleaning one API / module at a time seems better to ensure the best semantic for each.