ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
[REL] Dynamic Shaders

« Previous 10 events | 1 ... 26 27 28 29 30 31 32 | Next 10 events »
Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  06:07:54  11 May 2014
profilee-mailreply Message URLTo the Top
templargfx
(Novice)
 
On forum: 05/08/2014
Messages: 28
Hi Meltac,

So I have been messing with your shaders, and it looks like there may be a mathmatical error in the sun position calculation for Sun Shafts when the sun is off screen. It works really well with the sun on screen, but as soon as the sun leaves the screen space, things go a little wonky :

World objects intersecting with the screen edge block sun shafts, when normally they would not
Sun Shafts stop rendering all together when the sun is behind you (may be an engine limitation? Culling?)
When the sun is just off screen space, but still rendering shafts, things go particularly haywire, with shafts either "shattering" (no longer uniform) or covering the entire screen. Slightest of viewing angle changes in this situation causes massive changes to the sun shafts.


I am trying to wrap my head around the code to work on it myself, but I am usure of the engine variables, and which are custom variables. Is there a wiki link to the "global" variables set by the engine. Especially in regards to sun position?
  22:42:26  11 May 2014
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
 

Message edited by:
Meltac
05/11/2014 22:43:44
Messages: 1519
Hi again templargfx! Thanks for your testing and reporting feedback.

The behavior you describe is well known. Do you by chance have background knowledge on how those sun shafts are being created? They are purely a screen-space effect and therefore not caused by volumetric light as it is the case in more recent engines and games. Basically you can consider them a fake effect for something that would be extremely hard to achieve in a well-performing way on the given engine (without modifying the engine binaries themselves).

For being a pure screen-space effect (post-process) it's impossible for those shafts to behave absolutely realistic. Unintended side-effects as those you are describing are expectable artifacts of faking real volumetric light. Basically the way the sun shafts are implemented they will never look absolutely realistic, that's the cost of making them working at all on this fairly dated engine.

Nonetheless improvements are still possible with with the given approach. I've incorporated already a few additions making the overall result look both nicer and more authentic. If you figure out further refinements or algorithmic tweaks I'd be eager to hear them
  01:42:26  12 May 2014
profilee-mailreply Message URLTo the Top
templargfx
(Novice)
 
On forum: 05/08/2014
Messages: 28

---QUOTATION---
Hi again templargfx! Thanks for your testing and reporting feedback.

The behavior you describe is well known. Do you by chance have background knowledge on how those sun shafts are being created? They are purely a screen-space effect and therefore not caused by volumetric light as it is the case in more recent engines and games. Basically you can consider them a fake effect for something that would be extremely hard to achieve in a well-performing way on the given engine (without modifying the engine binaries themselves).

For being a pure screen-space effect (post-process) it's impossible for those shafts to behave absolutely realistic. Unintended side-effects as those you are describing are expectable artifacts of faking real volumetric light. Basically the way the sun shafts are implemented they will never look absolutely realistic, that's the cost of making them working at all on this fairly dated engine.

Nonetheless improvements are still possible with with the given approach. I've incorporated already a few additions making the overall result look both nicer and more authentic. If you figure out further refinements or algorithmic tweaks I'd be eager to hear them
---END QUOTATION---



The "deal breaker" for myself with the current sun shafts is the fact that they disappear if you face away from them. Looking at the code, the "artificial sun position" which I assume is the calculation of the theoretical sun position once it has left screen space in order to continue rendering the shafts. This code seems to need some work, however without knowing the engine variables that relate to this, and what values they contain I can't do much. I would just start looking through the SDK, but that will take too much time, which I don't have spare.
  10:53:43  12 May 2014
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519

---QUOTATION---
The "deal breaker" for myself with the current sun shafts is the fact that they disappear if you face away from them. Looking at the code, the "artificial sun position" which I assume is the calculation of the theoretical sun position once it has left screen space in order to continue rendering the shafts. This code seems to need some work, however without knowing the engine variables that relate to this, and what values they contain I can't do much. I would just start looking through the SDK, but that will take too much time, which I don't have spare.
---END QUOTATION---



You are right about it being weird to have the shafts disappear when not facing the sun. Whether that could be fixed with the given approach I cannot say, mainly because the algorithmic approach does not come from my own feather, but if you'd manage to change this behavior that would certainly be a very helpful contribution to the mod.

