1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

RBR Fog Setup

Discussion in 'Bob's Track Builder' started by Steely69, Apr 30, 2009.

  1. Quick question with the RBR Fog setup. I'm using a low poly large terrain with a background pic as the texture for a far background effect. With v07.01 the background terrain seemed unaffected by the fog whilst with v07.03 it is. V07.03 works spectacularly with the closer trackside terrain but I was wondering if there is any way to have the best of both worlds and get the far terrain to be still unaffected with v07.03? I've played a little with the scattering.h file but don't particularly understand what it's all about.
    The attached pic is the exact same project running in v70.01 & then in v07.03.
     

    Attached Files:

  2. have you tried to edit this line, float2 FogStartEnd = float2(0.0f, 2000.0); change the 2000 to something higher and that should increase the fog distance.
     
  3. I put that out to 10000 and it does come better but the far terrain is still about half(ish) fogged out. I was also trying to discern what difference that change makes to the closer terrain but I couldn't see a whole lot difference there. It would be nice to have the far terrain full texture but if it can't be acheived no problem, v07.03 makes a beautiful job of the near terrain.
     
  4. Try with that settings, it should work :


    float FogEnd = 500.0;
    float FogStart = 0.0f;
    float3 fogColor = float3(0.5f, 0.5f, 0.65f);
    float fog = (FogEnd - depth)/(FogEnd - FogStart);
    fog = clamp(fog, 0.0f, 1.0f);
    color.xyz = lerp(fogColor.xyz, color.xyz, fog);

    Cheers !

    :wink2:
     
  5. Thx jay_p but my scattering file looks like below and I can't quite see what you've changed,

    #define SCATTERING
    float4 vExtInscMultipliers;
    float4 vSunColorIntensity;
    float4 vBetaRayleigh;
    float4 vBetaDashRayleigh;
    float4 vBetaMie;
    float4 vBetaDashMie;
    float4 vBetaRayleighMie;
    float4 vOneOverBetaRM;
    float4 vHG;
    float4 vConstants;
    float3 vFogColor = float3(0.51f, 0.58f, 0.66f);
    float2 FogStartEnd = float2(0.0f, 2000.0);
    float4 Scattering(float3 vPos, float3 vEyePos, float3 vLightDir, float4 color)
    {
    float3 vEyeVert = vEyePos - vPos;
    float dist = length(vEyeVert.xyz);
    vEyeVert = normalize(vEyeVert);
    float cosTheta = max(0, dot(vLightDir.xyz, vEyeVert.xyz));
    float Phase1theta = cosTheta * cosTheta + 1.0f;
    float3 extinction = - vBetaRayleighMie.xyz * dist * vConstants.y;
    extinction = exp(-extinction);
    float4 r4;
    r4.x = vHG.z * cosTheta + vHG.y;
    r4.x = rsqrt(r4.x);
    r4.y = r4.x * r4.x;
    r4.x = r4.y * r4.x;
    float Phase2theta = r4.x * vHG.x;
    float3 rayleigh = vBetaDashRayleigh *Phase1theta;
    float3 mie = vBetaDashMie * Phase2theta;
    float3 temp = vConstants.x - extinction;
    float3 inscatter = mie + rayleigh;
    inscatter*=temp;
    inscatter *= vOneOverBetaRM;
    inscatter *= vExtInscMultipliers.y;
    inscatter *= vSunColorIntensity.xyz * vSunColorIntensity.w;
    extinction.xyz *= vSunColorIntensity.xyz * vSunColorIntensity.w;
    float4 res = color;
    float fog = (FogStartEnd.y * 2 - dist)/(FogStartEnd.y * 2 - FogStartEnd.x);
    fog = min(fog, 1);
    res.rgb = lerp(vFogColor.xyz, res.rgb, fog);
    res.rgb *= saturate(extinction.xyz);
    res.rgb += clamp(-inscatter.xyz, 0.0f, 0.25f);
    res.rgb = saturate(res.rgb);
    return res;
    }
     
  6. I have exactly the same problem and tried exactly the same with fog startend, with obviously the same results.
    I will try your modification, thanks Jay

    I agree with Steely, please Jay, show us how the complete file should look
     
  7. Sorry, the coding of that feature have updated in v0.7.0.3. I will try to sort that out. Maybe Piddy or black f. can answer that question...
     
  8. sorry to bring about this thing again but, please, is there maybe any way to switch off fog in RBR by the file scattering.h?
    This would be greatly appreciated because it would allow RBR users to build nice scenery using far big planes that now look washed out with whatever number I put in fogstartend variable.

    Thanks
     
  9. Is it possible to use the scattering.h file from v0702 with the v0705? Maybe that's a way to 'roll back' to the older version. I don't have a copy of the v0702 update so I can't test it but maybe it'd work?

    If anyone could post the earlier scattering.h file it'd be most appreciated...

    thx
     
  10. some good news on the matter, with thanks to jharro to let me know the situation and for giving me a temporary solution for testing.
    First and most important, he is still working on the scattering and fog shader, so in the future there will be some interface to control it (so don't pester him and let him think of the maths :wink2:).

    As it is now, if you want to eliminate the fog effect (but also Rayleigh and Mie atmospheric scattering, as far as I understand), the text in the file scattering.h can be replaced by this few lines:

    #define SCATTERING

    float4 Scattering(float3 vPos, float3 vEyePos, float3 vLightDir, float4 vColor)
    {
    return vColor;
    }

    this way results will be like in v0.6, and we can test far scenery, knowing that working like this is possible.
    thanks again to the btb/RBR developers!
     
  11. Thx to all!