PhBRML Examples


Simple example

#VRML V2.0 utf8

# unit neutral color
DEF neutral PhBLxySpectrum { xy 0.333333 0.333333 }

# physically based light source appearance
DEF Light PhBAppearance {
  surface PhBHomogeneousSurface {
    edf PhBEDF {
      intensity 10000.   		# [lux]
      spectrum USE neutral
      emitter PhBDiffuseEmitter {}
    }
  }
}

# unit red color
DEF red PhBLxySpectrum { xy 0.6400 0.3300 }

# diffuse red appearance
DEF DiffuseRed PhBAppearance {
  surface PhBHomogeneousSurface {
    bsdf PhBSDF { 
      intensity 0.8   
      spectrum USE red    
      scatterer PhBDiffuseReflector {}
    }
  }
}

# unit blue color
DEF blue PhBLxySpectrum { xy 0.1500 0.0600 }

# shiny blue appearance
DEF ShinyBlue PhBAppearance {
  surface PhBHomogeneousSurface {
    bsdf [
      PhBSDF { intensity 0.2   spectrum USE blue    
               scatterer PhBDiffuseReflector {} },
      PhBSDF { intensity 0.6   spectrum USE neutral 
               scatterer PhBPhongReflector { sharpness 20. } }
    ]
  }
}

Group {
  children [
    Transform {		      # First child: - a light source
      translation 0 0 10
      children [
        Shape {
          geometry Sphere { radius 0.1 }
          appearance USE Light
        }
      ]
    }

    Transform {               # Second child - a diffuse red sphere
      translation 3 0 1
      children [
        Shape {
          geometry Sphere { radius 2.3 }
          appearance USE DiffuseRed
        }
      ]
    }

    Transform {               # Third child - a shiny blue box 
      translation -2.4 .2 1
      rotation     0 1 1  .9
      children [
        Shape {
          geometry Box {}
          appearance USE ShinyBlue
        }
      ]
    }

  ] # end of children for world
}

Water-like atmosphere

# water-like atmosphere
PhBAtmosphere {
  medium PhBMedium {
    indexOfRefraction 1.5 0.0 
    scatteringCrossSection 0.05		# on the average one scattering or
    absorptionCrossSection 0.05		# absorption event per 20 meters.
    phaseFunction [ PhBPhF { 
      spectrum USE lightblue
      phaseFunction PhBIsotropicPhaseFunction {} 
    } ]
  }
}

RGB image textured diffuse surfaces

#VRML V2.0 utf8

# prototype for a diffuse RGB image textured surface
PROTO RGBTexturedDiffuseSurface [
  exposedField SFNode texture NULL
  exposedField SFNode textureTransform NULL
  exposedField SFNode textureProjection NULL
] {
   PROTO DiffuseRed [] {
      PROTO red [] { PhBLxySpectrum { xy 0.64 0.33 } }
      PhBHomogeneousSurface {
	 bsdf [ PhBSDF { spectrum red {}   scatterer PhBDiffuseReflector {} } ]
      }
   }
   PROTO DiffuseGreen [] {
      PROTO green [] { PhBLxySpectrum { xy 0.29 0.60 } }
      PhBHomogeneousSurface {
	 bsdf [ PhBSDF { spectrum green {}  scatterer PhBDiffuseReflector {} } ]
      }
   }
   PROTO DiffuseBlue [] {
      PROTO blue  [] { PhBLxySpectrum { xy 0.15 0.06 } }
      PhBHomogeneousSurface {
	 bsdf [ PhBSDF { spectrum blue {}   scatterer PhBDiffuseReflector {} } ]
      }
   }
   PhBTexturedSurface {
      texture IS texture
      surfaces [ DiffuseRed {}, DiffuseGreen {}, DiffuseBlue {}]
      textureTransform IS textureTransform
      textureProjection IS textureProjection
   }
}

# use it like this:
Transform {
   children Shape {
      appearance DEF text1 PhBAppearance {
	 surface RGBTexturedDiffuseSurface {
	    texture ImageTexture { url "file:image.gif" }
	 }
      }
      geometry Sphere {}
   }
}


This page is maintained by Philippe Bekaert