00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "lux.h"
00026 #include "texture.h"
00027 #include "paramset.h"
00028
00029 namespace lux
00030 {
00031
00032
00033 template <class T1, class T2>
00034 class ScaleTexture : public Texture<T2> {
00035 public:
00036
00037 ScaleTexture(boost::shared_ptr<Texture<T1> > t1,
00038 boost::shared_ptr<Texture<T2> > t2) {
00039 tex1 = t1;
00040 tex2 = t2;
00041 }
00042 T2 Evaluate(
00043 const DifferentialGeometry &dg) const {
00044 return tex1->Evaluate(dg) * tex2->Evaluate(dg);
00045 }
00046
00047 static Texture<float> * CreateFloatTexture(const Transform &tex2world, const TextureParams &tp);
00048 static Texture<Spectrum> * CreateSpectrumTexture(const Transform &tex2world, const TextureParams &tp);
00049 private:
00050 boost::shared_ptr<Texture<T1> > tex1;
00051 boost::shared_ptr<Texture<T2> > tex2;
00052 };
00053
00054
00055 template <class T, class U> inline Texture<float> * ScaleTexture<T,U>::CreateFloatTexture(const Transform &tex2world,
00056 const TextureParams &tp) {
00057 return new ScaleTexture<float, float>(tp.GetFloatTexture("tex1", 1.f),
00058 tp.GetFloatTexture("tex2", 1.f));
00059 }
00060
00061 template <class T,class U> inline Texture<Spectrum> * ScaleTexture<T,U>::CreateSpectrumTexture(const Transform &tex2world,
00062 const TextureParams &tp) {
00063 return new ScaleTexture<Spectrum, Spectrum>(
00064 tp.GetSpectrumTexture("tex1", Spectrum(1.f)),
00065 tp.GetSpectrumTexture("tex2", Spectrum(1.f)));
00066 }
00067
00068 }
00069