Reduce "shadow acne" artifacts
PiperOrigin-RevId: 725640931 Change-Id: I95df97d6076b99c12e291f69e8e54bbe70538293
This commit is contained in:
committed by
Copybara-Service
parent
cef5b31a3f
commit
ac2a324fbd
@@ -32,6 +32,7 @@ General
|
|||||||
behavior is to perform such a shallow copy. The old behavior of creating a deep copy of the child model while
|
behavior is to perform such a shallow copy. The old behavior of creating a deep copy of the child model while
|
||||||
attaching can be restored by setting the deep copy flag to 1.
|
attaching can be restored by setting the deep copy flag to 1.
|
||||||
- Added :ref:`potential<sensor-e_potential>` and :ref:`kinetic<sensor-e_kinetic>` energy sensors.
|
- Added :ref:`potential<sensor-e_potential>` and :ref:`kinetic<sensor-e_kinetic>` energy sensors.
|
||||||
|
- Improved shadow rendering in the native renderer.
|
||||||
|
|
||||||
MJX
|
MJX
|
||||||
^^^
|
^^^
|
||||||
|
|||||||
+10
-2
@@ -1205,10 +1205,15 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
|||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
glViewport(
|
glViewport(
|
||||||
1, 1, con->shadowSize-2, con->shadowSize-2); // avoid infinite shadows from edges
|
1, 1, con->shadowSize-2, con->shadowSize-2); // avoid infinite shadows from edges
|
||||||
glCullFace(GL_FRONT);
|
|
||||||
glShadeModel(GL_FLAT);
|
glShadeModel(GL_FLAT);
|
||||||
glDisable(GL_LIGHTING);
|
glDisable(GL_LIGHTING);
|
||||||
glColorMask(0, 0, 0, 0);
|
glColorMask(0, 0, 0, 0);
|
||||||
|
int cull_face = glIsEnabled(GL_CULL_FACE);
|
||||||
|
glDisable(GL_CULL_FACE); // all faces cast shadows
|
||||||
|
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||||
|
float kOffsetFactor = -1.5f;
|
||||||
|
float kOffsetUnits = -4.0f;
|
||||||
|
glPolygonOffset(kOffsetFactor, kOffsetUnits); // prevents "shadow acne"
|
||||||
|
|
||||||
// render all geoms to depth texture
|
// render all geoms to depth texture
|
||||||
for (int j=0; j < ngeom; j++) {
|
for (int j=0; j < ngeom; j++) {
|
||||||
@@ -1220,7 +1225,10 @@ void mjr_render(mjrRect viewport, mjvScene* scn, const mjrContext* con) {
|
|||||||
con->currentBuffer == mjFB_WINDOW ? 0 : con->offFBO);
|
con->currentBuffer == mjFB_WINDOW ? 0 : con->offFBO);
|
||||||
glDrawBuffer(drawbuffer);
|
glDrawBuffer(drawbuffer);
|
||||||
glViewport(viewport.left, viewport.bottom, viewport.width, viewport.height);
|
glViewport(viewport.left, viewport.bottom, viewport.width, viewport.height);
|
||||||
glCullFace(GL_BACK);
|
if (cull_face) {
|
||||||
|
glEnable(GL_CULL_FACE);
|
||||||
|
}
|
||||||
|
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||||
glShadeModel(GL_SMOOTH);
|
glShadeModel(GL_SMOOTH);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glColorMask(1, 1, 1, 1);
|
glColorMask(1, 1, 1, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user