Spaces:
Running
on
Zero
Running
on
Zero
File size: 4,547 Bytes
5f9d349 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
/*
* Copyright (C) 2020, Inria
* GRAPHDECO research group, https://team.inria.fr/graphdeco
* All rights reserved.
*
* This software is free for non-commercial, research and evaluation use
* under the terms of the LICENSE.md file.
*
* For inquiries contact [email protected] and/or [email protected]
*/
#pragma once
# include "Config.hpp"
# include <core/system/Config.hpp>
# include <core/graphics/Texture.hpp>
# include <core/graphics/Shader.hpp>
# include <core/graphics/Mesh.hpp>
# include <core/renderer/RenderMaskHolder.hpp>
namespace sibr {
/** Second version of the ULR render. use separate samplers for each input image.
*/
class SIBR_EXP_ULR_EXPORT ULRV2Renderer : public RenderMaskHolder
{
SIBR_CLASS_PTR(ULRV2Renderer);
/** Constructor.
*\param cameras input cameras
*\param w rendering width
*\param h rendering height
*\param maxCams maximum number of cameras selcted for rendering a frame
*\param fShader name of the fragment shader
*\param vShader name of the vertex shader
*\param facecull should backface culling be performed during the prepass.
**/
ULRV2Renderer(const std::vector<InputCamera::Ptr> & cameras, const uint w, const uint h, const unsigned int maxCams = 0, const std::string & fShader = "ulr/ulr_v2", const std::string & vShader = "ulr/ulr_v2", const bool facecull = true);
/** Setup the ULR shaders.
*\param fShader name of the fragment shader
*\param vShader name of the vertex shader
**/
void setupULRshader(const std::string & fShader = "ulr/ulr_v2", const std::string & vShader = "ulr/ulr_v2");
/** Render.
*\param imgs_ulr vector of selected image IDs
*\param eye novel viewpoint
*\param scene the scene to render
*\param altMesh optional alternative mesh
*\param inputRTs the RGBD input images
*\param dst destination target
*/
void process(const std::vector<uint>& imgs_ulr, const sibr::Camera& eye,
const sibr::BasicIBRScene::Ptr& scene,
std::shared_ptr<sibr::Mesh>& altMesh,
const std::vector<std::shared_ptr<RenderTargetRGBA32F> >& inputRTs,
IRenderTarget& dst);
/** Should occlusion testing be performed.
*\param val true if testing should occur
*/
void doOccl(bool val) { _doOccl = val; }
/** \return a reference to the occlusion threshold */
float & epsilonOcclusion() { return _epsilonOcclusion; }
/** Are the mask smooth values or binary.
*\param val true if they are binary
*/
void setAreMasksBinary(bool val) { _areMasksBinary = val; }
/** Should the masks be inverted.
*\param val true if they should
*/
void setDoInvertMasks(bool val) { _doInvertMasks = val; }
/** Should black pixels be ignored when accumulating colors.
*\param val true if they should be ignored
*/
void setDiscardBlackPixels(bool val) { _discardBlackPixels = val; }
/** Should backface culling be performed.
*\param val true if it should
*/
void setCulling(bool val) { _shouldCull = val; }
/** \return a pointer to the soft visibility texture array if it exists */
Texture2DArrayLum32F * & getSoftVisibilityMaps(void) { return soft_visibility_maps; }
/** \return a reference to the soft visibility threshold. */
sibr::GLuniform<float> & getSoftVisibilityThreshold() { return _soft_visibility_threshold; }
/** \return a pointer to the ULR OpenGL program. */
sibr::GLShader * getProgram() { return &_ulrShader; }
/** \return the number of cameras */
size_t getNumCams() { return _numCams; }
public:
sibr::RenderTargetRGBA32F::Ptr _depthRT; ///< the prepass render target.
private:
sibr::GLShader _ulrShader;
sibr::GLShader _depthShader;
std::vector<sibr::GLParameter> _icamProj;
std::vector<sibr::GLParameter> _icamPos;
std::vector<sibr::GLParameter> _icamDir;
std::vector<sibr::GLParameter> _inputRGB;
std::vector<sibr::GLParameter> _masks;
std::vector<sibr::GLuniform<int> > _selected_cams;
Texture2DArrayLum32F * soft_visibility_maps;
sibr::GLuniform<float> _soft_visibility_threshold;
sibr::GLuniform<bool> _use_soft_visibility;
sibr::GLParameter _occTest;
sibr::GLParameter _areMasksBinaryGL;
sibr::GLParameter _doInvertMasksGL;
sibr::GLParameter _discardBlackPixelsGL;
sibr::GLParameter _doMask;
sibr::GLParameter _ncamPos;
sibr::GLParameter _camCount;
sibr::GLParameter _proj;
sibr::GLuniform<float> _epsilonOcclusion;
bool _doOccl;
bool _areMasksBinary;
bool _doInvertMasks;
bool _discardBlackPixels;
bool _shouldCull;
size_t _numCams;
};
} /*namespace sibr*/
|