I was seriously going to do that after lunch lol. Great minds think alike lol
OpenGL 4 reflections
I'm still having trouble with not doing reflections if the normal is compared against something else, in order to overwrite the specularity map with black. If I can get this working, then the upper tiles can be reflective too.
The relevant portion of the point.fs.glsl file is:
if(specular_only == 1)
{
FragColor = texture(specularTexture, fs_in.TexCoords);
// This is driving me nuts...
// vec3 n = normalize(fs_in.untransformed_position);
// vec3 n2 = normalize(viewPos - vec3(0, 0, 0)); // Use this as an example position
// if(dot(n, n2) > -0.9)
// FragColor = vec4(0, 0, 0, 1);
return;
}
P.S. The whole code and media are at: https://github.com/sjhalayka/obj_ogl4
An example of what I want to get rid of is:
taby said:
vec3 n2 = normalize(viewPos - vec3(0, 0, 0));
Probably you don't need a view vector at all for this. You only need to check if the fragment normal in world space is matching the planer reflection direction, which is up in the actual case.
Yep, here we go:
if(specular_only == 1)
{
FragColor = texture(specularTexture, fs_in.TexCoords);
vec3 n = fs_in.untransformed_normal;
vec3 n2 = vec3(0, 1, 0); // Use this as an example position
if(dot(n, n2) < 0.95)
FragColor = vec4(0, 0, 0, 1);
return;
}
Yeah, looks great.
I guess there should be some simple hack to offset the reflection depending on height a bit. But i have no precise idea how. ; )
Yeah, I’m thinking that scale by -1 on y axis, then translate upward. I’m thinking that the mesh height has something to do with it. Things will be clearer with time.
Thanks so much for all of your help!
taby said:
Yeah, I’m thinking that scale by -1 on y axis, then translate upward. I’m thinking that the mesh height has something to do with it. Things will be clearer with time.
For such case it would be helpful to have a reference. Once you see ground truth, it should be easier to get an idea and then proof its error.
So maybe it's worth you implement a second reflection plane just to get this reference.