Skip to content
Snippets Groups Projects
Commit 7026cb33 authored by Sreekanth Arikatla's avatar Sreekanth Arikatla
Browse files

BUG: Fix PBR textures

Fix PBR textures and add colors
parent ac031a62
No related branches found
No related tags found
No related merge requests found
Showing
with 63 additions and 48 deletions
......@@ -86,7 +86,7 @@ main()
auto material = std::make_shared<RenderMaterial>();
material->setDisplayMode(RenderMaterial::DisplayMode::Wireframe);
material->setPointSize(6.);
material->setEdgeColor(Color::LightGray);
material->setEdgeColor(Color::Marigold);
material->setLineWidth(4.);
auto surfMeshModel = std::make_shared<VisualModel>(surfMesh);
surfMeshModel->setRenderMaterial(material);
......
......@@ -62,8 +62,8 @@ main()
auto surfaceMesh = MeshIO::read(iMSTK_DATA_ROOT "/head/head_revised.obj");
auto material = std::make_shared<RenderMaterial>();
material->setDisplayMode(RenderMaterial::DisplayMode::WireframeSurface);
material->setShadingModel(RenderMaterial::ShadingModel::Flat);
material->setDisplayMode(RenderMaterial::DisplayMode::Surface);
material->setShadingModel(RenderMaterial::ShadingModel::PBR);
auto headDiffuseTexture = std::make_shared<Texture>(iMSTK_DATA_ROOT "head/HeadTexture_BaseColor.png", Texture::Type::Diffuse);
auto headNormalTexture = std::make_shared<Texture>(iMSTK_DATA_ROOT "head/HeadTexture_Normal.png", Texture::Type::Normal);
auto headAoTexture = std::make_shared<Texture>(iMSTK_DATA_ROOT "head/HeadTexture_AO.png", Texture::Type::AmbientOcclusion);
......
......@@ -141,7 +141,7 @@ generateFluid(const std::shared_ptr<Scene>& scene, const double particleRadius)
// Create a visual model
auto fluidVisualModel = std::make_shared<VisualModel>(fluidGeometry);
auto fluidMaterial = std::make_shared<RenderMaterial>();
fluidMaterial->setDisplayMode(RenderMaterial::DisplayMode::Points);
fluidMaterial->setDisplayMode(RenderMaterial::DisplayMode::Fluid);
fluidMaterial->setVertexColor(Color::Orange);
fluidMaterial->setPointSize(10.);
fluidVisualModel->setRenderMaterial(fluidMaterial);
......
......@@ -42,6 +42,8 @@ Color Color::Red(1.0, 0.0, 0.0, 1.0);
Color Color::Yellow(1.0, 1.0, 0.0, 1.0);
Color Color::Orange(1.0, 0.6, 0.0, 1.0);
Color Color::Pink(1.0, 0.0, 1.0, 1.0);
Color Color::Teal(0.5, 1.0, 0.8, 1.0);
Color Color::Marigold(0.9, 0.9, 0.4);
Color::Color()
{
......
......@@ -120,6 +120,8 @@ struct Color
static Color Pink;
static Color Orange;
static Color Yellow;
static Color Teal;
static Color Marigold;
};
#pragma warning(default : 4201)
......
......@@ -417,6 +417,12 @@ SurfaceMesh::getVertexNormalsNotConst()
return m_vertexNormals;
}
StdVectorOfVec3d&
SurfaceMesh::getVertexTangentsNotConst()
{
return m_vertexTangents;
}
void
SurfaceMesh::setVertexTangents(const StdVectorOfVec3d& tangents)
{
......
......@@ -217,6 +217,7 @@ protected:
/// \brief Get vertex normals
///
StdVectorOfVec3d& getVertexNormalsNotConst();
StdVectorOfVec3d& getVertexTangentsNotConst();
std::vector<TriangleArray> m_trianglesVertices; ///> Triangle connectivity
std::vector<NeighborsType> m_vertexNeighborTriangles; ///> Neighbor triangles to vertices
......
......@@ -121,11 +121,11 @@ imstk_add_library( Rendering
H_FILES
imstkRenderer.h
${RENDERING_H_FILES}
vtkCapsuleSource.h
imstkVtkCapsuleSource.h
CPP_FILES
imstkRenderer.cpp
${RENDERING_CPP_FILES}
vtkCapsuleSource.cpp
imstkVtkCapsuleSource.cpp
SUBDIR_LIST
${RENDERING_SUBDIR}
DEPENDS
......
......@@ -38,24 +38,19 @@ public:
Points,
WireframeSurface,
VolumeRendering,
Fluid
Fluid ///< Renders a set of points using a screen-space fluid renderer
};
/// surface shading model. Defaults to Phong
enum class ShadingModel
{
Phong,
PBR, // Physicall based rendering
Flat,
Gouraud
Phong, ///< Phong shading model (default)
Gouraud, ///< Gouraud shading model (default)
Flat, ///< Flat shading model with no interpolation
PBR ///< Physically based rendering
};
enum class PointGlyphType
{
Sphere,
Cube
};
// Volume rendering blend mode
/// Volume rendering blend mode
enum class BlendMode
{
Alpha,
......@@ -145,7 +140,7 @@ public:
bool getCastsShadows() const;
///
/// \brief Get/Set shadow receiving ability
/// \brief Get/Set edge visibility
///
void setEdgeVisibility(const bool visibility) { m_edgeVisibility = visibility; };
bool getEdgeVisibility() const { return m_edgeVisibility; };
......@@ -161,20 +156,22 @@ public:
///
/// \brief Checks if the material must be handled uniquely
///
bool isDecal(); // remove?
bool isParticle(); // remove?
bool isLineMesh(); // remove?
bool isDecal();
bool isParticle();
bool isLineMesh();
DisplayMode getRenderMode() const { return m_displayMode; };
ShadingModel getShadingModel() const { return m_shadingModel; };
void setShadingModel(const ShadingModel& model) { m_shadingModel = model; }
bool isModified() const { return m_modified; };
void setModified(const bool c) { m_modified = c; };
void setModified(const bool modified) { m_modified = modified; };
float getOcclusionStrength() const { return m_occlusionStrength; }
void setOcclusionStrength(const float o) { m_occlusionStrength = o; };
float getNormalStrength() const { return m_normalStrength; }
void setNormalnStrength(const float n) { m_normalStrength = n; };
const Color& getEdgeColor() const { return m_edgeColor; };
void setEdgeColor(const Color& color) { m_edgeColor = color; };
......@@ -196,13 +193,6 @@ protected:
friend class VulkanParticleRenderDelegate;
friend class VTKdbgLinesRenderDelegate;
// State
bool m_tessellated = false; //?
bool m_isDecal = false; //?
bool m_isLineMesh = false; //?
bool m_isParticle = false; //?
// Textures
std::vector<std::shared_ptr<Texture>> m_textures; ///< Ordered by Texture::Type
......@@ -214,37 +204,41 @@ protected:
float m_opacity = 1.0;
///-------------Wireframe specific properties----------------
PointGlyphType m_pointGlyphType = PointGlyphType::Sphere;
float m_lineWidth = 1.f;
float m_pointSize = 2.f;
Color m_edgeColor = Color(0.9, 0.9, 0.4);
Color m_vertexColor = Color(0.5, 1.0, 0.8);
bool m_edgeVisibility = true;
bool m_vertexVisibility = true;
Color m_edgeColor = Color::Marigold;
Color m_vertexColor = Color::Teal;
bool m_edgeVisibility = true; ///< \note not used (vtk backend)
bool m_vertexVisibility = true; ///< \note not used (vtk backend)
///----------------PBR specific properties-------------------
float m_emissivity = 0.0;
float m_emissivity = 0.f;
Color m_emmisiveColor = Color::White;
float m_metalness = 0.f; ///< Value for metalness with range: [0.0, 1.0]
float m_roughness = 1.f; ///< Value for roughness with range: [0.0, 1.0]
float m_metalness = 0.f; ///< Value for metalness with range: [0.0, 1.0]
float m_roughness = 10.f; ///< Value for roughness with range: [0.0, 1.0]
float m_occlusionStrength = 10.0;
float m_normalStrength = 10.0;
float m_occlusionStrength = 10.f;
float m_normalStrength = 1.f;
///-----------------Global states/flags----------------------
///---------------------Global states------------------------
bool m_imageBasedLighting = false;
// Shadows
bool m_receivesShadows = true; //?
bool m_castsShadows = true; //?
bool m_receivesShadows = true; ///< \note not implemented
bool m_castsShadows = true; ///< \note not implemented
// remove one of these?
/// \todo remove one of these?
bool m_stateModified = true; ///< Flag for expensive state changes
bool m_modified = true; ///< Flag for any material property changes
bool m_backfaceCulling = true; ///< For performance, uncommon for this to be false
DisplayMode m_displayMode = DisplayMode::Surface;
ShadingModel m_shadingModel = ShadingModel::Phong;
bool m_tessellated = false;
bool m_isDecal = false;
bool m_isLineMesh = false;
bool m_isParticle = false;
};
}
......@@ -39,12 +39,14 @@
#include <vtkProperty.h>
#include <vtkOpenGLPolyDataMapper.h>
#include <vtkVersion.h>
#include <vtkPolyDataTangents.h>
namespace imstk
{
VTKSurfaceMeshRenderDelegate::VTKSurfaceMeshRenderDelegate(std::shared_ptr<VisualModel> visualModel) :
m_mappedVertexArray(vtkSmartPointer<vtkDoubleArray>::New()),
m_mappedNormalArray(vtkSmartPointer<vtkDoubleArray>::New())
m_mappedNormalArray(vtkSmartPointer<vtkDoubleArray>::New()),
m_mappedTangentArray(vtkSmartPointer<vtkDoubleArray>::New())
{
m_visualModel = visualModel;
......@@ -131,7 +133,7 @@ VTKSurfaceMeshRenderDelegate::VTKSurfaceMeshRenderDelegate(std::shared_ptr<Visua
(float)tangent[2] };
tangents->InsertNextTuple(tempTangent);
}
polydata->GetPointData()->AddArray(tangents);
polydata->GetPointData()->SetTangents(tangents);
}
// Update Transform, Render Properties
......
......@@ -58,8 +58,8 @@ public:
void initializeTextures(TextureManager<VTKTextureDelegate>& textureManager);
protected:
vtkSmartPointer<vtkDoubleArray> m_mappedVertexArray; ///> Mapped array of vertices
vtkSmartPointer<vtkDoubleArray> m_mappedNormalArray; ///> Mapped array of normals
vtkSmartPointer<vtkDoubleArray> m_mappedTangentArray; ///> Mapped array of tangents
};
}
......@@ -527,6 +527,9 @@ VTKRenderer::updateRenderDelegates()
m_renderDelegates.push_back(delegate);
m_objectVtkActors.push_back(delegate->getVtkActor());
m_vtkRenderer->AddActor(delegate->getVtkActor());
//((vtkActor*)delegate->getVtkActor())->GetProperty()->PrintSelf(std::cout, vtkIndent());
visualModel->m_renderDelegateCreated = true;
}
}
......
......@@ -96,6 +96,11 @@ VTKTextureDelegate::loadTexture(std::shared_ptr<Texture> texture)
m_sourceTexture->RepeatOff();
m_sourceTexture->SetInputConnection(imgReader->GetOutputPort());
if (texture->getType() == Texture::Type::Diffuse)
{
m_sourceTexture->SetUseSRGBColorSpace(true);
}
/*vtkNew<vtkPNGReader> normalReader;
normalReader->SetFileName(tFileName.c_str());
normalReader->Update();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment