Commit e9396fae authored by Alexander Maximilian Nilles's avatar Alexander Maximilian Nilles
Browse files

Improve traced light cancer on objects

parent 8d1074f1
......@@ -39,9 +39,10 @@ void main()
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;
float nsteps = texture(steps, uv).r;
vec3 pos = camPos.xyz + t * normalize(passDir);
vec3 norm = texture(normals, uv).rgb;
for(int i = 0; i < lightData.length(); ++i)
{
......@@ -54,7 +55,8 @@ void main()
float tMax_to_light = l.type == 1 ? 1000.0f : length(l.pos - pos.xyz);
vec3 light_dir = getLightDirection(l, pos);
float shadow = softshadow(pos + 2.0f * DINO_SHADOW_TRACE_PRECISION * norm,
float shadow = softshadow(pos + (smoothstep(35.f, 0.f, nsteps) * 25.f + 2.0f) *
DINO_SHADOW_TRACE_PRECISION * norm,
light_dir,
0.0f,
tMax_to_light,
......
......@@ -80,13 +80,12 @@ std::string PrFieldDiscretizer::code() const
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 dist + max(min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0)), 0.0);
}
return dist + length(max(d, 0.0));
#else
return dist;
#endif
return dist;)";
)";
}
void PrFieldDiscretizer::onSerialize(nlohmann::json& out) const
......
......@@ -405,13 +405,12 @@ std::string PrMeshDiscretizer::code() const
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 dist + max(min(max(d.x, max(d.y, d.z)), 0.0) + length(max(d, 0.0)), 0.0);
}
return dist + length(max(d, 0.0));
#else
return dist;
#endif
return dist;)";
)";
}
void PrMeshDiscretizer::onSerialize(nlohmann::json& out) const
......
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