The Shader Viewer is a lite-C program. It can be used to look through the scene and model shaders that come with Gamestudio, and to edit shaders and observe the result immediately on the screen. To start it, just run shadertest.c in the projects\shadertest folder.
The Shader Viewer automatically loads every shader addressed in mtlFX.c and mtlView.c with the following comment tags:
//////////////////////////////////////////////////////////////////// //Shader Name: XXX //Material Name: mtl_xxx //Standard Model: xxx.mdl //Variable1: var1 //Variable2: var2 //Variable3: Not used //Variable4: Not used
The Shader Name may consist of a maximum of 24 characters and will be displayed in the Shader Panel. The Material Name must match the existing material identifier. The Standard Model will be loaded when a new shader is selected and must exist in the shadertest folder. Already included are two models: marine.mdl and box.mdl, as well as a terrain water.hmp The marine.mdl model is for demonstration only; if you want to use it for your projects, please license it from http://www.3drt.com.
To change shader-parameters at runtime, the Shader Panel also offers 4 sliders for the scene shader as well as for the model shader. To give a hint what the parameters are for they can be named by the Variable1 to Variable4 comment tags. Within the model shader, the variables are addressed by the vecSkill41 vector and within the scene shaders through the vecSkill1 vector.
General Stuff |
|
Frames/Second |
Shows the actual fps which can be affected by the selected shaders. |
Sky Cube |
Toggle the standard sky cube on/off or load your own. |
Sky & Sun Color |
Set the background color and the sun color. |
Alpha |
Entity alpha value, used by some shaders for adjusting the refraction factor. |
Albedo |
Entity albedo value, used by some shaders for adjusting the reflectitivity. |
Blue Green Red |
Entity blue, green, red values, used by some shaders for tinting the surface color. |
Shader |
|
Scene Shader |
Scroll through the postprocessing shader library or load your own scene shader. |
Shader Variables |
Change the scene shader parameters. |
Model Shader |
Scroll through the surface shader library or load your own surface shader. |
Shader Variables |
Change the four surface shader parameters. |
Material |
Shows the material name |
Ambient |
Adjust the material ambient color. This affects the illumination of the model by static environment light. |
Diffuse |
Adjust the material diffuse color. This affects the illumination of the model by dynamic lights and sun light. |
Emissive |
Adjust the material emissive color. This adds light to the overall illumination. |
Specular |
Adjust the material specular color. This affects the reflection of dynamic lights in view direction. |
Power |
Adjust the material power parameter. This affects the 'sharpness' of specular reflection. |
Model |
|
Open |
Load your own model, map, or terrain entity. |
Skin |
Toggle the model texture. Switch the texture off to see what the shader is doing. |
Skins |
Number of model skins. |
Vertices |
Number of model vertices. |
Selected Skin |
Thumbnail of the selected model skin. |
Shown Skin |
Scroll through the model skins. |
Animation |
Toggle the model animation, if any. |
Frames |
Number of animation frames. |
Scale |
Scale the model to fit it better ontp the screen. |
Light |
|
[+] |
Adds a dynamic light. The light can be selected with the mouse. |
[-] |
Removes the selected light. |
Movement |
Choose a movement behavior for the selected light. You can move it with the mouse, or let it rotate around or swing by the entity. |
Color |
Change the color of the selected light. |
Distance |
Adjust the distance of the selected light to the model. |
All Panels
To move a panel, just press the left mouse button over the button in the upper left corner.
Additional help
In the upper middle part of the window you will always find some additional information about what you are pointing at.
Navigation
To rotate the model entity, press the right mouse-button.
Right click also toggles the autorotation.
To zoom in or out use the mouse-wheel.
Editing a shader
All shader .fx files are located in the code subfolder. For editing a shader, copy the .fx file into the projects\shadertest folder, then start shadertest.c. Move the slider until you see the effect on the screen. You can now open the .fx shader code in SED, and edit it - whenever you save, you'll see the effect of your changes on the screen. If you're getting a syntax error message instead, just fix the error in the shader code and save again.