-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix sun and lens flares #37
base: master
Are you sure you want to change the base?
Conversation
Initialization of GAUSS (the DOF blur filter) would fail and cause a crash at startup if dofBlurAmount was set to anything larger than zero and the dofOverrideResolution was zero or unspecified. This change treats the DOF resolution as 360 when configured as zero for the purpose of initializing the blur filter and detecting the DOF render targets.
Whether the sun and lens flares are drawn are determined by the result of an occlusion query. If the query returns a larger number of pixels drawn than expected, which often happens when running in a higher resolution than the default, the sun and lens flares might not be drawn. This change wraps the IDirect3DQuery9 objects used for occlusion queries and modifies the returned number of pixels drawn to correspond with the default resolution, which makes the sun and lens flares appear as expected.
If I understand correctly this should fix Sun appearing/disappearing randomly after object passes in between camera and Sun? I am try to test this but so far Sun still flickers on and off. What DSfix.ini settings you have?
|
@SalamatiQus The render resolution should be the only setting that affects the result. Mine is 2560x1440. I suspect there is a rounding issue with some resolutions. Let me see if i can find the problem. |
@SalamatiQus I used a DSfix.ini containing only your settings above, and tried repeatedly blocking and unblocking the sun on the balcony with Solaire, but the sun always behaved correctly. Does it work better for you if you make this addition? diff --git a/d3d9query.cpp b/d3d9query.cpp
index 6c3e478..e0f77c6 100644
--- a/d3d9query.cpp
+++ b/d3d9query.cpp
@@ -41,6 +41,10 @@ HRESULT APIENTRY hkIDirect3DQuery9::GetData(void* pData, DWORD dwSize, DWORD dwG
if (result == D3D_OK) {
auto pixelsDrawn = reinterpret_cast<DWORD*>(pData);
pixelsDrawn[0] = static_cast<DWORD>(pixelsDrawn[0] / RSManager::get().getAreaScale());
+ SDLOG(0, "pixelsDrawn: %d\n", pixelsDrawn[0]);
+ if (pixelsDrawn[0] > 368) {
+ pixelsDrawn[0] = 368;
+ }
}
return result;
}
\ No newline at end of file |
With this addition Sun now shows properly. Tried different locations, different render and dof resolutions. Praise the Sun :) |
@SalamatiQus Great! I'm curious why you need that fix, though. If you enable logging, what numbers come from the |
It seems that DSFix only creates empty dsfix.log file with any value of |
@SalamatiQus You probably need to comment out this line: diff --git a/main.h b/main.h
index 0b02c30..4ac1a55 100644
--- a/main.h
+++ b/main.h
@@ -20,7 +20,7 @@
#define VERSION "2.4"
-#define RELEASE_VER
+//#define RELEASE_VER
#define WITHOUT_GFWL_LIB
|
That worked.
|
I think I have found reason why I needed fix. I have forced antialiasing for Dark Souls through nvidiaInspector tool. If there is no forced AA then Sun is working with initial patch, however setting any kind of AA (with exception of post-process AA) through drivers will make Sun disappear again. Tried MSAA, CSAA, SGSSAA and TrSSAA. |
@SalamatiQus I've tried reproducing the problem by forcing AA through Nvidia profile inspector, but i have not been able to make forced AA have any effect. What settings do you use? |
I have |
Occlusion queries might return larger values than expected if driver-enforced antialiasing is enabled. This change makes an occlusion query for a square of a known size to determine what result that should be expected. This is used by the IDirect3DQuery9 wrapper to scale the result of further queries appropriately, considering both the rendering resolution and unexpected multisampling enforced by the driver.
@SalamatiQus Thanks! I've improved the fix now so it should work with forced anti aliasing without requiring the fix that caps the value at 368. This should handle partial hiding of the sun properly, and wont' break if this is used in another place where larger values are expected. |
9b834cc uses ATL just for |
where did you get d3d9query.h? i can't seem to find it |
@prototype99 It was added in this PR. |
Oh whoops guess I should pay more attention to file names |
I think I found new case where Sun and Flares still disappear. It happened with following DSfix settings
|
@SalamatiQus I can confirm that the bug still appears with the settings you specify. I will take a look at it. |
Whether the sun and lens flares are drawn are determined by the result of
an occlusion query. If the query returns a larger number of pixels drawn
than expected, which often happens when running in a higher resolution
than the default, the sun and lens flares might not be drawn.
This change wraps the IDirect3DQuery9 objects used for occlusion queries
and modifies the returned number of pixels drawn to correspond with the
default resolution, which makes the sun and lens flares appear as
expected.