KRRenderSettings is now feeding push constants using reflection.
This commit is contained in:
@@ -634,7 +634,11 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM
|
||||
{
|
||||
KRModelView modelView(ri.viewport, matModel);
|
||||
|
||||
std::vector<const KRReflectedObject*> objects = { &modelView, ri.viewport };
|
||||
std::vector<const KRReflectedObject*> objects = {
|
||||
&modelView,
|
||||
ri.viewport,
|
||||
&ri.camera->settings
|
||||
};
|
||||
setPushConstants(objects);
|
||||
|
||||
setPushConstant(ShaderValue::absolute_time, getContext().getAbsoluteTime());
|
||||
@@ -698,22 +702,6 @@ void KRPipeline::updatePushConstants(KRNode::RenderInfo& ri, const Matrix4& matM
|
||||
//light_spot_count = spot_lights.size();
|
||||
}
|
||||
|
||||
// Fog parameters
|
||||
setPushConstant(ShaderValue::fog_near, ri.camera->settings.fog_near);
|
||||
setPushConstant(ShaderValue::fog_far, ri.camera->settings.fog_far);
|
||||
setPushConstant(ShaderValue::fog_density, ri.camera->settings.fog_density);
|
||||
setPushConstant(ShaderValue::fog_color, ri.camera->settings.fog_color);
|
||||
|
||||
if (hasPushConstant(ShaderValue::fog_scale)) {
|
||||
setPushConstant(ShaderValue::fog_scale, 1.0f / (ri.camera->settings.fog_far - ri.camera->settings.fog_near));
|
||||
}
|
||||
if (hasPushConstant(ShaderValue::density_premultiplied_exponential)) {
|
||||
setPushConstant(ShaderValue::density_premultiplied_exponential, -ri.camera->settings.fog_density * 1.442695f); // -fog_density / log(2)
|
||||
}
|
||||
if (hasPushConstant(ShaderValue::density_premultiplied_squared)) {
|
||||
setPushConstant(ShaderValue::density_premultiplied_squared, (float)(-ri.camera->settings.fog_density * ri.camera->settings.fog_density * 1.442695)); // -fog_density * fog_density / log(2)
|
||||
}
|
||||
|
||||
// Sets the diffuseTexture variable to the first texture unit
|
||||
setPushConstant(ShaderValue::diffusetexture, 0);
|
||||
|
||||
|
||||
@@ -229,3 +229,38 @@ void KRRenderSettings::setEnableRealtimeOcclusion(bool enable)
|
||||
{
|
||||
m_enable_realtime_occlusion = enable;
|
||||
}
|
||||
|
||||
bool KRRenderSettings::getShaderValue(ShaderValue value, float* output) const
|
||||
{
|
||||
switch (value) {
|
||||
case ShaderValue::fog_near:
|
||||
*output = fog_near;
|
||||
return true;
|
||||
case ShaderValue::fog_far:
|
||||
*output = fog_far;
|
||||
return true;
|
||||
case ShaderValue::fog_density:
|
||||
*output = fog_density;
|
||||
return true;
|
||||
case ShaderValue::fog_scale:
|
||||
*output = 1.0f / (fog_far - fog_near);
|
||||
return true;
|
||||
case ShaderValue::density_premultiplied_exponential:
|
||||
*output = -fog_density * 1.442695f; // -fog_density / log(2)
|
||||
return true;
|
||||
case ShaderValue::density_premultiplied_squared:
|
||||
*output = (float)(-fog_density * fog_density * 1.442695)); // -fog_density * fog_density / log(2)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KRRenderSettings::getShaderValue(ShaderValue value, Vector3* output) const
|
||||
{
|
||||
switch (value) {
|
||||
case ShaderValue::fog_color:
|
||||
*output = fog_color;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,10 @@
|
||||
|
||||
#include "KREngine-common.h"
|
||||
|
||||
#include "KRShaderReflection.h"
|
||||
|
||||
class KRRenderSettings
|
||||
: public KRReflectedObject
|
||||
{
|
||||
public:
|
||||
KRRenderSettings();
|
||||
@@ -135,4 +138,7 @@ public:
|
||||
private:
|
||||
float m_lodBias;
|
||||
bool m_enable_realtime_occlusion;
|
||||
|
||||
bool getShaderValue(ShaderValue value, float* output) const final;
|
||||
bool getShaderValue(ShaderValue value, hydra::Vector3* output) const final;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user