Skip to content

Water Shading

Pre-release
Pre-release

Choose a tag to compare

@stephen-hqxu stephen-hqxu released this 30 Apr 14:59

Release 0.13.0-Preview.3

BSDF

In this release we implemented a BSDF shader dedicated for rendering reflection and refraction of transparent object such as water. We have also added a material system to make rendering special effect flexibly and be easier to add supports for more objects in the future.

Currently BSDF is implemented using screen-space reflection/refraction therefore certain limitations apply. We will try to improve the visual quality and reduce artefacts brought by this approach, as well as introducing better algorithms, in the future.

We also update and refactor STPScenePipeline to support the newly added transparent objects and post effect.

  • Add a new fragment shader that implements BSDF for water reflection and refraction using screen-space technique.
  • Add STPBidirectionalScattering as a new rendering component for rendering reflective and refractive water (for now).
  • Add STPBidirectionalScatteringSetting.
  • Add STPMaterialLibrary which allows specifying material properties for special rendering components like water.
  • STPWater is now allowed to specify material property with a material ID.
  • Introduce a new G-Buffer, material buffer. This buffer is a unsigned int format texture which stores material ID. This G-Buffer is enabled and has memory allocated only when material library is attached to the scene pipeline.

General fixes and improvement

  • Improve STPAlphaCulling and now it supports use of dual boolean expressions.
  • Replace unique light space size record in STPScenePipeline from std::vector to std::unordered_set.
  • Improve ambient occlusion shader to reuse the casted projection matrix in every iteration to avoid repetitive casting.
  • Change noise texture in STPHeightfieldTerrain to a bindless sampler.
  • Improve the HBAO algorithm a bit to make the occlusion more noticeable, i.e., stronger.
  • Refactor view to NDC conversion function from STPAmbientOcclusion.glsl into STPCameraInformation.glsl.
  • Add a new function for camera to linearise depth.
  • STPScreen now passes shared vertex buffer around via a std::weak_ptr rather than a pointer to a std::shared_ptr.
  • STPTexture and STPSampler now allows to set integer and unsigned integer format of border colour.
  • Remove setData(vec3) function in STPLightSpectrum because it is not useless.
  • STPSun now copies STPSunSetting under its instance instead of taking a reference.

STPWater

  • Fix a mistake in water tessellation shader which uses a variable before it is declared.
  • Simplify the tessellation shader slightly.
  • Fix a few silly mistakes in the shader which causes error during compilation.
  • Fix some errors in the wave function.
  • Improve water plane culling algorithm to reduce the chance of false positive.