Creating a Waterfall Material: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(better)
No edit summary
Line 1: Line 1:
This is a Tutorial to create a Waterfall material. It will scroll downward and refract the image behind it, and optionally reflect.
This is a Tutorial to create a Waterfall material. It will scroll downward and refract the image behind it.
 
{{note|LightmappedReflective is for Orange Box only.}}


== The bump map ==
== The bump map ==
Line 22: Line 20:
== The Material ==
== The Material ==
=== The basic Material ===
=== The basic Material ===
At first you have create a materialfile(vmt) and name it waterfall.vmt or similar.
At first you have to create a material file(vmt) and name it something like waterfall.vmt.
In the materialfile you should use the '''[[LightmappedReflective]]''' shader:
In the material file you should use the '''[[Refract]]''' shader:


  '''LightmappedReflective'''
  '''Refract'''
  {
  {
  }
  }
<br>
<br>
So we don't need a '''$basetexture''' but we need a '''$RefractTexture''' and optionaly a '''$ReflectTexture'''.
We don't need a '''$basetexture''' for this shader.
 
The attribute for the '''$RefractTexture''' parameter is ''_rt_WaterRefraction'' and for '''$ReflectTexture''' is it ''_rt_WaterReflection''.
 
Now it should look like this:
 
LightmappedReflective
{
'''$RefractTexture _rt_WaterRefraction'''
}


That is now the base of our Material. Now we add the Normalmap with '''$normalmap''' and the path to it like ''"nature/waterfall_n"''.
That is now the base of our Material. Now we add the Normalmap with '''$normalmap''' and the path to it like ''"nature/waterfall_n"''.
Line 44: Line 33:
For the right refraction amount we add '''$refractamount''' with a value between 0 and 1 like ''0.08''.
For the right refraction amount we add '''$refractamount''' with a value between 0 and 1 like ''0.08''.


  LightmappedReflective
  Refract
  {
  {
$RefractTexture _rt_WaterRefraction
  '''$normalmap nature/waterfall_n'''
  '''$normalmap nature/waterfall_n'''
   '''$refractamount .08'''
   '''$refractamount .08'''
  }
  }


See [[Water (shader)]] for more commands you'll want to use.
See [[Refract]] for more commands you'll want to use.


=== Scroll animation ===
=== Scroll animation ===
Line 72: Line 60:
So now the whole vmt should look like this
So now the whole vmt should look like this


  LightmappedReflective
  Refract
  {
  {
$RefractTexture _rt_WaterRefraction
  $normalmap nature/waterfall_n
  $normalmap nature/waterfall_n
  $refractamount .08
  $refractamount .08
Line 87: Line 74:
  }
  }
  }
  }
=== Optional: Reflection ===
When you want Reflections you must add '''$ReflectTexture''', '''$reflectamount''' and '''$fresnelpower'''.
Use for '''$fresnelpower''' a value of ''5'' because I think it looks the best.
For '''$reflectamount''' you must find your own value because there is no "Perfect value".
"LightmappedReflective"
{
"$RefractTexture" _rt_WaterRefraction
'''"$ReflectTexture" _rt_WaterReflection'''
  "$normalmap" "nature/waterfall_n"
  "$refractamount" .08
  '''"$reflectamount" .3'''
'''"$fresnelpower" 5'''
  "Proxies"
{
"TextureScroll"
{
"texturescrollvar" "$bumpTransform"
"texturescrollrate" 1.3
"texturescrollangle" 270.00
}
}
}
== Mapping ==
This section shows how to embed the waterfall.<br><br>
At first you must create a [[Brush]] with the '''Nodraw''' material<br>
then you add to one side the '''waterfall''' material.<br>
You do this with selecting the Brush and then press ''Shift+A'' then the Window ''Face Edit Sheet'' appears, when you go with the cursor into the 3D window you can see that you can select single faces now.<br>
Select one Face and click ''Browse'' in the ''Face Edit Sheet''.<br>
In the ''Browse'' window you can select materials, to find your material fast you can enter the name of your material into the ''Filter'' textfield.<br>
When you have selected your Material click ''Apply''.<br><br>
After this you have to make your Brush to an entity by pressing ''Ctrl+T''.<br>
Select the class '''func_reflective_glass''' and make the Solidity to '''Never solid'''.<br>
Now you can compile your map.
== TODO ==
*make a better tutorial for embeding into a map


[[Category:Material System]]
[[Category:Material System]]
[[Category:Tutorials]]
[[Category:Tutorials]]

Revision as of 11:39, 5 October 2010

This is a Tutorial to create a Waterfall material. It will scroll downward and refract the image behind it.

The bump map

For a waterfall you need a Normalmap which Refracts the light so that the things behind it gets distorted. I used The_GIMP for this Tutorial.

The 'solid noise' image
The 'Normalmap' image
  1. Make a new Image with a maximum size of 1024x1024, I used a size of 512x512 pixels.
  2. We create now a solid Noise so you go to Filters → Render → Clouds → Solid noise. Set:
    • x to 16.0(the highest possible)
    • y to between 1.0 and 3.0
    • Detail to 15(highest possible)
    • Finally, you must check the Tileable box to make it seamless.
  3. Save your file as TGA and open it with VTFEdit.
  4. Check the texture config dialogue's Generate Normal map box and set:
    • Filter to 4 Sample
    • Height Source to Average RGB
    • Scale to 9.0
    • Normal Format and Alpha Format to RGBA8888.
  5. Save this bump map in a folder like "nature/" in your mod materials folder or game materials folder and give it a name like "waterfall_n.vtf".

The Material

The basic Material

At first you have to create a material file(vmt) and name it something like waterfall.vmt. In the material file you should use the Refract shader:

Refract
{
}


We don't need a $basetexture for this shader.

That is now the base of our Material. Now we add the Normalmap with $normalmap and the path to it like "nature/waterfall_n".

For the right refraction amount we add $refractamount with a value between 0 and 1 like 0.08.

Refract
{
	$normalmap nature/waterfall_n
 	$refractamount .08
}

See Refract for more commands you'll want to use.

Scroll animation

When you use your material in a map you should see that the refraction looks frozen, so you must add a "Scrolling" effect.

We can do this with an animated texture, or for the easier way we can add the TextureScroll material proxy:

Proxies
{
	TextureScroll
	{
		texturescrollvar $bumpTransform
		texturescrollrate 1.3
		texturescrollangle 270.00
	}
}


So now the whole vmt should look like this

Refract
{
	$normalmap nature/waterfall_n
	$refractamount .08
	Proxies
	{
		TextureScroll
		{
			texturescrollvar $bumpTransform
			texturescrollrate 1.3
			texturescrollangle 270.00
		}
	}
}