Fix perform shading property bug

This commit is contained in:
Malin E
2023-11-23 14:57:17 +01:00
parent e3e1bdcfa6
commit 536ba1eb5b
3 changed files with 14 additions and 8 deletions

View File

@@ -45,10 +45,11 @@ namespace {
constexpr std::string_view _loggerCat = "RenderableTube";
constexpr int8_t CurrentMajorVersion = 0;
constexpr int8_t CurrentMinorVersion = 1;
constexpr std::array<const char*, 9> UniformNames = {
constexpr std::array<const char*, 12> UniformNames = {
"modelViewTransform", "projectionTransform", "normalTransform", "color",
"opacity", "performShading", "nLightSources", "lightDirectionsViewSpace",
"lightIntensities"
"lightIntensities", "ambientIntensity", "diffuseIntensity",
"specularIntensity"
};
constexpr openspace::properties::Property::PropertyInfo ColorInfo = {
@@ -140,8 +141,8 @@ RenderableTube::Shading::Shading()
: properties::PropertyOwner({ "Shading" })
, enabled(ShadingEnabledInfo, true)
, ambientIntensity(AmbientIntensityInfo, 0.2f, 0.f, 1.f)
, diffuseIntensity(DiffuseIntensityInfo, 0.7f, 0.f, 1.f)
, specularIntensity(SpecularIntensityInfo, 0.f, 0.f, 1.f)
, diffuseIntensity(DiffuseIntensityInfo, 1.f, 0.f, 1.f)
, specularIntensity(SpecularIntensityInfo, 1.f, 0.f, 1.f)
{
addProperty(enabled);
addProperty(ambientIntensity);
@@ -574,6 +575,10 @@ void RenderableTube::render(const RenderData& data, RendererTasks&) {
_uniformCache.lightDirectionsViewSpace,
_lightDirectionsViewSpaceBuffer
);
_shader->setUniform(_uniformCache.ambientIntensity, _shading.ambientIntensity);
_shader->setUniform(_uniformCache.diffuseIntensity, _shading.diffuseIntensity);
_shader->setUniform(_uniformCache.specularIntensity, _shading.specularIntensity);
}
// Render

View File

@@ -91,7 +91,8 @@ private:
UniformCache(modelViewTransform, projectionTransform, normalTransform, color,
opacity, performShading, nLightSources, lightDirectionsViewSpace,
lightIntensities) _uniformCache;
lightIntensities, ambientIntensity, diffuseIntensity,
specularIntensity) _uniformCache;
std::vector<float> _lightIntensitiesBuffer;
std::vector<glm::vec3> _lightDirectionsViewSpaceBuffer;

View File

@@ -32,9 +32,9 @@ uniform vec3 color;
uniform float opacity;
uniform bool performShading = true;
uniform float ambientIntensity = 0.2;
uniform float diffuseIntensity = 1.0;
uniform float specularIntensity = 1.0;
uniform float ambientIntensity;
uniform float diffuseIntensity;
uniform float specularIntensity;
uniform int nLightSources;
uniform vec3 lightDirectionsViewSpace[8];