1#include <Corrade/Utility/Resource.h>
2#include <Magnum/GL/AbstractShaderProgram.h>
3#include <Magnum/GL/Shader.h>
4#include <Magnum/GL/Texture.h>
5#include <Magnum/GL/Version.h>
14 Utility::Resource rs(
"data");
16 GL::Shader vertShader{GL::Version::GL460, GL::Shader::Type::Vertex};
17 GL::Shader fragShader{GL::Version::GL460, GL::Shader::Type::Fragment};
18 vertShader.addSource(rs.getString(
"RayMarchingShader.vert"));
19 fragShader.addSource(rs.getString(
"RayMarchingShader.frag"));
21 CORRADE_INTERNAL_ASSERT_OUTPUT(vertShader.compile() && fragShader.compile());
22 this->attachShaders({vertShader, fragShader});
23 CORRADE_INTERNAL_ASSERT(this->link());
34 this->
SSSUniform = this->uniformLocation(
"enableSubsurfaceScattering");
A class representing the shader responsible for the ray marching of the application.
Definition RayMarchingShader.h:10
Int projectionMatrixUniform
Definition RayMarchingShader.h:159
void setSSSMode(const UnsignedInt &mode)
Set the subsurface scattering mode uniform. This is used to determine how to render the subsurface sc...
Definition RayMarchingShader.h:121
Int SSSModeUniform
Definition RayMarchingShader.h:166
Int subSurfaceStrengthUniform
Definition RayMarchingShader.h:170
void setSurfaceColor(const Color3 &color)
Set the surface color uniform. This decides in which color to render the surface.
Definition RayMarchingShader.h:133
void setReflectionCount(const UnsignedInt &reflectionCount)
Set the reflection count uniform. This decides how many times the ray is reflected.
Definition RayMarchingShader.h:127
@ StructureTextureUnit
Definition RayMarchingShader.h:152
@ SDFTextureUnit
Definition RayMarchingShader.h:151
@ StructureMaskTextureUnit
Definition RayMarchingShader.h:154
@ StructurePosTextureUnit
Definition RayMarchingShader.h:153
Int surfaceColorUniform
Definition RayMarchingShader.h:168
Int SSSUniform
Definition RayMarchingShader.h:165
Int surfaceRenderingModeUniform
Definition RayMarchingShader.h:162
void setCameraPosition(const Vector3 &position)
Update the camera position uniform of this shader.
Definition RayMarchingShader.h:85
void setSubSurfaceStrength(const float strength)
Set the subsurface strength uniform. This is used for determining how strong the subsurface scatterin...
Definition RayMarchingShader.h:145
void setViewportSize(const Vector2ui &viewportSize)
Update the viewport size uniform of this shader.
Definition RayMarchingShader.h:67
void setSSS(const bool SSS)
Set the subsurface scattering uniform. This is used to determine whether to render the subsurface sca...
Definition RayMarchingShader.h:115
void setDisplayMode(const UnsignedInt &mode)
Set the display mode uniform. This decides whether to render the structure, the surface,...
Definition RayMarchingShader.h:103
Int subSurfaceColorUniform
Definition RayMarchingShader.h:169
void setViewMatrix(const Matrix4 &matrix)
Update the view matrix uniform of this shader.
Definition RayMarchingShader.h:79
Int sdfSizeUniform
Definition RayMarchingShader.h:161
void setProjectionMatrix(const Matrix4 &matrix)
Update the projection matrix uniform of this shader.
Definition RayMarchingShader.h:73
void setDmax(const float dmax)
Set the attenuation distance uniform. This is used for attenuating the inner structure based on dista...
Definition RayMarchingShader.h:109
Int viewMatrixUniform
Definition RayMarchingShader.h:158
void bindStructurePos(GL::Texture2D &texture)
Bind the given structure positions texture to the shader.
Definition RayMarchingShader.h:55
Int displayModeUniform
Definition RayMarchingShader.h:163
RayMarchingShader()
Loads the shader files from disk, then compiles and links them.
Definition RayMarchingShader.h:13
Int cameraPositionUniform
Definition RayMarchingShader.h:160
void setSubSurfaceColor(const Color3 &color)
Set the subsurface color uniform. This decides in which color to render the subsurface scattering eff...
Definition RayMarchingShader.h:139
void setSurfaceRenderingMode(const UnsignedInt &mode)
Set the surface rendering mode uniform. This decides how the surface is rendered.
Definition RayMarchingShader.h:97
Int dmaxUniform
Definition RayMarchingShader.h:164
Int reflectionCountUniform
Definition RayMarchingShader.h:167
void bindStructureMask(GL::Texture2D &texture)
Bind the given structure mask texture to the shader.
Definition RayMarchingShader.h:61
void bindStructure(GL::Texture2D &texture)
Bind the given structure texture to the shader.
Definition RayMarchingShader.h:49
Int viewportSizeUniform
Definition RayMarchingShader.h:157
void bindSdf(GL::Texture3D &texture)
Bind the given sdf texture to the shader.
Definition RayMarchingShader.h:43
void setSdfSize(const Vector3 &size)
Set the size of the sdf grid in object space.
Definition RayMarchingShader.h:91