dilevin / computer-graphics-shader-pipeline

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

Partitioned sphere in bump.fs #37

Open Navash914 opened 4 years ago

Navash914 commented 4 years ago

When I try to apply bump mapping, my planet and moon seem to get divided into clearly defined partitions:

2020-02-26-160459_1920x1080_scrot

What could be causing this?

For reference, the way I'm trying to bump is:

// Get Tangent and Bitangent Vectors vec3 T, B; tangent(normalize(normal_fs_in), T, B); float eps = 0.0001;

// Get the two vectors to cross vec3 v1 = (bump_position(is_moon, normal_fs_in + eps T) - bump_position(is_moon, normal_fs_in)) / eps; vec3 v2 = (bump_position(is_moon, normal_fs_in + eps B) - bump_position(is_moon, normal_fs_in)) / eps;

// Get normal n = normalize(cross(v1, v2));

And n is passed as the normal to blinn phong shading (I changed nothing else from procedural_color, which is working).

abhimadan commented 4 years ago

Try plotting your bump heights as colours on the spheres. This looks like a problem with either your use of Perlin noise or the data you're passing to the Perlin noise function.

abhimadan commented 4 years ago

Also, make sure you're doing bump mapping calculations in model space (i.e., before any transformations). In your current code, it's being done in camera space. If the sphere coordinates aren't in model space, you can't use position and normal interchangeably.

AnqiGao98 commented 4 years ago

same problem. have u fixed it?