Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract AO and VoxelGenerator from SphereRenderer #1202

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
5cb2a16
test setup for voxel generator
Oct 29, 2022
7710dda
fix and add calleeSlot to VoxelGenerator
Oct 31, 2022
caa7197
slots
Oct 31, 2022
1d61bf7
minor changes, getExtents
Nov 29, 2022
c1b038f
VoxelGenerator structure
Nov 29, 2022
a86d61f
small changes
Dec 21, 2022
2fd7db6
get data callback and metadata
Dec 23, 2022
30329d9
try init MDAOVolumeGenerator in VoxelGenerator
Dec 25, 2022
e390f04
volume texture handle
Dec 26, 2022
d4cff12
voxelgenerator creates volumetexture
Dec 30, 2022
cfb4da9
cleanup. move volume size slot to voxel generator
Dec 30, 2022
274a2fc
fix
Dec 30, 2022
6f789b6
init voxel texture only once
Dec 31, 2022
769d051
get openGL context
Jan 19, 2023
ca7647a
remove some hardcoded parts. try add vao
Jan 21, 2023
fae54d1
shader options. experiment with gpu_data
Jan 25, 2023
fd7f9e1
small changes
Jan 28, 2023
8b1c203
VAO in voxel generator works
Feb 3, 2023
136b187
try to use common volume size. something wrong. slow
Feb 20, 2023
8fa5bec
started cleanup
Feb 23, 2023
75576d7
no error without particle call. cleanup
Feb 23, 2023
72bcd87
cleanup and small fixes
Feb 24, 2023
db070ac
update header
Feb 24, 2023
41cf3f6
merge master, adjust VoxelGenerator. Error in SphereRenderer shaders
Apr 13, 2023
370f08c
GL_AMD_conservative_depth instead of GL_ARB_conservative_depth
Apr 17, 2023
76f4fa4
GL_ARB_conservative_depth (undo previous commit)
Apr 18, 2023
f24304d
setup for AO module
Apr 18, 2023
c5607b0
move AO to compositing_gl plugin
Apr 27, 2023
d4a7218
AO module slots
Apr 28, 2023
081cd4a
pass textures
Apr 29, 2023
ceeda46
small fix in Voxelgenerator getMetadataCallback
Apr 30, 2023
8bc444f
AO as Rendermodule, displays Fragmentcoordinates
Jun 7, 2023
d268c60
AO module gets normal, depth and color textures. problem in evaluateA…
Jun 10, 2023
8e41593
AO module mostly works
Jun 11, 2023
4221117
amb cone const calculation, clipbox
Jun 12, 2023
354e0e2
AO chainrendering, SimpleRenderTarget normal texture format
Jun 20, 2023
257c5ec
remove AO from SphereRenderer, add light slot to AO module
Jun 26, 2023
eee7e4b
Merge branch 'UniStuttgart-VISUS:master' into extract_voxel_generator
OliviaOdenthal Jun 26, 2023
f0d2c26
RaycastVolumeRenderer: switch between CPU and GPU RAM
reinago Jul 5, 2023
2afdb34
Format fix.
Jul 5, 2023
08926ec
Merge branch 'master' into extract_voxel_generator
reinago Jul 20, 2023
6d0be98
like this you can even look at the volume
reinago Jul 20, 2023
8fbe1c2
set voxel texture resolution
Aug 2, 2023
cac3699
vol resolution check
reinago Aug 4, 2023
df90021
cleanup
Aug 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ __pycache__/
# Individual developer settings for local machines
mmprjs/**/*
*.orig
/out/install/x64-Debug
3 changes: 2 additions & 1 deletion plugins/compositing_gl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ megamol_plugin(compositing_gl
opengl
DEPENDS_PLUGINS
mmstd
mmstd_gl)
mmstd_gl
geometry_calls)

if (compositing_gl_PLUGIN_ENABLED)
# Additional sources
Expand Down
392 changes: 392 additions & 0 deletions plugins/compositing_gl/src/AO.cpp

