View Issue Details

IDProjectCategoryView StatusLast Update
0004825The Dark ModGraphicspublic20.12.2018 17:11
Reporterstgatilov Assigned Tostgatilov  
PrioritynormalSeveritytweakReproducibilityalways
Status assignedResolutionopen 
Product VersionTDM 2.06 
Target VersionTDM 2.08Fixed in Version 
Summary0004825: Investigate approach to avoid/reduce light toggling on surfaces
DescriptionThis issue is about the following topic on forum:
  http://forums.thedarkmod.com/topic/19139-nonsmooth-graphics-due-to-bumpmapping/

Right now, whenever a guard with a torch moves through a doorway, there is a moment when the nearby wall toggles from "partly lit" to "completely unlit" (it happens when light source crosses the wall's plane).
Since this is a nonsmooth change in visual appearance, it is very noticeable. It would be great to remove or reduce this effect.
Additional InformationSome initial attempts failed (see forum): they made low-polygon look of apples much more apparent.

The goal is to continue discussion and if some acceptable hack exists, add it to interaction shader.
TagsNo tags attached.

Activities

stgatilov

stgatilov

04.08.2018 10:46

developer  

light_toggling_counter.patch (941 bytes)
Index: glprogs/interaction.fs
===================================================================
--- glprogs/interaction.fs	(revision 15253)
+++ glprogs/interaction.fs	(working copy)
@@ -114,7 +114,15 @@
 
 	vec3 specularColor = specularCoeff * fresnelCoeff * specular * (diffuse * 0.25 + vec3(0.75));
 	float R2f = clamp(localL.z * 4.0, 0.0, 1.0);
-	float light = clamp(rimLight * R2f + NdotL, 0.0, 1.5);
+
+	float diffuseCoeff = NdotL;
+	//hacky coefficient to make lighting smooth when L is almost in surface tangent plane
+	vec3 meshNormal = normalize(var_TangentBitangentNormalMatrix[2]);
+	float MNdotL = dot(meshNormal, L);
+	if (MNdotL < min(0.25, NdotL))
+		diffuseCoeff = mix(MNdotL, NdotL, MNdotL / 0.25);
+
+	float light = clamp(rimLight * R2f + diffuseCoeff, 0.0, 1.5);
 	vec3 totalColor = (specularColor * R2f + diffuse) * light * u_diffuseColor.rgb * lightColor() * var_Color.rgb;
 
 	return totalColor;
nbohr1more

nbohr1more

06.08.2018 03:18

developer   ~0010738

Hmm.

This is a mixed result.

On one hand, the example wood table in the mission Inn Business seems to
work much better than the default interaction.

On the other hand, the new shader has reduced the rim lighting effect which
has decreased the apparent depth of the normals.

Then finally, the intended behavior works as expected on the stone top table
in the Noble's room regardless of which interaction.fs I choose.

That points to the stone table having good smoothing groups whereas the wood table has some sort of smoothing group problem?

(Eg. It's possible to fix this problem by fixing the assets?)
stgatilov

stgatilov

06.08.2018 15:09

developer   ~0010740

Last edited: 06.08.2018 15:10

View 5 revisions

The attached patch fixes (interpolated normal <--> bumpmapped normal) transition.

It means that:
1. If you have a mesh without bumpmapping, then the change will have no effect.
2. If you have a bumpmapped mesh with bad face groups (large faces with non-constant normal), then the issue will still remain. It will look a bit different, but the toggling will still happen. And near the edge of toggling the face starts looking flatter.
3. If you have a bumpmapped mesh with good face groups, then this patch will solve the toggling problem perfectly.

Ideally, large faces with non-constant normal should be removed by editing such models.

BTW, the effect of the change depends on the angle between light rays and surface. It has no effect when the angle is larger than 15 degrees. At angle = 0, the bumpmapping normals are completely ignored. During transition from 15 degrees to 0 degrees, the bumpmapped normals are gradually smoothened.
Strictly speaking, it works a bit differently, but the end results is about the same =)

Issue History

Date Modified Username Field Change
05.06.2018 17:13 stgatilov New Issue
05.06.2018 17:13 stgatilov Status new => assigned
05.06.2018 17:13 stgatilov Assigned To => stgatilov
04.08.2018 10:46 stgatilov File Added: light_toggling_counter.patch
06.08.2018 03:18 nbohr1more Note Added: 0010738
06.08.2018 15:09 stgatilov Note Added: 0010740
06.08.2018 15:09 stgatilov Note Edited: 0010740 View Revisions
06.08.2018 15:10 stgatilov Note Edited: 0010740 View Revisions
06.08.2018 15:10 stgatilov Note Edited: 0010740 View Revisions
06.08.2018 15:10 stgatilov Note Edited: 0010740 View Revisions
20.12.2018 17:11 stgatilov Target Version TDM 2.07 => TDM 2.08