OpenGL2: Don't project sun shadows onto nothing #680
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Don't project sun shadows (r_forceSun 1) on to view depth equal to 1.0 (nothing drawn or skybox). This caused a full second shadow of the entire level in tr.screenShadowImage. It would move as the camera far plane changed and rotate/stretch strangely as the camera view changed.
It was visible in-game on lightmapped transparent surfaces facing the skybox and happen to overlap the extra shadow of the level.
This affected the glass in wop_padship's underwater room.
World of Padman (engine fork) screenshots of wop_padship showing the issue:
![shot0003](https://private-user-images.githubusercontent.com/405505/352703256-f3ebe64d-09bb-4eb6-b49f-b7e5387af6a5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5Mzg3MDgsIm5iZiI6MTczODkzODQwOCwicGF0aCI6Ii80MDU1MDUvMzUyNzAzMjU2LWYzZWJlNjRkLTA5YmItNGViNi1iNDlmLWI3ZTUzODdhZjZhNS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QxNDI2NDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04MWFlODNhYzY3MmRhYTdiNjhmZDcyZTA4NTIyOTk1ZjE4YmQwNDRkOGYyY2IyODIxMGQwMDg0Mjc3NWM4OTY1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.AIchRGIIWuqPyohk7CeY8b5xcYJvCImpx9PD78ANhz4)
![shot0002](https://private-user-images.githubusercontent.com/405505/352703280-e2fba1be-0d1b-44ad-a176-212638d9d560.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5Mzg3MDgsIm5iZiI6MTczODkzODQwOCwicGF0aCI6Ii80MDU1MDUvMzUyNzAzMjgwLWUyZmJhMWJlLTBkMWItNDRhZC1hMTc2LTIxMjYzOGQ5ZDU2MC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QxNDI2NDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0wNTE2NjdjMzBkMzQ4YzVkM2U5MjI4ODYxZGQ4NmE4NWJhNTlmODUwNWU5YWUyZjc4ZGFhODJmNzg5YjM1YWU2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.JU64gDTzK4n8vDyIVJpKPlk7AtZs_SAeGzG4sP2Dht4)
"oh there's the problem, there is a phantom ship."
(The glass should all be the same brightness.)
ioquake3 with q3dm1 map:
![shot0055](https://private-user-images.githubusercontent.com/405505/352703608-b18afa9e-eaa7-404c-9d76-d046b6f2dd4f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5Mzg3MDgsIm5iZiI6MTczODkzODQwOCwicGF0aCI6Ii80MDU1MDUvMzUyNzAzNjA4LWIxOGFmYTllLWVhYTctNDA0Yy05ZDc2LWQwNDZiNmYyZGQ0Zi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwN1QxNDI2NDhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kZjcwNTk2MWNmZjExODczN2ZlMTkyMTg3ZmNhNWMxYTVmNmRiZTExN2U5NjYyNDRmMzQ1OGNmZjgzZWEzNWFlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.KAQ40A_UjbX-BrJ5JcGmiNqdVk6WAbARJAoP5EJwnOs)
(All maps had a second shadow in the shadowmap image but I don't know of cases it caused issues.)