20 #if !defined(__MITSUBA_HW_VPL_H_)
21 #define __MITSUBA_HW_VPL_H_
67 void setScene(
const Scene *scene);
80 void setVPL(
const VPL &vpl);
103 void bind(
const VPL &vpl,
const BSDF *bsdf,
105 const Matrix4x4 &instanceTransform,
bool faceNormals);
121 void drawAllGeometryForVPL(
const VPL &vpl,
const Sensor *sensor);
124 void drawBackground(
const Sensor *sensor,
173 std::vector<Shader *> deps;
174 shader->putDependencies(deps);
175 for (std::vector<Shader *>::iterator it = deps.begin();
176 it != deps.end(); ++it)
182 : shader(node.shader), children(node.children),
183 parameterIDs(node.parameterIDs) { }
186 inline std::string
generateCode(std::ostringstream &oss,
int &
id)
const {
187 std::vector<std::string> depNames;
188 for (
size_t i=0; i<children.size(); ++i)
189 depNames.push_back(children[i].generateCode(oss,
id));
191 shader->generateCode(oss, evalName, depNames);
198 std::vector<std::string> depNames;
199 for (
size_t i=0; i<children.size(); ++i)
200 children[i].resolve(program,
id);
203 shader->resolve(program, evalName, parameterIDs);
210 for (
size_t i=0; i<children.size(); ++i)
211 children[i].bind(program, targetNode.
children[i], textureUnitOffset);
212 shader->bind(program, targetNode.
parameterIDs, textureUnitOffset);
220 for (
size_t i=0; i<children.size(); ++i)
221 children[i].unbind();
225 inline void toString(std::ostringstream &oss)
const {
228 oss << shader->getClass()->getName();
229 if (children.size() > 0) {
231 for (
size_t i=0; i<children.size(); ++i) {
232 children[i].toString(oss);
233 if (i+1<children.size())
241 std::ostringstream oss;
270 : vpl(vpl), bsdf(bsdf), emitter(emitter), faceNormals(faceNormals), program(NULL) { }
273 inline void generateCode(std::ostringstream &oss, std::string &vplEvalName,
274 std::string &bsdfEvalName, std::string &emitterEvalName)
const {
276 vplEvalName = vpl.generateCode(oss,
id);
277 bsdfEvalName = bsdf.generateCode(oss,
id);
279 emitterEvalName = emitter.generateCode(oss,
id);
285 vpl.resolve(program,
id);
286 bsdf.resolve(program,
id);
288 emitter.resolve(program,
id);
293 vpl.bind(targetConf.
program, targetConf.
vpl, textureUnitOffset);
294 bsdf.bind(targetConf.
program, targetConf.
bsdf, textureUnitOffset);
296 emitter.bind(targetConf.
program, targetConf.
emitter, textureUnitOffset);
309 std::ostringstream oss;
314 if (emitter.shader) {
316 emitter.toString(oss);
319 oss <<
", faceNormals";
329 const std::vector<Renderer::TransformedGPUGeometry> &
geo;
335 const Shader *shader1 = geo[idx1].first->getShader();
336 const Shader *shader2 = geo[idx2].first->getShader();
338 if (shader1 && (shader1->
getFlags() & Shader::ETransparent))
340 if (shader2 && (shader2->
getFlags() & Shader::ETransparent))
343 return shader1 < shader2;
354 ssize_t geometryIndex, ssize_t opaqueGeometryIndex) :
355 trafo(trafo), geometryIndex(geometryIndex),
356 opaqueGeometryIndex(opaqueGeometryIndex) { }
365 std::vector<
Renderer::TransformedGPUGeometry> m_geometry;
366 std::vector<
Renderer::TransformedGPUGeometry> m_opaqueGeometry;
377 int m_backgroundParam_camPosition;
378 int m_backgroundParam_camDirection;
379 int m_backgroundParam_clipToWorld;
380 int m_backgroundParam_emitterScale;
389 Float m_nearClip, m_farClip;
392 bool m_diffuseSources, m_diffuseReceivers;
393 int m_shadowMapResolution;
395 Float m_clamping, m_alpha;
void unbind()
Release resources that were bound by bind()
Definition: vpl.h:216
MTS_EXPORT_CORE std::string formatString(const char *pFmt,...)
Wrapped snprintf.
VPLConfiguration(Shader *vpl, Shader *bsdf, Shader *emitter, bool faceNormals)
Create a new configuration for the given (vpl, bsdf, emitter) triplet.
Definition: vpl.h:269
Float getClamping() const
Return the clamping distance.
Definition: vpl.h:131
const AnimatedTransform * trafo
Definition: vpl.h:349
AnimatedGeometryRecord(const AnimatedTransform *trafo, ssize_t geometryIndex, ssize_t opaqueGeometryIndex)
Definition: vpl.h:353
ssize_t opaqueGeometryIndex
Definition: vpl.h:351
void resolve(GPUProgram *program, int &id)
Resolve all parameters of the shader chain.
Definition: vpl.h:197
Abstract radiance emitter interface.
Definition: emitter.h:443
void setClamping(Float clamping)
Set the clamping distance.
Definition: vpl.h:128
std::string generateCode(std::ostringstream &oss, int &id) const
Generate GLSL code for the entire shader chain.
Definition: vpl.h:186
Shader base class for use with a VPL-style renderer.
Definition: shader.h:54
Utility class for creating different kinds of shadow maps (cube, directional, and paraboloid shadow m...
Definition: shadow.h:32
DependencyNode(const DependencyNode &node)
Copy constructor.
Definition: vpl.h:181
MaterialOrder(const std::vector< Renderer::TransformedGPUGeometry > &geo)
Definition: vpl.h:331
This class is responsible for the on-demand creation of GPU shaders to render shapes that are illumin...
Definition: vpl.h:48
bool operator()(size_t idx1, size_t idx2) const
Definition: vpl.h:334
std::vector< int > parameterIDs
Definition: vpl.h:167
void generateCode(std::ostringstream &oss, std::string &vplEvalName, std::string &bsdfEvalName, std::string &emitterEvalName) const
Generate GLSL code for the entire shader chain.
Definition: vpl.h:273
Principal scene data structure.
Definition: scene.h:49
Describes the configuration of a (vpl, bsdf, emitter) shader chain triplet.
Definition: vpl.h:251
bool faceNormals
Definition: vpl.h:253
Abstract sensor interface.
Definition: sensor.h:66
int param_camPosition
Definition: vpl.h:259
DependencyNode(Shader *shader=NULL)
Create from a Shader object.
Definition: vpl.h:170
uint32_t getFlags() const
Return a list of flags.
Definition: shader.h:70
GPUProgram * program
Definition: vpl.h:254
ssize_t geometryIndex
Definition: vpl.h:350
Abstract shader program (for fragment/vertex shading)
Definition: gpuprogram.h:30
VPLConfiguration()
Dummy constructor.
Definition: vpl.h:266
void unbind()
Release resources that were bound by bind()
Definition: vpl.h:300
const std::vector< Renderer::TransformedGPUGeometry > & geo
Definition: vpl.h:329
bool getDiffuseSources() const
Return whether or not non-diffuse VPLs are used.
Definition: vpl.h:143
Order materials so that they can be drawn with the least number of GPU pipeline flushes. Draw transparent objects last.
Definition: vpl.h:328
int param_minDistSqr
Definition: vpl.h:263
void bind(const VPLConfiguration &targetConf, int textureUnitOffset)
Bind all referenced resources (textures etc)
Definition: vpl.h:292
void resetCounter()
Reset the VPL counter.
Definition: vpl.h:152
int param_shadowMap
Definition: vpl.h:260
const Scene * getScene() const
Return the currently bound scene.
Definition: vpl.h:70
int getShadowMapResolution() const
Return the current shadow map resolution.
Definition: vpl.h:137
void setDiffuseSources(bool diffuseSources)
Set whether or not non-diffuse VPLs are used.
Definition: vpl.h:140
Helper data structure to keep track of shapes that are undergoing keyframe animations.
Definition: vpl.h:348
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
int param_vplPosition
Definition: vpl.h:258
Reference counting helper.
Definition: ref.h:40
void setShadowMapResolution(int resolution)
Set the current shadow map resolution.
Definition: vpl.h:134
void resolve(GPUProgram *program)
Resolve all parameters of the shader chain.
Definition: vpl.h:283
Abstract BSDF base-class.
Definition: bsdf.h:215
DependencyNode vpl
Definition: vpl.h:252
Abstract renderer implementation.
Definition: renderer.h:79
std::string toString() const
Definition: vpl.h:240
A data structure for 1/2/3D and cube texture mapping. Also has optional render-to-texture functionali...
Definition: gputexture.h:32
This helper class stores a reference to a Shader and all sub-shaders that are part of its evaluation...
Definition: vpl.h:164
void bind(GPUProgram *program, const DependencyNode &targetNode, int &textureUnitOffset)
Bind all referenced resources (textures etc)
Definition: vpl.h:207
Basic 4x4 matrix data type.
Definition: matrix.h:656
void setDiffuseReceivers(bool diffuseReceivers)
Set whether or not surfaces are drawn assumed to be diffuse.
Definition: vpl.h:146
const Shader * shader
Definition: vpl.h:165
std::vector< DependencyNode > children
Definition: vpl.h:166
void toString(std::ostringstream &oss) const
Generate a textual summary of the entire shader chain.
Definition: vpl.h:225
bool getDiffuseReceivers() const
Return whether or not surfaces are assumed to be diffuse.
Definition: vpl.h:149
int param_vplPower
Definition: vpl.h:261
int param_vplWi
Definition: vpl.h:262
std::string toString() const
Generate a textual summary of the entire shader chain.
Definition: vpl.h:308
Parent of all Mitsuba classes.
Definition: object.h:38
DependencyNode bsdf
Definition: vpl.h:252
int param_vplTransform
Definition: vpl.h:257
DependencyNode emitter
Definition: vpl.h:252