Skip to content

Materials

KillzXGaming edited this page Aug 9, 2023 · 33 revisions

3DS materials are handled by a fixed pipeline (similar to Wii/Gamecube) instead of using fragment shaders.

The materials are built using combiners and stages which determine how to display the material.

image

This is the example of a very simple material. PixelL is shading/lighting. It multiplies by the texture to get a shaded output with texture.

General

You can save the material as a preset (gets saved to tool directory) for easy reuse.

image

The top of the material editor includes material name and option to use fragment lighting.

image

Fragment lighting must be enabled for combiners that use pixel/specular lighting!

Copy Paste

You can copy/paste individual materials to clipboard from the right click menu.

image

image

Export/Replace

Materials can be exported/replaced as .json from the right click menu.

image

These can be edited in a text editor.

Info

image

Face Culling - Controls what face to hide. Hides the back face by default. Set to Never to show both faces.

Enable Fog - Uses fog if the game supports loading them for the model. Light Set - Determines what light ID to use. The lights are handled game specific. MK7 for example has a seperate light file for tracks.

Texture Maps

image

Texture maps configure what texture to display on the material (when used in the combiner section).

Changing

To select or change the texture, you can click this button. It will give you a list of all current textures loaded.

image

Or you can type in the name manually.

image

Wrap Modes (Mirror, Repeat)

image

Configures how the texture will wrap in the border of the UV box. Mirror will mirror the texture, clamp will clamp the last pixels used.

UV Config

image

Mapping Type - Controls how to display the texture onto the model. UV Coordinates is default. Projection map and other types can do more fancy effects but may not display in the 3D view currently.

UV Layer - Determines what UV layer to use. Some games use the second one for shadow maps so you can have one UV for base texture, second for shadows.

Transforming

image

Simply controls the scale, rotation and translation of the UVs. The transform method is based on different 3D programs.

Filtering

image

This mode is how the image should be displayed from a distance.

  • Linear : Blurry but looks more natural, less pixelated
  • Nearest : Pixel perfect. Ideal for sprites.

Make sure to use the mipmap option for min filter to use mipmaps.

  • Min LOD : The mip to display. This should be 0.
  • LOD Bias : Adjusts the level of detail changing from a distance. Negative can be sharper, positive can be more blurry.

Tex Coord IDs

image

Simply configures what set of texture coordinates to use. 0 1 2 0 uses the first 3 texture coordinates. Other types will share the second and third coordinate set to help save on performance. This shouldn't be requried to edit unless a texture doesn't use the normal 0 1 2 0 type and you need a unique third UV.

Tips

To see the image better, you can resize the window from the bottom.

image

Colors

image

  • Diffuse Color - The color of diffuse lighting Pixel Lighting in combiner must be used

  • Emission Color - The color of emissive lighting Pixel Lighting in combiner must be used

  • Ambient Color - The color of ambient lighting Pixel Lighting in combiner must be used

  • Specular Color 0 - The color of specular 0 lighting Specular Lighting in combiner must be used

  • Specular Color 1 - The color of specular 1 lighting Specular Lighting in combiner must be used

  • Constant Colors - Colors configured with the combiner. These can be adjusted inside the combiner UI.

  • Blend Color - Color optionally used based on render state blend settings.

Render State

image

Configures how to render effects like blending and depth.

You shouldn't need to edit most of this data as you can use the presets.

image

  • Opaque - Non transparent.
  • Transparent - Supports transparency but not see through.
  • Translucent - Can be seen through.

LUTs

These are look up tables used for configuring lighting.

image

Previewing

Many games will load the LUTs outside the file so if you are trying to preview them in MK7 or SM3DL, those are in seperate files. You can load external LUTs from other bcres/bch by putting them in the LUTs folder of the program.

  • MK7 LUTs - RaceCommon.szs\DFD3F577.bcres in STB or RaceCommon.szs\LUT\common_lut.bclts in EFE.
  • SM3DL LUTs - ObjectData\Shader.szs\Shader.bcsdr

image

To get a good view of how these look, you can switch to Specular debug shading mode to view the specular directly.

image

Here we can see the lighting being used all around this model aside from that darkened spot. The light is represented up to 180 degrees.

image

Types

Distribution Specular 0/1

This is the primary way specular effects are handled. Specular 1 being like an optional layer of specular to add on.

Reflect RGB

Extra layer of specular with 3 optional channels.

Fresnel

Gives fresnel lighting.

Using LUTs

You need to checkmark the LUT you want to use.

image

If the option is grayed out, configure the layer config.

image

Switch to different presets until the options enabled are what you want. Keep in mind the bottom most are performance intensive

Next select the LUT you want to use. If you want to add them, refer to this guide.

image

Next select your LUT. Configure the other options if wanted.

Input

image

Determines the lighting model to use on the LUT. Phong or blinn phong is best used. Use fixed lighting for certain effects like cell shading or fresnel if desired.

Scale

image

The LUT intensity.

Geometric Factor

This setting determines to use the normals from the model to affect the specular 0/1 light.

image

Combiners

These combine everything together, similar to shader nodes or tev stages used on Wii/Gamecube. There is up to 6 stages. Each stage has a function to multiply/add/subtract/mix different inputs. Inputs include lighting, shading, textures, and previous stages.

Stages

image

A stage stores a set of inputs A, B and C which get used in a function. These inputs range from textures, shading, lighting and colors. This example I multiply texture times the model shading.

A stage combines multiple functions together.

image

Here I added a stage. Put the last stage (one above it) as an input, then multipled by constant color 5.

You can add stages with Add Stage at the bottom.

image

Inputs

Icon Type Info Preview
image SpecL Controls specular lighting configured by LUTs and specular colors. image
FragmentPrimaryCombinerSource PixelL Controls shading along with using diffuse, ambient and emissive colors. image
VertexCombinerSource VertexL Controls vertex color/alpha. Games with custom vertex shaders may use this for custom effects. image
image PrevStage Uses the last stage on top of the current one.
image PrevBuffer Uses the previous stage of the stage with Update Buffer checked. Else it uses a fixed color.
image Tex0 - Tex2 Select the first, second or third texture maps.
image Constant Selects a specified color.

Functions

image

Here you can use various functions to compute your material. A/B/C being the input values you can configure.

Update Buffer

This is a feature that allows you to save the previous stage to use later.

image

Channel Component

image

Color is made up of red, green and alpha channels. You can switch between red, green, blue and alpha (transparent) channels.

Fresnel Guide

image

If you want glow around your model like this, first go to the LUT tab.

image

Make sure the layer config includes fresnel. If it does not, keep changing until one does with desired effects.

Then select the LUT to use. Also make sure fresnel primary is selected. Fresnel secondary can be toggled for specular if needed.

Lastly use the PixelL alpha channel in the stage tab which will display fresnel

image

You want it to add to the previous stage to show the glow above.

image

If desired, you can multiply a color to PixelL alpha to control the fresnel color.

image