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/06/03 10:04] MHtutorials:light-modeling-light-shader [2025/12/10 06:33] (current) – [Phong Shader] MH
Line 121: Line 121:
  
 Note: In modern Phong shader implementations, roughness and glossiness are used instead of specular and shininess. Note: In modern Phong shader implementations, roughness and glossiness are used instead of specular and shininess.
 +
 +=== Common Shader Definitions ===
 +
 +There are a few common optical properties that one will regularly face. Things like mirror effects, or glass shader are just two of them. Below some examples on how to define these common shaders in GroIMP.
 +
 +<code java>
 +// mirror
 +static Phong mirrorShader = new Phong();
 +static {
 +  mirrorShader.setDiffuse(new RGBColor(0.0, 0.0, 0.0)); // should work with black and white as base colour
 +  mirrorShader.setSpecular(new Graytone(1));
 +  mirrorShader.setShininess(new Graytone(1));
 +}
 +
 +
 +// glass
 +static Phong glassShader = new Phong();
 +static {
 +  glassShader.setDiffuse(new RGBColor(1.0, 1.0, 1.0)); // base colour white
 +  glassShader.setDiffuseTransparency(new Graytone(0.97)); // 97% transparent
 +  glassShader.setSpecular(new Graytone(0.5));
 +  glassShader.setShininess(new Graytone(0.5)); 
 +}
 +
 +// semi-transparent
 +static Phong semiTransparentShader = new Phong();
 +static {
 +  semiTransparentShader.setDiffuse(new Graytone(1,0)); // base colour white
 +  semiTransparentShader.setDiffuseTransparency(new Graytone(0.5)); // 50% transparent
 +}
 +
 +// total absorber (pure black, reflecting nothing)
 +static Phong absorberShader = new Phong();
 +static {
 +  absorberShader.setDiffuse(new Graytone(0..0));
 +}
 +
 +// red reflector (only reflecting red)
 +static Phong redShader = new Phong();
 +static {
 +  redShader.setDiffuse(new RGBColor(1.0, 0.0, 0.0));
 +}
 +</code>
  
  
tutorials/light-modeling-light-shader.txt · Last modified: 2025/12/10 06:33 by MH