This wiki is archived and useful information is being migrated to the main bzflag.org website

Difference between revisions of "Material"

From BZFlagWiki
Jump to: navigation, search
m (specified Links for LinkMaterial)
(improved display of content)
 
(9 intermediate revisions by 6 users not shown)
Line 6: Line 6:
 
|
 
|
 
  material
 
  material
   name example_material
+
   name <u>example_material</u>
 
   texture filename
 
   texture filename
 
   addtexture filename
 
   addtexture filename
Line 33: Line 33:
 
|}
 
|}
 
Valid parameters for a Material are:
 
Valid parameters for a Material are:
<properties>
+
{|{{Prettytable}}
name=name for reference
+
|-
texture=set the texture (must be .png but don't include the extension unless on the Internet)
+
| {{Hl3}} |'''Parameter'''
addtexture=add a texture (again, no extension is needed)
+
| {{Hl3}} |'''Description'''
notextures=don't use textures.
+
|-
notexcolor=don't apply the [[Color(BZW)|color]] to the texture
+
| '''name''' || name for reference.
notexalpha=don't use the texture's alpha channel
+
|-
texmat=specify a [[TextureMatrix|texture matrix]]. -1 for no texture matrix. (addtexture must be used before texmat)
+
| '''texture''' || set the texture (must be .png but don't include the extension unless on the Internet).
dyncol=specify a [[DynamicColor|dynamic color]]. -1 for no dynamic color.
+
|-
ambient=ambient color
+
| '''addtexture''' || add a texture (again, no extension is needed).
diffuse=diffuse (main)[[Color(BZW)|color]]
+
|-
[[Color(BZW)|color]]=synonym for diffuse
+
| '''notextures''' || don't use textures.
specular=specular [[Color(BZW)|color]]
+
|-
emission=emission [[Color(BZW)|color]]
+
| '''notexcolor''' || don't apply the [[Color(BZW)|color]] to the texture.
shininess=shiny!
+
|-
resetmat=restore default values
+
| '''notexalpha''' || don't use the texture's alpha channel.
spheremap=use spherical texture coordinate mapping
+
|-
noradar=do not display on radar (except normal mode)
+
| '''texmat''' || specify a [[TextureMatrix|texture matrix]]. -1 for no texture matrix. (addtexture must be used before texmat).
noshadow=do not render shadows
+
|-
noculling=do not cull by face winding (double-sided)
+
| '''dyncol''' || specify a [[DynamicColor|dynamic color]]. -1 for no dynamic color.
nosorting=do not do front-to-back alpha sorting
+
|-
nolighting=disable lighting
+
| '''ambient''' || ambient color.
alphathresh=alpha thresholding value
+
|-
groupalpha=sort translucent faces as a group
+
| '''diffuse''' || diffuse (main)[[Color(BZW)|color]].
occluder=faces with this material will occlude
+
|-
</properties>
+
| '''[[Color(BZW)|color]]''' || synonym for diffuse.
 +
|-
 +
| '''specular''' || specular [[Color(BZW)|color]].
 +
|-
 +
| '''emission''' || emission [[Color(BZW)|color]].
 +
|-
 +
| '''shininess''' || shiny!.
 +
|-
 +
| '''resetmat''' || restore default values.
 +
|-
 +
| '''spheremap''' || use spherical texture coordinate mapping.
 +
|-
 +
| '''noradar''' || do not display on radar (except normal mode).
 +
|-
 +
| '''noshadow''' || do not render shadows.
 +
|-
 +
| '''noculling''' || do not cull by face winding (double-sided).
 +
|-
 +
| '''nosorting''' || do not do front-to-back alpha sorting.
 +
|-
 +
| '''nolighting''' || disable lighting.
 +
|-
 +
| '''alphathresh''' || alpha thresholding value.
 +
|-
 +
| '''groupalpha''' || sort translucent faces as a group.
 +
|-
 +
| '''occluder''' || faces with this material will occlude.
 +
|}
 +
 
 
To actually apply a material, you must use some sort of reference in an object, like so:
 
To actually apply a material, you must use some sort of reference in an object, like so:
 
{|
 
{|
Line 66: Line 94:
 
   rotation 0
 
   rotation 0
 
   size 10 10 5
 
   size 10 10 5
   matref example_material
+
    
 +
  # refer to the previously defined material with its particular name we gave it before
 +
  # compare underlined text in the code at the [[#Code|page top]]
 +
  '''matref <u>example_material</u>'''
 
  end
 
  end
 
|}
 
|}
 +
Please note the ''matref'' is the '''name''' of the defined material, not the name of the .png/url file!
 +
 +
==Translucency==
 +
Material translucency is enabled by setting the alpha component of a material's [[Color(BZW)|color]] to a value less than one. Translucent objects should be sparingly, because everything behind them must always be rendered. In addition, very large translucent objects may be sorted and drawn in the wrong order. This is caused by the fact that the Z-buffer cannot be used because it would allow another translucent object to cover the translucent object, which would not look right. Thus, the translucent elements are instead sorted by determining the distance to a point in the center, which works well as long as there are not too many large translucent objects.
 +
The same applies to textures that have translucent sections.
 +
  
==Transparency==
 
The transparency effect is created by setting the alpha component of a material's [[Color(BZW)|color]] to a value less than one.
 
Transparent objects should be sparingly, because everything behind them must always be rendered. In addition, very large transparent objects may be sorted and drawn in the wrong order. This is caused by the fact that the Z-buffer cannot be used because it would allow another transparent object to cover the transparent object, which would not look right. Thus, the transparent elements are instead sorted by determining the distance to a point in the center, which works well as long as there are not too many large transparent objects.
 
The same applies to textures that have transparent sections.
 
  
 
==Magic Material Names==
 
==Magic Material Names==
 
===General===
 
===General===
[[GroundMaterial]]<br>
+
* [[GroundMaterial]]
WaterMaterial<br>
+
* WaterMaterial
LinkMaterial  For Teleporter Links<br>
+
* [[LinkMaterial]] For Teleporter Links
TeleMaterial For Teleporter Frame (BZFlag version 3.0)
+
  
===Skybox===
+
===[[Skybox]]===
[[LeftSkyboxMaterial]]<br>
+
* LeftSkyboxMaterial
[[RightSkyboxMaterial]]<br>
+
* RightSkyboxMaterial
[[FrontSkyboxMaterial]]<br>
+
* FrontSkyboxMaterial
[[BackSkyboxMaterial]]<br>
+
* BackSkyboxMaterial
[[TopSkyboxMaterial]]<br>
+
* TopSkyboxMaterial
[[BottomSkyboxMaterial]]<br>
+
* BottomSkyboxMaterial
  
 
==History==
 
==History==
Line 94: Line 126:
  
 
==Editor Support==
 
==Editor Support==
Materials are supported in [[Blender]] with [[BZWTools]], [[pyBZEdit]], and [[Wings3D]] with the [[BZW Exporter for Wings3D]]. Materials are NOT supported in [[BZEdit]], [[BZFed]] or IBZEdit.
+
Materials are supported in [[Blender]] with [[BZWTools]], [[pyBZEdit]], and [[Wings3D]]. Materials are NOT supported in [[BZEdit]], [[BZFed]] or IBZEdit.
  
 
==A note about textures==
 
==A note about textures==

Latest revision as of 20:27, 8 February 2017

A material is used in a BZFlag world to define a new look for otherwise regular objects, such as meshboxes.

Code[edit]

To put a material in your map, first it must be defined:

material
 name example_material
 texture filename
 addtexture filename
 notextures
 notexcolor
 notexalpha
 texmat -1
 dyncol -1
 ambient 0.0 0.0 0.0 1.0
 diffuse 1.0 1.0 1.0 1.0
 color 1.0 1.0 1.0 1.0
 specular 0.0 0.0 0.0 1.0
 emission 0.0 0.0 0.0 1.0
 shininess 0.0
 resetmat
 spheremap 
 noradar 
 noshadow
 noculling 
 nosorting 
 nolighting 
 alphathresh 0.0 
 groupalpha
 occluder 
end

Valid parameters for a Material are:

Parameter Description
name name for reference.
texture set the texture (must be .png but don't include the extension unless on the Internet).
addtexture add a texture (again, no extension is needed).
notextures don't use textures.
notexcolor don't apply the color to the texture.
notexalpha don't use the texture's alpha channel.
texmat specify a texture matrix. -1 for no texture matrix. (addtexture must be used before texmat).
dyncol specify a dynamic color. -1 for no dynamic color.
ambient ambient color.
diffuse diffuse (main)color.
color synonym for diffuse.
specular specular color.
emission emission color.
shininess shiny!.
resetmat restore default values.
spheremap use spherical texture coordinate mapping.
noradar do not display on radar (except normal mode).
noshadow do not render shadows.
noculling do not cull by face winding (double-sided).
nosorting do not do front-to-back alpha sorting.
nolighting disable lighting.
alphathresh alpha thresholding value.
groupalpha sort translucent faces as a group.
occluder faces with this material will occlude.

To actually apply a material, you must use some sort of reference in an object, like so:

meshbox
 position 0 0 10
 rotation 0
 size 10 10 5
 
 # refer to the previously defined material with its particular name we gave it before
 # compare underlined text in the code at the page top
 matref example_material
end

Please note the matref is the name of the defined material, not the name of the .png/url file!

Translucency[edit]

Material translucency is enabled by setting the alpha component of a material's color to a value less than one. Translucent objects should be sparingly, because everything behind them must always be rendered. In addition, very large translucent objects may be sorted and drawn in the wrong order. This is caused by the fact that the Z-buffer cannot be used because it would allow another translucent object to cover the translucent object, which would not look right. Thus, the translucent elements are instead sorted by determining the distance to a point in the center, which works well as long as there are not too many large translucent objects. The same applies to textures that have translucent sections.


Magic Material Names[edit]

General[edit]

Skybox[edit]

  • LeftSkyboxMaterial
  • RightSkyboxMaterial
  • FrontSkyboxMaterial
  • BackSkyboxMaterial
  • TopSkyboxMaterial
  • BottomSkyboxMaterial

History[edit]

Materials were added in BZFlag 2.0.0.

Editor Support[edit]

Materials are supported in Blender with BZWTools, pyBZEdit, and Wings3D. Materials are NOT supported in BZEdit, BZFed or IBZEdit.

A note about textures[edit]

A material can be composed of colors and textures. Textures are .png files that are either in the client directory or on the Internet. The terms material and texture are often confused and misunderstood, so bear the above in mind.