Skip to content

Commit

Permalink
Release v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
a1ex90 committed May 21, 2021
1 parent 7a77419 commit 853e38f
Show file tree
Hide file tree
Showing 46 changed files with 3,625 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "ext/QTOpenGLWindow"]
path = ext/QTOpenGLWindow
url = https://github.com/a1ex90/QTOpenGLWindow
[submodule "lib/ext/Discregrid"]
path = lib/ext/Discregrid
url = https://github.com/InteractiveComputerGraphics/Discregrid.git
52 changes: 52 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 3.10)

project(Leaven)

set(CMAKE_CXX_STANDARD 14)

# Enable QT Meta Object Compiler
set(CMAKE_AUTOMOC ON)
# Enable QT User Interface Compiler
set(CMAKE_AUTOUIC ON)
# Enable QT Rource Compiler
set(CMAKE_AUTORCC ON)

if (UNIX)
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif(OPENMP_FOUND)
endif (UNIX)

# Require QT5
find_package(Qt5 COMPONENTS Core Quick Widgets REQUIRED)

# OpenGLWindow Library
add_subdirectory(ext/QTOpenGLWindow)

# Leaven Library
#add_compile_definitions(USE_DOUBLE)
add_subdirectory(lib)

include_directories(src)
include_directories(lib/src)

