User Tools

Site Tools


tutorials:light-modeling-light-shader

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
tutorials:light-modeling-light-shader [2025/01/13 23:17] – extended MHtutorials:light-modeling-light-shader [2025/01/22 15:13] (current) – [Lambert Shader] MH
Line 20: Line 20:
 Lambertian reflection (Lambert 1760) is a widely used reflection model for diffuse reflection. The Lambert reflection model assumes an ideal diffusely reflecting surface, where the apparent brightness to an observer is the same regardless of the observer's angle of view, in this way it the reflected radiant intensity obeys Lambert's cosine law. Lambertian reflection (Lambert 1760) is a widely used reflection model for diffuse reflection. The Lambert reflection model assumes an ideal diffusely reflecting surface, where the apparent brightness to an observer is the same regardless of the observer's angle of view, in this way it the reflected radiant intensity obeys Lambert's cosine law.
  
 +In GroIPM, a shader that simulates a Lambertian reflections can be implemented in two ways. The most straight forward way is to use a //RGBAShader// that just defines a colour (and an optional transparent part). The following code will generate a green box.
 +
 +<code java>
 +protected void init() [
 +    Axiom ==> Box(0.1, 1, 1).(setShader(new RGBAShader(0, 1, 0)));
 +]
 +</code>
 +
 +There are a set for standard coulours (red, green, blue, black, white, etc.) defined that can be used instead. For instance the same green shader from above can be generated using the following code.   
 +
 +<code java>
 +protected void init() [
 +    Axiom ==> Box(0.1, 1, 1).(setShader(GREEN));
 +]
 +</code>
 +
 +The second way would be to use a //Phong// shader and use only the diffuse (reflectance) part of it whereas the not required aspects are turned off. The following will create an equivalent Lambertian reflection using a //Phong// shader object.
 +
 +<code java>
 +protected void init() [
 +    Axiom ==> Box(0.1, 1, 1).(setShader(new Phong().(
 +      setDiffuse(new RGBColor(0,1,0)),
 +      setTransparency(new Graytone(0)), // no transparency
 +      setSpecular(new Graytone(0)), // no specular reflection
 +      setShininess(new Graytone(0)) // no shininess
 +    )));
 +]
 +</code>
  
 ==== Phong Shader ==== ==== Phong Shader ====
tutorials/light-modeling-light-shader.1736806659.txt.gz · Last modified: 2025/01/13 23:17 by MH