Had fresnel without Reshade, no more

Discussion in 'Content Creation' started by Brother_Dave, Jul 28, 2018.

  1. Brother_Dave

    Brother_Dave
    Expand Collapse

    Joined:
    Aug 16, 2012
    Messages:
    1,662
    I thought id just chip in what i did since im obsessed about getting fresnel for the reflections on the cars.
    In the screenshots ive got it working and its not thanks to any overlay app like Reshade (in two of the shots im using Reshade for SSAO and so on).

    Im in no way a shader coder, but has some logic thinking capability lol so can figure some of the things out.

    To be honest i dont know exactly what got it working (did only do so with a bright sky though, never found how to increase it without the bright sky, before it was gone..).
    What i did was using the newer shaders in the latest version of Torque3D which adds some nice settings, along with adjusting the beamng postfx/shader settings files to get them running. Also, i dont know if BeamNG has them or not, but there has been some changes to them in order of functionality, DOF and/or Bloom didn have correct coding or something like that.
    Combined with that i tried adding/modifying the water fresnel shader to the vehicle shader, since the water fresnel works without PBR then fresnel should too, right? Well somewhere along the way i got it working, although i dont know what did it, if this was the thing or not! Didnt drop FPS noticeably either so i was a happy camper.

    Heres the negative news; i had done some earlier changes to other maps than WCUSA and thought that a fresh install would be in its place, trying to do that with every update. WELL... the changes i did to get fresnel working so far was gone ofcourse, only problem is that what i thought i needed to do to get it running on a fresh install didnt do it so now its gone o_O

    Might try to get it wokring again but im knackered about it right now, so wont be trying for a while :(
     

    Attached Files:

    • screenshot_00271.png
    • screenshot_00272.png
    • screenshot_00273.png
    • screenshot_00274.png
    • NotaGTRfresnelReshade.png
    • NotaGTRfresnel.png
    • Like Like x 6
  2. Aboroath

    Aboroath
    Expand Collapse

    Joined:
    Aug 25, 2013
    Messages:
    3,804
    Delicious looking screens, very much like the cars in a AAA game. Keep on keepin' on brother!
     
    • Like Like x 1
    • Agree Agree x 1
  3. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    You should never work in the game path especially when the game is on Steam, even without update steam could have passively check some files and decided to clean everything.
    Please use the userpath (C:\Users\user\Documents\BeamNG.drive),This folder have the highest priority in the virtual filesystem, It will overwrite any file from the game.
     
    • Agree Agree x 1
    • Informative Informative x 1
  4. Brother_Dave

    Brother_Dave
    Expand Collapse

    Joined:
    Aug 16, 2012
    Messages:
    1,662
    Wont do that mistake again, was quite certain i had the 'procedure' right, saved the files ive modified/added adn did a clean install but no, gone. Have tried just alittle bit since then but it really dont have the time nore energy for it atm but now i know its possible, its 'just' a matter of getting things right :)
     
    • Agree Agree x 1
  5. Brother_Dave

    Brother_Dave
    Expand Collapse

    Joined:
    Aug 16, 2012
    Messages:
    1,662
    Might be on to something, cant get it to falloff as i did in the earlier tries though, kind of eliminates the whole fresnel shading since it just reflects the living crap out of the car.
     
  6. The Shotty

    The Shotty
    Expand Collapse

    Joined:
    Mar 15, 2014
    Messages:
    1,556
    can you post a pic comparing an official car before and after?
     
    • Agree Agree x 1
  7. stbest95

    stbest95
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    259
    i seriously hope the devs get fresnel into the game soon.
    without it the reflections look absolutely terrible, especially when looking at flat surfaces.
    turning them off actually looks better.
     
    • Agree Agree x 1
  8. Brother_Dave

    Brother_Dave
    Expand Collapse

    Joined:
    Aug 16, 2012
    Messages:
    1,662
    I dont have any from the latest progress, was so bad i started over. Ive attached screenshots down below;
    'NotaGTRfresnelReshade.png' is the first fresnel effect and my Reshade preset which i use for contrast, SSAO and a few other lighting effects.
    'Screenshot_00274.png'is vanilla ingame with the first fresnel effect (the one now gone), also might be some ingame PostFx, cant remember.
    'Screenshot_00275.png' is vanilla ingame with no ingame PostFX. Just took the shot.
    BTW, no screenshots of a official. Yet.

    I wouldnt say terrible but its obvious that T3d gfx part of the engine engine comes without much candy out the box. Fresnel does add alot to the looks of painted metal. The water in the T3D engine already utilizes fresnel with all needed components, to bad they (Torque 3D developer/s) havent added it outside of that. Now, i played RoR back in the days and was happy as can be with those graphics due to its revolutionary nodes and beams system but i guess my 'demands' has grown since then :rolleyes:
     

    Attached Files:

    • screenshot_00275.png
    • NotaGTRfresnelReshade.png
    • screenshot_00274.png
    • Like Like x 2
  9. ryakra

    ryakra
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    213
    I have been trying to do this and a bit more, do you have any more info on which files you modified and what you changed?
     
  10. Tsutarja495

    Tsutarja495
    Expand Collapse

    Joined:
    Mar 16, 2014
    Messages:
    819
    Bump, I just want to express my interest in this particular topic.
    What I've done so far:
    Code:
    //-----------------------------------------------------------------------------
    // Uniforms                                                               
    //-----------------------------------------------------------------------------
    uniform float4       rtParams1;
    uniform float3       eyePos; // This is in object space!
    uniform float4x4     modelMat;
    
    
    
    
    
    
    
    //-----------------------------------------------------------------------------
    // Structures                                                                 
    //-----------------------------------------------------------------------------
    struct ConnectData
    {
       float4 texCoord   : TEXCOORD0;
       float2 tex2       : TEXCOORD1;
    
       float4 objPos           : TEXCOORD4; 
      
       float3x3 tangentMat     : TEXCOORD6; 
    };
    
    
    struct Fragout
    {
       float4 col : COLOR0;
    };
    
    
    //-----------------------------------------------------------------------------
    // Fade edges of axis for texcoord passed in
    //-----------------------------------------------------------------------------
    float fadeAxis( float val )
    {
       // Fades from 1.0 to 0.0 when less than 0.1
       float fadeLow = saturate( val * 10.0 );
      
       // Fades from 1.0 to 0.0 when greater than 0.9
       float fadeHigh = 1.0 - saturate( (val - 0.9) * 10.0 );
    
       return fadeLow * fadeHigh;
    }
    
    float fresnel(float NdotV, float bias, float power)
    {
       return bias + (1.0-bias)*pow(abs(1.0 - max(NdotV, 0)), power);
    }
    
    uniform_sampler2D(refractMap, 1);
    uniform_sampler2D(texMap, 0);
    uniform_sampler2D(bumpMap, 2);
    
    
    //-----------------------------------------------------------------------------
    // Main                                                                       
    //-----------------------------------------------------------------------------
    Fragout main( ConnectData IN )
    {
       Fragout OUT;
    
       float3 bumpNorm = tex2D( bumpMap, IN.tex2 ) * 2.0 - 1.0;
       float2 offset = float2( bumpNorm.x, bumpNorm.y );
       float4 texIndex = IN.texCoord;
    
       // The fadeVal is used to "fade" the distortion at the edges of the screen.
       // This is done so it won't sample the reflection texture out-of-bounds and create artifacts
       // Note - this can be done more efficiently with a texture lookup
       float fadeVal = fadeAxis( texIndex.x / texIndex.w ) * fadeAxis( texIndex.y / texIndex.w );
    
       const float distortion = 0.2;
       texIndex.xy += offset * distortion * fadeVal;
      
       float3 eyeVec = IN.objPos.xyz - eyePos;
       eyeVec = mul( (float3x3)modelMat, eyeVec );
       eyeVec = mul( IN.tangentMat, eyeVec );
      
       eyeVec = -eyeVec;
       eyeVec = normalize( eyeVec );
       float ang = saturate( dot( eyeVec, bumpNorm ) );
      
       // fresnel calculation   
       float fresnelTerm = fresnel( ang, 0.2, 7.0 );   
    
       float4 reflectColor = tex2D( refractMap, texIndex.xy / texIndex.w );
       float4 diffuseColor = tex2D( texMap, IN.tex2 );
    
       OUT = lerp( diffuseColor, reflectColor * diffuseColor.a, fresnelTerm * diffuseColor.a );
    
       return OUT;
    }
    
    Code:
    //-----------------------------------------------------------------------------
    // Uniforms                                                               
    //-----------------------------------------------------------------------------
    uniform float4       rtParams1;
    uniform float3       eyePos; // This is in object space!
    uniform float4x4     modelMat;
    
    
    
    //-----------------------------------------------------------------------------
    // Structures                                                                 
    //-----------------------------------------------------------------------------
    struct ConnectData
    {
       float2 texCoord   : TEXCOORD0;
       float4 tex2       : TEXCOORD1;
      
       float4 objPos           : TEXCOORD4; 
      
       float3x3 tangentMat     : TEXCOORD6; 
    };
    
    
    struct Fragout
    {
       float4 col : COLOR0;
    };
    
    uniform_sampler2D( texMap, 0);
    uniform_sampler2D( refractMap, 1);
    
    float fresnel(float NdotV, float bias, float power)
    {
       return bias + (1.0-bias)*pow(abs(1.0 - max(NdotV, 0)), power);
    }
    
    //-----------------------------------------------------------------------------
    // Main                                                                       
    //-----------------------------------------------------------------------------
    Fragout main( ConnectData IN )
    {
       Fragout OUT;
    
       float4 diffuseColor = tex2D( texMap, IN.texCoord );
       float4 reflectColor = tex2D( refractMap, IN.tex2.xy / IN.tex2.w );
      
       float3 eyeVec = IN.objPos.xyz - eyePos;
       eyeVec = mul( (float3x3)modelMat, eyeVec );
       eyeVec = mul( IN.tangentMat, eyeVec );
      
       eyeVec = -eyeVec;
       eyeVec = normalize( eyeVec );
       float ang = saturate( dot( eyeVec, material.normal ) );
      
    
      
       // fresnel calculation   
       float fresnelTerm = fresnel( ang, 0.2, 7.0 );
    
       OUT = lerp( diffuseColor, reflectColor * diffuseColor.a, fresnelTerm * diffuseColor.a);
    
       return OUT;
    }
    

    So far nothing has worked, so I'm curious as to how you got this working.
     
  11. Brother_Dave

    Brother_Dave
    Expand Collapse

    Joined:
    Aug 16, 2012
    Messages:
    1,662
    You need to quote or tag me in order for me to get a notice about you writing so sorry about the delayed response :)

    I know more now than i did when tackling this but i still dont know how i did it. I remember it being really weak unless i brightened the sky/light of the map but Beamng has other gamma usage than T3d so that mightve been that.
    I might be wrong here but are you certain you use the call names used in beamng/t3d shaders? Also, is this the only files youve modded, not sure if you need to change another file in order for the game to use them.

    The water already use fresnel so you could have a look in the shaders connected to that.
     
  12. HeepXJ40

    HeepXJ40
    Expand Collapse

    Joined:
    Feb 6, 2020
    Messages:
    283
    This is very old, but will this ever be a project again?
     
  13. Brother_Dave

    Brother_Dave
    Expand Collapse

    Joined:
    Aug 16, 2012
    Messages:
    1,662
    I think i can say no, not even maybe, just no unfortunatly. I have very little time and energy to spend on any of my BeamNG mods/fixes atm. If i had the time i would now focus on the PostFx bloom, brightness settings and so on which is still not working and leaves results as to square bloom etc. Im guessing i can just use some of my postfxmanager-files fixes for that but i really dont have the time.

    There still is the Liman3D shader pack vol1 and 2 which contains a bunch of different shaders, amongst those there is fresnel. It works on a texture level afaik so apparently very easy to implement, they even come with instructions (which can be found on their site). That would be one way to get it.

    Link to the shader pack:
    http://liman3d.com/shaderpackvol1_overview.html
     
  14. HeepXJ40

    HeepXJ40
    Expand Collapse

    Joined:
    Feb 6, 2020
    Messages:
    283
    oooh okay. thanks for the link.
     
    • Like Like x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice