01_user_documentation:05_object:02_light:12_shaders
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| 01_user_documentation:05_object:02_light:12_shaders [2025/01/30 12:18] – ↷ Links adapted because of a move operation gaetan | 01_user_documentation:05_object:02_light:12_shaders [2025/05/30 17:29] (current) – sophiewachtel | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ~~NOTOC~~ | ~~NOTOC~~ | ||
| - | ====== | + | ====== |
| + | |||
| + | A **shader** is a component that implements a *local illumination model* in GroIMP, defining how light interacts with the surface of an object. The local illumination model is the theoretical framework that describes how incoming light is absorbed, reflected, or transmitted by surfaces at a local point. A shader is the concrete implementation of this model, encoded as an object or class in GroIMP that controls these optical properties for rendering and simulation purposes. | ||
| + | |||
| + | It specifies the optical properties such as **absorption**, | ||
| + | |||
| + | |||
| + | ==== Common Shader Types ==== | ||
| + | |||
| + | For implementation and parameter setting see the tutorial [[02_user_tutorials: | ||
| + | |||
| + | === Lambert Shader === | ||
| + | Lambertian reflection (Lambert, 1760) is a widely used model for diffuse reflection. It assumes an ideal diffusely reflecting surface, where the apparent brightness remains constant regardless of the observer’s viewing angle. Consequently, | ||
| + | |||
| + | === Phong Shader === | ||
| + | A Phong shader represents a Phong-like reflector. Its bidirectional reflection/ | ||
| + | |||
| + | At a given point x, let c< | ||
| + | |||
| + | c< | ||
| + | |||
| + | Let c< | ||
| + | |||
| + | Now if // | ||
| + | |||
| + | * k< | ||
| + | |||
| + | * k< | ||
| + | |||
| + | * k< | ||
| + | |||
| + | Otherwise, set | ||
| + | |||
| + | * k< | ||
| + | |||
| + | * k< | ||
| + | |||
| + | * k< | ||
| + | |||
| + | The bidirectional reflection distribution function is | ||
| + | |||
| + | BRDF(x, ω< | ||
| + | |||
| + | where β is the angle between ω< | ||
| + | |||
| + | BTDF(x, ω< | ||
| + | |||
| + | where η stands for the index of refraction, T for the direction of transmission according to Fresnel' | ||
| + | |||
| + | The Phong shader supports: | ||
| + | |||
| + | - `setDiffuse()` — sets the diffuse (reflected) component | ||
| + | - `setTransparency()` — sets how much light is transmitted | ||
| + | - `setSpecular()` — sets the mirror-like reflection for highlights | ||
| + | - `setShininess()` — controls the size and sharpness of specular highlights | ||
| + | - `setAmbient()` — ambient light scattering in the scene | ||
| + | - `setEmissive()` — defines self-emission of light | ||
| + | - `setInterpolatedTransparency()` — toggles interpolation of transmitted light | ||
| + | |||
| + | |||
| + | Below is an illustration of the effect of specular and shininess: | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | Note: In modern Phong shader implementations, | ||
| + | |||
| + | === Switch Shader === | ||
| + | |||
| + | This abstract base class defines a shader which switches between a set of actual shaders based on the shading environment and ray direction. This can be used, e.g., to use different shaders for front and back side (// | ||
| + | |||
| + | |||
| + | == Algorithm Switch Shader == | ||
| + | The // | ||
| + | |||
| + | * //public AlgorithmSwitchShader (Shader guiShader, Shader raytracerShader, | ||
| + | * //public AlgorithmSwitchShader (Shader guiShader, Shader radiationShader)// | ||
| + | |||
| + | Personal note: I nearly never use the // | ||
| + | |||
| + | == Side Switch Shader == | ||
| + | The // | ||
| + | |||
| + | |||
| + | ===== References ===== | ||
| + | |||
| + | * Lambert JH, Photometria, | ||
| + | * Phong BT, Illumination of Computer-Generated Images, Department of Computer Science, University of Utah, UTEC-CSc-73-129, | ||
| - | Shaders | ||
| ====== ====== | ====== ====== | ||
| {{namespace> | {{namespace> | ||
01_user_documentation/05_object/02_light/12_shaders.1738235893.txt.gz · Last modified: 2025/01/30 12:18 by gaetan
