- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3.7k
Material System Details
        IanLilleyT edited this page Jun 22, 2012 
        ·
        42 revisions
      
    Design and implementation ideas for our material system.
- Done: Add simple tests that verify the material by rendering a polygon. Currently, we don't have tests for most materials._
- Done: Explore materials implemented using procedural textures, i.e., brick, marble, granite, wood, asphalt, etc. Later, we'll procedurally shade a city with these building blocks._
- Done: Add better reference documentation._
- Done: Add an opacity/alpha map material.
- Done: Decouple diffuse and specular components.
- Split agi_getMaterialColorinto two separate GLSL functions:agi_getMaterialDiffuseComponentandagi_getMaterialSpecularComponent.
- Add gloss/specular map material.
- This will slightly impact the lighting code.
 
- Split 
- Done: Allow the material to modify the surface normal.
- Add a third GLSL function that materials can optionally implement called agi_getMaterialNormalthat takes and returns a normal.
- Implement a bump map material using this. Implement a normal map material too.
 
- Add a third GLSL function that materials can optionally implement called 
- Done: Add the world-space eye direction, i.e. the vector from the camera to the fragment in world coordinates, to agi_getMaterial*(or do we only need it foragi_getMaterialDiffuseComponentinitially?). Use this to implement:- A diffuse reflective material that uses an environment map for reflection, and a 2D texture for the diffuse component.  Blend these with a reflectivityparameter.
- A diffuse refractive material that also uses an environment map. Expose the two indices of refraction.
- A Fresnel material - approximate, of course.
- Include optional reflection and refractive maps for the above reflective and refractive materials, maybe Fresnel.
 
- A diffuse reflective material that uses an environment map for reflection, and a 2D texture for the diffuse component.  Blend these with a 
- Done: All materials should return the specular exponent.
- Done: All materials should return the emission color.
- Add a material for an emission map.
 
- Polylines
- Polylines currently use very simple shaders, and are rendered in three passes using the stencil buffer to achieve an outline effect (turn ANGLE off; start Chrome with --use-gl=desktop).
- Replace the three-pass algorithm with a single pass algorithm that, in a fragment shader, uses the distance from the fragment to the line to determine if the fragment is part of the outline. Read Tron, Volumetric Lines, and Meshless Tubes.
- First hard-code the above in the Polyline, then factor it out into a new PolylineOutlineMaterial.
- Create a PolylineGlowMaterialbased on Tron, Volumetric Lines, and Meshless Tubes.
- Make Polylines work with the rest of the materials as reasonable. Polylines will need to be able to compute at least 1D texture coordinates. I could see some potential for 2D and 3D coordinates as well. All materials will not work with all primitives. We'll need to document a feature matrix.
 
- Polylines currently use very simple shaders, and are rendered in three passes using the stencil buffer to achieve an outline effect (turn ANGLE off; start Chrome with 
- How do we combine multiple materials, e.g.,
- A diffuse map and an alpha map to render .png files, for example. See #43.
- A diffuse map and a specular map.
- Crumbling bricks that combine brick and bump map materials.
- A bumpy diffuse reflective surface that combines the bump map and diffuse reflection materials.
- A diffuse map, diffuse reflective, specular map, and bump map. A bumpy, diffuse lit and reflective surface with shiny areas.
- Blend two diffuse maps based on a parameter, e.g., terrain height, or third map.
 
- Implement the CentralBodyfragment shader using materials, instead of hard-coding bump, specular, etc.
Details to follow...
- Different lighting models. Consider Phong, Blinn-Phong, Gaussian, Cook-Torrance, Oren-Nayar, Strauss, Ward, and Ashikhmin-Shirley. Which are most useful? Which fit best into our engine? See Learning Modern 3D Graphics Programming and Programming Vertex, Geometry, and Pixel Shaders.
- Light types: point, direction, spot. Area?
- Multiple lights: turn lights on/off per primitive.  This will replace affectedByLightingon Polygon and CentralBody.
- How does this fit with the effects framework for models? Can they work well together?
- How important is it to support multiple texture coordinates, i.e., different coordinates for different materials on the same object?
- Do we have a need for relief mapping, etc?
- How do screen-space techniques like fog, glow, and bloom fit in?
- Effects frameworks like CgFX, Direct3D 10 FX Files, and COLLADA FX have materials as does every graphics engine under the sun, such as: