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 virtual ~ScaleTexture() { }
00043 virtual T2 Evaluate(const TsPack *tspack, const DifferentialGeometry &dg) const {
00044 return tex1->Evaluate(tspack, dg) * tex2->Evaluate(tspack, dg);
00045 }
00046 virtual void SetPower(float power, float area) {
00047
00048 tex1->SetPower(power, area);
00049 tex2->SetPower(power, area);
00050 }
00051 virtual void SetIlluminant() {
00052
00053 tex1->SetIlluminant();
00054 tex2->SetIlluminant();
00055 }
00056 static Texture<float> * CreateFloatTexture(const Transform &tex2world, const TextureParams &tp);
00057 static Texture<SWCSpectrum> * CreateSWCSpectrumTexture(const Transform &tex2world, const TextureParams &tp);
00058 private:
00059 boost::shared_ptr<Texture<T1> > tex1;
00060 boost::shared_ptr<Texture<T2> > tex2;
00061 };
00062
00063
00064 template <class T, class U> inline Texture<float> * ScaleTexture<T,U>::CreateFloatTexture(const Transform &tex2world,
00065 const TextureParams &tp) {
00066 return new ScaleTexture<float, float>(tp.GetFloatTexture("tex1", 1.f),
00067 tp.GetFloatTexture("tex2", 1.f));
00068 }
00069
00070 template <class T,class U> inline Texture<SWCSpectrum> * ScaleTexture<T,U>::CreateSWCSpectrumTexture(const Transform &tex2world,
00071 const TextureParams &tp) {
00072 return new ScaleTexture<SWCSpectrum, SWCSpectrum>(
00073 tp.GetSWCSpectrumTexture("tex1", RGBColor(1.f)),
00074 tp.GetSWCSpectrumTexture("tex2", RGBColor(1.f)));
00075 }
00076
00077 }
00078