PBR: Difference between revisions

From Empires Wiki
Jump to navigation Jump to search
No edit summary
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:PBR_comparison.png|200px|thumb|right|Comparison: left are the base Source Engine shaders, right is the PBR shader.]]
Physically based rendering shader. Source code is available at: https://github.com/thexa4/source-pbr
Physically based rendering shader. Source code is available at: https://github.com/thexa4/source-pbr


== Parameters ==
== Parameters ==
* $basetexture - The albedo texture
* $basetexture - The albedo texture
* $normaltexture - The normal map
* $normaltexture - Sets the normal map (for backwards compatibility)
* $bumpmap - Sets the normal map (new way of setting normalmap)
* $mraotexture - A texture with the metalness on the red channel, roughness on the green channel and ambient occlusion on the blue channel.
* $mraotexture - A texture with the metalness on the red channel, roughness on the green channel and ambient occlusion on the blue channel.
* $envmap - Must be set to "env_cubemap"
* $envmap - Defaults to "env_cubemap", allows you to use a custom one.
* $pbrlookup - Must be set to "dev/pbr_lookup"
* $surfaceprop - One of the following: https://developer.valvesoftware.com/wiki/$surfaceprop
* $surfaceprop - One of the following: https://developer.valvesoftware.com/wiki/$surfaceprop
* $model - Should have a value of "1" if the texture is used on a prop.
* $model - Should have a value of "1" if the texture is used on a prop.
Line 12: Line 14:
* %keywords - A list of keywords separated by commas, should contain 'empires' as first element. Examples of keywords are: architectural,brown,gray,grime,hanger,industrial,metal,modern,shed,urban,wall,floor
* %keywords - A list of keywords separated by commas, should contain 'empires' as first element. Examples of keywords are: architectural,brown,gray,grime,hanger,industrial,metal,modern,shed,urban,wall,floor
* $basetexturetransform - Looks like this: "center 0.5 0.5 scale 0.1025 0.1025 rotate 0 translate 0 0" for a 2m by 2m texture.
* $basetexturetransform - Looks like this: "center 0.5 0.5 scale 0.1025 0.1025 rotate 0 translate 0 0" for a 2m by 2m texture.
 
* $alphatest <0|1> - Enables clipping the pixel when the alpha goes below $alphatestreference.
=== Upcoming parameters ===
* $pbrlookup is deprecated
* $alphatestreference <float> -  
* $alphatestreference <float> -  
* $emissiontexture - Allows setting an emission texture. Enabled self illumination.
* $emissiontexture - Allows setting an emission texture. Enabled self illumination.
Line 23: Line 23:
  {
  {
   "$basetexture"  "mymod/newtexture_albedo"
   "$basetexture"  "mymod/newtexture_albedo"
   "$normaltexture" "mymod/newtexture_normal"
   "$bumpmap"       "mymod/newtexture_normal"
   "$mraotexture"  "mymod/newtexture_mrao"
   "$mraotexture"  "mymod/newtexture_mrao"
  "$envmap"        "env_cubemap"
  "$pbrlookup"    "dev/pbr_lookup"
   "$surfaceprop"  "metal"
   "$surfaceprop"  "metal"
  "$model"        "0"
  }
  }



Revision as of 22:55, 7 October 2019

Comparison: left are the base Source Engine shaders, right is the PBR shader.

Physically based rendering shader. Source code is available at: https://github.com/thexa4/source-pbr

Parameters

  • $basetexture - The albedo texture
  • $normaltexture - Sets the normal map (for backwards compatibility)
  • $bumpmap - Sets the normal map (new way of setting normalmap)
  • $mraotexture - A texture with the metalness on the red channel, roughness on the green channel and ambient occlusion on the blue channel.
  • $envmap - Defaults to "env_cubemap", allows you to use a custom one.
  • $surfaceprop - One of the following: https://developer.valvesoftware.com/wiki/$surfaceprop
  • $model - Should have a value of "1" if the texture is used on a prop.
  • $translucent - Setting this to "1" enables alpha blending.
  • %keywords - A list of keywords separated by commas, should contain 'empires' as first element. Examples of keywords are: architectural,brown,gray,grime,hanger,industrial,metal,modern,shed,urban,wall,floor
  • $basetexturetransform - Looks like this: "center 0.5 0.5 scale 0.1025 0.1025 rotate 0 translate 0 0" for a 2m by 2m texture.
  • $alphatest <0|1> - Enables clipping the pixel when the alpha goes below $alphatestreference.
  • $alphatestreference <float> -
  • $emissiontexture - Allows setting an emission texture. Enabled self illumination.
  • $useEnvAmbient <0|1> - Makes it use the lowest mip level of the cubemap for ambient light instead of the ambient cubes. Can cause artifacts with moving props.

Example

"PBR"
{
 "$basetexture"   "mymod/newtexture_albedo"
 "$bumpmap"       "mymod/newtexture_normal"
 "$mraotexture"   "mymod/newtexture_mrao"
 "$surfaceprop"   "metal"
 "$model"         "0"
}

Integrating in your mod

The shader is built on top of the Base SDK github code. If you continued working on top of that and still use git, you can merge in this change: https://help.github.com/articles/syncing-a-fork/
You have to start the game with the -forceallmips startup parameter for rough materials to look good.

Mapping

  • You have to start hammer with a -game <yourmod> startup parameter. You can add this by editing 'bin/Hammer.bat'
  • Make sure cubemaps are on on 128x128 or higher (default in Empires)
  • The shader works with the Unreal Engine format of https://gametextures.com

Getting help

If you need help or have suggestions, please contact @Thexa4 on the Empires Discord or the Source Modding Community.