Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
content badge
swh:1:cnt:afdb582082df91cffeeea2775ddf4884ff5232f7

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
(requires biblatex-software package)
Generating citation ...
/*

Copyright 2018 Lingqi Yan

This file is part of WaveOpticsBrdf.

WaveOpticsBrdf is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

WaveOpticsBrdf is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with WaveOpticsBrdf.  If not, see <https://www.gnu.org/licenses/>.

*/

#ifndef WDF_H
#define WDF_H

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <complex>
#include <vector>
#include <Eigen/Dense>
#include "exrimage.h"
#include "gaborkernel.h"

using namespace std;
using namespace Eigen;

class EXRImage;

struct Query {
    Vector2 mu_p;
    Float sigma_p;
    Vector2 omega_i;
    Vector2 omega_o;

    Float lambda;           // in microns.
};

// Heightfield.
// Suppose it starts from (0, 0) and
// extends to positive (w * mTexelWidth, h * mTexelWidth) and
// is tiling along both axes.
class Heightfield {
public:
    Heightfield() {}
    Heightfield(EXRImage *heightfieldImage, Float texelWidth = 1.0, Float vertScale = 1.0)
        : mHeightfieldImage(heightfieldImage), mTexelWidth(texelWidth), mVertScale(vertScale) {}
    GaborKernel g(int i, int j, Float F, Float lambda);

    Vector2 n(Float i, Float j);
public:
    EXRImage *mHeightfieldImage;
    Float mTexelWidth;      // in microns.
    Float mVertScale;
};

class BrdfBase {
public:
    BrdfBase() {}
    BrdfBase(Heightfield *heightfield) : mHeightfield(heightfield) {}
public:
    virtual Float queryBrdf(const Query &query) = 0;
    virtual Float* genBrdfImage(const Query &query, int resolution) = 0;

protected:
    Heightfield *mHeightfield;
};

class GeometricBrdf: public BrdfBase {
public:
    GeometricBrdf() {}
    GeometricBrdf(Heightfield *heightfield, int sampleNum = 10000000) : mHeightfield(heightfield), mSampleNum(sampleNum) {}
    Float* genNdfImage(const Query &query, int resolution);
    virtual Float queryBrdf(const Query &query);
    virtual Float* genBrdfImage(const Query &query, int resolution);
protected:
    Heightfield *mHeightfield;
private:
    int mSampleNum;
};


class WaveBrdf: public BrdfBase {
public:
    WaveBrdf() {}
    WaveBrdf(Heightfield *heightfield) : mHeightfield(heightfield) {}
    virtual Float queryBrdf(const Query &query);
    virtual Float* genBrdfImage(const Query &query, int resolution);
protected:
    Heightfield *mHeightfield;
};

class WaveBrdfAccel: public WaveBrdf {
public:
    WaveBrdfAccel() {}

    WaveBrdfAccel(Heightfield *heightfield, string method);

    comp queryIntegral(const Query &query, int layer, int xIndex, int yIndex);
    virtual Float queryBrdf(const Query &query);
    virtual Float* genBrdfImage(const Query &query, int resolution);

protected:
    Heightfield *mHeightfield;

private:
    vector<vector<GaborKernelPrime>> gaborKernelPrime;
    vector<vector<vector<AABB>>> angularBB;
    int mTopLayer;

public:
    string mMethod;
};

#endif

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API