Skip to content

Add Physics Based Rendering (PBR) shading method to grdimage and grdview - #9230

Open
joa-quim wants to merge 4 commits into
masterfrom
PBR-shading
Open

joa-quim wants to merge 4 commits into
masterfrom
PBR-shading

Conversation

@joa-quim

@joa-quim joa-quim commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

PBR is a shading method used by the VTK library in GPU rendering. In i'GMT I managed to had it replicated (almost) in C and this PR ports it into GMT. The shading quality of this method seems rather more appealing than what we have so far. It is implemented in grdimage and grdview as option -F and a shortcut -I+f can be used to that resorts to default values (maybe these def values can be tuned). Code was accelerated with OMP and runs rather rapidly in spite having to do quite some more work than the pure gradient methods we have in GMT so far.

As an example, this

gmt grdimage @earth_gebco_15s -R-156.2/-154.7/18.8/20.35 -Cgeo -F315/35+o+s+t+v3+l1.4+f0.5 -JM15c -Ba -png hawaii

produces this image (notice the presence of shadows)

hawaii

@joa-quim
joa-quim requested a review from a team September 25, 2026 23:10
@github-actions

Copy link
Copy Markdown
Contributor

Summary of changed images

This is an auto-generated report of images that have changed on the DVC remote

Status Path
added test/baseline/grdimage/pbr.ps
added test/baseline/grdview/pbr.ps
modified test/baseline/grdimage/
modified test/baseline/grdview/

Image diff(s)

Details

Added images

  • test/baseline/grdimage/pbr.png

  • test/baseline/grdview/pbr.png

Modified images

Path Old New

Report last updated at commit 623d037

@joa-quim joa-quim changed the title Add Physics Based Shading (PBR) shading method to grdimage and grdview Add Physics Based Rendering(PBR) shading method to grdimage and grdview Sep 25, 2026
@joa-quim joa-quim changed the title Add Physics Based Rendering(PBR) shading method to grdimage and grdview Add Physics Based Rendering (PBR) shading method to grdimage and grdview Sep 25, 2026
@Esteban82 Esteban82 added new feature PR that implements a new feature or capability in GMT add-changelog Add PR to the changelog labels Sep 26, 2026

@Esteban82 Esteban82 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I got the same map.

**-F**\ *azim*/*elev*\ [**+f**\ *fill*][**+i**\ *ior*][**+l**\ *light*][**+m**\ *metallic*][**+o**\ [*radius*]][**+r**\ *roughness*][**+s**][**+t**][**+v**\ *ve*]
Shade the grid with physically based lighting instead of illuminating it with |-I| (the two
cannot be combined). The shaded image is made on the grid's own nodes and then projected and
plotted as any image, so |-A|, |-E| and |-J| work as usual. Use **-I+f** as a short form that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The new shading looks good, but why support -I+f? Can we just use -F with no arguments to mean using the default settings?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The idea was to give the -I, that I believe is very embedded in users memory, a quick shortcut to also use this new illumination. But you are right that at least, -F should do that too. To be honest, I don't even like the idea to introduce a new letter to do illuminations but at the time the idea to overload the -I with all new -F flags seemed bad idea. But now I'm not so sure anymore. What do you guys think of dropping -F and letting -I take the extra burden like in (the P is from the PBR method name)

-I+P[azim/elev+...]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What do you guys think of dropping -F and letting -I take the extra burden like in (the P is from the PBR method name)

The two shadings have totally different modifiers. Combining them into one flag will make the documentation difficult to read.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So -F and -I are mutually exclusive, or is -F a modifier for -I? (I see now that the docs says ‘cannot be combined’). Adding a new option (-F) for illumination might be confusing, but so is creating a -I monster with dizzying amount of modifiers. What confuses the least..?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ps: very nice to see a new illumination method!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Andreas, you summarized it well. What confuses less?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog new feature PR that implements a new feature or capability in GMT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants