mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
Change skybox and shadow to buffer pool. (#2762)
This commit is contained in:
@@ -116,7 +116,7 @@ void ForwardPipeline::updateUBOs(RenderView *view) {
|
||||
updateUBO(view);
|
||||
const auto scene = GET_SCENE(view->getCamera()->getSceneID());
|
||||
const auto mainLight = GET_MAIN_LIGHT(scene->mainLightID);
|
||||
const auto shadowInfo = _shadowMap;
|
||||
const auto shadowInfo = _shadows;
|
||||
|
||||
if (mainLight && shadowInfo->enabled) {
|
||||
const auto node = GET_NODE(mainLight->nodeID);
|
||||
|
||||
@@ -10,8 +10,7 @@ struct UBOShadow;
|
||||
struct Fog;
|
||||
struct Ambient;
|
||||
struct Skybox;
|
||||
struct PlanarShadow;
|
||||
struct ShadowMap;
|
||||
struct Shadows;
|
||||
|
||||
class CC_DLL ForwardPipeline : public RenderPipeline {
|
||||
public:
|
||||
@@ -39,7 +38,7 @@ public:
|
||||
CC_INLINE float getShadingScale() const { return _shadingScale; }
|
||||
CC_INLINE float getFpScale() const { return _fpScale; }
|
||||
CC_INLINE bool isHDR() const { return _isHDR; }
|
||||
CC_INLINE const ShadowMap *getShadowMap() const { return _shadowMap; }
|
||||
CC_INLINE const Shadows *getShadows() const { return _shadows; }
|
||||
|
||||
void setRenderObjcts(const RenderObjectList &ro) { _renderObjects = std::move(ro); }
|
||||
void setShadowObjects(const RenderObjectList &ro) { _shadowObjects = std::move(ro); }
|
||||
@@ -52,8 +51,7 @@ private:
|
||||
Fog *_fog = nullptr;
|
||||
Ambient *_ambient = nullptr;
|
||||
Skybox *_skybox = nullptr;
|
||||
PlanarShadow *_planarShadow = nullptr;
|
||||
ShadowMap *_shadowMap = nullptr;
|
||||
Shadows *_shadows = nullptr;
|
||||
gfx::Buffer *_lightsUBO = nullptr;
|
||||
LightList _validLights;
|
||||
gfx::BufferList _lightBuffers;
|
||||
|
||||
@@ -27,7 +27,6 @@ void sceneCulling(ForwardPipeline *pipeline, RenderView *view) {
|
||||
RenderObjectList shadowObjects;
|
||||
|
||||
const auto mainLight = GET_MAIN_LIGHT(scene->mainLightID);
|
||||
const auto planarShadows = GET_PLANAR_SHADOW(scene->planarShadowID);
|
||||
if (mainLight) {
|
||||
//TODO coulsonwang
|
||||
// if (planarShadows.enabled) {
|
||||
@@ -36,7 +35,7 @@ void sceneCulling(ForwardPipeline *pipeline, RenderView *view) {
|
||||
}
|
||||
|
||||
if (GET_SKYBOX(scene->skyboxID)->enabled && (camera->getClearFlag() & SKYBOX_FLAG)) {
|
||||
renderObjects.emplace_back(genRenderObject(GET_SKYBOX(scene->skyboxID), camera));
|
||||
renderObjects.emplace_back(genRenderObject(GET_MODEL(GET_SKYBOX(scene->skyboxID)->model), camera));
|
||||
}
|
||||
|
||||
const auto stamp = Application::getInstance()->getTotalFrames();
|
||||
|
||||
@@ -11,8 +11,9 @@ const se::PoolType AABB::type = se::PoolType::AABB;
|
||||
const se::PoolType Frustum::type = se::PoolType::FRUSTUM;
|
||||
const se::PoolType Scene::type = se::PoolType::SCENE;
|
||||
const se::PoolType MainLight::type = se::PoolType::UNKNOWN;
|
||||
const se::PoolType Ambient::type = se::PoolType::UNKNOWN;
|
||||
const se::PoolType Fog::type = se::PoolType::UNKNOWN;
|
||||
const se::PoolType Ambient::type = se::PoolType::AMBIENT;
|
||||
const se::PoolType Fog::type = se::PoolType::FOG;
|
||||
const se::PoolType Skybox::type = se::PoolType::SKYBOX;
|
||||
const se::PoolType InstancedAttribute::type = se::PoolType::UNKNOWN;
|
||||
const se::PoolType BufferView::type = se::PoolType::UNKNOWN;
|
||||
const se::PoolType FlatBuffer::type = se::PoolType::UNKNOWN;
|
||||
@@ -20,7 +21,6 @@ const se::PoolType RenderingSubMesh::type = se::PoolType::UNKNOWN;
|
||||
const se::PoolType Node::type = se::PoolType::NODE;
|
||||
const se::PoolType Root::type = se::PoolType::ROOT;
|
||||
const se::PoolType RenderWindow::type = se::PoolType::RENDER_WINDOW;
|
||||
const se::PoolType ShadowMap::type = se::PoolType::UNKNOWN;
|
||||
const se::PoolType PlanarShadow::type = se::PoolType::UNKNOWN;
|
||||
const se::PoolType Shadows::type = se::PoolType::SHADOW;
|
||||
} // namespace pipeline
|
||||
} // namespace cc
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "renderer/core/CoreStd.h"
|
||||
#include "math/Vec2.h"
|
||||
#include "math/Vec3.h"
|
||||
#include "math/Vec4.h"
|
||||
#include "scripting/dop/ArrayPool.h"
|
||||
#include "scripting/dop/BufferPool.h"
|
||||
#include "scripting/dop/ObjectPool.h"
|
||||
@@ -164,6 +165,7 @@ struct CC_DLL MainLight {
|
||||
};
|
||||
|
||||
struct CC_DLL Ambient {
|
||||
float enabled = 0;
|
||||
float skyIllum = 0;
|
||||
cc::Vec4 skyColor;
|
||||
cc::Vec4 groundAlbedo;
|
||||
@@ -173,30 +175,34 @@ struct CC_DLL Ambient {
|
||||
|
||||
struct CC_DLL Fog {
|
||||
float enabled = 0;
|
||||
float fogType = 0;
|
||||
float fogDensity = 0;
|
||||
float fogStart = 0;
|
||||
float fogEnd = 0;
|
||||
float fogDensity = 0;
|
||||
float fogAtten = 0;
|
||||
float fogTop = 0;
|
||||
float fogRange = 0;
|
||||
float fogAtten = 0;
|
||||
cc::Vec4 fogColor;
|
||||
|
||||
const static se::PoolType type;
|
||||
};
|
||||
|
||||
struct CC_DLL ShadowMap {
|
||||
struct CC_DLL Shadows {
|
||||
float enabled = 0;
|
||||
float dirty = 0;
|
||||
float shadowType = 0;
|
||||
float distance = 0;
|
||||
float instancePass = 0;
|
||||
float planarPass = 0;
|
||||
float nearValue = 0;
|
||||
float farValue = 0;
|
||||
float aspect = 0;
|
||||
float pcfType = 0;
|
||||
float orthoSize = 0;
|
||||
cc::Vec2 size;
|
||||
|
||||
const static se::PoolType type;
|
||||
};
|
||||
|
||||
struct CC_DLL PlanarShadow {
|
||||
uint32_t enabled = 0;
|
||||
cc::Vec3 normal;
|
||||
cc::Vec4 color;
|
||||
cc::Vec4 sphere;
|
||||
|
||||
const static se::PoolType type;
|
||||
};
|
||||
@@ -210,8 +216,13 @@ struct CC_DLL InstancedAttribute {
|
||||
const static se::PoolType type;
|
||||
};
|
||||
|
||||
struct CC_DLL Skybox : public ModelView {
|
||||
struct CC_DLL Skybox {
|
||||
uint32_t enabled = 0;
|
||||
uint32_t isRGBE = 0;
|
||||
uint32_t useIBL = 0;
|
||||
uint32_t model = 0;
|
||||
|
||||
const static se::PoolType type;
|
||||
};
|
||||
|
||||
struct CC_DLL BufferView {
|
||||
@@ -278,7 +289,6 @@ struct CC_DLL RenderWindow {
|
||||
const static se::PoolType type;
|
||||
};
|
||||
|
||||
|
||||
//Get buffer pool data
|
||||
#define GET_SUBMODEL(index) SharedMemory::getBuffer<SubModelView>(index)
|
||||
#define GET_PASS(index) SharedMemory::getBuffer<PassView>(index)
|
||||
@@ -295,12 +305,11 @@ struct CC_DLL RenderWindow {
|
||||
#define GET_MAIN_LIGHT(index) SharedMemory::getBuffer<MainLight>(index)
|
||||
#define GET_AMBIENT(index) SharedMemory::getBuffer<Ambient>(index)
|
||||
#define GET_FOG(index) SharedMemory::getBuffer<Fog>(index)
|
||||
#define GET_PLANAR_SHADOW(index) SharedMemory::getBuffer<PlanarShadow>(index)
|
||||
#define GET_SKYBOX(index) SharedMemory::getBuffer<Skybox>(index)
|
||||
#define GET_FRUSTUM(index) SharedMemory::getBuffer<Frustum>(index)
|
||||
#define GET_AABB(index) SharedMemory::getBuffer<AABB>(index)
|
||||
#define GET_WINDOW(index) SharedMemory::getBuffer<RenderWindow>(index)
|
||||
#define GET_SHADOWMAP(index) SharedMemory::getBuffer<ShadowMap>(index)
|
||||
#define GET_SHADOWS(index) SharedMemory::getBuffer<Shadows>(index)
|
||||
|
||||
//TODO
|
||||
#define GET_NAME(index) (String(0))
|
||||
|
||||
@@ -41,7 +41,7 @@ void ShadowFlow::activate(RenderPipeline *pipeline) {
|
||||
RenderFlow::activate(pipeline);
|
||||
|
||||
auto device = gfx::Device::getInstance();
|
||||
const auto shadowMapSize = static_cast<ForwardPipeline *>(pipeline)->getShadowMap()->size;
|
||||
const auto shadowMapSize = static_cast<ForwardPipeline *>(pipeline)->getShadows()->size;
|
||||
_width = shadowMapSize.x;
|
||||
_height = shadowMapSize.y;
|
||||
|
||||
@@ -104,7 +104,7 @@ void ShadowFlow::activate(RenderPipeline *pipeline) {
|
||||
|
||||
void ShadowFlow::render(RenderView *view) {
|
||||
auto pipeline = static_cast<ForwardPipeline *>(_pipeline);
|
||||
const auto shadowInfo = pipeline->getShadowMap();
|
||||
const auto shadowInfo = pipeline->getShadows();
|
||||
if (!shadowInfo->enabled) return;
|
||||
|
||||
const auto shadowMapSize = shadowInfo->size;
|
||||
|
||||
@@ -39,7 +39,7 @@ bool ShadowStage::initialize(const RenderStageInfo &info) {
|
||||
|
||||
void ShadowStage::render(RenderView *view) {
|
||||
const auto pipeline = static_cast<ForwardPipeline *>(_pipeline);
|
||||
const auto shadowInfo = pipeline->getShadowMap();
|
||||
const auto shadowInfo = pipeline->getShadows();
|
||||
_additiveShadowQueue->clear(pipeline->getDescriptorSet()->getBuffer(UBOShadow::BLOCK.binding));
|
||||
|
||||
const auto shadowObjects = pipeline->getShadowObjects();
|
||||
|
||||
@@ -12,7 +12,7 @@ enum class PoolType {
|
||||
PIPELINE_LAYOUT,
|
||||
FRAMEBUFFER,
|
||||
// buffers
|
||||
PASS,
|
||||
PASS = 100,
|
||||
SUB_MODEL,
|
||||
MODEL,
|
||||
SCENE,
|
||||
@@ -22,6 +22,10 @@ enum class PoolType {
|
||||
AABB,
|
||||
RENDER_WINDOW,
|
||||
FRUSTUM,
|
||||
AMBIENT,
|
||||
FOG,
|
||||
SKYBOX,
|
||||
SHADOW,
|
||||
// INSTANCED_ATTRIBUTE,
|
||||
// MAIN_LIGHT,
|
||||
// AMBIENT,
|
||||
@@ -31,7 +35,7 @@ enum class PoolType {
|
||||
// FLAT_BUFFER,
|
||||
|
||||
// array
|
||||
SUB_MODEL_ARRAY,
|
||||
SUB_MODEL_ARRAY = 200,
|
||||
MODEL_ARRAY,
|
||||
UNKNOWN
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user