color changing water

Discussion in 'Mapping Questions & Discussion' started by lunarpumpkin, Sep 9, 2016.

  1. lunarpumpkin

    lunarpumpkin L2: Junior Member

    Messages:
    72
    Positive Ratings:
    12
    is it even possible to achieve color changing water? since the color generally come from the fog in the water
     
  2. Dr. Orange

    Dr. Orange L6: Sharp Member

    Messages:
    356
    Positive Ratings:
    267
    It should be possible to set up a material proxy that changes the water fog color over time giving the water different colors. See this list of material proxies for more information.
     
  3. lunarpumpkin

    lunarpumpkin L2: Junior Member

    Messages:
    72
    Positive Ratings:
    12
    how do you set custom variables that youc an edit in proxies?
     
  4. lunarpumpkin

    lunarpumpkin L2: Junior Member

    Messages:
    72
    Positive Ratings:
    12
  5. Dr. Orange

    Dr. Orange L6: Sharp Member

    Messages:
    356
    Positive Ratings:
    267
    Well, you have to do some scripting within your water .vmt file. I forgot to link this as well: https://developer.valvesoftware.com/wiki/Material_proxies
    Since fog is using three values as a rgb, you need to set up accordingly. First, you should setup three variables for each of the rgb values. You can create custom variables in .vmt files that can be used by proxies. Something like this:
    Code:
    "$fogr" "0"
    "$fogg" "0"
    "$fogb" "0"
    
    On their own, these variables doesn't do anything, but you can write to and read from them at runtime.
    Proxies have to be created within the "Proxies" block of your vmt file. You'll have to use an individual proxy for each of your rgb values. For instance, if you want the red value of the fog pulse between 0.0 and 1.0, you should add a Sine proxy. A Sine proxy will cuase the affected variable to constantly oscillate. It should look something like this.
    Code:
    "Proxies"
    {
    "Sine"
    {
      "resultVar" "$fogr" // This would be the custom variable for the specific fog rgb value you want to change.
      "sineperiod" "5" // How fast you want the value to pulse
      "sinemin" "0.0" // Set the min and max values to the min and max values you want your colors to be.
      "sinemax" " 1.0"
    }
    }
    This will cuase the $fogr value to oscillate between 0.0 (no red) to 1.0 (full red).
    Now, you need to read from these variables and add them to your $fogcolor variable, which is what the game actually uses to render the water color. This is accomplished through the Equals proxy. What this does is simply copy the value of one variable, and paste it into another. Additionally, it can also specify where it should put your value, if there are multiple values, like in $fogcolor. You should setup an Equals proxy for each of your rgb values like this:
    Code:
    "Equals"
    {
    "srcVar1" "$fogr" // The name of the variable you want to copy
    "resultVar" "$fogcolor[0]" // The last number indicates where you want to insert the variable. 0 is for red, 1 is for green, and 2 is for blue.
    }
    And that should be it. I haven't actually tested it, but theoreticly, it should work.
     
    • Thanks Thanks x 1
    Last edited: Sep 9, 2016
  6. lunarpumpkin

    lunarpumpkin L2: Junior Member

    Messages:
    72
    Positive Ratings:
    12
    true but what i want is for the golor to go from 1 0 0 to 1 1 0 to 0 1 0 to 0 1 1 to 0 0 1 to 1 0 1 to 1 0 0 again and so on , so im gonna use a bunch of conditions to achieve this result , thx for the help tho
     
    • Agree Agree x 1
  7. Dr. Orange

    Dr. Orange L6: Sharp Member

    Messages:
    356
    Positive Ratings:
    267
    You're welcome!
     
  8. Pocket

    aa Pocket func_croc

    Messages:
    4,477
    Positive Ratings:
    2,205
    If you can figure it out, let me know. I'm not good enough with math to convert the available functions into the perfect hue cycling you've described, so the best I could do was set three sine functions that are offset by a third of the length of the period. Which results in the yellow, teal, and fuchsia phases being dimmer than they ought to be, among other things.
     
  9. lunarpumpkin

    lunarpumpkin L2: Junior Member

    Messages:
    72
    Positive Ratings:
    12
    ironic considering the tag under your name and icon. XD
    ima try my best
     
  10. lunarpumpkin

    lunarpumpkin L2: Junior Member

    Messages:
    72
    Positive Ratings:
    12
    to be honest i have no fucking idea how to get an "if" and conditions to make it happen as the only variable for condition is LessOrEqual and only take 2 input ... this is gonna be a real fucking puzzle ... if someone else who might understand how the fuck these work https://developer.valvesoftware.com/wiki/Material_proxies_programming more than me could help thatll be really a preciated.
     
  11. lunarpumpkin

    lunarpumpkin L2: Junior Member

    Messages:
    72
    Positive Ratings:
    12
    wait can color in sin go beyond and bellow 0 and 1? but lock at 0 and 1? if so just make it 2 0 -1 and make them folow with the same speed , they should hit the max color and stay on it till the other tunt fade off and the new one show
     
  12. lunarpumpkin

    lunarpumpkin L2: Junior Member

    Messages:
    72
    Positive Ratings:
    12
    it worked , enjoy

    "Water"
    {
    "%keywords" "tf"
    "%tooltexture" "lunarpumpkin/water/lunarwater_normal"
    "%compilewater" 1
    "$forceexpensive" 1
    "$envmap" "env_cubemap"
    // "$abovewater" 1
    $underwateroverlay "lunarpumpkin/water/lunarwater04_overlay"

    "$refracttexture" "_rt_WaterRefraction"
    "$refractamount" ".75"
    "$refracttint" "{0 0 50}"

    "$reflectentities" 1
    "$reflecttexture" "_rt_WaterReflection"
    "$reflectamount" ".75"
    "$reflecttint" "{0 0 50}"

    "$scale" "[1 1]"

    "$bumpmap" "lunarpumpkin/water/lunarwater_dudv"
    "$normalmap" "lunarpumpkin/water/lunarwater_normal"

    "$surfaceprop" "water"
    "$bottommaterial" "lunarpumpkin/water/lunarwater04_beneath.vmt"
    "$bumpframe" "0"

    $lunarvar1 0
    $lunarvar2 0
    $lunarvar3 0


    "$fogenable" 1
    "$fogcolor" "[0.0 0.0 1.0]"
    "$fogstart" "0"
    "$fogend" "800"

    "Proxies"
    {

    "Sine"
    {
    "sineperiod" "9"
    "sinemin" "-1.0"
    "sinemax" " 2.0"
    "timeoffset" "0"
    "resultVar" "$lunarvar1"
    }

    "Sine"
    {
    "sineperiod" "9"
    "sinemin" "-1.0"
    "sinemax" " 2.0"
    "timeoffset" "3"
    "resultVar" "$lunarvar2"
    }

    "Sine"
    {
    "sineperiod" "9"
    "sinemin" "-1.0"
    "sinemax" " 2.0"
    "timeoffset" "6"
    "resultVar" "$lunarvar3"
    }

    "Equals"
    {
    "srcVar1" "$lunarvar1"
    "resultVar" "$fogcolor[0]"
    }

    "Equals"
    {
    "srcVar1" "$lunarvar2"
    "resultVar" "$fogcolor[1]"
    }

    "Equals"
    {
    "srcVar1" "$lunarvar3"
    "resultVar" "$fogcolor[2]"
    }

    "AnimatedTexture"
    {
    "animatedtexturevar" "$normalmap"
    "animatedtextureframenumvar" "$bumpframe"
    "animatedtextureframerate" 30.00
    }

    "TextureScroll"
    {
    "texturescrollvar" "$bumptransform"
    "texturescrollrate" .1
    "texturescrollangle" 0
    }
    "WaterLOD"
    {
    "dummy" 0
    }
    }
    }
     
    • Thanks Thanks x 1