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_UV_H
00029 #define PBRT_TEXTURES_UV_H
00030
00031
00032 #include "pbrt.h"
00033 #include "texture.h"
00034 #include "paramset.h"
00035
00036
00037 class UVTexture : public Texture<Spectrum> {
00038 public:
00039
00040 UVTexture(TextureMapping2D *m) {
00041 mapping = m;
00042 }
00043 ~UVTexture() {
00044 delete mapping;
00045 }
00046 Spectrum Evaluate(const DifferentialGeometry &dg) const {
00047 float s, t, dsdx, dtdx, dsdy, dtdy;
00048 mapping->Map(dg, &s, &t, &dsdx, &dtdx, &dsdy, &dtdy);
00049 float rgb[3] = { s - Floor2Int(s), t - Floor2Int(t), 0.f };
00050 return Spectrum::FromRGB(rgb);
00051 }
00052 private:
00053 TextureMapping2D *mapping;
00054 };
00055
00056
00057 Texture<float> *CreateUVFloatTexture(const Transform &tex2world,
00058 const TextureParams &tp);
00059 UVTexture *CreateUVSpectrumTexture(const Transform &tex2world,
00060 const TextureParams &tp);
00061
00062 #endif // PBRT_TEXTURES_UV_H