Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions demos/audioanalysis/src/audioanalysisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ namespace nap
// Draw some gui elements
ImGui::SetNextWindowSize(ImVec2(512, 512), ImGuiCond_FirstUseEver);
ImGui::Begin("Audio analysis");
ImGui::PlotHistogram("", mPlotvalues.data(), mPlotvalues.size(), mTickIdx, nullptr, 0.0f, 0.2f, ImVec2(ImGui::GetColumnWidth(), 128)); // Plot the output values
ImGui::SliderFloat("Filter Frequency", &mAnalysisFrequency, 0.0f, 10000.0f, "%.3f", 2.0f);
ImGui::SliderFloat("Filter Bandwidth", &mAnalysisBand, 1.f, 10000.0f, "%.3f", 2.0f);
ImGui::SliderFloat("Audio Gain", &mAnalysisGain, 0.5f, 5.f, "%.3f", 1.f);
ImGui::PlotHistogram("Histogram", mPlotvalues.data(), mPlotvalues.size(), mTickIdx, nullptr, 0.0f, 0.2f, ImVec2(ImGui::GetColumnWidth(), 128)); // Plot the output values
ImGui::SliderFloat("Filter Frequency", &mAnalysisFrequency, 0.0f, 10000.0f, "%.3f", ImGuiSliderFlags_Logarithmic);
ImGui::SliderFloat("Filter Bandwidth", &mAnalysisBand, 1.f, 10000.0f, "%.3f", ImGuiSliderFlags_Logarithmic);
ImGui::SliderFloat("Audio Gain", &mAnalysisGain, 0.5f, 5.f, "%.3f");
if (ImGui::RadioButton("Audio file input", mInputSource == EAudioFile))
mInputSource = EAudioFile;
if (ImGui::RadioButton("Audio device input", mInputSource == EAudioDevice))
Expand Down
40 changes: 20 additions & 20 deletions demos/audiovisualfft/data/objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@
"StereoPanning": 0.5,
"AutoPlay": false,
"StartPosition": 17000.0,
"Duration": 0.0,
"FadeInTime": 0.0,
"FadeOutTime": 0.0,
"Pitch": 1.0
},
{
Expand Down Expand Up @@ -194,25 +191,25 @@
"Type": "nap::BufferBindingVec4",
"mID": "InPositions_2c26c4bb",
"Name": "InPositions",
"Buffer": "PositionBufferDummy"
"Buffer": "Vec4BufferDummy"
},
{
"Type": "nap::BufferBindingVec4",
"mID": "OutPositions_94e6febd",
"Name": "OutPositions",
"Buffer": "PositionBufferDummy"
"Buffer": "Vec4BufferDummy"
},
{
"Type": "nap::BufferBindingVec4",
"mID": "InNormals_2817da11",
"Name": "InNormals",
"Buffer": "PositionBufferDummy"
"Buffer": "Vec4BufferDummy"
},
{
"Type": "nap::BufferBindingVec4",
"mID": "OutNormals_bb180dba",
"Name": "OutNormals",
"Buffer": "PositionBufferDummy"
"Buffer": "Vec4BufferDummy"
}
],
"Constants": [
Expand Down Expand Up @@ -253,7 +250,7 @@
"Type": "nap::BufferBindingVec4",
"mID": "Positions_07091c33",
"Name": "Positions",
"Buffer": "PositionBufferDummy"
"Buffer": "Vec4BufferDummy"
},
{
"Type": "nap::BufferBindingUInt",
Expand All @@ -265,25 +262,25 @@
"Type": "nap::BufferBindingVec4",
"mID": "OutNormals_57d4a5a7",
"Name": "OutNormals",
"Buffer": "PositionBufferDummy"
"Buffer": "Vec4BufferDummy"
},
{
"Type": "nap::BufferBindingUInt",
"mID": "Triangles_ee9855e9",
"Name": "Triangles",
"Buffer": "TriangleBufferDummy"
"Buffer": "UIntBufferDummy"
},
{
"Type": "nap::BufferBindingInt",
"mID": "Adjacency_638d952e",
"Name": "Adjacency",
"Buffer": "AdjacencyBufferDummy"
"Buffer": "IntBufferDummy"
},
{
"Type": "nap::BufferBindingVec4",
"mID": "InNormals_88aa8533",
"Name": "InNormals",
"Buffer": "PositionBufferDummy"
"Buffer": "Vec4BufferDummy"
}
],
"Constants": [
Expand Down Expand Up @@ -673,6 +670,7 @@
255
]
},
"Clear": true,
"SampleShading": false,
"PreserveAspect": true
}
Expand Down Expand Up @@ -1394,9 +1392,9 @@
},
{
"Type": "nap::VertexBufferVec4",
"mID": "PositionBufferDummy",
"mID": "Vec4BufferDummy",
"Usage": "Static",
"Count": 262144,
"Count": 1,
"Clear": false,
"FillPolicy": ""
},
Expand All @@ -1420,23 +1418,23 @@
"Type": "nap::IndexBuffer",
"mID": "IndexBufferDummy",
"Usage": "Static",
"Count": 1565190,
"Count": 1,
"Clear": false,
"FillPolicy": ""
},
{
"Type": "nap::VertexBufferUInt",
"mID": "TriangleBufferDummy",
"mID": "UIntBufferDummy",
"Usage": "Static",
"Count": 1565190,
"Count": 1,
"Clear": false,
"FillPolicy": ""
},
{
"Type": "nap::GPUBufferInt",
"mID": "AdjacencyBufferDummy",
"mID": "IntBufferDummy",
"Usage": "Static",
"Count": 1572864,
"Count": 1,
"Clear": false,
"FillPolicy": ""
},
Expand Down Expand Up @@ -1556,7 +1554,9 @@
{
"Type": "nap::audio::AudioFileResource",
"mID": "AudioFile",
"AudioFilePath": "hang.mp3"
"AudioFilePath": "hang.mp3",
"Resample": false,
"ResampleMode": "Sinc Fastest"
}
]
}
18 changes: 5 additions & 13 deletions demos/audiovisualfft/data/shaders/normals.comp
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,34 @@ layout(constant_id = 0) const uint MAX_GROUP_SIZE_X = 32;
// Derive attribute buffer sizes from plane dimensions
const uint ROW_COUNT = 1024;
const uint COLUMN_COUNT = 256;
const uint CELL_COUNT = (ROW_COUNT-1)*(COLUMN_COUNT-1);

