Commit 8d1074f1 authored by Alexander Maximilian Nilles's avatar Alexander Maximilian Nilles
Browse files

Fix new lightcancer on discrete fields

parent 33c4c786
/**
* @brief Multiplies the image with an ambient occlusion term
*/
* @brief Multiplies the image with an ambient occlusion term
*/
void main()
{
int id = int(texture(ids, uv).r);
int id = int(texture(ids, uv).r);
if(id >= 0)
{
float t = texture(ts, uv).r;
vec3 pos = camPos.xyz + t * normalize(passDir);
vec3 norm = texture(normals, uv).rgb;
float t = texture(ts, uv).r;
vec3 pos = camPos.xyz + t * normalize(passDir);
vec3 norm = texture(normals, uv).rgb;
float occ = 0.1f + 0.9f * fullMap(pos + 1.0f * norm);
fragColor = vec4(texture(prevResult, uv).rgb * smoothstep(0.f, 1.f, occ), 1.0f);
}
else
{
fragColor = texture(prevResult, uv);
}
else
{
fragColor = texture(prevResult, uv);
}
}
\ No newline at end of file
......@@ -77,11 +77,16 @@ std::string_view PrFieldDiscretizer::name() const { return "FieldDiscretizer"; }
std::string PrFieldDiscretizer::code() const
{
return R"(vec3 tc = (in_position - b_min) / (b_max - b_min);
float dist = textureLod(sampler3D(dmap), tc, 0).r;
#ifdef DINO_EXTEND_DISCRETE_FIELDS
if(any(lessThan(in_position, b_min)) || any(greaterThan(in_position, b_max))) {
vec3 d = abs(in_position - 0.5f * (b_max + b_min)) - 0.5f*(b_max - b_min);
return max(min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0)), 0.0) + textureLod(sampler3D(dmap), tc, 0).r;
return dist + max(min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0)), 0.0);
}
return textureLod(sampler3D(dmap), tc, 0).r;)";
#endif
return dist;)";
}
void PrFieldDiscretizer::onSerialize(nlohmann::json& out) const
......
......@@ -402,11 +402,16 @@ std::string_view PrMeshDiscretizer::name() const { return "MeshDiscretizer"; }
std::string PrMeshDiscretizer::code() const
{
return R"(vec3 tc = (in_position - b_min) / (b_max - b_min);
float dist = textureLod(sampler3D(dmap), tc, 0).r;
#ifdef DINO_EXTEND_DISCRETE_FIELDS
if(any(lessThan(in_position, b_min)) || any(greaterThan(in_position, b_max))) {
vec3 d = abs(in_position - 0.5f * (b_max + b_min)) - 0.5f*(b_max - b_min);
return max(min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0)), 0.0) + textureLod(sampler3D(dmap), tc, 0).r;
return dist + max(min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0)), 0.0);
}
return textureLod(sampler3D(dmap), tc, 0).r;)";
#endif
return dist;)";
}
void PrMeshDiscretizer::onSerialize(nlohmann::json& out) const
......
......@@ -235,6 +235,11 @@ void Renderer::rebuildRenderables()
for(size_t i = 0; i < m_deferredPrograms.size() - 1; ++i)
{
std::vector<Shader::ShaderSource> src = sharedSource;
if(m_renderLayers[i]->getType() == RenderLayer::AMBIENT_OCCLUSION ||
m_renderLayers[i]->getType() == RenderLayer::SOFT_SHADOWS)
{
src.insert(src.begin() + 1, "#define DINO_EXTEND_DISCRETE_FIELDS\n");
}
src.push_back(m_renderLayers[i]->getShaderSource());
m_deferredPrograms[i] = Program();
m_deferredPrograms[i].attachNew(GL_VERTEX_SHADER,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment