Use new cgi source.

This commit is contained in:
hal8174 2024-04-23 14:15:44 +02:00
parent 57ae058d9a
commit 20cc279b72
158 changed files with 157 additions and 92879 deletions

View file

@ -60,7 +60,7 @@ namespace embree {
void SceneGraph::TriangleMeshNode::calculateInDegree() {
indegree++;
if (indegree == 1)
if (indegree == 1 && material != 0)
material->calculateInDegree();
}
@ -107,7 +107,7 @@ namespace embree {
void SceneGraph::TriangleMeshNode::resetInDegree() {
closed = false;
if (indegree == 1)
if (indegree == 1 && material != 0)
material->resetInDegree();
indegree--;
}

View file

@ -505,6 +505,23 @@ namespace embree {
virtual void print(std::ostream& cout, int depth);
};
struct LightNode : public Node {
virtual void print(std::ostream& cout, int depth);
virtual void calculateStatistics(Statistics& stat);
virtual bool calculateClosed(bool group_instancing);
virtual LightType getType() const = 0;
virtual Ref<LightNode> transform(const AffineSpace3fa& space) const = 0;
virtual Ref<LightNode> lerp(const Ref<LightNode>& light1_in, float f) const = 0;
virtual Ref<LightNode> get(float time) const = 0;
};
/*! Mesh. */
struct TriangleMeshNode : public Node {
typedef Vec3fa Vertex;
@ -524,11 +541,13 @@ namespace embree {
public:
TriangleMeshNode(const avector<Vertex>& positions_in,
const avector<Vertex>& normals_in,
const std::vector<Vec2f>& texcoords,
const std::vector<Triangle>& triangles,
Ref<MaterialNode> material)
: Node(true), time_range(0.0f, 1.0f), texcoords(texcoords), triangles(triangles), material(material) {
const avector<Vertex>& normals_in,
const std::vector<Vec2f>& texcoords,
const std::vector<Triangle>& triangles,
Ref<MaterialNode> material,
Ref<LightNode> lightnode = 0
)
: Node(true), time_range(0.0f, 1.0f), texcoords(texcoords), triangles(triangles), material(material), light(lightnode) {
positions.push_back(positions_in);
normals.push_back(normals_in);
}
@ -545,13 +564,17 @@ namespace embree {
time_range(imesh->time_range),
positions(transformMSMBlurVec3faBuffer(imesh->positions, spaces)),
normals(transformMSMBlurNormalBuffer(imesh->normals, spaces)),
texcoords(imesh->texcoords), triangles(imesh->triangles), material(imesh->material) {
texcoords(imesh->texcoords), triangles(imesh->triangles), material(imesh->material), light(imesh->light) {
}
virtual void setMaterial(Ref<MaterialNode> material) {
this->material = material;
}
virtual void setLight(Ref<LightNode> light) {
this->light = light;
}
virtual BBox3fa bounds() const {
BBox3fa b = empty;
for (const auto& p: positions)
@ -596,6 +619,11 @@ namespace embree {
virtual void resetInDegree();
protected:
TriangleMeshNode() {
}
public:
BBox1f time_range;
std::vector<avector<Vertex> > positions;
@ -603,52 +631,79 @@ namespace embree {
std::vector<Vec2f> texcoords;
std::vector<Triangle> triangles;
Ref<MaterialNode> material;
Ref<LightNode> light;
};
struct LightNode : public Node {
virtual void print(std::ostream& cout, int depth);
template<typename Light>
struct LightNodeImpl : public LightNode {
ALIGNED_STRUCT_(16);
virtual void calculateStatistics(Statistics& stat);
LightNodeImpl(const Light& light)
: light(light) {
}
virtual bool calculateClosed(bool group_instancing);
virtual LightType getType() const {
return light.getType();
}
virtual LightType getType() const = 0;
virtual Ref<LightNode> transform(const AffineSpace3fa& space) const {
return new LightNodeImpl(light.transform(space));
}
virtual Ref<LightNode> transform(const AffineSpace3fa& space) const = 0;
virtual Ref<LightNode> get(float time) const {
return (LightNode*)this;
}
virtual Ref<LightNode> lerp(const Ref<LightNode>& light1_in, float f) const = 0;
virtual Ref<LightNode> lerp(const Ref<LightNode>& light1_in, float f) const {
const Ref<LightNodeImpl<Light> > light1 = light1_in.dynamicCast<LightNodeImpl<Light> >();
assert(light1);
return new LightNodeImpl(Light::lerp(light, light1->light, f));
}
virtual Ref<LightNode> get(float time) const = 0;
};
Light light;
};
template<typename Light>
struct LightNodeImpl : public LightNode {
ALIGNED_STRUCT_(16);
// QuadLightMesh is responsible for creating a mesh that represents the light and the light itself. latter the light is added automatically to the scenegraph
struct QuadLightMesh : public TriangleMeshNode {
// Constructor that takes parameters to set up the quad light mesh and its light node
QuadLightMesh(const Vec3fa& vertex0, const Vec3fa& vertex1, const Vec3fa& vertex2, const Vec3fa& vertex3,
const Vec3fa& radiance)
: TriangleMeshNode() { // Initialize the base class
LightNodeImpl(const Light& light)
: light(light) {
}
virtual LightType getType() const {
return light.getType();
}
material = 0;
// Initialize positions vector for vertices
positions.resize(1); // Resize to handle one timestep by default
positions[0].push_back(vertex0);
positions[0].push_back(vertex1);
positions[0].push_back(vertex2);
positions[0].push_back(vertex3);
virtual Ref<LightNode> transform(const AffineSpace3fa& space) const {
return new LightNodeImpl(light.transform(space));
}
// Initialize normals vector for vertices
normals.resize(1); // Assuming one normal per vertex for one timestep
normals[0].push_back(Vec3fa(0, -1, 0)); // Assuming the normal pointing downwards
normals[0].push_back(Vec3fa(0, -1, 0));
normals[0].push_back(Vec3fa(0, -1, 0));
normals[0].push_back(Vec3fa(0, -1, 0));
virtual Ref<LightNode> get(float time) const {
return (LightNode *) this;
}
// Define triangles for the quad
triangles.push_back(Triangle(0, 1, 2));
triangles.push_back(Triangle(0, 3, 1));
virtual Ref<LightNode> lerp(const Ref<LightNode>& light1_in, float f) const {
const Ref<LightNodeImpl<Light> > light1 = light1_in.dynamicCast<LightNodeImpl<Light> >();
assert(light1);
return new LightNodeImpl(Light::lerp(light, light1->light, f));
}
// Initialize light node with the quad light
light = new SceneGraph::LightNodeImpl<SceneGraph::QuadLight>(
SceneGraph::QuadLight(vertex0, vertex1, vertex2, vertex3, radiance));
Light light;
};
// Set texture coordinates if necessary (can be omitted if not used)
texcoords = std::vector<Vec2f>();
// This class only manages a single timestep by default
time_range = BBox1f(0, 1);
}
};
enum InstancingMode {
INSTANCING_NONE, INSTANCING_GEOMETRY, INSTANCING_GROUP, INSTANCING_FLATTENED, INSTANCING_MULTI_LEVEL