Texturemap Rendering and Sampling

Started by
5 comments, last by dpadam450 9 years, 2 months ago

Suppose i have a model with given vertex colors and a texture parameterization. i then render all faces of the model to a texturemap with interpolated vertex colors. this results in a texturemap of the model ( image1 )

now i can render my model texturemapped, which results in image2 and image3

but as you can see, i have some troubles there with texture sampling. in image2 you see clearly some white sprinkles at texture seams.

I think this comes through texture minification (while rendering the texturemapped model) and maybe also different rasterization, i can't exactly tell :/

My first solution was while drawing to the texturemap, first draw a wireframe prepass with increased linewidth, then overdraw the model ... indeed this reduced the problem, but some white sprinkles are still visible

how would you solve this?

other ideas:

draw without AA, inpaint algorithm for white pixels ( but i think this is too much work )

use texture with alpha, setting white pixels to invisible ( not sure if this would work ) also this is no robust solution if a renderer is used without alpha support

image1

K4Oo2TI.png

image2hkDStAv.png

image3

e7dWTUd.png

image4 - texturemap zoomed

jKsADSK.png

Advertisement

As you suggested, you can draw to the texture map as is and then do a second pass the same exact way just with wireframe and very thick lines. That is the way I solved this problem. If there were sprinkles maybe it was because your lines weren't thick enough.

Setting your texture sampling to nearest will probably work too.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

The thick line solution sounds good :)

In the past I've used something like the "draw without AA, inpaint algorithm for white pixels" solution.
My "white" pixels had zero alpha while the rendered pixels had 100% alpha. I did a post-process blur on the texture, only writing to areas with zero alpha, and only reading from areas with 100% alpha, which spread appropriate colour values into the non-rendered areas.

(Depending on how conservaticely your original render-colour-to-texture pass is rasterized) if you're using bilinear filtering, you only need this border area to extend about 1px. But, if you're using mip-mapping, the border must extend an extra 2px per mip level that exists.

As you suggested, you can draw to the texture map as is and then do a second pass the same exact way just with wireframe and very thick lines. That is the way I solved this problem. If there were sprinkles maybe it was because your lines weren't thick enough.

Setting your texture sampling to nearest will probably work too.

thx padam450, setting texture sampling to nearest is not an option for me because the model has to be renderable with any renderer

i discovered the problem with linerendering. if the angle between two edges is <90° i also get some white space next to the vertex position which is not acceptable

g99aMkg.png

i could render dots with appropriate size

aKrgvrw.png

but i feel like there must be a better solution ...

The thick line solution sounds good smile.png

In the past I've used something like the "draw without AA, inpaint algorithm for white pixels" solution.
My "white" pixels had zero alpha while the rendered pixels had 100% alpha. I did a post-process blur on the texture, only writing to areas with zero alpha, and only reading from areas with 100% alpha, which spread appropriate colour values into the non-rendered areas.

(Depending on how conservaticely your original render-colour-to-texture pass is rasterized) if you're using bilinear filtering, you only need this border area to extend about 1px. But, if you're using mip-mapping, the border must extend an extra 2px per mip level that exists.

thx hodgman!

the blur approach sounds very reasonable to me! also super simple to implement :)

i thought this a bit further... as you said the blur should be only applied to pixels with alpha=0

therefore would normalize the blur kernel with the sum of weights at positions where alpha != 0

if i apply the blur once i get a border of 1 pixel around my chart

in the 1d case (with blur [0.5 1 0.5]) it would look like this:

FOWnUep.png

so applying the "blur" multiple times with a fragment shader, eventually fills the whole texture

The line method should work just fine. How thick of lines were you using? I had to bump mine to be several pixels thick maybe even like 10 pixels and that should fill in that corner gap in your picture.

Either way the blur should do the job too and sounds like it is.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

This topic is closed to new replies.

Advertisement