Skip to content

Commit

Permalink
Code release
Browse files Browse the repository at this point in the history
  • Loading branch information
oargudo committed Oct 7, 2020
1 parent 279c800 commit 55319ba
Show file tree
Hide file tree
Showing 92 changed files with 9,818 additions and 1 deletion.
2,024 changes: 2,024 additions & 0 deletions GlaciersFeatures.ipynb

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions GlaciersRender.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

INCLUDEPATH += code
INCLUDEPATH += code/core
INCLUDEPATH += code/appRender
INCLUDEPATH += $$(GLEW_DIR)

VPATH += code

SOURCES += \
glacierterrain.cpp \
appRender/main.cpp \
appRender/mainwindow.cpp \
appRender/glacierswidget.cpp \
appRender/featurespainter.cpp \
core/core.cpp \
core/scalarfield2.cpp \
core/vectorfield2.cpp \
core/shader-utils.cpp

HEADERS += \
glacierterrain.h \
appRender/mainwindow.h \
appRender/glacierswidget.h \
appRender/featurespainter.h \
core/core.h \
core/scalarfield2.h \
core/vectorfield2.h \
core/shader-utils.h

FORMS += \
appRender/mainwindow.ui

LIBS += -L$$(GLEW_DIR) -lglew32
LIBS += -lopengl32 -lglu32

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
41 changes: 41 additions & 0 deletions GlaciersSim.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

INCLUDEPATH += code
INCLUDEPATH += code/core
INCLUDEPATH += code/appRender
INCLUDEPATH += $$(GLEW_DIR)

VPATH += code

SOURCES += \
glacierterrain.cpp \
appSimulation/main.cpp \
appSimulation/mainwindow.cpp \
appSimulation/glacierswidget.cpp \
core/core.cpp \
core/scalarfield2.cpp \
core/vectorfield2.cpp \
core/shader-utils.cpp

HEADERS += \
glacierterrain.h \
appSimulation/mainwindow.h \
appSimulation/glacierswidget.h \
core/core.h \
core/scalarfield2.h \
core/vectorfield2.h \
core/shader-utils.h

FORMS += \
appSimulation/mainwindow.ui

LIBS += -L$$(GLEW_DIR) -lglew32
LIBS += -lopengl32 -lglu32

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
100 changes: 99 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,102 @@

Interactive simulation of glaciers on a terrain and procedural modeling of several glacier features.

Coming soon...!

## Repository contents

This repository contains our implementation of the paper, needed data, and examples.

| Directory | Description |
| ---: | :--- |
| **[code](./code)** | Source code of the two OpenGL applications: simulation and feature placement. |
| **[data](./data)** | Input terrains, application data, intermediate results and maps. |
| **[img](./img)** | Teaser image and other beautiful pictures of our glaciers rendered using E-On software's VUE. |
| **[shaders](./shaders)** | Shaders for rendering and ice simulation. |


## Requirements

We have tested this implementation on a Windows 10 machine equipped with an NVIDIA GeForce GTX 1060.

For the simulation and rendering applications, we used Qt Creator and tested the projects using both the ``MinGW`` and the ``MSVC2019`` kits (64 bit). Importing the .pro files into Visual Studio 2019 with Qt Visual Studio Tools 2.6.0 also created working solutions directly.

C++ libraries:
```
Qt 5.15, OpenGL 4.3, GLEW 2.1.0
```
You will need to define a ``GLEW_DIR`` environment variable pointing to the location of the headers and library files.

For the features notebook, we used a miniconda Python 3.7 environment installing the following packages:
```
numpy, matplotlib, jupyter, pypng, opencv, scikit-image
```


## Running the code

The workflow consists of three sequential steps.

### 1. Glacier simulation

Compile and run [GlaciersSim.pro](./GlaciersSim.pro).

The ice simulation is executed in an interactive terrain editor using OpenGL and a Compute Shader.

The input is an elevation map, we assume height to be encoded in a 16 bit png as decimeters (0.1m). Additionally, a solar radiance map, a precipitation map or an initial ice layer can also be provided. See [data/terrains](./data/terrains) for examples. We included preset scenes configurations to replicate some of the results shown in the paper.

The core of the glacier simulation implementation is the SIA compute shader [sia.glsl](./shaders/sia.glsl), which is used from the [GlacierTerrain class](./code/glacierterrain.h).


### 2. Feature placement

Run the [GlaciersFeatures.ipynb](/GlaciersFeatures.ipynb) jupyter notebook. It contains all the functions, instructions and comments explaining the main ideas, so you only need to follow it in order.

This notebook will read the elevation map of the bedrock, the simulated ice thickness, and the mask of ice cells above ELA, and output all the necessary extra maps that will later be used to prepare the final rendering.


### 3. Render

Compile and run [GlaciersRender.pro](./GlaciersRender.pro).

We include a simple Qt OpenGL app that we used to test the feature placement and generate the necessary maps that would be streamed to the offline renders using ``E-On software's VUE``. Note that the goal of this application is to demonstrate the placement, not to be photorealistic.


## Remarks and to-do

The code we provide here is a cleaned version of our research code for demonstration purposes and is provided *as is*.

The C++ application relied on many classes from the team's internal libraries. We have extracted and refactored the relevant functions for this code release, so don't expect these classes to be fully reusable out of this context, commonly needed functionality might be missing.

It would also be interesting to integrate the features computation into the OpenGL app editor directly. This part was faster to experiment using Python and we haven't ported the final code into the apps.


### Known issues

GlacierSim: brush edits on a map added for demonstration purposes. They do not propagate to other levels of the multiresolution, but this should be easy to fix.


## Article

The article is published in [ACM Transactions on Graphics](https://doi.org/10.1145/3414685.3417855). The authors' version can also be read [here](https://hal.archives-ouvertes.fr/hal-02929531/document).

If you use this code for your research, please cite our paper:
```
@article{Argudo2020glaciers,
title = {Simulation, Modeling and Authoring of Glaciers},
author = {Argudo,Oscar and Galin,Eric and Peytavie,Adrien and Paris,Axel and Gu\'{e}rin,Eric},
journal = {ACM Transactions on Graphics (SIGGRAPH Asia 2020)},
year = {2020},
volume = {39},
number = {6}
}
```


## Acknowledgements

* Alex Jarosch for sharing a Python implementation of their paper "Restoring mass conservation to shallow ice flow models over complex terrain", which was used as a starting point in our experiments. Check out [his repository](https://github.com/alexjarosch/sia-fluxlim) for their code and a link to their paper.

* [Jordi Camins](http://www.gelicehielo.com/) for his advice on modeling the glacier features.

* Jürg Alean and Michael Hambrey from Glaciers online. Their [photoglossary](https://www.swisseduc.ch/glaciers/glossary/index-en.html) was very useful for understanding and modeling the glacier features.

Loading

0 comments on commit 55319ba

Please sign in to comment.