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 WrinkledTexture : public Texture<T> {
00030 public:
00031
00032 ~WrinkledTexture() {
00033 delete mapping;
00034 }
00035 WrinkledTexture(int oct, float roughness, TextureMapping3D *map) {
00036 omega = roughness;
00037 octaves = oct;
00038 mapping = map;
00039 }
00040 T Evaluate(const DifferentialGeometry &dg) const {
00041 Vector dpdx, dpdy;
00042 Point P = mapping->Map(dg, &dpdx, &dpdy);
00043 return Turbulence(P, dpdx, dpdy, omega, octaves);
00044 }
00045 private:
00046
00047 int octaves;
00048 float omega;
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 WrinkledTexture<float>(tp.FindInt("octaves", 8),
00057 tp.FindFloat("roughness", .5f), map);
00058 }
00059
00060 extern "C" DLLEXPORT Texture<Spectrum> * CreateSpectrumTexture(const Transform &tex2world,
00061 const TextureParams &tp) {
00062
00063 TextureMapping3D *map = new IdentityMapping3D(tex2world);
00064 return new WrinkledTexture<Spectrum>(tp.FindInt("octaves", 8),
00065 tp.FindFloat("roughness", .5f), map);
00066 }