Large diffs are not rendered by default.

153 changes: 153 additions & 0 deletions plugins/compositing_gl/src/AO.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#pragma once

#include "geometry_calls/VolumetricDataCall.h"
#include "glowl/glowl.h"
#include "mmcore/Call.h"
#include "mmcore/CalleeSlot.h"
#include "mmcore/CallerSlot.h"
#include "mmcore/param/BoolParam.h"
#include "mmcore/param/FloatParam.h"
#include "mmcore/param/ParamSlot.h"
#include "mmcore_gl/utility/ShaderFactory.h"
#include "mmstd_gl/renderer/Renderer3DModuleGL.h"


#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>

namespace megamol::compositing_gl {

class AO : public megamol::mmstd_gl::Renderer3DModuleGL {

public:
/**
* Answer the name of this module.
*
* @return The name of this module.
*/
static const char* ClassName(void) {
return "AO";
}

/**
* Answer a human readable description of this module.
*
* @return A human readable description of this module.
*/
static const char* Description(void) {
return "AO";
}

/**
* Answers whether this module is available on the current system.
*
* @return 'true' if the module is available, 'false' otherwise.
*/
static inline bool IsAvailable(void) {
return true;
}

/**
* Initialises a new instance.
*/
AO(void);

/**
* Finalises an instance.
*/
~AO(void);

protected:
/**
* Implementation of 'Create'.
*
* @return 'true' on success, 'false' otherwise.
*/
bool create(void);


bool GetExtents(mmstd_gl::CallRender3DGL& call) override;

/**
* Implementation of 'Release'.
*/
void release(void);

bool Render(mmstd_gl::CallRender3DGL& call) override;

private:

core::CalleeSlot output_tex_slot_; // Ambient occlusion texture (left slot)

core::CallerSlot voxels_tex_slot_; // VolumetricDataCall (right slot)

core::CallerSlot get_lights_slot_;

/** Slot for querying normals render target texture, i.e. a rhs connection */
core::CallerSlot normals_tex_slot_;

/** Slot for querying depth render target texture, i.e. a rhs connection */
core::CallerSlot depth_tex_slot_;

/** Slot for querying color render target texture, i.e. a rhs connection */
core::CallerSlot color_tex_slot_;

/** Slot for querying camera, i.e. a rhs connection */
core::CallerSlot camera_slot_;


GLuint texture_handle_;
GLuint voxel_handle_;
GLuint vertex_array_;
GLuint vbo_;

std::shared_ptr<glowl::Texture2D> color_tex_;
std::shared_ptr<glowl::Texture2D> depth_tex_;
std::shared_ptr<glowl::Texture2D> normal_tex_;

glm::mat4 cur_mvp_inv_;
glm::vec3 cur_cam_pos_;
glm::vec4 cur_light_dir_;

vislib::math::Cuboid<float> cur_clip_box_;

int cur_vp_width_;
int cur_vp_height_;

std::unique_ptr<msf::ShaderFactoryOptionsOpenGL> shader_options_flags_;

std::shared_ptr<glowl::GLSLProgram> lighting_prgm_;

std::unique_ptr<glowl::BufferObject> ao_dir_ubo_;

core::param::ParamSlot vol_size_slot_;
core::param::ParamSlot ao_cone_apex_slot_;
core::param::ParamSlot enable_lighting_slot_;
core::param::ParamSlot ao_offset_slot_;
core::param::ParamSlot ao_strength_slot_;
core::param::ParamSlot ao_cone_length_slot_;

/**
* render deferreded pass with volume, depth, normal and color texture
*/
void renderAmbientOcclusion();

/**
* generate cone directions to be used in AO shader
*/
void generate3ConeDirections(std::vector<glm::vec4>& directions, float apex);

/**
* get volume data from volumetric data call
*/
bool updateVolumeData(const unsigned int frameID);

/**
* recreate resources like shaders and buffers
*/
bool recreateResources(void);
};

} // namespace megamol::compositing_gl
3 changes: 2 additions & 1 deletion plugins/compositing_gl/src/SimpleRenderTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ bool megamol::compositing_gl::SimpleRenderTarget::create() {

m_GBuffer = std::make_shared<glowl::FramebufferObject>(1, 1);
m_GBuffer->createColorAttachment(GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT); // surface albedo
m_GBuffer->createColorAttachment(GL_RGB16F, GL_RGB, GL_HALF_FLOAT); // normals
m_GBuffer->createColorAttachment(GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT); // normals
//m_GBuffer->createColorAttachment(GL_RGB16F, GL_RGB, GL_HALF_FLOAT); // normals

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/compositing_gl/src/compositing_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "mmcore/factories/AbstractPluginInstance.h"
#include "mmcore/factories/PluginRegister.h"

#include "AO.h"
#include "AntiAliasing.h"
#include "DepthDarkening.h"
#include "DrawToScreen.h"
Expand Down Expand Up @@ -45,6 +46,7 @@ class CompositingPluginInstance : public megamol::core::factories::AbstractPlugi
this->module_descriptions.RegisterAutoDescription<megamol::compositing_gl::TextureDepthCompositing>();
this->module_descriptions.RegisterAutoDescription<megamol::compositing_gl::NormalFromDepth>();
this->module_descriptions.RegisterAutoDescription<megamol::compositing_gl::SSAO>();
this->module_descriptions.RegisterAutoDescription<megamol::compositing_gl::AO>();
this->module_descriptions.RegisterAutoDescription<megamol::compositing_gl::AntiAliasing>();
this->module_descriptions.RegisterAutoDescription<megamol::compositing_gl::PNGDataSource>();
this->module_descriptions.RegisterAutoDescription<megamol::compositing_gl::TexInspectModule>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ uniform sampler2D inColorTex;
uniform sampler2D inNormalsTex;
uniform sampler2D inDepthTex;

uniform bool inUseHighPrecision;

uniform vec3 inObjLightDir;
uniform vec3 inObjCamPos;

Expand Down Expand Up @@ -51,9 +49,6 @@ void main()
vec3 color = texelFetch(inColorTex, texelCoord, 0).xyz;
vec4 normal = texelFetch(inNormalsTex, texelCoord, 0);

if (!inUseHighPrecision)
normal = normal * 2.0 - 1.0;

vec3 ray = normalize(objPos.xyz - inObjCamPos.xyz);
vec3 lightCol = LocalLighting(ray, normal.xyz, inObjLightDir, color);

Expand Down
4 changes: 4 additions & 0 deletions plugins/moldyn_gl/src/moldyn_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "rendering/GlyphRenderer.h"
#include "rendering/GrimRenderer.h"
#include "rendering/SphereRenderer.h"
#include "rendering/VoxelGenerator.h"
//#include "rendering/AO.h"

namespace megamol::moldyn_gl {
class MoldynGLPluginInstance : public megamol::core::factories::AbstractPluginInstance {
Expand All @@ -31,6 +33,8 @@ class MoldynGLPluginInstance : public megamol::core::factories::AbstractPluginIn
this->module_descriptions.RegisterAutoDescription<megamol::moldyn_gl::rendering::ArrowRenderer>();
this->module_descriptions.RegisterAutoDescription<megamol::moldyn_gl::rendering::SphereRenderer>();
this->module_descriptions.RegisterAutoDescription<megamol::moldyn_gl::rendering::GlyphRenderer>();
this->module_descriptions.RegisterAutoDescription<megamol::moldyn_gl::rendering::VoxelGenerator>();
//this->module_descriptions.RegisterAutoDescription<megamol::moldyn_gl::rendering::AO>();
}
};
} // namespace megamol::moldyn_gl
Loading