00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if defined(_MSC_VER)
00025 #pragma once
00026 #endif
00027
00028 #ifndef PBRT_TEXTURES_WINDY_H
00029 #define PBRT_TEXTURES_WINDY_H
00030
00031
00032 #include "pbrt.h"
00033 #include "texture.h"
00034 #include "paramset.h"
00035
00036
00037 template <typename T> class WindyTexture : public Texture<T> {
00038 public:
00039
00040 ~WindyTexture() {
00041 delete mapping;
00042 }
00043 WindyTexture(TextureMapping3D *map) : mapping(map) { }
00044 T Evaluate(const DifferentialGeometry &dg) const {
00045 Vector dpdx, dpdy;
00046 Point P = mapping->Map(dg, &dpdx, &dpdy);
00047 float windStrength = FBm(.1f * P, .1f * dpdx, .1f * dpdy, .5f, 3);
00048 float waveHeight = FBm(P, dpdx, dpdy, .5f, 6);
00049 return fabsf(windStrength) * waveHeight;
00050 }
00051 private:
00052
00053 TextureMapping3D *mapping;
00054 };
00055
00056
00057 WindyTexture<float> *CreateWindyFloatTexture(const Transform &tex2world,
00058 const TextureParams &tp);
00059 WindyTexture<Spectrum> *CreateWindySpectrumTexture(const Transform &tex2world,
00060 const TextureParams &tp);
00061
00062 #endif // PBRT_TEXTURES_WINDY_H