Incorrect Interpolation from Vertex Shader to Pixel Shader

Started by
12 comments, last by PDX_Catalyst 15 years, 9 months ago
Well, I played with the numbers, but it only changed the shade amounts, not the pattern, and I realized that logically that's what I should expect. Changing the normals will change the amount of shading contributed by each vertex, but the amount of shading at each vertex point isn't the problem. The problem is the way the three shade amounts are interpolating across the triangle. This also seems to be an issue with the interpolation of other numbers being passed from the vertex shader. For instance when I pass a float4 that holds texture information it seems to interpolate incorrectly as well... though I haven't looked into that one yet.

I really wish I could get in there and write that interpolation formula myself.

Any other thoughts?
Advertisement
Ok, so it's just the way bilinear sampling is. I created a small image that had one pixel per vertice, each colored the correct shade amount. I put that image into Photoshop and blew it up using bilinear resampling. It had the same patterns in it. Bicubic also had that pattern. Bicubic Smoother looked great.

So... I guess the only way to get rid of those patterns is to do the sampling myself in the pixel shader (from a terrain/shade map) and use a formula similar to what Photoshop uses for Bicubic Smoother.

Sounds expensive. =(
Make sure you aren't normalizing your normals in the vertex shader.
Otherwise you are getting gouraud shading which results in a diamond shading pattern.

This link explains it nicely (search for normalize).
http://wiki.truevision3d.com/hlsl_intrinsics

I had this problem a while back. Most noticable with specular highlights.

I tried that but I still got the same lines. I figured out with photoshop that the lines are just a product of the linear interpolation (as described in my previous reply). The only solution I've come up with so far is making a map of the shading at each vertex and then taking a sort of blurred sample of it. That's only really works because it's for a grid terrain. Wouldn't help if I were shading a model or something.

I also have three texture strengths in the map (shade in alpha). The blurred sampling makes for some nice texture transitions too.

This topic is closed to new replies.

Advertisement