const uint MAX_ADJACENT_TRI_COUNT = 6;
const uint VERTS_PER_TRI_COUNT = 3;
const uint TRIS_PER_CELL_COUNT = 2;
const uint INDS_PER_TRI_COUNT = 3;

const uint POSITION_COUNT = ROW_COUNT*COLUMN_COUNT;
const uint TRIANGLE_COUNT = CELL_COUNT*TRIS_PER_CELL_COUNT;
const uint TRIANGLE_INDEX_COUNT = TRIANGLE_COUNT*INDS_PER_TRI_COUNT;

const float EPSILON = 0.0001;

layout(std430) readonly buffer Positions
{
vec4 positions[POSITION_COUNT];
vec4 positions[];
};

layout(std430) readonly buffer Triangles
{
uint triangles[TRIANGLE_INDEX_COUNT];
uint triangles[];
};

layout(std430) readonly buffer Adjacency
{
int adjacency[POSITION_COUNT*MAX_ADJACENT_TRI_COUNT];
int adjacency[];
};

layout(std430) readonly buffer InNormals
{
vec4 innormals[POSITION_COUNT];
vec4 innormals[];
};

layout(std430) writeonly buffer OutNormals
{
vec4 outnormals[POSITION_COUNT];
vec4 outnormals[];
};

struct triangle
Expand Down
5 changes: 2 additions & 3 deletions demos/audiovisualfft/data/shaders/positions.comp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ layout(constant_id = 0) const uint MAX_GROUP_SIZE_X = 32;
// Derive attribute buffer sizes from plane dimensions
const uint ROW_COUNT = 1024;
const uint COLUMN_COUNT = 256;
const uint POSITION_COUNT = ROW_COUNT*COLUMN_COUNT;

layout(std430) readonly buffer InPositions
{
vec4 inpositions[POSITION_COUNT];
vec4 inpositions[];
};

layout(std430) writeonly buffer OutPositions
{
vec4 outpositions[POSITION_COUNT];
vec4 outpositions[];
};