As for the engine variables there is actually not too much explanation possible here. First of all there is to my knowledge no API documentation or wiki (at least no non-russian one ), and there are not many (again, non-russian) modders having deep knowledge about that part of X-Ray. I had to learn most of these things by deep-diving into the existing shader files and simply try-and-error'ing things, what as you say can be quite time-consuming. What I can is that there are only very few engine variables being used in that file, basically only the world sun direction. All the rest are local variables. And note that the artificial sun position is not what you are assuming, it's actually not even used anymore and can be considered a code artifact.
  16:06:52  13 May 2014
profilee-mailreply Message URLTo the Top
templargfx
(Novice)
 
On forum: 05/08/2014
 

Message edited by:
templargfx
05/13/2014 16:15:11
Messages: 28
Parallax Mapping

Over the last week I have been messing with parallax mapping, and finally got decent results. But better yet, I understand how it works now!

The problem it seems has everything to do with the textures, and nothing to do with sky4ce's implementation. Almost all the bump# alpha channels are modified color maps. This means that the height data actually lies around 60-200 on the alpha channel, and not 0-255. It also means they are innacurate representations of height. There are however a few textures with proper displacement maps in the alpha channel, such as the rock wall in Sidorovich's bunker, or the corrugated iron roofing.

This is what the CONTRAST_COEF variables by sky4ce are for. Anything below Q1 or above Q2 is ignored, what is left normalized.

What I did is use Linear Interpolation (lerp) to increase the control of this code so that no data is ignored, but instead the alpha channel is warped to enhance the center. I took values I derived and tested against many textures in GIMP.
The result is much better depth to almost all the textures that use Parallax Mapping in the game, with more defined details and better shapes.


Here is my parallax settings. I have added 2 variables to control the new code. I also updated the explenations

//////////////////////////////////////////////////////////////
//Parallax Occlusion Mapping
//////////////////////////////////////////////////////////////

	//Basic Options:
	#define MAX_SAMPLES int(80)		//Maximum amount of samples done to a texture. TMP:Increase if you see slices, decrease for performance
	#define MIN_SAMPLES int(10)		//Minimum amount of samples done to a texture.
	#define PARALLAX_OFFSET float(0.012)	//Height of surface per sample. TMP:Displacement scale. stay low without a texture pack
	#define FINAL_INTERSECTION_LOOPS int(20)	//Amount of additional samples to increase accuracy. TMP:costly. can help with artifacts

	//Performance Options:
	//#define PARALLAX_FADE			//Parllax textures fade back to regular normals with distance; increases FPS and fixes anisotropic filtering. #Disabling this strangely gave me a much higher FPS.
	#define START_FADE float(0.0009)	//Distance the fading starts
	#define STOP_FADE float(0.0014)		//Distance the fading stops, and the texture returns to just using normals.
	
	//Other Options:
	//#define USE_TEXTURE_PACK		//Uses height maps built into texture files, rather than self generating them. 
  //TMP:Height map clearly comes from the bump# alpha channel.
  //#define CORRECT_PERSPECTIVE		//WARNING!!! artifacts will appear if defined TMP:actually incorrects perspective
	#define BRIGHTNESS_COEF float(0.0)	//Added to Texture Height Map before before below are used
	
  //How this works : The original Alpha channel on the texture is warped to enhance the center area of the map, without losing the lower and upper.
  //Most alpha channels are derived from the colour map, and work best with the below settings
  //However a few textures have proper displacement maps (corrigated iron roof) and suffer 
  //Height 0 -> Q1H = 0 -> Q1 from alpha channel
	//Height Q1H -> Q2H = Q1 -> Q2 from alpha channel
	//Height Q2H -> 1 = Q2 -> 1 from alpha channel
  #define CONTRAST_COEF_Q1 float(0.41176)	//alpha channel level normalized to 0..1 (0.35294 = 90 on alpha channel)105
  #define CONTRAST_COEF_Q1H float(0.15) //Height of this level on final map
	#define CONTRAST_COEF_Q2 float(0.62745)	//alpha channel level normalized to 0..1 (0.62745 = 160 on alpha channel)
  #define CONTRAST_COEF_Q2H float(0.85) //Height of this level on final map (Note-most brick textures' "surface" is between 160-200 on alpha channel, lowering this will increase shifting of the bricks)



