I start with a normal sphere which I need to deform into an oval-looking shape. I do this by stretching one axis, which in my code will be the y axis.
mat4 ToOvalMat = mat4(vec4(1., 0., 0., 0.),
vec4(0., 1.5, 0., 0.),
vec4(0., 0., 1., 0.),
vec4(0., 0., 0., 1.));
I stretch it by 1.5 multiplied by an input called a. It works well for my intentions, but I still need to figure out a good way to fix the normals and get proper shadows, as they are still tied to the original sphere.
After hunting for an answer on Google I stumpled upon GPU Gems - Deformers, which related to the normals but I don't quite understand the concepts explained. The Jacobian Matrix seems like it would be able to solve my normals problem but I am not so sure and would like some kind of help or feedback regarding my calculation, as it is hard to see from the render in my given test program.
Since I am stretching in the y dimension I have a normal unit matrix of size 4, where I just replace the y 1 with 1.5a. This would be my Jacobian Matrix, if I understood the text properly. Inversing and then transposing this matrix would then be what I would multiply my normals with. Can I also use this on my ShadowMatrix?
Normal = (transpose(inverse(ToOvalMat)) * vec4(VertexNormal, 0.)).xyz;
Normal = normalize((ViewMatrix * WorldMatrix * vec4(Normal, 0.)).xyz);
I am getting some artifacts with these calculations and they are not completely selling it for me in regards to believability, which makes me feel like something is off with my matrices or something. And I completely guessed with the ShadowMatrix as I have not yet looked into it enough yet since I've been stuck on the normals up until now.