<p>I am trying to implement shadow mapping. Therefore I am trying to render the back faces of the geometry to reduce the shadow acne.</p>
<p>When culling back faces everything works (the geometry will be rendered).
When culling front faces, the geometry is invisible.</p>
<p>what could be reasons for that behavior?</p>
<p>BTW: The geometry is closed (so when rendering only the back faces you should see it).
the fragment shader is not checking for face direction... so there is not the problem.</p>
<p>I replaced the fragment shader to:</p>
<pre><code>void main()
{
    gl_FragColor = vec4(1,1,1,1);
}
</code></pre>
<p>the result is still black (wrong).
But when rendering front faces, the result is white (correct)</p>
<p>I am using</p>
<pre><code>glFrontFace(GL_CCW); 
glEnable(GL_CULL_FACE); 
glCullFace(GL_FRONT);
</code></pre>
<p>I've also tried to do this:
disabling culling and add the following to the fragment shader:</p>
<pre><code>if(gl_FrontFacing == true)
{
    discard;
}
</code></pre>
<p>In principle it is like culling, with difference, that I have a lot of fragment calls... but when doing this way, it works perfectly. But this is not an option due to the bad performance. But it shows me, that the front face culling should work :/</p>
<p>I tried to define front face as CW (which is wrong... my front face is CCW) and culling back faces. This is working as well. But my favorite and easiest to understand solution would be to define front face as CCW and culling front faces when needed.</p>

CC BY-SA 4.0
2022-05-20T06:07:10.570Z
When you're doing backface culling (which works), do you define your front faces as CCW as well?
csisy
CC BY-SA 4.0
2022-05-20T09:28:25.730Z
@csisy yes I do define the faces to be CCW
Thomas
<opengl>
geometry is invisible when culling front faces
Thomas
# geometry is invisible when culling front faces

(Asked by: username_0 on 2022-05-09)

I am trying to implement shadow mapping. Therefore I am trying to render the back faces of the geometry to reduce the shadow acne.

When culling back faces everything works (the geometry will be rendered).
When culling front faces, the geometry is invisible.

what could be reasons for that behavior?

BTW: The geometry is closed (so when rendering only the back faces you should see it).
the fragment shader is not checking for face direction... so there is not the problem.

I replaced the fragment shader to:

```
void main()
{
    gl_FragColor = vec4(1,1,1,1);
}

```

the result is still black (wrong).
But when rendering front faces, the result is white (correct)

I am using

```
glFrontFace(GL_CCW); 
glEnable(GL_CULL_FACE); 
glCullFace(GL_FRONT);

```

I've also tried to do this:
disabling culling and add the following to the fragment shader:

```
if(gl_FrontFacing == true)
{
    discard;
}

```

In principle it is like culling, with difference, that I have a lot of fragment calls... but when doing this way, it works perfectly. But this is not an option due to the bad performance. But it shows me, that the front face culling should work :/

I tried to define front face as CW (which is wrong... my front face is CCW) and culling back faces. This is working as well. But my favorite and easiest to understand solution would be to define front face as CCW and culling front faces when needed.

**Tags:** opengl

> **Comments:**
> **username_1**: When you're doing backface culling (which works), do you define your front faces as CCW as well?  
> **username_0**: @username_1 yes I do define the faces to be CCW  

---

## 0 answers

