Sign in to follow this  

Custom shadow transformation trouble

Recommended Posts

[font="Arial,"][size="4"]This is a cross post of mine from [url=""]Stackoverlfow[/url]:[/size]

[size="4"]I am trying to cast a shadow with a projection transformation. But it seems that OpenGL doesn't like my matrix as it does not draw anything after glMultMatrix. After I pop my matrix everything's ok. I'm also using JOGL, maybe the problem's with that, but I doubt it since my custom translation and rotation matrices work fine.[/size]

[size="4"]The matrix looks like this:[/size]

[code]lightPosition = {x, y, z, 1}
planeEquation = {a, b, c, d}
pl = a*x + b*y + c*z + d

a*x-pl b*x c*x d*x
a*y b*y-pl c*y d*y
a*z b*z c*z-pl d*z
a b c d-pl[/code]
[size="4"]Now this is a matrix which I calculated, but I also used two other flavors I searched for on the internet; one a bit different, and another which is exactly like mine times -1. Is this enough information? Or should I submit code also?[/size]

[size="4"]Maybe it's my plane equation?[/size]

[code]three points on plane = p0, p1, p2

v0 = p1 - p0
v1 = p2 - p0

n = {a, b, c} = v0 (cross) v1
d = -(n (dot) p0)

planeEquation = {a, b, c, d}[/code]
[/font][font="Arial,"][/font][font="Arial,"][size="4"]Does it sound familiar to anyone? Or it's just a code thing?[/size]

[size="4"][font="Arial,"]There's this test that I'm trying to do, and that to draw a single vertex point with and without the matrix (for an x-z plane and a {0, 20, 0} spot light), and with an orthogonal projection matrix. Also, I'm trying to calculate myself the normalized device coordinates of that vertex by getting OpenGL's projection and model view matrices and multiplying it with them, and normalizing with the w coordinate.[/font][/size][/font]
[font="Arial,"] [/font]
[font="Arial,"][size="4"]What I get is that without my "shadow matrix" it displays the point nicely and it seems my calculations of the vertex match what I'm seeing. But with my "shadow matrix" I get nothing, although the vertex's coordinates lie within the [-1,1] range on all axes.[/size]

[size="4"]This is just too strange...[/size]

[size="4"]added test program here: [url=""]https://gist.github....d5ab3cbc92dffe6[/url][/size]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this