I think I fixed it

Published March 23, 2006
Advertisement
I think I fixed the problem with my specular highlights. I'm still not 100% convinced (doubt I ever will be) but at least they now don't look completely fubar'd [lol]

Seems that I made the mistake of passing a "raw" vector from the VS->PS via a TEXCOORD semantic. I'm sure I've done similar things before and not had any problems, but I guess in this instance it decided to hurt me.

Normalizing the vector before handing it over to the PS seems to have solved it:


Simple test of the specular on a sphere - a 16.0 exponent being used.


The same sphere but through the final blinn-phong shader. The specular highlight is more difficult to see this time, but it is there [grin]

My tasks this evening, time permitting will be to test my anisotropic model - which should allow me to control the shape of the specular contribution. Also, from this thread it seems my ATI drivers are over a year out of date - so I'll see about upgrading those and see if they solve my VPU-wants-to-explode crashes.

To finish off this entry, I got a PM from superpig yesterday:
Quote:Sam G cited your material system article in the MS Developer Day sessions today [grin]
"Sam G" being Sam Glassenberg - the program manager for Direct3D and the material system being this one if you missed it.

Two things I'd like to do at some point in my career are to write a book and give a talk at GDC (or quivalent) - I suppose being cited in one of the GDC talks is a step in the right direction [grin][grin][grin]

Jack
0 likes 6 comments

Comments

Cypher19
Um, I think you'll have better results if you normalize the vector in the PS, immediately before lighting calc, as opposed to in the VS. Your normal mapping in the second photo would look much better I imagine. (Also, do you know what that little halo is in the first shot?)

Also, what's with that white stuff in the TR corner of the 2nd shot? Accidental glare?
March 23, 2006 01:37 PM
jollyjeffers
I renormalize them again in the PS, so I can guarantee that they're of unit-length for the lighting calculations. I can't see a good reason why I had to do it the way I did, but it was broken and now it works - go figure [oh]

As for the halo - uhm, what halo? I can't see one! There's a little bit of bloom appearing on one side, but thats the closest I can see...

Cheers,
Jack
March 23, 2006 02:36 PM
acid2
Big congrats on the mention in GDC - you need to link to the slide if/when its online ^^
March 23, 2006 02:43 PM
Cypher19
Jack: Well, it looks like there's a ring where the grey is held on for a bit too long. It may be a JPEG error (when magnified it looks pretty banded and more pixely than it should be) or less likely a precision error.
March 23, 2006 03:52 PM
SimmerD
If it's your eye or light position you are passing down, then it should not be normalized in the VS, it's a position, not a vector, so needs to be linearly interpolated.

That said, if you are computing R or H, these are not linear positions, but vectors, so you can normalize them and pass them down ( to renormalize again ).

The best way is to pass E and L down to the pixel shader as unnormalized texcoords, then normalize them, then compute R or H in the pixel shader.

Failing to do this can cause wobbles.
March 23, 2006 10:46 PM
jollyjeffers
Thanks for the comments

Quote:Big congrats on the mention in GDC - you need to link to the slide if/when its online ^^
I will if the slides are available and provided it actually appears on the slides (could have been a spoken citation - I don't know for sure!)

Quote:It may be a JPEG error (when magnified it looks pretty banded and more pixely than it should be) or less likely a precision error.
I'm not sure if it's the same thing, but there are a number of artifacts with the texture mapping. A bit of one of the seams is visible in the above shot, but I would call it more distortion than a halo.

I'll look into it further when I get time.

Quote:If it's your eye or light position you are passing down, then it should not be normalized in the VS, it's a position, not a vector, so needs to be linearly interpolated.
Yup, I compute the vectors in the VS rather than pass the positions down. I might be wrong, but I figured that the eye-vector would be correct when interpolated by the hardware and thus be quicker than (re)computing it in the PS.

Quote:The best way is to pass E and L down to the pixel shader as unnormalized texcoords, then normalize them, then compute R or H in the pixel shader.
hmm, I don't think thats what I'm doing. Maybe I'll give this method another shot...

I was thinking last night that it might be something to do with my coordinate systems. My VS is converting all vectors to tangent-space using an appropriate matrix, thus all PS computations should be done in tangent-space which makes sense to me. But at least one of the reference books doesn't seem to do this for the HALF vector...

Cheers,
Jack

March 24, 2006 04:16 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement