Maya 1.0
|
Heightfield rendering widget based on sphere-tracing. More...
#include <realtime.h>
Public Member Functions | |
TerrainRaytracingWidget (QWidget *parent=nullptr) | |
Default constructor. | |
~TerrainRaytracingWidget () | |
Destructor. Release shader program, vao and textures. | |
virtual void | SetHeightField (ScalarField2 *hfPtr) |
Internal update function of the widget. | |
virtual void | UpdateInternal () |
Update the GPU data from the internal CPU heightfield pointer. | |
void | UpdateBuffer (GLuint) |
Manually change the underlying heightfield buffer. | |
void | SetShading (const ScalarField2 &) |
Set the additional shading buffer that can be used by the glsl. | |
void | UseShading (const bool &=true) |
Set the additional shading flag. | |
void | SetExternAlbedo (GLuint) |
Update the albedo texture with an existing OpenGL texture. UseAlbedo(true) should have been called before, or no update will be performed. | |
void | UseExternAlbedo (const bool &=true) |
Update the albedo texture flag. | |
void | SetAlbedo (const QImage &) |
Update the albedo texture. UseAlbedo(true) should have been called before, or no update will be performed. | |
void | UseAlbedo (const bool &=true) |
Update the internal albedo texture flag. | |
void | UseWireframe (const bool &=true) |
Set the wireframe flag. | |
void | UseCost (const bool &=true) |
Set the cost shading flag. | |
void | UseElevationShading (const bool &) |
Set the elevation shading flag. | |
void | UseGreenBrownYellowShading (const bool &) |
Set the shading from color map flag. | |
void | SetCamera (const Camera &) |
Function override from AbstractTerrainWidget. | |
void | Reload () |
Hot reload of the glsl program. Properly rebinds the albedo texture. | |
void | SetElevationRange (double, double) |
Set the elevation range for the terrain. | |
void | SetSteps (int) |
Set the maximum number of raymarching step. | |
void | SetEpsilon (float) |
Set the minimum stepping distance for raymarching. | |
void | SetLight (const Vector &) |
Set the directional light. | |
void | SetAntialiasing (int) |
Set the amount of antialiasing. | |
void | UseSmoothShadow (const bool &=true) |
Set the smooth shadow flag. | |
void | SetSmoothShadowSteps (int) |
Set the number of smooth shadow steps. | |
void | SetSmoothShadowMarchingSteps (int) |
Set the maximum number of smooth shadow raymarching steps. | |
void | SetSmoothShadowMarchingEpsilon (float) |
Set the minimum marching epsilon for smooth shadow rays. | |
void | SetSmoothShadowStrength (float) |
Set the smooth shadow strength. | |
void | UseSelfShadow (const bool &=true) |
Set the smooth shadow flag. | |
void | SetSelfShadowMarchingSteps (int) |
Set the maximum number of self shadow raymarching steps. | |
void | SetSelfShadowMarchingEpsilon (float) |
Set the minimum marching epsilon for self shadow rays. | |
void | SetSelfShadowStrength (float) |
Set the self shadow strength. | |
Protected Attributes | |
ScalarField2 * | sf = nullptr |
Pointer to heightfield. | |
Box2 | bbox |
Bounding box of the heightfield. | |
float | zMax = 0.0 |
Min/max elevation of the heighfield. | |
float | K = 1.0 |
Global Lipschitz constant of the heightfield. | |
int | ny = 0 |
Grid sizes. | |
GLuint | shaderProgram = 0 |
GL program for shader. | |
GLuint | raytraceVAO = 0 |
Raytracer VAO. | |
GLBuffer | hfBuffer |
Heightfield elevation buffer. | |
GLBuffer | shadingBuffer |
Shading buffer. | |
std::vector< float > | tmpData |
Temporary float vector. | |
GLuint | albedoTextureBuffer = 0 |
Albedo texture buffer. | |
GLuint | externAlbedo = 0 |
Extern albedo texture buffer. | |
bool | useAlbedo = false |
Albedo texture flag. | |
bool | useWireframe = false |
Wireframe flag. | |
bool | useCost = false |
Cost shading flag. | |
bool | useElevationShading = false |
Elevation shading flag. | |
bool | useGreenBrownYellow = false |
Shading from color map flag. | |
bool | useShadingBuffer = false |
Additional shading buffer use flag. | |
Heightfield rendering widget based on sphere-tracing.
void TerrainRaytracingWidget::SetAlbedo | ( | const QImage & | albedo | ) |
Update the albedo texture. UseAlbedo(true) should have been called before, or no update will be performed.
albedo | texture |
References albedoTextureBuffer, sf, and shaderProgram.
void TerrainRaytracingWidget::SetAntialiasing | ( | int | AA | ) |
Set the amount of antialiasing.
AA | antialiasing, should be between [1, 128]. |
References shaderProgram.
void TerrainRaytracingWidget::SetCamera | ( | const Camera & | cam | ) |
Function override from AbstractTerrainWidget.
Used to store the camera vertical angle of view, which avoids calling atan() intensively.
cam | new camera |
void TerrainRaytracingWidget::SetElevationRange | ( | double | min, |
double | max ) |
void TerrainRaytracingWidget::SetEpsilon | ( | float | eps | ) |
Set the minimum stepping distance for raymarching.
eps | minimum stepping distance |
References shaderProgram.
void TerrainRaytracingWidget::SetExternAlbedo | ( | GLuint | texture | ) |
Update the albedo texture with an existing OpenGL texture. UseAlbedo(true) should have been called before, or no update will be performed.
albedo | texture |
References externAlbedo, sf, and shaderProgram.
|
virtual |
Internal update function of the widget.
Updates the internal height buffer from the heightfield pointer, recomputes the Lipschitz constant and min/max elevations.
References sf, and UpdateInternal().
void TerrainRaytracingWidget::SetLight | ( | const Vector & | light | ) |
Set the directional light.
light | light direction |
References shaderProgram, and VectorFloat::z.
void TerrainRaytracingWidget::SetSelfShadowMarchingEpsilon | ( | float | eps | ) |
Set the minimum marching epsilon for self shadow rays.
eps | marching epsilon |
References shaderProgram.
void TerrainRaytracingWidget::SetSelfShadowMarchingSteps | ( | int | steps | ) |
Set the maximum number of self shadow raymarching steps.
steps | max number of steps |
References shaderProgram.
void TerrainRaytracingWidget::SetSelfShadowStrength | ( | float | strength | ) |
void TerrainRaytracingWidget::SetShading | ( | const ScalarField2 & | shading | ) |
Set the additional shading buffer that can be used by the glsl.
shading | 2D shading map, must be the same size as the underlying heightfield. |
References ScalarField2::at(), sf, shadingBuffer, and tmpData.
void TerrainRaytracingWidget::SetSmoothShadowMarchingEpsilon | ( | float | eps | ) |
Set the minimum marching epsilon for smooth shadow rays.
eps | marching epsilon |
References shaderProgram.
void TerrainRaytracingWidget::SetSmoothShadowMarchingSteps | ( | int | steps | ) |
Set the maximum number of smooth shadow raymarching steps.
steps | max number of steps |
References shaderProgram.
void TerrainRaytracingWidget::SetSmoothShadowSteps | ( | int | steps | ) |
void TerrainRaytracingWidget::SetSmoothShadowStrength | ( | float | strength | ) |
void TerrainRaytracingWidget::SetSteps | ( | int | s | ) |
void TerrainRaytracingWidget::UpdateBuffer | ( | GLuint | buffer | ) |
Manually change the underlying heightfield buffer.
This function is useful when performing erosion on the gpu - no need to retrieve the data on the CPU and manually recreate all the buffers.
Note that the buffer must contain data whose size is equal to the base heightfield.
buffer | initialized buffer with elevation data. |
References hfBuffer.
|
virtual |
Update the GPU data from the internal CPU heightfield pointer.
This function is computationally intensive as it recomputes the Lipschitz constant of the terrain and send data to the GPU.
References bbox, hfBuffer, K, ny, sf, shadingBuffer, tmpData, and zMax.
Referenced by SetHeightField().
void TerrainRaytracingWidget::UseAlbedo | ( | const bool & | u = true | ) |
Update the internal albedo texture flag.
u | new value for albedo flag. |
References useAlbedo.
void TerrainRaytracingWidget::UseCost | ( | const bool & | cost = true | ) |
void TerrainRaytracingWidget::UseElevationShading | ( | const bool & | u | ) |
Set the elevation shading flag.
u | flag |
References useElevationShading, and useGreenBrownYellow.
void TerrainRaytracingWidget::UseExternAlbedo | ( | const bool & | u = true | ) |
Update the albedo texture flag.
u | new value for albedo flag. |
void TerrainRaytracingWidget::UseGreenBrownYellowShading | ( | const bool & | u | ) |
Set the shading from color map flag.
u | flag |
References useElevationShading, and useGreenBrownYellow.
void TerrainRaytracingWidget::UseSelfShadow | ( | const bool & | use = true | ) |
void TerrainRaytracingWidget::UseShading | ( | const bool & | use = true | ) |
void TerrainRaytracingWidget::UseSmoothShadow | ( | const bool & | use = true | ) |
void TerrainRaytracingWidget::UseWireframe | ( | const bool & | wire = true | ) |