#VRML 2.0 utf8

PROTO red [] { PhBLxySpectrum { xy 0.64 0.33 } }
PROTO green [] { PhBLxySpectrum { xy 0.29 0.60 } }
PROTO blue [] { PhBLxySpectrum { xy 0.15 0.06 } }

# prototype for a diffuse RGB image textured surface
PROTO RGBTexturedDiffuseSurface [
 exposedField SFNode texture NULL ,
 exposedField SFNode textureTransform NULL ,
 exposedField SFNode textureProjection NULL
] {
   PROTO Diffuse [ exposedField SFNode spectrum NULL ] { 
      PhBSurface {
	 bsdf PhBSDF { spectrum IS spectrum   scatterer PhBDiffuseReflector {} }
      }
   }

   PhBTexturedSurface {
      texture IS texture
      surfaces [ Diffuse { spectrum red{} }, 
		 Diffuse { spectrum green {} }, 
		 Diffuse { spectrum blue {} } ]
      textureTransform IS textureTransform
      textureProjection IS textureProjection
   }
}

# use it like this:
DEF textured PhBAppearance {
  surface RGBTexturedDiffuseSurface {
    texture ImageTexture {
      url "file:image.gif"
    }
  }
}
