LDraw.org Discussion Forums

Full Version: Another texture mapping experiment...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Following my first foray in uncharted texmap country, I made another try, this time using Eomer helmet.
The big problem is to create the image for texture map. The part is not flat, so despite rather good lighting, it's not uniform, and plenty of reflexions. Moreover, printing itself is full of smudges. So you have to redraw the image anyway...
[Image: helmet-side-photo.jpg]
So I tried to kill two birds with one stone, and use LDraw Patterns Creator to create the drawing. OK, LPC is certainly not the most handy vector drawing program, but with it I obtained "old style" triangle based texturing of the part for comparison (and usage with MLCad...)
The next step was to generate images from the LDraw model. Easy...
- Open it using LDView
- In LDView options, disable lighting and edge lines. Set the field of view to a very low angle value (0.1°).
- Save a snapshot from the directions you want to project, with a transparent background. Here from side:
[Image: helmet-side-tex.png]
- You may want to show all conditional lines and make another snapshot. This shows the facets limits and will help to properly crop the image.
- Using an image editor, remove all areas that use main color, and crop your file to the area needed for mapping. For the helmet, I used two projections, one from front, one from side.
Here is the compared result.
[Image: helmet1.png]
Front helmet is the textured one, back helmet is the triangle-based texturing. As you can see, the good point of texmap is that LDView can do its magic and give a nice, smooth result.
Out of curiosity, I generated another version of triangle textured subpart, this time with conditional lines everywhere to force smooth shading. Result is smoother, but not as good as texture map...
[Image: helmet-c.png]

Now, texture maps have their own problems...
- I still find it very difficult to derive correct values for mapping parameters. Theoretically it's simple, practically it's another story (maybe it's just that I have not yet got the hang of it...). The method I use is to create helper triangles to materialize projection area and when they are right, copy the values in texmap meta:
[Image: helmet-triangle-helpers.png]
- For some reason, LDView properly smooth texmapped mirrored subpart... but not the other side!
[Image: helmet2.png]
- Even though the images I used are relatively high resolution, edges are not so crisp, and there is a slight fringe effect. It seems that partial transparency causes some issue to LDView. Here is an enlarged snapshot, showing that areas in transition region is transparent, instead of merging with main color. I even tried to use completely hard edge around image (helmet2.dat in attached files), the transition area is reduced but still there.
[Image: helmet-fringe.png].

Attached a zip file (renamed .txt to be able to post it here) containing the helmets...
I've been playing with the texmap extension in LDCad (it's not perfect yet), but I was wondering..

How would you expect this texture to blend in combination with the background triangles.

[attachment=1306]

For example setting the part color to green would result in this in my current implementation, but I don't think that's correct.

I also noticed we loose material properties when using textures (no gold/metal look like the fallback code)
Only transparent or partially transparent portions of the texture should allow the background triangle color to be visible. I use GL_MODULATE as my texture env mode, and call glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR) in my lighting setup so that specular highlights will look right with GL_MODULATE, since they're broken otherwise.
Thanks

I didn't even notice the specular thing, but I was already using GL_MODULATE. However using GL_DECAL seems to do the trick.

[attachment=1307]

don't know how it will behave combined with alpha transparency parts yet though. I still need to incorporated the texture stuff into the transparency rendering path in order to fine tune that.

Also I'm having a little gap at the front, but I noticed LDView has the same gap so it might be a part flaw?

ps: I noticed LDView 4.2 beta1 only uses the textures once (one side on 1st part like Philo wrote, and second part usage seems to only use the fallback code.)
I am not so happy with the creased look of my Friends heads... so I tried texmap on one of them. The texmap image was generated with the exact same method described it - it would be very easy to generate such an image for all existing heads.
[attachment=1350]
As you can see, the result is MUCH better! The only drawback (with LDView) is the grey fringe that appears at the opaque/transparent transition. Roland, I would be happy to see how it looks with LDCad Wink
Here's how it looks in the current version.

[attachment=1352]

LDCad doesn't have the gray edges because I use the 'nearest pixel' texture mode instead of linear. Linear will also cause seams when two textures meet (e.g. the front of the helmet), so I switched a while back. Downside it will look more pixelated at close ups when using low res pictures.
Wow! Thanks, Roland. Yes, we can see pixels, but nothing objectabe at a reasonnable size (and the texture image is pretty small, both in pixel and file size). But actually... the textured-by-triangles version already looks quite good! Any chance that some day you create a light weight/fast load viewer using the same engine? Wink
No problem,

On the viewer thing, the engine is very editing orientated so splitting it into a second application probably wont save much launch time etc.

But I have been thinking about doing more (building instruction wise) with the read only mode in a future version.

So for a quick viewing LDView will probably remain the best choice.