dilevin / computer-graphics-shader-pipeline

Computer Graphics Assignment about the Shader Pipeline
2 stars 5 forks source link

Phong shading not shading correctly (and noise in centre) bump map #11

Closed csc418-anon closed 5 years ago

csc418-anon commented 5 years ago

I have a directional light coming from the top left, so the bottom right of the sphere should be dark, yet it isn't.

I also have a bit of noise right in the centre, not sure why, but when you rotate it it's not there, it's just that specific part of the sphere.

But my biggest issue is the lighting, where it's lighting more of the sphere than it should.

image

This is supposed to be the 'back', yet there is lighting. I tried debugging the Normals without bumps, and it passes all the checkmarks, even the Perlin Noise seems to be colouring things in correctly. Any suggestions?

image
rarora7777 commented 5 years ago

Does your Blinn-Phong sphere (without noise) look okay?

Also, since you are using a directional light, it is possible that the Perlin-noised normals on these parts of the sphere actually have a positive dot product with the light direction. So your result may be completely correct.

If the answer to the first question is yes, and you're sure that the result you have posted is incorrect, then please post a result which doesn't use Perlin noise for the kd, ka, etc. and I can try to help out more.

csc418-anon commented 5 years ago

Thank you for the response, genuinely appreciate it!

This was with Perlin Noise but no bumps (JSON -06

image

I just noticed there's weird discontinuation lines as shown in this image, however the overall sphere is 'okay'

This is the image w/o Perlin Noise, and just the bumps:

When I zoom in really closely, the noise appears, when I zoom out, it disappears

image image

Anyways any suggestion is much appreciated!

rin-23 commented 5 years ago

regarding your light problem. when passing view, normal and light vectors to blingphong function you need to make sure they are in the same space (view space for example).

rin-23 commented 5 years ago

Try fixing the light first and see if that gets rid of noise.

csc418-anon commented 5 years ago

So it looks like this:

image

It still looks slightly off on the lit part. The noise seems to be gone.

EDIT:

image

vs

image

Another edit,

This is the lighting, kind of a given point close up, but kind of expected I assume?

image

And lastly, when I change my height function (still returns -0.1-0.1). But the zooming in/out issue is fixed now.

image
csc418-anon commented 5 years ago

@rin-23 Thank you for your help.

For those that run into a similar issue: So basically I a lot went wrong when producing the bump maps, firstly I didn't update my point to view space, which was a major issue.

Secondly, I was using a sin function to determine the bump height with the noise, and it just looks awkward, and off, so I just removed it, and started playing with the frequency inside the noise to create literal bumps of terrain (similar to those in the gif).

Thanks again @rin-23 for the response, cheers.