# Find all Header and Source files
file(GLOB_RECURSE ${PROJECT_NAME}_HEADERS src/*.h qrc/*.qrc)
file(GLOB_RECURSE ${PROJECT_NAME}_SOURCES src/*.cpp)

# Copy assets to build dir
file(COPY assets DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS}
)

target_link_libraries(${PROJECT_NAME}
QTOpenGLWindow
LeavenLib
Qt5::Core
Qt5::Quick
)

56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
# public release coming soon
[](path-to-header-img)
# LEAVEN
LEAVEN is an easy-to-use and lightweight surface and volume mesh sampling standalone application tailored for the needs of particle-based simulation. It aims to lower one entry barrier for starting with particle-based simulations while still pose a benefit to advanced users. LEAVEN has methods for random uniform surface sampling, as well as random uniform volume sampling and grid-based volume sampling. LEAVEN's methods can also be included as a library in other projects. It is the implementation from [SS21].

**Author:** Alexander Sommer, **License:** MIT

## Getting Started
### Dependencies
- [CMake](https://cmake.org/) 3.10
- C++ 14
- [Eigen](https://eigen.tuxfamily.org/) 3.3
- [QT5](https://www.qt.io/) (only for UI not Library)
- [OpenMP](https://www.openmp.org/) (optional)

### Build Instructions
The project ist based on [CMake](https://cmake.org/). Makefiles can be generated using [CMake](https://cmake.org/) and compiled with a C++ compiler. The project has been tested on Ubuntu and Windows 10 with Visual Studio.

## Usage UI
[](link-to-ui-img)
### View Manipulation

Input | Action
------------ | -------------
Left Mousebutton + Movement | Rotating (Arcball)
Middle Mousebutton + Movement | Panning
Right Mousebutton + Movement | Zooming

## Usage Library
Add this module to your project CMake file:
```
add_subdirectory(Leaven/lib)
include_directories(Leaven/lib)
...
target_link_libraries(...
LeavenLib
)
```
Static methods for surface/volume sampling are found in:
```
#include "volumeSampler.h"
#include "surfaceSampler.h"
```
Per example this generates a randomized volume sampling from given vertices and face indices:
```
Eigen::Matrix<float, 3,-1> vertices = ...
Eigen::Matrix<unsigned int, 3, -1> indices = ...
float particleRadius = ...
std::vector<Eigen::Matrix<float, 3, 1>> sampling = VolumeSampler::sampleMeshRandom(vertices, indices, particleRadius);
```

## References
- [SS21] A. Sommer and U. Schwanecke, 2021. "LEAVEN - Lightweight Surface and Volume Mesh Sampling Application for Particle-based Simulations", WSCG 21 (to be published)
- [KDBB17] D. Koschier, C. Deul, M. Brand and J. Bender, 2017. "An hp-Adaptive Discretization Algorithm for Signed Distance Field Generation", IEEE Transactions on Visualiztion and Computer Graphics 23, 10, 2208-2221.
- [BWWM10] J. Bowers, R. Wang, L. Wei and D. Maletz, 2010. "Parallel Poisson Disk Sampling with Spectrum Analysis on Surfaces", ACM Trans. Graph 29.

6 changes: 6 additions & 0 deletions assets/icons/load.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/minus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/save.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/spinner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions assets/icons/work.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions assets/shaders/gl3/checkerboard.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#version 130

//uniform bool uGrid;

//uniform vec4 uColorPrimary;
//uniform vec4 uColorSecondary;

//uniform float uFadeNear;
//uniform float uFadeFar;

in vec2 vTexcoord;
in vec4 cameraSpacePosition;

out vec4 fragColor;

void main()
{
float uFadeNear = 0.01;
float uFadeFar = 10;

vec4 uColorPrimary = vec4(1.0,1.0,1.0,0.7);
vec4 uColorSecondary = vec4(0.1,0.1,0.1,0.7);

bool uGrid = false;

vec2 fw = fwidth(vTexcoord);
vec2 square = fract(vTexcoord);

vec4 color;
if (uGrid)
{
if (square.x > 0.99 || square.y > 0.99)
{
color = vec4(uColorPrimary);
}
else
{
color = vec4(uColorSecondary);
}
}
else
{
vec2 p = smoothstep(vec2(0.5), vec2(0.5) + fw, square) + (1.0 - smoothstep(vec2(0.0), vec2(0.0) + fw, square));
color = mix(uColorPrimary, uColorSecondary, p.x * p.y + (1.0 - p.x) * (1.0 - p.y));
}

float f = 1.0 - smoothstep(uFadeNear, uFadeFar, length(cameraSpacePosition));
color.a = min(color.a, f);

fragColor = color;
}
19 changes: 19 additions & 0 deletions assets/shaders/gl3/checkerboard.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#version 130

in vec3 vertexPosition;
in vec2 aTexcoord;

out vec2 vTexcoord;
out vec4 cameraSpacePosition;

uniform mat4 modelViewMatrix;
uniform mat4 mvp;

void main()
{
cameraSpacePosition = modelViewMatrix * vec4( vertexPosition, 1.0 );

vTexcoord = aTexcoord;

gl_Position = mvp * vec4( vertexPosition, 1.0 );
}
9 changes: 9 additions & 0 deletions assets/shaders/gl3/part.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#version 130

uniform vec4 color;
out vec4 fragColor;

void main()
{
fragColor = color;
}
17 changes: 17 additions & 0 deletions assets/shaders/gl3/part.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#version 130

in vec3 vertexPosition;

out vec3 position;

uniform mat4 modelViewMatrix;
uniform mat4 mvp;
uniform float ps;

void main()
{
position = vec3( modelViewMatrix * vec4( vertexPosition, 1.0 ) );

gl_PointSize = ps;
gl_Position = mvp * vec4( vertexPosition, 1.0 );
}
42 changes: 42 additions & 0 deletions assets/shaders/gl3/phong.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#version 130

uniform struct LightInfo {
vec4 position;
vec3 intensity;
} light;

struct MaterialInfo
{
vec3 ka; // Ambient reflectivity
vec3 kd; // Diffuse reflectivity
vec3 ks; // Specular reflectivity
float shininess; // Specular shininess factor
};
uniform MaterialInfo material;
uniform float opacity;

in vec3 position;
in vec3 normal;

out vec4 fragColor;


vec3 adsModel( const in vec3 pos, const in vec3 n )
{
vec3 s = normalize( vec3( light.position ) - pos );
vec3 v = normalize( -pos );
vec3 r = reflect( -s, n );

float diffuse = max( dot( s, n ), 0.0 );

float specular = 0.0;
if ( dot( s, n ) > 0.0 )
specular = pow( max( dot( r, v ), 0.0 ), material.shininess );

return light.intensity * ( material.ka + material.kd * diffuse + material.ks * specular );
}

void main()
{
fragColor = vec4( adsModel( position, normalize( normal ) ), opacity);
}
20 changes: 20 additions & 0 deletions assets/shaders/gl3/phong.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#version 130

in vec3 vertexPosition;
in vec3 vertexNormal;

out vec3 position;
out vec3 normal;

uniform mat4 modelViewMatrix;
uniform mat3 normalMatrix;
uniform mat4 projectionMatrix;
uniform mat4 mvp;

void main()
{
normal = normalize( normalMatrix * vertexNormal );
position = vec3( modelViewMatrix * vec4( vertexPosition, 1.0 ) );

gl_Position = mvp * vec4( vertexPosition, 1.0 );
}
56 changes: 56 additions & 0 deletions assets/shaders/gl3/spheres.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#version 130

uniform struct LightInfo {
vec4 position;
vec3 intensity;
} light;

uniform vec4 color;
uniform vec3 eye;

in vec3 position;
out vec4 fragColor;


vec3 CalcPointLight(LightInfo light, vec3 normal, vec3 surfacePos, vec3 surfaceToCamera) {
float ambientCoff = 0.3f;
float att = 0.1f;
vec3 surfaceToLight = normalize(light.position.xyz - surfacePos);
//AMBIENT COMPONENT
vec3 ambient = ambientCoff * color.xyz * light.intensity;

//DIFFUSE COMPONENT
float diffuseCoefficient = max(0.0, dot(normal, surfaceToLight));
vec3 diffuse = diffuseCoefficient * color.xyz * light.intensity;

//SPECULAR COMPONENT
float specularCoefficient = 1.0f;
vec3 materialSpecularColor = 0.02f * color.xyz;
float materialShininess = 10000.0;
if(diffuseCoefficient > 0.0)
specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normal))), materialShininess);
vec3 specular = specularCoefficient * materialSpecularColor * light.intensity;

//Attenuation
float distanceToLight = length(light.position.xyz - surfacePos);
float attenuation = 1.0 / (1.0 + att * pow(distanceToLight, 2));

return (ambient + attenuation*(diffuse + specular));
}

void main() {
vec3 surfaceToCamera = normalize(eye - position);
vec3 normal;
normal.xy = gl_PointCoord* 2.0 - vec2(1.0);
float mag = dot(normal.xy, normal.xy);
if(mag > 1.0)
discard; // kill pixels outside circle

normal.z = sqrt(1.0-mag);
// calculate lighting
vec3 linearColor = CalcPointLight(light, normal, position, surfaceToCamera);

// vec3 gamma = vec3(1.0/2.2);
vec3 gamma = vec3(1.0/2.8);
fragColor = vec4(pow(linearColor, gamma), color[3]);
}
Loading

0 comments on commit 853e38f

Please sign in to comment.