LDraw.org Discussion Forums

Full Version: Texture mapping experiment
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
You'll find here my first experiment with Texture mapping extension...
A few issues...
- Resolution (here 300dpi) looks fairly low, despite a rather large image size.
- The image was obtained by scanning the sticker sheet. But there are color matching issues! image file 10602r0.png is raw from scanner. In the image used for mapping (10602r.png) I tried to substitute yellow and red values obtained from LDconfig.ldr, but when you look at part with sticker (64683stick-r.dat) using LDView, you see that match is still far from perfect. And what happens if LDConfig color definition is tuned? The sticker will no longer match...
- Smooth shading doesn't seem effective in LDView with texmap (see parts with "condlines" in filename)
- This forum doesn't let me post texture images directly! (or a zipped folder...).

Comments? Suggestions?

Edit: Just noticed that subfile 64683s03.dat wrongly contained top surface. Now corrected in archive linked above.
Maybe playing around with a fixed palette (using some of the LDraw colors) helps. You could then (in theory) use a descent image converter to map all pixels to the nearest LDraw colors.
Interesting suggestion.
BTW1, is it possible to use paletized PNGs? LDView doesn't seem to support them Sad
BTW2, do you plan to add texmap to LDCad? (I know you are busy with flex parts Wink
#1: I think so, the libpng source seem to support it. But you could also use a different (loss less) format for the palette conversion (gif, bmp), and then convert it back to rgb(a) afterwards. irfanview could possible do most of the work (with some plugins).

#2: Yes I will add support for textures in LDCad, biggest issue for me with that is how to keep the 'normal' rendering at the current speed.


Thinking about libpng, you could probably make a relatively easy c++ program using libpng to convert a png to one using the nearest LDraw colors without having to use all kinds of tools.
Maybe that's not so simple. I made some tests using Photoshop, using a 4 colors palette with only LDraw colors. Problem is that RGB -> 4 colors palette conversion finds a red fringe around black areas...
could be Photoshop applying anti aliasing. Or if the source it self has a gradient (usually also aa) of red on that location.

Maybe you could use a second 'lesser' red control color, you can change to black afterwards.
No, I think it's just proximity of jellow and black that produce an intermediate tone actually closer to red. Anyway for relatively straighforward pattern like this one, it would be better/simpler to vectorize the image. But then we are not far away from old style patterns Wink
This unwanted dithering might be caused by Photoshop mapping pixels to the nearest palette color in an area where it's pretty much 50/50 between 'rounding' to yellow or black so it goes yellow for one pixel and black for one besides it although it might only be like 1rgb value higher or lower. Not sure how to fix that, I'm not that familiar with Photoshop.

I actually think most patterns will be indeed better of using the old way, but textures are very handy for extremely complex stuff or placeholders until someone finds the time to make a vector version.
Indeed, this one is pretty simple. I started this experimentation with a really complex one in mind...
I'll investigate what might be needed to support paletted PNGs in LDView. Could you send me a sample file (both texture and part)? That would make my life easier.
Pages: 1 2 3