rawrunprotected / rasterizer Goto Github PK
View Code? Open in Web Editor NEWA state-of-the-art software occlusion culling system
A state-of-the-art software occlusion culling system
Occluder.cpp: 71:
for (int j = 0; j < quadNormals.size(); ++j)
{
int k = centroidAssignment[j];
centroids[k] = _mm_add_ps(centroids[k], quadNormals[j]);
}
centroidAssignment should be initialized, otherwise centroids[k] may overflow.
Do:
Create a single occluder which consists of a tetrahedron mesh (4 vertices, 12 indices).
Observe:
A crash in Occluder::bake()
.
Hints:
The size of std::vector<__m128> orderedVertices
can be less than 32
which means this code will crash:
__m128 v0 = _mm_mul_ps(_mm_sub_ps(orderedVertices[i + j + 0], refMin), invExtents);
__m128 v1 = _mm_mul_ps(_mm_sub_ps(orderedVertices[i + j + 4], refMin), invExtents);
__m128 v2 = _mm_mul_ps(_mm_sub_ps(orderedVertices[i + j + 8], refMin), invExtents);
__m128 v3 = _mm_mul_ps(_mm_sub_ps(orderedVertices[i + j + 12], refMin), invExtents);
__m128 v4 = _mm_mul_ps(_mm_sub_ps(orderedVertices[i + j + 16], refMin), invExtents);
__m128 v5 = _mm_mul_ps(_mm_sub_ps(orderedVertices[i + j + 20], refMin), invExtents);
__m128 v6 = _mm_mul_ps(_mm_sub_ps(orderedVertices[i + j + 24], refMin), invExtents);
__m128 v7 = _mm_mul_ps(_mm_sub_ps(orderedVertices[i + j + 28], refMin), invExtents);
I`m interesting in the algorithm inside the rasterizer, but the links cannot be opened. http://threadlocalmutex.comhttp/threadlocalmutex.com/?p=163
// Main.cpp line 186
// Sort front to back
#ifdef BUG
std::sort(begin(g_occluders), end(g_occluders), [&](const auto& o1, const auto& o2) {
__m128 dist1 = _mm_sub_ps(o1->m_center, g_cameraPosition);
__m128 dist2 = _mm_sub_ps(o2->m_center, g_cameraPosition);
return _mm_comile_ss(_mm_dp_ps(dist1, dist1, 0x7f), _mm_dp_ps(dist2, dist2, 0x7f));
});
#else
std::sort(begin(g_occluders), end(g_occluders), [&](const auto& o1, const auto& o2) {
__m128 center1 = o1->m_center;
__m128 center2 = o2->m_center;
float dx1 = center1.m128_f32[0] - g_cameraPosition.m128_f32[0];
float dy1 = center1.m128_f32[1] - g_cameraPosition.m128_f32[1];
float dz1 = center1.m128_f32[2] - g_cameraPosition.m128_f32[2];
float dx2 = center2.m128_f32[0] - g_cameraPosition.m128_f32[0];
float dy2 = center2.m128_f32[1] - g_cameraPosition.m128_f32[1];
float dz2 = center2.m128_f32[2] - g_cameraPosition.m128_f32[2];
return dx1 * dx1 + dy1 * dy1 + dz1 * dz1 < dx2 * dx2 + dy2 * dy2 + dz2 * dz2;
});
#endif//
BUG report:
intel 9700k win10 64bits VS2015 debug version,
while camera move far from scene app must crushed,
i speculate sort function using SSE may inaccurate so std::sort make some element ( unique_ptr ) in g_occluders to nullptr;
replace with FPU instructions seems fix it up.
Why is the "greaterArea" used as the division when calculating the depthpane?
Looking at the code (Rasterizer.cpp Line.947), it selects one of the two triangles of the quad by comparing the area projected on the screen plane. Why?
// Compute screen space depth plane
__m256 greaterArea = _mm256_cmp_ps(_mm256_andnot_ps(minusZero256, area1), _mm256_andnot_ps(minusZero256, area2), _CMP_LT_OQ);
Must only one of the two triangles contribute to the final depthPlane?
What if there is a quad composed of two triangles with similar large areas?
If I have an understanding error, please point it out.
I have a question. After rasterization, the depth buffer is ok, but how to get a visibility check?
What would be the simplest way to integrate backface culling control (on/off) into rasterize()
?
Sometimes it is useful to run the code on "bad" geometry.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.