• Create Account

# oggs91

Member Since 01 Sep 2010
Offline Last Active Dec 21 2015 10:25 AM

### In Topic: Can't fix shadow acne with bias

15 February 2015 - 03:35 AM

For the shadow acne, try culling the front faces when rendering your shadow map (if you're not already. I didn't see it in your code, but I'm not terribly familiar with directx. But, I imagine directx lets you front/back cull faces). Then go back to back-face culling when rendering the scene.

think about how big a texel from the shadowmap is if it's projected onto your terrain, clearly the area each texel has to cover is bigger if the light is low above the ground and producing very long shadows. biasing can correct this to a certain extent but if your shadowmap resolution is too small that won't help either. a simple solution would be to just increase the shadowmap resolution, and/or limit the possible light angle.

i think a proper solution would be to use a cascaded shadowmapping technique

### In Topic: Help with basic deferred lighting please - Solved

14 February 2015 - 06:58 PM

```vec3 normal = normalize(transpose(inverse(mat3(u_modelMat))) * texture2D(tNormals, fragTexCoord0.xy).rgb);
```

this has to be done in the geometry pass, your lighting pass does not know which fragment comes from what object ( u_modelMat is for a specific object )

your normal transformation was ok i think in post #3

anyway to find out why the dot product is always zero draw lightVector and normal as RGB an inspect the two resulting images (you can also make abs() to show negative values too ) ... if you can't conclude whats wrong post the output images

### In Topic: Help with basic deferred lighting please - Solved

13 February 2015 - 02:52 PM

replace

vec3 halfVector = normalize(lightVector + normalize(-position));

with

vec3 viewVector = normalize(position - cameraPosition);

vec3 halfVector = normalize(lightVector + viewVector);

like light position you also have to pass the camera position as a uniform to the shader

remember you are doing lighting there in worldspace, not in viewspace. in viewspace the direction to the viewer would be -position

Edit: Hahah - nice surprise in the middle of your demo video !

thx

### In Topic: Help with basic deferred lighting please - Solved

13 February 2015 - 10:11 AM

• GL_FRAMEBUFFER_UNSUPPORTED is returned if the combination of internal formats of the attached images violates an implementation-dependent set of restrictions.

https://www.opengl.org/sdk/docs/man3/xhtml/glCheckFramebufferStatus.xml

i'm not sure what is the problem here

see for possible formats https://www.opengl.org/sdk/docs/man/html/glTexImage2D.xhtml

but anyway, you want 16 or 32 bit values for position and normals, also with 3 not 4 values

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, height, 0, GL_RGB, GL_FLOAT, NULL); // position, 3 float values

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, height, 0, GL_RGB, GL_FLOAT, NULL); // normals, 3 float values
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_FLOAT, NULL); // diffuse color, 3 float values, or 4 values with alpha (GL_RGBA)

for more details consider my deferred rendering code https://github.com/oggs91/CGUE2014-15/blob/master/src/DeferredPipeline.cpp line 333

### In Topic: Help with basic deferred lighting please - Solved

13 February 2015 - 02:11 AM

that's no opengl command ...

gl_createGBufTex(GL_TEXTURE2, GL_RGB32F, id_textures[GBUFFER_TEXTURE_TYPE_NORMAL], GL_RGB, screenWidth, screenHeight); // Normal

could you provide sourcecode for this?

since you don't specifiy it in gl_createGBufTex the GL_FLOAT part may be missing

PARTNERS