Here are some screenshots (my steam account is open to public)

Brick Wall Corner
http://steamcommunity.com/sharedfiles/filedetails/?id=259434692
Brick Wall Angle1
http://steamcommunity.com/sharedfiles/filedetails/?id=259434646
Brick Wall Angle2
http://steamcommunity.com/sharedfiles/filedetails/?id=259434661
Tiles Closup
http://steamcommunity.com/sharedfiles/filedetails/?id=259434705
Wood Wall Close
http://steamcommunity.com/sharedfiles/filedetails/?id=259444840
Old Wall no torch
http://steamcommunity.com/sharedfiles/filedetails/?id=259434794
Old Wall torch
http://steamcommunity.com/sharedfiles/filedetails/?id=259434813
Rocky Ground no torch
http://steamcommunity.com/sharedfiles/filedetails/?id=259444854
Rocky Ground torch
http://steamcommunity.com/sharedfiles/filedetails/?id=259444868

Here is the corrugated iron roof with my settings
http://steamcommunity.com/sharedfiles/filedetails/?id=259434678
Here is the roof with the shader switched to work with full range data
http://steamcommunity.com/sharedfiles/filedetails/?id=259444828
  23:16:33  13 May 2014
profilee-mailreply Message URLTo the Top
LoNer1
Настоящий Cталкер, Русская Версия
(Resident)

 

 
On forum: 10/23/2009
Messages: 1890
That looks really good!
  23:45:13  13 May 2014
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
 

Message edited by:
Meltac
05/13/2014 23:45:35
Messages: 1519
Wow, thanks templargfx for that information and for fiddling with those values! The result looks indeed awesome.

Could you please send me an archive containing the files you modified?
  02:19:11  14 May 2014
profilee-mailreply Message URLTo the Top
templargfx
(Novice)
 
On forum: 05/08/2014
Messages: 28

---QUOTATION---
Wow, thanks templargfx for that information and for fiddling with those values! The result looks indeed awesome.

Could you please send me an archive containing the files you modified?
---END QUOTATION---




Here you go (and anyone else)

http://fbe.am/sTv

I have merged my custom common.h with your Dynamic Shader 1.2b common.h so you should be able to just drop this into your current game (that is running 1.2b)

I have increased Q2 a little to give better parallax on those textures with correct displacement maps.

I have also left in my poisson disc with 6 slices. Gives significant increase in performance, but can cause artifacts in SSAO so I have left it commented out.

Tiled Floor
http://steamcommunity.com/sharedfiles/filedetails/?id=259604735
Painted Brick Wall
http://steamcommunity.com/sharedfiles/filedetails/?id=259605799
  04:28:02  14 May 2014
profilee-mailreply Message URLTo the Top
templargfx
(Novice)
 
On forum: 05/08/2014
 

Message edited by:
templargfx
05/14/2014 4:43:16
Messages: 28
Shadows!

Well this is interesting!

Shadows cast off Parallax Surface?

No Shadows
http://steamcommunity.com/sharedfiles/filedetails/?id=259642035

Shadows
http://steamcommunity.com/sharedfiles/filedetails/?id=259641990

Now you will notice the ground shadow to the left changes. I am still playing with the settings to hopefully come up with a middle-ground.

--EDIT-- Dangit, that's SSAO not shadows (I think)
--EDIT2-- Nope, definitely shadow based!
  10:59:45  14 May 2014
profilee-mailreply Message URLTo the Top
Meltac
messing with code
(Resident)

 

 
On forum: 01/21/2010
Messages: 1519
Thanks again

The parallax shadows are indeed quite interesting. However the well-known shadow bug (dark parallel stripes) kicks in really badly here

I am preparing a first patch for the beta, containing a few hotfixes for the most major issues. In that patch I will probably leave any further improvements out of scope in order to concentrate on stability.

After that patch having been released I shall elaborate which improvements (yours and mine as well as tweaks from others) should be part of a second patch to be released a little later.

So, let me know when you're done with your tweaks!

Cheers
 
Each word should be at least 3 characters long.
Search:    
Search conditions:    - spaces as AND    - spaces as OR   
 
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
 

All short dates are in Month-Day-Year format.


 

Copyright © 1995-2019 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.