载入中...
搜索中...
未找到
SurfaceFluidSceneRenderer.cpp
浏览该文件的文档.
2
3#include "graphics/Graphics.h"
4#include "graphics/Mesh.h"
5
6#include <algorithm>
7
8namespace eve::fluids {
9
12
14 const SurfaceDropletRenderInstance& instance) {
15 glm::mat4 model(1.f);
16 model[0] = glm::vec4(instance.majorAxis, 0.f);
17 model[1] = glm::vec4(instance.normal * instance.capHeight, 0.f);
18 model[2] = glm::vec4(instance.minorAxis, 0.f);
19 model[3] = glm::vec4(instance.position + instance.normal * instance.capHeight, 1.f);
20 return model;
21}
22
24 const glm::vec4& tint) {
25 drawCount_ = 0;
26 if (!graphics_) return;
27 if (!sphere_) sphere_ = graphics_->newMeshSphere(16, 8);
28 if (!sphere_) return;
29
30 for (const SurfaceDropletRenderInstance& instance : renderData.droplets()) {
32 SurfaceFluidRenderData::evaluateMaterial(std::max(0.35f, instance.wetness));
33 graphics_->setMesh3DMaterial(0.f, material.roughness);
34 graphics_->drawMesh(sphere_, modelMatrix(instance), nullptr, tint);
35 ++drawCount_;
36 }
37}
38
39} // namespace eve::fluids
glm::vec4 tint
glm::mat4 model
Material * material
Builds renderer-independent droplet instances and wet PBR parameters.
const std::vector< SurfaceDropletRenderInstance > & droplets() const
Droplets.
static WetSurfaceMaterialSample evaluateMaterial(float wetness, const WetSurfaceMaterialParams &params={})
Evaluate wet PBR values from a normalized wetness input.
SurfaceFluidSceneRenderer(graphics::Graphics *graphics)
Surface fluid scene renderer.
void draw(const SurfaceFluidRenderData &renderData, const glm::vec4 &tint=glm::vec4(0.72f, 0.88f, 0.96f, 0.78f))
Draw all attached droplet caps into an already-open 3D frame.
static glm::mat4 modelMatrix(const SurfaceDropletRenderInstance &instance)
Build a unit-sphere model matrix whose lower pole touches the surface.
virtual void setMesh3DMaterial(float metallic, float roughness)=0
Metallic (0..1) and roughness (0..1) for the next default mesh draw.
virtual void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint)=0
Draw one mesh with model matrix. Requires begin3DFrame() (or an open swapchain pass).
virtual Mesh * newMeshSphere(int slices=32, int stacks=16)=0
Procedural UV sphere (radius 1, Y-up). Owned by Graphics. slices = longitude divisions,...
GLSL compute kernels for the GPU surface-flow solver.
Definition FluidTarget.h:12
World-space oriented cap instance consumed by droplet instancing shaders.
Evaluated material values suitable for a wet-surface shader.