载入中...
搜索中...
未找到
RenderSystem3D.cpp
浏览该文件的文档.
84Lighting3DPack packLights3D(const std::vector<PackedLight3D> &lights, const Camera3D::Data *cam) {
113void splitLights(const std::vector<PackedLight3D> &packed, std::vector<ClusteredLightGpu> &points,
254void Renderable3D::setNormalTexture(Texture *texture) { meshRenderer()->normalTexture = texture; }
256void Renderable3D::setHeightTexture(Texture *texture) { meshRenderer()->heightTexture = texture; }
398void RenderSystem3D::setDirectionalLight(float dx, float dy, float dz, float r, float g, float b) {
497CameraView buildCameraView(Camera3D::Data *cd, const std::vector<PackedLight3D> &packed, bool useClustered,
512 cv.clustered = buildClusteredLighting(clusteredPoints, clusteredDirs, cv.view, cd->nearZ, cd->farZ,
563 const float aspect = (gfx.getHeight() > 0) ? float(gfx.getWidth()) / float(gfx.getHeight()) : 1.f;
571 glm::vec3 dir = shadowCaster ? glm::vec3(shadowCaster->dx, shadowCaster->dy, shadowCaster->dz) : gLightDir;
581 glm::vec3(cd->upX, cd->upY, cd->upZ), fovRad, aspect, cd->nearZ, cd->farZ, shadowBias, shadowStrength);
623 cams.push_back(buildCameraView(defaultCam->data().operator->(), packed, useClustered, aspect, clusteredPoints,
631 cams.push_back(buildCameraView(d, packed, useClustered, aspect, clusteredPoints, clusteredDirs, gfx));
654 const float maxScale = std::max(std::abs(xf->sx), std::max(std::abs(xf->sy), std::abs(xf->sz)));
675 item.inDefaultView = defaultCam ? cams[0].frustum.sphereVisible(item.worldC, item.worldR) : true;
742 gfx.drawMeshGBuffer(item.mesh, cv.viewProj * item.model, item.model, cv.data->nearZ, cv.data->farZ, alb, tr,
bool clusteredUploaded
Whether the clustered SSBOs were uploaded for this camera this frame.
Definition RenderSystem3D.cpp:494
void setIntensity(float intensity)
Definition AmbientOcclusion.cpp:272
void setPower(float power)
Definition AmbientOcclusion.cpp:278
void applyFromGBuffer(Graphics *gfx, Texture *hwDepth, Texture *worldNormal)
Definition AmbientOcclusion.cpp:432
void setQuality(const std::string &quality)
"low" | "medium" | "high" (unknown → medium).
Definition AmbientOcclusion.cpp:215
void setRadius(float radius)
Definition AmbientOcclusion.cpp:262
Definition RenderSystem3D.h:18
float getScreenRayOriginY()
Definition RenderSystem3D.cpp:219
float getScreenRayOriginZ()
Definition RenderSystem3D.cpp:220
void setUp(float x, float y, float z)
Definition RenderSystem3D.cpp:150
void screenToRay(float screenX, float screenY, float viewW, float viewH)
Build a world-space picking ray from a screen pixel. Stores origin (camera eye) and normalized direct...
Definition RenderSystem3D.cpp:174
void setEnvIntensity(float intensity)
Definition RenderSystem3D.cpp:170
void setTarget(float x, float y, float z)
Definition RenderSystem3D.cpp:143
void setAmbient(float r, float g, float b)
Definition RenderSystem3D.cpp:161
void setEye(float x, float y, float z)
Definition RenderSystem3D.cpp:136
void setEnvMap(Texture *cube)
Specular IBL cubemap (Graphics::newCubemap). nullptr disables IBL.
Definition RenderSystem3D.cpp:168
float getScreenRayOriginX()
Definition RenderSystem3D.cpp:218
Definition Canvas.h:16
virtual int getWidth() const =0
virtual int getHeight() const =0
Screen-space buffers for mid/post effects (AO, fog, stylize outline, …).
Definition GBuffer.h:24
Definition Graphics.h:56
virtual void beginShadowPass(int cascadeIndex)=0
Depth-only shadow pass for one cascade layer (0..2). Draws are recorded into the next begin3DFrame co...
virtual void setMesh3DShadows(const ShadowUpload &upload)=0
Upload CSM constants for subsequent default mesh draws (active=false disables).
virtual void endGBufferPass()=0
virtual void setMesh3DClip(float nearZ, float farZ)=0
Near/far used to pack linear depth into scene color A (SSGI).
virtual void setMesh3DMaterial(float metallic, float roughness)=0
Metallic (0..1) and roughness (0..1) for the next default mesh draw.
virtual void setMesh3DViewProj(const glm::mat4 &viewProj)=0
virtual void drawMeshGBuffer(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model, float nearZ, float farZ, Texture *albedo=nullptr, float tintR=1.f, float tintG=1.f, float tintB=1.f)=0
virtual void setMesh3DCameraPos(const glm::vec3 &eye)=0
Camera eye used by mesh shaders that need view/rim (stored in Mesh3DUBO).
virtual void endShadowPass()=0
virtual void setMesh3DClusteredActive(bool active)=0
Cheap per-draw toggle for the already-uploaded clustered light table. Unlike setMesh3DClusteredLighti...
virtual void begin3DFrameToCanvas(Canvas *canvas)=0
Open a 3D render pass targeting an offscreen Canvas (color + depth) at the canvas size....
virtual void setMesh3DEnv(Texture *cube, float intensity)=0
Specular IBL environment for subsequent default mesh draws. cube must be from newCubemap (or nullptr ...
virtual void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount=1.f)=0
Texture cell bombing for the next default mesh draw (breaks tiling). cellScale: cells per UV unit (ty...
virtual void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP)=0
virtual void beginGBufferPass(int width, int height)=0
Depth/normal(/albedo) fill pass for mid/post effects. One-shot submit (like shadow); call before begi...
virtual void setMesh3DClusteredLighting(const ClusteredLightingUpload &upload)=0
Enable clustered forward path for subsequent default mesh draws (SSBO light lists)....
virtual void setMesh3DParallax(float scale, float minLayers=8.f, float maxLayers=32.f)=0
Parallax occlusion mapping for the next default mesh draw. scale: UV displacement strength (0=off)....
Outline * pipelineOutline()
Pipeline-owned Outline used by RenderSystem3D when the "outline" feature is on.
Definition Graphics.cpp:774
virtual void setMesh3DView(const glm::mat4 &view)=0
Camera view matrix for subsequent drawMesh (view-space depth / CSM select).
virtual void setMesh3DSceneDepth(Texture *depth)=0
Optional scene hardware depth (G-buffer hwDepth, Vulkan NDC z) bound to mesh3d shader binding 7....
AmbientOcclusion * pipelineAmbientOcclusion()
Pipeline-owned AO / GI / AA used by RenderSystem3D when features "ao" / "gi" / "aa" are enabled....
Definition Graphics.cpp:759
virtual void setMesh3DShadowReceive(bool receive)=0
Per-draw: when false, shadow sampling is forced off for the next mesh draw.
virtual bool supportsGBufferPost() const
Whether gbuffer-based post-process shaders (AO, GI) can be created on this backend....
Definition Graphics.h:104
virtual void begin3DFrame()=0
Begin a 3D frame: shadow/gbuffer (if pending) then a sampleable scene color pass (color+depth)....
virtual void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint, Shader *shader)=0
Draw mesh with an explicit Mesh3D Shader (nullptr = default PBR pipeline).
RenderControl * getRenderControl()
Shared compilable 3D render control (features → pass list + GBuffer). Owned by Graphics; valid for th...
Definition Graphics.cpp:173
virtual void end3DFrameToCanvas()=0
virtual void setMesh3DNormalTexture(Texture *normal)=0
Optional normal map for the next drawMesh / drawMeshShader (nullptr = flat).
virtual void setMesh3DHeightTexture(Texture *height)=0
Optional height map for parallax (R channel; nullptr = flat / off).
virtual void setMesh3DLighting(const Lighting3DPack &pack)=0
Per-frame ambient + up to 8 lights packed into Mesh3DUBO.
Packages shading method + surface parameters into one attachable asset.
Definition Material.h:26
bool isTransparentHair() const
True when this material should go through the hair transparent pass.
Definition Material.cpp:68
void bind(Graphics &gfx) const
Push this material onto Graphics mesh3d state for the next draw. Does not issue the draw itself.
Definition Material.cpp:72
Shader * effectiveShader() const
Effective shader for Mesh3D draws (may be null → default PBR pipeline).
Definition Material.cpp:63
float boundsCx
Model-space bounding sphere used for view/cascade frustum culling. Computed from vertex positions at ...
Definition Mesh.h:29
bool hasBounds() const
True when a valid bounding sphere is available for culling.
Definition Mesh.h:35
Screen-space model outline (t3ssel8r-style), computed from the GBuffer hardware depth + world-normal ...
Definition Outline.h:31
void setClip(float nearZ, float farZ)
Near/far used to linearize the hardware depth.
Definition Outline.cpp:106
bool apply(Graphics *gfx, Texture *hwDepth, Texture *worldNormal)
Draw the outline over the currently bound canvas / screen. hwDepth is the D32 GBuffer (Vulkan NDC z),...
Definition Outline.cpp:143
bool isEnabled(const std::string &feature) const
Definition RenderControl.cpp:70
bool hasPass(const std::string &name) const
Definition RenderControl.cpp:95
static void addShadowExtraDrawer(ShadowExtraDrawer drawer)
Definition RenderSystem3D.cpp:410
static void setDirectionalLight(float dx, float dy, float dz, float r, float g, float b)
Legacy single directional light used when no enabled Light3D exists.
Definition RenderSystem3D.cpp:398
static void addGBufferExtraDrawer(GBufferExtraDrawer drawer)
Definition RenderSystem3D.cpp:405
static void renderToCanvas(Graphics &gfx, Canvas *target, Camera3D *camera)
Definition RenderSystem3D.cpp:920
static void render(Graphics &gfx)
Definition RenderSystem3D.cpp:544
std::function< void(Graphics &gfx, const glm::mat4 &lightVP, const Camera3D::Data &cam)> ShadowExtraDrawer
Register a callback that casts shadows for geometry outside the Renderable3D ECS (e....
Definition RenderSystem3D.h:277
std::function< void(Graphics &gfx, const Camera3D::Data &cam, const glm::mat4 &viewProj, float aspect)> GBufferExtraDrawer
Register a callback that fills the G-buffer (depth/normal/albedo) for geometry outside the Renderable...
Definition RenderSystem3D.h:264
void setNormalTexture(Texture *texture)
Definition RenderSystem3D.cpp:254
void setCamera(Camera3D *camera)
Definition RenderSystem3D.cpp:370
bool getCastOcclusion()
Definition RenderSystem3D.cpp:368
float getParallaxMaxLayers()
Definition RenderSystem3D.cpp:356
int getMeshLodLevelAtDistance(float distance)
Definition RenderSystem3D.cpp:394
void setCastOcclusion(bool cast)
Definition RenderSystem3D.cpp:366
std::string getPartName(int index)
Definition RenderSystem3D.cpp:295
float getParallaxMinLayers()
Definition RenderSystem3D.cpp:354
Material * getPartMaterial(int index)
Definition RenderSystem3D.cpp:307
void setRotation(float yaw, float pitch, float roll)
Definition RenderSystem3D.cpp:232
float getTexCellBombRotation()
Definition RenderSystem3D.cpp:340
void setHeightTexture(Texture *texture)
Height map for parallax (R channel; white = raised). nullptr disables sampling.
Definition RenderSystem3D.cpp:256
void setPart(int index, const std::string &name, Mesh *mesh, Material *material)
Bind a named mesh+material part (e.g. Assimp submesh / body region). index 0..kMaxParts-1....
Definition RenderSystem3D.cpp:272
void setTexCellBomb(float cellScale, float strength, float rotAmount=1.f)
Texture cell bombing — random per-cell UV offset/rotation blended across a 2×2 neighborhood to hide t...
Definition RenderSystem3D.cpp:329
float getTexCellBombScale()
Definition RenderSystem3D.cpp:336
void setTint(float r, float g, float b, float a=1.f)
Definition RenderSystem3D.cpp:317
void setMetallic(float metallic)
Definition RenderSystem3D.cpp:325
void setTexture(Texture *texture)
Definition RenderSystem3D.cpp:252
void setReceiveLight(bool receive)
Definition RenderSystem3D.cpp:360
void setShader(Shader *shader)
Definition RenderSystem3D.cpp:258
void setMaterial(Material *material)
Attach a Material that packages shading method + surface params.
Definition RenderSystem3D.cpp:260
void setParallax(float scale, float minLayers=8.f, float maxLayers=32.f)
Parallax occlusion mapping. scale 0 disables (default). Typical scale 0.02..0.08. Requires a height t...
Definition RenderSystem3D.cpp:342
void setPosition(float x, float y, float z)
Definition RenderSystem3D.cpp:225
void setXRayShader(Shader *shader)
Attach an X-ray mesh shader (see Shader::setXray) for occluded silhouettes.
Definition RenderSystem3D.cpp:264
float getTexCellBombStrength()
Definition RenderSystem3D.cpp:338
void setXRayHighlight(bool on)
When true, this entity is an X-ray target: its G-buffer pixels are replaced by occluders and it is re...
Definition RenderSystem3D.cpp:268
Mesh * getPartMesh(int index)
Definition RenderSystem3D.cpp:301
void setCastShadow(bool cast)
Definition RenderSystem3D.cpp:362
bool getXRayHighlight()
Definition RenderSystem3D.cpp:270
float getParallaxScale()
Definition RenderSystem3D.cpp:352
void setMeshLod(int index, Mesh *mesh, float switchDistance=0.f)
Configure geometric LOD. index 0 = highest detail. For index > 0, switchDistance is the camera distan...
Definition RenderSystem3D.cpp:372
void setRoughness(float roughness)
Definition RenderSystem3D.cpp:327
void setScale(float sx, float sy, float sz)
Definition RenderSystem3D.cpp:243
void setReceiveShadow(bool receive)
Definition RenderSystem3D.cpp:364
void setVisible(bool visible)
Definition RenderSystem3D.cpp:358
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:17
void rtDraw(const char *api, const char *detail=nullptr)
Definition RenderTrace.h:48
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition AnimTrail.h:6
glm::mat4 perspectiveVulkanRH_ZO(float fovyRad, float aspect, float zNear, float zFar)
Right-handed, zero-to-one depth perspective for Vulkan swapchains.
Definition ClipSpace.h:20
glm::vec4 Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
ClusteredLightingUpload buildClusteredLighting(const std::vector< ClusteredLightGpu > &points, const std::vector< ClusteredLightGpu > &dirs, const glm::mat4 &view, float nearZ, float farZ, int screenW, int screenH, float fovYRad, const glm::vec4 &ambient)
Build clustered tables for point lights in view space.
Definition ClusteredLight.cpp:9
ShadowUpload buildDirectionalCSM(const glm::vec3 &lightDirTowardSurface, const glm::vec3 &eye, const glm::vec3 &target, const glm::vec3 &up, float fovYRad, float aspect, float nearZ, float farZ, float bias, float strength)
Build 3 cascade light view-proj matrices for a directional light.
Definition Shadow.cpp:83
static constexpr int kMaxLights
Definition ClusteredLight.h:17
CPU-built clustered lighting upload for one frame/camera. Point lights are clustered; directional lig...
Definition ClusteredLight.h:32
Definition Light.h:107
Definition Light.h:90
One mesh + material slot on a multi-part model (Assimp mesh / body region). When Material* is null,...
Definition Material.h:134
static constexpr int kMaxLodLevels
Definition RenderSystem3D.h:86
static constexpr int kMaxParts
Definition RenderSystem3D.h:87
Definition Shadow.h:25