Skip to content

[3D] Add categorized renderer#64569

Open
ptitjano wants to merge 26 commits intoqgis:masterfrom
ptitjano:symbology-3d-category
Open

[3D] Add categorized renderer#64569
ptitjano wants to merge 26 commits intoqgis:masterfrom
ptitjano:symbology-3d-category

Conversation

@ptitjano
Copy link
Collaborator

@ptitjano ptitjano commented Jan 16, 2026

Description

This PR ads support for categorized renderer in QGIS 3D.
On the 3d renderering side this adds:

  • a new chunk loader called QgsCategorizedChunkLoader
  • a new 3d renderer called QgsCategorizedChunkLoader

Both implementations are similar to the existing rule based and vector renderers.

On the widget side, this adds:

  • a new button to preview a symbol and configure it: Qgs3DSymbolButton (a simplified version of its 2D counter part: QgsSymbolButton)
  • a new widget QgsCategorized3DRendererWidget to configure the renderer. It is similar to its 2D counterpart and it tries to factorize some common code (mostly the model of the tree view used to display the categories)

Some new vector symbol and material utils functions are introduced. They are used in the new widgets:

  • a function to generate a material (phong, gooch, etc..) from a base color
  • a function to compute an average color from a material (phong, gooch, etc..)
  • a function to generate a symbol preview as an icon
  • a function to copy the material settings from one vector material to an other one

Demo

qgis3d-categorized.mp4

Updates

20 january

Funded by Stadt Frankfurt am Main

Closes #51640
Closes #53963

@ptitjano ptitjano self-assigned this Jan 16, 2026
@ptitjano ptitjano added Feature 3D Relates to QGIS' 3D engine or rendering labels Jan 16, 2026
@github-actions github-actions bot added this to the 4.0.0 milestone Jan 16, 2026
@ptitjano ptitjano force-pushed the symbology-3d-category branch 9 times, most recently from 4d64c84 to 849cc79 Compare January 16, 2026 23:14
@github-actions
Copy link
Contributor

github-actions bot commented Jan 17, 2026

🍎 MacOS Qt6 builds

Download MacOS Qt6 builds of this PR for testing.
This app is not notarized, run sudo xattr -d com.apple.quarantine /Applications/QGIS*.app to avoid the warning
(Built from commit c64789a)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit c64789a)

@ptitjano ptitjano force-pushed the symbology-3d-category branch 4 times, most recently from 61bf941 to f796430 Compare January 19, 2026 01:00
@nyalldawson
Copy link
Collaborator

@ptitjano above review is partial only -- i haven't checked the gui or 3d handler yet.

@ptitjano ptitjano force-pushed the symbology-3d-category branch 2 times, most recently from d37f249 to 690ab06 Compare January 20, 2026 15:10
@ptitjano
Copy link
Collaborator Author

@ptitjano above review is partial only -- i haven't checked the gui or 3d handler yet.

thanks

@ptitjano ptitjano force-pushed the symbology-3d-category branch from 690ab06 to f78fa15 Compare January 21, 2026 08:30
@nyalldawson nyalldawson added the Freeze Exempt Feature Freeze exemption granted label Jan 27, 2026
@ptitjano ptitjano force-pushed the symbology-3d-category branch from f78fa15 to dd6687e Compare February 4, 2026 13:16
@github-actions github-actions bot added the GUI/UX Related to QGIS application GUI or User Experience label Feb 4, 2026
@ptitjano ptitjano force-pushed the symbology-3d-category branch 3 times, most recently from 410a159 to 7219bba Compare February 4, 2026 13:24
void Qgs3DSymbolButton::showSettingsDialog()
{
QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( this );
QgsSingleSymbol3DRendererWidget *widget = new QgsSingleSymbol3DRendererWidget( mLayer, this );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why QgsSingleSymbol3DRendererWidget? QgsSymbol3DWidget would be more appropriate.

Copy link
Collaborator Author

@ptitjano ptitjano Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we need a widget which inherits from QgsPanelWidget. Maybe, the existing QgsSymbol3DWidget could be adapted to inherit from QgsPanelWidget?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More precisely, I don't understand the difference between QgsSingleSymbol3DRendererWidget and QgsSymbol3DWidget

: QgsTemplatedCategorizedRendererModel<QgsCategorized3DRenderer>( parent, screen )
{}

Qt::ItemFlags QgsCategorized3DRendererModel::flags( const QModelIndex &index ) const
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's SO much duplicate code here. is there no way to reduce this via the template QgsTemplatedCategorizedRendererModel? (and similarly with the widget)

Copy link
Collaborator Author

@ptitjano ptitjano Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind reducing reducing the duplicate code, quite the opposite. But I was under the impression that this was not the way to do it. Currently, almost no widget code is shared between 2D and 3D. Take for example the rulebasedrenderer. All the code is duplicated.


virtual void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override = 0;

int rowCount( const QModelIndex &parent = QModelIndex() ) const override
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can speed up compilation by moving these to the .cpp file, and then doing something like: https://github.com/qgis/QGIS/blob/master/src/core/project/qgsprojectstoredobjectmanager.cpp#L121

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this can be done because in that cause, one would need to include qgscategorized3drenderer.h in the cpp file. However, one cannot access 3d directory from the gui one. Or am I missing something?

ptitjano added 21 commits March 11, 2026 17:21
`QgsCategorized3DRenderer::createEntity` is not implemented at the
moment. This will be done with QgsCategorizedChunkLoader` in the next
commit.
This function calculates a weighted average of the ambient, diffuse,
and specular color components to produce a single representative
color.
…e color

This function calculates a weighted average of the ambient, diffuse,
and specular color components to produce a single representative
color.
This function calculates a weighted average of the cool, warm,
diffuse and specular color components to produce a single
representative color.
For phong and gooch, this uses the average logic introduced in the
previous commits. For materials with only one color, this returns the
base color.
This adds a utility function to get the average color of a 3d symbol.
This adds a new function to generate a preview icon of a vector 3d symbol
based on its type (line, point or polygon) and its average color.
This function decomposes a base color into phong material
components (ambient, diffuse, specular, shininess).
…e color

This function decomposes a base color into phong material
components (ambient, specular, shininess).
This function decomposes a base color into gooch components (cool,
diffuse, specular, warm, alpha and beta).
…olor

For phong and gooch, this uses the base color logic introduced in the
previous commits. For materials with only one color, this sets its
color.
This methods sets the base color of the material settings associated
with a 3D vector symbol.
This function copies the material properties of a vector 3D symbol
from one symbol to another.
@ptitjano ptitjano force-pushed the symbology-3d-category branch 2 times, most recently from 984dde1 to 2dcf2b1 Compare March 11, 2026 16:56
And add them in `QgsTemplatedCategorizedRendererModel`.
This will be needed by `Qgs3DSymbolButton` in the next commit.
This widget is used to configure a 3d categorized renderer.

Closes: qgis#53963
This prevents fetching features that won't be rendered.
@ptitjano ptitjano force-pushed the symbology-3d-category branch from 2dcf2b1 to c64789a Compare March 13, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3D Relates to QGIS' 3D engine or rendering Feature GUI/UX Related to QGIS application GUI or User Experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Styling 3D features adding categorized option 3D view Rule-based styling

3 participants