S&box Wiki

Revision Difference

guide_to_materials#548342

<cat>Material.Intro</cat>⤶ <title>Guide to Materials</title>⤶ ⤶ # A beginners guide to materials⤶ ⤶ This contains all of the basic information about materials.⤶ This guide assumes you've already [created a material](Importing_and_creating_assets#creatingassets) or [imported a material](Importing_and_creating_assets#materials).⤶ ⤶ ## Texture naming conventions⤶ ⤶ The following texture naming conventions are typically used - they're not required, but highly recommended, since they allow the game to recognise your textures automatically when making materials.⤶ ⤶ | Texture type | name |⤶ | ---------------- |:----------------:|⤶ | base color / diffuse / albedo | name_color |⤶ | texture mask¹ | name_mask |⤶ | normal map | name_normal |⤶ | roughness / glossiness map² | name_rough |⤶ | metallic map³ | name_metal |⤶ | ambient occlusion map³ | name_ao |⤶ | blend mask⁴ | name_blend |⤶ | height map⁵ | name_height |⤶ | transparency / translucency / opacity map| name_trans |⤶ | self illumination / emissive map| name_selfillum |⤶ | freedom of motion map | name_freedom |⤶ ⤶ ¹ Used as a Tint Mask for coloring in Hammer mostly.\⤶ ² The glossiness map is the inverse of the roughness map, so the image needs to be inverted before using it.\⤶ ³ Make sure to enable the respective texture in the left PBR menu.\⤶ ⁴ pretty much a texture mask to help make the blend between two textures nicer.\⤶ ⁵ Needs the `Parallax Occlusion` shader.⤶ ⤶ <warning>Make sure your base image texture files are to the power of 2, meaning its width and height in pixels are one of these sizes: 128, 256, 512, 1024, 2048 4096 (I recommend never to go higher than 4096, try keep most textures within the 256 - 1024 range ideally), you have to do this or your textures will not work.</warning>⤶ ⤶ ## What shader should you use?⤶ ⤶ You can click the button above the material properties (to the left of the material variables) in order to change the material's shader.⤶ ⤶ <upload src="aa125/8dad937d2a18667.png" size="89604" name="image.png" />⤶ ⤶ The following shaders are included by default - for most purposes you'll either want **complex** or **simple**.⤶ ⤶ | Shader | Use/Description |⤶ | ------------- |:-------------:|⤶ | Blendable | This is for when you want to make a material to be used in a map, it can blend between 4 materials aka layers in one go, e.g. for a dirt and road, it will smoothly blend between without custom textures or modelling trickery needed⤶ | Complex | This is similar to simple although gives more options for what you can adjust and do, like more texture input types and so on, so if simple does not have the option you need complex most likely will |⤶ | Eyeball | Generic eyeball shader for your characters|⤶ | Glass | Standard glass shader that will do the job in most cases. |⤶ | Projected Decals | here is where you would make your decals, unlike others trans map does not make its translucent on the material, stays white, but it is translucent in-game don't worry |⤶ | Simple | This is your go to shader, if its for a simple job like a basic material with only a couple of texture maps, then this shader will do the job for you |⤶ | Skin | Shader for skin/flesh materials.⤶ | Sky | This is for skyboxes, it accepts only parallax style skybox textures, accepts 2x1 style textures e.g. w-1024 x h-512 |⤶ | Static Overlay | Shader for rendering static overlays placed in Hammer.⤶ | Water | Fancy Water for sbox |⤶ ⤶ ## Adding Textures⤶ ⤶ Lets say for now you only need the simple shader, lets have a look at it.⤶ ⤶ There are three ways to add textures:⤶ ⤶ 1. Drag your texture from the **Assets Browser**:⤶ <upload src="a768a/8da610fdf848fe5.gif" size="371851" name="9a1b8d5482.gif" />⤶ ⤶ 2. Click the **magnifying glass** next to the folder path field and search it in the **Texture Browser** window.⤶ ⤶ 3. Click the folder icon next to the magnifying glass and search for it in the Windows Explorer.⤶ ![search example](https://i.imgur.com/01PzmlG.png)⤶ ⤶ In some cases, you will need to enable shader features on the left in order to use specific textures - for example, **Ambient Occlusion** or **Metalness** textures.⤶ ⤶ ![shader options](https://i.imgur.com/u91rlQo.png)⤶ ⤶ ## Saving and compiling⤶ ⤶ <key>CTRL</key> + <key>S</key> will save your material to disk.⤶ If things aren't looking right, click **File** and then **Force Compile to Disk** in order to force the material to re-compile.