uniform UBO
Expand Down
2 changes: 1 addition & 1 deletion demos/computeflocking/src/computeflockingapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace nap
if (ImGui::CollapsingHeader("Bloom Texture", ImGuiTreeNodeFlags_DefaultOpen))
{
const float aspect = coloradjust_comp->getOutputTexture().getHeight() / static_cast<float>(coloradjust_comp->getOutputTexture().getWidth());
const float width = ImGui::GetWindowContentRegionWidth();
const float width = ImGui::GetContentRegionAvail().x;
ImGui::Image(coloradjust_comp->getOutputTexture(), { width, width * aspect });
}
ImGui::End();
Expand Down
6 changes: 3 additions & 3 deletions demos/lightsandshadow/src/lightsandshadowapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ namespace nap
light.setColor(color);

auto inten = light.getIntensity();
if (ImGui::SliderFloat("Intensity", &inten, 0.0f, 5.0f, "%.3f", 2.0f))
if (ImGui::SliderFloat("Intensity", &inten, 0.0f, 5.0f, "%.3f", ImGuiSliderFlags_Logarithmic))
light.setIntensity(inten);

auto shadow = light.getShadowStrength();
if (ImGui::SliderFloat("Shadow Strength", &shadow, 0.0f, 1.0f, "%.3f", 1.0f))
if (ImGui::SliderFloat("Shadow Strength", &shadow, 0.0f, 1.0f, "%.3f"))
light.setShadowStrength(shadow);

auto spread = light.getShadowSpread();
if (ImGui::SliderFloat("Shadow Spread", &spread, 0.0f, 10.0f, "%.3f", 1.0f))
if (ImGui::SliderFloat("Shadow Spread", &spread, 0.0f, 10.0f, "%.3f"))
light.setShadowSpread(spread);
}

Expand Down
2 changes: 1 addition & 1 deletion demos/oscmidi/src/oscmidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ namespace nap
std::string display_string = utility::stringFormat("Send OSC message to: %s, port: %d, with the specified address and value", mOscSender->mIPAddress.c_str(), mOscSender->mPort);
ImGui::Text(display_string.c_str());
ImGui::InputText("Address", &mOscOutputTag[0], mOscOutputTag.capacity());
ImGui::SliderFloat("Value", &mOscOutputValue, 0.f, 1.f, "%.3f", 1);
ImGui::SliderFloat("Value", &mOscOutputValue, 0.f, 1.f, "%.3f");
if (ImGui::Button("Send"))
{
std::string address = "/" + std::string(mOscOutputTag.data());
Expand Down
12 changes: 6 additions & 6 deletions system_modules/naprender/src/boxmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,21 @@ namespace nap
}

// Create attributes
nap::Vec3VertexAttribute& position_attribute = mMeshInstance->getOrCreateAttribute<glm::vec3>(vertexid::position);
nap::Vec3VertexAttribute& normal_attribute = mMeshInstance->getOrCreateAttribute<glm::vec3>(vertexid::normal);
nap::Vec3VertexAttribute& uv_attribute = mMeshInstance->getOrCreateAttribute<glm::vec3>(vertexid::getUVName(0));
nap::Vec4VertexAttribute& color_attribute = mMeshInstance->getOrCreateAttribute<glm::vec4>(vertexid::getColorName(0));
auto& position_attribute = mMeshInstance->getOrCreateAttribute<glm::vec3>(vertexid::position);
auto& normal_attribute = mMeshInstance->getOrCreateAttribute<glm::vec3>(vertexid::normal);
auto& uv_attribute = mMeshInstance->getOrCreateAttribute<glm::vec3>(vertexid::getUVName(0));
auto& color_attribute = mMeshInstance->getOrCreateAttribute<glm::vec4>(vertexid::getColorName(0));

// Set numer of vertices this mesh contains
mesh.setNumVertices((int)boxVertCount);
mesh.setNumVertices(static_cast<int>(boxVertCount));
mesh.setDrawMode(EDrawMode::Triangles);
mesh.setCullMode(mCullMode);
mesh.setUsage(mUsage);
mesh.setPolygonMode(mPolygonMode);

// Create vertex data based on scale factor
std::vector<glm::vec3> vertex_data(boxVertCount);
for (nap::uint i = 0; i < boxVertCount; i++)
for (uint i = 0; i < boxVertCount; i++)
vertex_data[i] = (unitBox[i] * mSize) + mPosition;

// Set data
Expand Down
30 changes: 25 additions & 5 deletions system_modules/naprender/src/renderablemesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@ namespace nap

