mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
@@ -89,9 +89,10 @@ export class LightProbeGroup extends Component {
|
||||
get method () {
|
||||
return this._method;
|
||||
}
|
||||
set method (val) {
|
||||
this._method = val;
|
||||
}
|
||||
// Support this feature later.
|
||||
// set method (val) {
|
||||
// this._method = val;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @en Minimum position of the light probe group
|
||||
|
||||
@@ -40,7 +40,7 @@ import { Attribute, DescriptorSet, Device, Buffer, BufferInfo,
|
||||
import { UBOLocal, UBOSH, UBOWorldBound, UNIFORM_LIGHTMAP_TEXTURE_BINDING, UNIFORM_REFLECTION_PROBE_CUBEMAP_BINDING, UNIFORM_REFLECTION_PROBE_TEXTURE_BINDING } from '../../rendering/define';
|
||||
import { Root } from '../../root';
|
||||
import { TextureCube } from '../../asset/assets';
|
||||
import { ShadowType } from '.';
|
||||
import { ShadowType } from './shadows';
|
||||
|
||||
const m4_1 = new Mat4();
|
||||
|
||||
|
||||
@@ -170,7 +170,8 @@ export function buildFxaaPass (camera: Camera,
|
||||
ppl.addDepthStencil(fxaaPassDSName, Format.DEPTH_STENCIL, width, height, ResourceResidency.MANAGED);
|
||||
}
|
||||
const fxaaPassIdx = 0;
|
||||
const fxaaPass = ppl.addRasterPass(width, height, 'fxaa', `CameraFxaaPass${cameraID}`);
|
||||
const fxaaPass = ppl.addRasterPass(width, height, 'fxaa');
|
||||
fxaaPass.name = `CameraFxaaPass${cameraID}`;
|
||||
fxaaPass.setViewport(new Viewport(area.x, area.y, width, height));
|
||||
if (ppl.containsResource(inputRT)) {
|
||||
const computeView = new ComputeView();
|
||||
|
||||
@@ -2344,17 +2344,14 @@ static bool js_cc_gi_LightProbes_data_set(se::State& s)
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::gi::LightProbes *arg1 = (cc::gi::LightProbes *) NULL ;
|
||||
cc::gi::LightProbesData *arg2 = 0 ;
|
||||
cc::gi::LightProbesData temp2 ;
|
||||
cc::gi::LightProbesData *arg2 = (cc::gi::LightProbesData *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::gi::LightProbes>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &temp2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg2 = &temp2;
|
||||
|
||||
cc_gi_LightProbes_data_set(arg1,*arg2);
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
cc_gi_LightProbes_data_set(arg1,arg2);
|
||||
|
||||
|
||||
return true;
|
||||
@@ -2369,11 +2366,11 @@ static bool js_cc_gi_LightProbes_data_get(se::State& s)
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::gi::LightProbes>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (cc::gi::LightProbesData *) &cc_gi_LightProbes_data_get(arg1);
|
||||
result = (cc::gi::LightProbesData *)cc_gi_LightProbes_data_get(arg1);
|
||||
|
||||
ok &= nativevalue_to_se(*result, s.rval(), s.thisObject());
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(*result, s.thisObject(), s.rval());
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
return true;
|
||||
@@ -3194,17 +3191,14 @@ static bool js_cc_gi_LightProbeInfo_data_set(se::State& s)
|
||||
const auto& args = s.args();
|
||||
size_t argc = args.size();
|
||||
cc::gi::LightProbeInfo *arg1 = (cc::gi::LightProbeInfo *) NULL ;
|
||||
cc::gi::LightProbesData *arg2 = 0 ;
|
||||
cc::gi::LightProbesData temp2 ;
|
||||
cc::gi::LightProbesData *arg2 = (cc::gi::LightProbesData *) NULL ;
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::gi::LightProbeInfo>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
|
||||
ok &= sevalue_to_native(args[0], &temp2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
arg2 = &temp2;
|
||||
|
||||
cc_gi_LightProbeInfo_data_set(arg1,*arg2);
|
||||
ok &= sevalue_to_native(args[0], &arg2, s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
cc_gi_LightProbeInfo_data_set(arg1,arg2);
|
||||
|
||||
|
||||
return true;
|
||||
@@ -3219,11 +3213,11 @@ static bool js_cc_gi_LightProbeInfo_data_get(se::State& s)
|
||||
|
||||
arg1 = SE_THIS_OBJECT<cc::gi::LightProbeInfo>(s);
|
||||
if (nullptr == arg1) return true;
|
||||
result = (cc::gi::LightProbesData *) &cc_gi_LightProbeInfo_data_get(arg1);
|
||||
result = (cc::gi::LightProbesData *)cc_gi_LightProbeInfo_data_get(arg1);
|
||||
|
||||
ok &= nativevalue_to_se(*result, s.rval(), s.thisObject());
|
||||
ok &= nativevalue_to_se(result, s.rval(), s.thisObject());
|
||||
SE_PRECONDITION2(ok, false, "Error processing arguments");
|
||||
SE_HOLD_RETURN_VALUE(*result, s.thisObject(), s.rval());
|
||||
SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval());
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
#include "LightProbe.h"
|
||||
#include "PolynomialSolver.h"
|
||||
#include "core/Root.h"
|
||||
#include "core/scene-graph/Scene.h"
|
||||
#include "math/Math.h"
|
||||
#include "math/Utils.h"
|
||||
#include "renderer/pipeline/custom/RenderInterfaceTypes.h"
|
||||
#include "core/scene-graph/Scene.h"
|
||||
|
||||
namespace cc {
|
||||
namespace gi {
|
||||
@@ -200,14 +200,18 @@ void LightProbes::initialize(LightProbeInfo *info) {
|
||||
_data = info->getData();
|
||||
}
|
||||
|
||||
void LightProbeInfo::activate(Scene* scene, LightProbes *resource) {
|
||||
void LightProbeInfo::activate(Scene *scene, LightProbes *resource) {
|
||||
_scene = scene;
|
||||
_resource = resource;
|
||||
_resource->initialize(this);
|
||||
}
|
||||
|
||||
void LightProbeInfo::clearSHCoefficients() {
|
||||
auto &probes = _data.getProbes();
|
||||
if (!_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto &probes = _data->getProbes();
|
||||
for (auto &probe : probes) {
|
||||
probe.coefficients.clear();
|
||||
}
|
||||
@@ -215,7 +219,7 @@ void LightProbeInfo::clearSHCoefficients() {
|
||||
clearAllSHUBOs();
|
||||
}
|
||||
|
||||
bool LightProbeInfo::addNode(Node* node) {
|
||||
bool LightProbeInfo::addNode(Node *node) {
|
||||
if (!node) {
|
||||
return false;
|
||||
}
|
||||
@@ -256,6 +260,13 @@ void LightProbeInfo::syncData(Node *node, const ccstd::vector<Vec3> &probes) {
|
||||
}
|
||||
|
||||
void LightProbeInfo::update(bool updateTet) {
|
||||
if (!_data) {
|
||||
_data = new LightProbesData();
|
||||
if (_resource) {
|
||||
_resource->setData(_data);
|
||||
}
|
||||
}
|
||||
|
||||
ccstd::vector<Vec3> points;
|
||||
|
||||
for (auto &item : _nodes) {
|
||||
@@ -271,15 +282,15 @@ void LightProbeInfo::update(bool updateTet) {
|
||||
auto pointCount = points.size();
|
||||
if (pointCount < 4) {
|
||||
resetAllTetraIndices();
|
||||
_data.reset();
|
||||
_data->reset();
|
||||
return;
|
||||
}
|
||||
|
||||
_data.updateProbes(points);
|
||||
_data->updateProbes(points);
|
||||
|
||||
if (updateTet) {
|
||||
resetAllTetraIndices();
|
||||
_data.updateTetrahedrons();
|
||||
_data->updateTetrahedrons();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "Delaunay.h"
|
||||
#include "SH.h"
|
||||
#include "base/Macros.h"
|
||||
#include "base/Ptr.h"
|
||||
#include "base/RefCounted.h"
|
||||
#include "base/std/container/vector.h"
|
||||
#include "math/Vec3.h"
|
||||
@@ -42,7 +43,7 @@ namespace gi {
|
||||
|
||||
class LightProbeInfo;
|
||||
|
||||
class LightProbesData {
|
||||
class LightProbesData : public RefCounted {
|
||||
public:
|
||||
LightProbesData() = default;
|
||||
|
||||
@@ -82,7 +83,11 @@ public:
|
||||
void initialize(LightProbeInfo *info);
|
||||
|
||||
inline bool empty() const {
|
||||
return _data.empty();
|
||||
if (!_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return _data->empty();
|
||||
}
|
||||
|
||||
inline void setGIScale(float val) { _giScale = val; }
|
||||
@@ -106,8 +111,8 @@ public:
|
||||
inline void setShowConvex(bool val) { _showConvex = val; }
|
||||
inline bool isShowConvex() const { return _showConvex; }
|
||||
|
||||
inline void setData(const LightProbesData &data) { _data = data; }
|
||||
inline const LightProbesData &getData() const { return _data; }
|
||||
inline void setData(LightProbesData *data) { _data = data; }
|
||||
inline LightProbesData *getData() const { return _data.get(); }
|
||||
|
||||
float _giScale{1.0F};
|
||||
uint32_t _giSamples{1024U};
|
||||
@@ -116,14 +121,14 @@ public:
|
||||
bool _showProbe{true};
|
||||
bool _showWireframe{true};
|
||||
bool _showConvex{false};
|
||||
LightProbesData _data;
|
||||
IntrusivePtr<LightProbesData> _data;
|
||||
};
|
||||
|
||||
struct ILightProbeNode {
|
||||
Node *node{nullptr};
|
||||
ccstd::vector<Vec3> probes;
|
||||
|
||||
explicit ILightProbeNode(Node* n)
|
||||
explicit ILightProbeNode(Node *n)
|
||||
: node(n) {}
|
||||
};
|
||||
|
||||
@@ -132,9 +137,9 @@ public:
|
||||
LightProbeInfo() = default;
|
||||
~LightProbeInfo() override = default;
|
||||
|
||||
void activate(Scene* scene, LightProbes *resource);
|
||||
void activate(Scene *scene, LightProbes *resource);
|
||||
void clearSHCoefficients();
|
||||
inline bool isUniqueNode() const { return _nodes.size() == 1;}
|
||||
inline bool isUniqueNode() const { return _nodes.size() == 1; }
|
||||
bool addNode(Node *node);
|
||||
bool removeNode(Node *node);
|
||||
void syncData(Node *node, const ccstd::vector<Vec3> &probes);
|
||||
@@ -224,16 +229,14 @@ public:
|
||||
}
|
||||
inline bool isShowConvex() const { return _showConvex; }
|
||||
|
||||
inline void setData(const LightProbesData &data) {
|
||||
inline void setData(LightProbesData *data) {
|
||||
_data = data;
|
||||
if (_resource) {
|
||||
_resource->setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
inline const LightProbesData &getData() const { return _data; }
|
||||
|
||||
// add addGroup, removeGroup, update after the component module is ported to cpp
|
||||
inline LightProbesData *getData() const { return _data.get(); }
|
||||
|
||||
//cjh JSB need to bind the property, so need to make it public
|
||||
float _giScale{1.0F};
|
||||
@@ -243,7 +246,7 @@ public:
|
||||
bool _showProbe{true};
|
||||
bool _showWireframe{true};
|
||||
bool _showConvex{false};
|
||||
LightProbesData _data;
|
||||
IntrusivePtr<LightProbesData> _data;
|
||||
|
||||
private:
|
||||
void clearAllSHUBOs();
|
||||
|
||||
@@ -389,8 +389,8 @@ void Model::updateSHUBOs() {
|
||||
const auto *lightProbes = pipeline->getPipelineSceneData()->getLightProbes();
|
||||
|
||||
_lastWorldBoundCenter.set(center);
|
||||
_tetrahedronIndex = lightProbes->getData().getInterpolationWeights(center, _tetrahedronIndex, weights);
|
||||
bool result = lightProbes->getData().getInterpolationSHCoefficients(_tetrahedronIndex, weights, coefficients);
|
||||
_tetrahedronIndex = lightProbes->getData()->getInterpolationWeights(center, _tetrahedronIndex, weights);
|
||||
bool result = lightProbes->getData()->getInterpolationSHCoefficients(_tetrahedronIndex, weights, coefficients);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ using namespace cc::gi;
|
||||
%attribute(cc::gi::LightProbes, bool, showProbe, isShowProbe, setShowProbe);
|
||||
%attribute(cc::gi::LightProbes, bool, showWireframe, isShowWireframe, setShowWireframe);
|
||||
%attribute(cc::gi::LightProbes, bool, showConvex, isShowConvex, setShowConvex);
|
||||
%attribute(cc::gi::LightProbes, cc::gi::LightProbesData&, data, getData, setData);
|
||||
%attribute(cc::gi::LightProbes, cc::gi::LightProbesData*, data, getData, setData);
|
||||
|
||||
%attribute(cc::gi::LightProbeInfo, float, giScale, getGIScale, setGIScale);
|
||||
%attribute(cc::gi::LightProbeInfo, uint32_t, giSamples, getGISamples, setGISamples);
|
||||
@@ -103,7 +103,7 @@ using namespace cc::gi;
|
||||
%attribute(cc::gi::LightProbeInfo, bool, showProbe, isShowProbe, setShowProbe);
|
||||
%attribute(cc::gi::LightProbeInfo, bool, showWireframe, isShowWireframe, setShowWireframe);
|
||||
%attribute(cc::gi::LightProbeInfo, bool, showConvex, isShowConvex, setShowConvex);
|
||||
%attribute(cc::gi::LightProbeInfo, cc::gi::LightProbesData&, data, getData, setData);
|
||||
%attribute(cc::gi::LightProbeInfo, cc::gi::LightProbesData*, data, getData, setData);
|
||||
|
||||
// ----- Import Section ------
|
||||
// Brief: Import header files which are depended by 'Include Section'
|
||||
|
||||
Reference in New Issue
Block a user