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 "pbrt.h"
00026 #include "texture.h"
00027 #include "paramset.h"
00028
00029 template <class T> class WindyTexture : public Texture<T> {
00030 public:
00031
00032 ~WindyTexture() {
00033 delete mapping;
00034 }
00035 WindyTexture(TextureMapping3D *map) {
00036 mapping = map;
00037 }
00038 T Evaluate(const DifferentialGeometry &dg) const {
00039 Vector dpdx, dpdy;
00040 Point P = mapping->Map(dg, &dpdx, &dpdy);
00041 float windStrength =
00042 FBm(.1f * P, .1f * dpdx, .1f * dpdy, .5f, 3);
00043 float waveHeight =
00044 FBm(P, dpdx, dpdy, .5f, 6);
00045 return fabsf(windStrength) * waveHeight;
00046 }
00047 private:
00048
00049 TextureMapping3D *mapping;
00050 };
00051
00052 extern "C" DLLEXPORT Texture<float> * CreateFloatTexture(const Transform &tex2world,
00053 const TextureParams &tp) {
00054
00055 TextureMapping3D *map = new IdentityMapping3D(tex2world);
00056 return new WindyTexture<float>(map);
00057 }
00058
00059 extern "C" DLLEXPORT Texture<Spectrum> * CreateSpectrumTexture(const Transform &tex2world,
00060 const TextureParams &tp) {
00061
00062 TextureMapping3D *map = new IdentityMapping3D(tex2world);
00063 return new WindyTexture<Spectrum>(map);
00064 }