Shaders

A shader is a way to assign visual material properties to geometry. They are applied to regions. To apply a shader to a specific region:

  1. Create the model (in our case a sphere: my.sph) and save it as a combination/region(sph.r).

    ShadersShot1
    Figure 1. Create a Sphere Using MGED
  2. Go to the “Edit” button on your Graphics Window/Command Window then click “Combination Editor” button.

    ShadersShot2
    Figure 2. MGED Edit Menu
  3. A new window will open. Hit the button on the right of the Name zone, click “Select from all” and chose the region you want to edit. .Combination Editor image::ShadersShot3.png[]

  4. Hit the “Show Shader” button.

    ShadersShot4
    Figure 3. Show Shader
  5. The window will change and you will be able to see the appearance properties of your region. Default shader for unspecified geometry is “plastic”. You can edit it by choosing from the list that opens if you click the button on the right of the shader zone.

    For you to get the 3D shape you have to raytrace your model. To do that you must write in the Command Window “B sph.r” and then “rt”, after avery change you make to your model. A new window will open with the raytraced model.

    (sph.r is the example model. Where sph.r is written you should write your models name.)

    ShadersShot5
    Figure 4. Raytracing in MGED

    Default:

    ShadersShot6
    Figure 5. Default Raytraced Sphere
    ShadersShot7
    Figure 6. Modifying Attributes
    ShadersShot8
    Figure 7. Object Properties
  6. Change the Transparency, mirror reflectance, Specular reflectivity, Difuse reflectivity, Refractive index, Extinction, Shininess and Emission values, raytracing at the same time, so you can find the shader you want.

    Blue mirror:

    ShadersShot9
    Figure 8. Blue Mirror Attributes
    ShadersShot10
    Figure 9. Blue Mirror
  7. If you want to apply more then one material property you can choose stack from the list. Use the “Add shader” button to add as many shaders you want.

    ShadersShot11
    Figure 10. Add Shader

    Example:

    ShadersShot12
    Figure 11. Set up Shader
    ShadersShot13
    Figure 12. New Settings Example

    You should note that the ordering of the shaders matter.

    If you change their order…​

    ShadersShot14
    Figure 13. Different Order

    You get…​

    ShadersShot15
    Figure 14. New Example

Here you can find an Introduction to MGED and Shaders presentation: Documentation