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

Shader variables and expressions

Discussion in 'Prepar3D' started by mole_man99, 13 Nov 2017.

  1. mole_man99

    mole_man99

    Joined:
    2 Mar 2011
    Messages:
    51
    Hi All

    Getting into P3d V4.

    I am trying to be clever with shader variables through PTA tool. PTA's own explanation of shader variables and expressions is a bit thin. I can not find in the SDK where the variables may be listed and explained.

    Simple example from PTA
    (saturate(1.0 - cb_Altitude/2438))

    As PTA explain, this changes the saturation level above 2438m, but changes from what to what? Does the minus mean above or below the variable? Sometimes it is a plus symbol. Not sure how and when to use which.

    Anybody know where it is hidden in the SDK learning centre, if there at all? I am assuming it's part of the P3D system, and not PTA specific.

    Cheers

    Graeme
     
  2. JB3DG

    JB3DG Resource contributor

    Joined:
    24 Jun 2010
    Messages:
    1,104
    Country:
    southafrica
    As per the MS DX SDK HLSL documentation, the saturate function clamps the x parameter within the range of 0 to 1. The input value is 1.0 - cb_Altitude/2438 so the value of cb_Altitude is in meters. if altitude is < 2438, divide by 2438 will give you a value between 0 and 1. 1.0 - 0.6 for example will give a value of 0.4. If altitude exceeds 2438, you will get a value of > 1. Therefore 1.0 - 1.2 for example will give -0.2. A value of -0.2 passed to the saturate function will be clamped to 0.
     
  3. mole_man99

    mole_man99

    Joined:
    2 Mar 2011
    Messages:
    51
    Wow that's way beyond me.

    I was wondering where the docs were, so they are in the DX SDK. I'll try downloading and see how I get on.

    Thanks for the reply.
     
  4. mole_man99

    mole_man99

    Joined:
    2 Mar 2011
    Messages:
    51
    After my 15th read (and a helpful chap at AVSIM), the penny dropped. Thanks. Just downloading the docs to see about clamping a rigid value to a certain alt then having it reduce.

    What a varied hobby this is.
     
  5. JB3DG

    JB3DG Resource contributor

    Joined:
    24 Jun 2010
    Messages:
    1,104
    Country:
    southafrica
    Would be interested in seeing the post at avsim...link?
     
  6. mole_man99

    mole_man99

    Joined:
    2 Mar 2011
    Messages:
    51
    Here you go, and I got a formula that works for me, pasted in the post along with some screens.
    https://www.avsim.com/forums/topic/524248-darken-ground-with-altitude/

    Do you know where all shader variables are listed? I am now looking for one that is linked to cloud cover and can't find a list in the P3D SDK. Can't even find ones I know about like cb_altitude.