int RenderableMesh::getVertexBufferBindingIndex(const std::string& meshVertexAttributeID) const
{
GPUMesh& gpu_mesh = mMesh->getMeshInstance().getGPUMesh();
const Material& material = mMaterialInstance->getMaterial();

int binding = 0;
for (auto& kvp : material.getShader().getAttributes())
const auto& material = mMaterialInstance->getMaterial();
for (const auto& kvp : material.getShader().getAttributes())
{
const Material::VertexAttributeBinding* material_binding = material.findVertexAttributeBinding(kvp.first);
const auto* material_binding = material.findVertexAttributeBinding(kvp.first);
assert(material_binding != nullptr);

// Override the position mesh attribute
Expand All @@ -100,5 +98,27 @@ namespace nap
return -1;
}


bool RenderableMesh::findVertexBufferBindingIndex(const std::string& meshVertexAttributeID, int& outIndex) const
{
int binding = 0;
const auto& material = mMaterialInstance->getMaterial();
for (const auto& kvp : material.getShader().getAttributes())
{
const auto* material_binding = material.findVertexAttributeBinding(kvp.first);
if (material_binding == nullptr)
return false;

// Override the position mesh attribute
if (material_binding->mMeshAttributeID == meshVertexAttributeID)
{
outIndex = binding;
return true;
}
++binding;
}
return false;
}

}

11 changes: 10 additions & 1 deletion system_modules/naprender/src/renderablemesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,21 @@ namespace nap
const std::vector<VkDeviceSize>& getVertexBufferOffsets() const { return mVertexBufferOffsets; }

/**
* Returns the vertex buffer binding index of the given mesh attribute, asserts and returs -1 if not found.
* Returns the vertex buffer binding index of the given mesh attribute, asserts and returns -1 if not found.
* @param meshVertexAttributeID the vertex attribute buffer name
* @return the vertex buffer binding index of the given mesh attribute
*/
int getVertexBufferBindingIndex(const std::string& meshVertexAttributeID) const;

/**
* Writes to outIndex the vertex buffer binding index of the given mesh attribute, returns true if found,
* returns false if not found.
* @param meshVertexAttributeID the vertex attribute buffer name
* @param outIndex the vertex buffer binding index of the given mesh attribute
* @return if the buffer binding index was found
*/
bool findVertexBufferBindingIndex(const std::string& meshVertexAttributeID, int& outIndex) const;

protected:
/**
* Constructor
Expand Down
5 changes: 2 additions & 3 deletions system_modules/naprender/src/renderbloomcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@
#include "gpubuffer.h"
#include "renderglobals.h"
#include "uniforminstance.h"
#include "renderglobals.h"
#include "blurshader.h"
#include "textureutils.h"

// External Includes
#include <entity.h>
#include <glm/gtc/matrix_transform.hpp>
#include <entity.h>
#include <nap/core.h>
#include <orthocameracomponent.h>

// nap::RenderBloomComponent run time class definition
Expand All @@ -31,6 +28,8 @@ RTTI_END_CLASS
// nap::RenderBloomComponentInstance run time class definition
RTTI_BEGIN_CLASS_NO_DEFAULT_CONSTRUCTOR(nap::RenderBloomComponentInstance)
RTTI_CONSTRUCTOR(nap::EntityInstance&, nap::Component&)
RTTI_FUNCTION(nap::material::instance::getOrCreateMaterial, &nap::RenderBloomComponentInstance::getOrCreateMaterial)
RTTI_FUNCTION("draw", &nap::RenderBloomComponentInstance::draw)
RTTI_END_CLASS

//////////////////////////////////////////////////////////////////////////
Expand Down
11 changes: 11 additions & 0 deletions system_modules/naprender/src/renderbloomcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ namespace nap
*/
Texture2D& getOutputTexture() { return *mOutputTexture; }

/**
* Returns the program used to render the mesh.
*
* TODO: This should be private, but our current RTTI implementation 'mangles' class name-spaces,
* causing the RTTR_REGISTRATION_FRIEND macro to fail -> needs to be fixed.
* It is therefore not recommended to use this function at runtime, use 'getMaterialInstance' instead!
*
* @return material handle
*/
MaterialInstance* getOrCreateMaterial() { return &mMaterialInstance; }

protected:
/**
* Draws the effect full screen to the currently active render target,
Expand Down
Loading