Possible to have shader use own ..._FAR_PLANE?
- brother_david
- Topic Author
BeamNG lacks fresnel so the paint looks kind of dull. Im using RBM to try and get a fresnel look. So far its working quite well but im having a few issues.
To stop RBM from giving everything no matter depth a reflection ive set the preprocessor RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=50 instead of the default 1000.
This however effects other shaders such as MXAO and DOF. Im not good at all with coding but looking at the RBM code i kind of get what some of it does. Is there a way to set the RBM depth to a fixed 50, or adjustable depth for that matter, in the code, instead of it reading RESHADE_DEPTH_LINEARIZATION_FAR_PLANE?
Also, if a vehicle has a paint color other than greyscale, the fresnel effect gets toned the opposite color, if a car is yellow then the fresnel has a blue'ish tone, if the car is red then the fresnel gets a green tone. Is there a way to bring the tone down ord esaturate it completely (other than the existing color settings which removes the effect instead)?
Theres a few other small issues but these are my main concern atm
My Reshade preset with fresnel:
https://beamng.com/attachments/screenshot_00097-png.393600/
Without:
https://beamng.com/attachments/screenshot_00097-png.393601/
Please Log in or Create an account to join the conversation.
- brother_david
- Topic Author
float EyeDepth = GetLinearDepth(coords.xy)*RESHADE_DEPTH_LINEARIZATION_FAR_PLANE;
To:
float EyeDepth = GetLinearDepth(coords.xy)*(RESHADE_DEPTH_LINEARIZATION_FAR_PLANE*0.2);
What do you think?
Please Log in or Create an account to join the conversation.
- brother_david
- Topic Author
I tried changing theline above to acouple of different version but none seemed to make any difference. Kind of stuck on how to make RBM use a individual _FAR_PLANE instead of changing the whole Reshade one.
Please Log in or Create an account to join the conversation.
- brother_david
- Topic Author
Compared to this, which uses my every shader (Depth Haze creates the blurry background, not DOF since it doesnt work) but RBM:
My problem is that every building and road in the background gets quite an obvious RBM effect unless i lower RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=1000 down to say 50.
Having it at 50 lets me have a good fresnel effect (still wih flaws that ive yet to solve) on the cars paint but that also effects DOF and MXAO in a negative way. MXAO is gone and DOF is to unless i increase the amount bu then it looks off.
My question is, is there a way to make the shader have a own "..._FAR_PLANE='-value? Or multiply the _FAR_PLANE with 0.2 to get 50 as a value? In that way i can use MXAO and DOF as usual but also have the fresnel effect.
Last, i dont know my way around coding shaders but im eager to learn enough to get by.
Please Log in or Create an account to join the conversation.
- crosire
float GetLinearDepth(float2 coords)
{
return ReShade::GetLinearizedDepth(coords);
}
float GetLinearDepth(float2 coords)
{
#if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
texcoord.y = 1.0 - texcoord.y;
#endif
float depth = tex2Dlod(DepthBuffer, float4(texcoord, 0, 0)).x;
#if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
const float C = 0.01;
depth = (exp(depth * log(C + 1.0)) - 1.0) / C;
#endif
#if RESHADE_DEPTH_INPUT_IS_REVERSED
depth = 1.0 - depth;
#endif
const float N = 1.0;
depth /= RESHADE_DEPTH_LINEARIZATION_FAR_PLANE_2 - depth * (RESHADE_DEPTH_LINEARIZATION_FAR_PLANE_2 - N);
return depth;
}
Please Log in or Create an account to join the conversation.
- Marty McFly
What your changes do is merely screwing up the depth values so after a certain distance the calculated positions of objects are so off that the shader won't create any reflections anymore.
So what I've got from your text is that you want a fade out option, correct?
Please Log in or Create an account to join the conversation.
- brother_david
- Topic Author
Im definitely with you on that its the wrong way to do it since it alteres the funtamental value that the FAR_PLANE gives but im simply bad at this (for now).
Yes that would be what im looking for, maybe something similar to the MXAO UI MXAO_FADE_DEPTH_START and MXAO_FADE_DEPTH_END (which is really nice btw).
Please Log in or Create an account to join the conversation.
- brother_david
- Topic Author
crosire wrote: Sure. Open "ReflectiveBumpMapping.fx" and search for the following code:
Replace that with the following:float GetLinearDepth(float2 coords) { return ReShade::GetLinearizedDepth(coords); }Now it will use the value of a RESHADE_DEPTH_LINEARIZATION_FAR_PLANE_2 define instead of RESHADE_DEPTH_LINEARIZATION_FAR_PLANE.float GetLinearDepth(float2 coords) { #if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN texcoord.y = 1.0 - texcoord.y; #endif float depth = tex2Dlod(DepthBuffer, float4(texcoord, 0, 0)).x; #if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC const float C = 0.01; depth = (exp(depth * log(C + 1.0)) - 1.0) / C; #endif #if RESHADE_DEPTH_INPUT_IS_REVERSED depth = 1.0 - depth; #endif const float N = 1.0; depth /= RESHADE_DEPTH_LINEARIZATION_FAR_PLANE_2 - depth * (RESHADE_DEPTH_LINEARIZATION_FAR_PLANE_2 - N); return depth; }
Tried to replace that piece of code with the one you gave me, unfortunatly it hands me a shader compiling error. Ive added ..._FAR_PLANE_2=40 to dxgi.ini, also tried adding it to Reshade.fxh if that matters but no luck.
Please Log in or Create an account to join the conversation.
- brother_david
- Topic Author
My current preset with:
_FAR_PLANE=1000, RBM
_FAR_PLANE=1000, No RBM
_FAR_PLANE=40, RBM
_FAR_PLANE=40 No RBM
Please Log in or Create an account to join the conversation.
- brother_david
- Topic Author
Tried to figure out how to get the code you posted Crosire, to work but no luck.
Also tried to make it the RBM settings distance adjustable but no luck with that either
Please Log in or Create an account to join the conversation.
- brother_david
- Topic Author
crosire wrote: Sure. Open "ReflectiveBumpMapping.fx" and search for the following code:
Replace that with the following:float GetLinearDepth(float2 coords) { return ReShade::GetLinearizedDepth(coords); }Now it will use the value of a RESHADE_DEPTH_LINEARIZATION_FAR_PLANE_2 define instead of RESHADE_DEPTH_LINEARIZATION_FAR_PLANE.float GetLinearDepth(float2 coords) { #if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN texcoord.y = 1.0 - texcoord.y; #endif float depth = tex2Dlod(DepthBuffer, float4(texcoord, 0, 0)).x; #if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC const float C = 0.01; depth = (exp(depth * log(C + 1.0)) - 1.0) / C; #endif #if RESHADE_DEPTH_INPUT_IS_REVERSED depth = 1.0 - depth; #endif const float N = 1.0; depth /= RESHADE_DEPTH_LINEARIZATION_FAR_PLANE_2 - depth * (RESHADE_DEPTH_LINEARIZATION_FAR_PLANE_2 - N); return depth; }
I must be stupid, i cannot get this to work. I dont know if i need to add lines to other files too? Reshade.fx for example?
Please Log in or Create an account to join the conversation.
- TheBlueOne
Please Log in or Create an account to join the conversation.
- brother_david
- Topic Author
Please Log in or Create an account to join the conversation.
- crosire
Please Log in or Create an account to join the conversation.
- brother_david
- Topic Author
Now ive tried replacing Depthbuffer with what you rote just now, so now the code looks like this:
float GetLinearDepth(float2 coords)
{
#if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
texcoord.y = 1.0 - texcoord.y;
#endif
float depth = tex2Dlod(ReShade::DepthBuffer, float4(texcoord, 0, 0)).x;
#if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
const float C = 0.01;
depth = (exp(depth * log(C + 1.0)) - 1.0) / C;
#endif
#if RESHADE_DEPTH_INPUT_IS_REVERSED
depth = 1.0 - depth;
#endif
const float N = 1.0;
depth /= RESHADE_DEPTH_LINEARIZATION_FAR_PLANE_2 - depth * (RESHADE_DEPTH_LINEARIZATION_FAR_PLANE_2 - N);
return depth;
}
Trying to find a typo in the code cause RBM wont show up in the shaders list but i get no error loading Reshade. Im guessing there is some coding error. Do i need to do something with the 'return depth;' code?
I highly appreciate all the help ive got so far, i am as you probably can see, a real newb when it comes to coding, so i understand if you get frustrated.
Please Log in or Create an account to join the conversation.
- crosire
Please Log in or Create an account to join the conversation.
- brother_david
- Topic Author
Shader looks off at the moment so if changing all to texcoords doesnt change much of the look then its a dead end unfortunatly.Getting that damn fresnel look for BeamNG is hard but might have tracked down another way to do it, that uses Torque 3Ds attributes dirct on the materials instead of an overlay on the screen.
Please Log in or Create an account to join the conversation.