Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Baking Blender Ray-Traces for Clothing/Skin

Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-13-2006 00:35
I'm annoyed. I want to design a skin. I'm using Blender and I want to ray-trace and have the results saved according to the U-V map for the object. The ray-tracer has to figure out the color at each ray intersection anyway, darn it! Does anyone know if there is a plug-in that will do this (or built-in feature, but I really doubt it because I have searched like crazy; the texture baker script seems to only do radiosity--if it really does that)?

I am about ready to implement my own raytracer to do this (or go find one of my old ones and see if I can modify it), which would be a real pain. That or learn Python and the Blender API. :( Help!

EDIT: Oh, and yes I know you couldn't get a full texture out of this. It would be necessary to interpolate and do several taces and fudge them together or use a default color or whatever....
Laukosargas Svarog
Angel ?
Join date: 18 Aug 2004
Posts: 1,304
08-13-2006 06:55
This seems to be a well kept secret...

BRayBaker


It's fiddly and awkward but it works well when it works !


:)



( btw. the built in Baker script will only render procedural textures to UV, hence it's pretty much useless )
_____________________
Geometry is music frozen...
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-13-2006 14:07
HELL yeah! Thank you so much! I'm going to try installing it right away! Wish me luck!
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-15-2006 23:16
Unfortunately BRayBaker doesn't seem to work at all. The absolute BEST I could do with it after a very large amount of playing is to have it spit out a hodge-podge of unmatched polys (and yes that is with absolutely all specular highlights and ray reflections turned off). I thought I could use the built-in Texture Baker and base my, "lighting," on a procedural texture that uses the vertex normals as inputs, but it seems the built-in Texture Baker won't look up vertex normals in the original mesh like it does positions. :mad: :mad: :mad:

So it looks like it is back to the drawing board. Possibly literally; I might just be writing up my own ray tracer just for this stupid little application....
Laukosargas Svarog
Angel ?
Join date: 18 Aug 2004
Posts: 1,304
08-16-2006 04:12
I've been using it for a while with only a few problems. But I've never tried burning an avatar skin though. One thing, if there's any alpha in your materials it will fail.

Like I said, it's fiddly and awkward but it does work, even on complex models as the model of the old man at the bottom of his page shows. ( Although that looks like it's several textures not just one).


Just about all aspects of Blender are awkward and take a while to learn, the renderer is fantastic, the UI is a joke, much functionality is missing or left to python scripts. But it's free!

If you write your own, would you consider open sourcing it so we can all benefit ?
_____________________
Geometry is music frozen...
Laukosargas Svarog
Angel ?
Join date: 18 Aug 2004
Posts: 1,304
08-16-2006 07:14
Thought I'd just play around with it to see if it works or not, below are two images,

the first is a composite of the original texture, and the 3 AV textures, head, upper and lower as output from BRayBaker...




This is the AV as seen in SL when the skin is uploaded...




The artifacts are caused by the heavy jpeg compression I used when I uploaded the files to flickr.


here are some things to remember..

- The original model in blender must have UV coords.

- Textures must be input mapped to UV. ( not to ORCO or Object etc )

- In the UV editor select the UV faces you want to bake

- In BRayBaker you must turn on the UV button and choose Selected Faces
other settings can be played around with. I generally leave them and resize the final image in Photoshop later.

- BRayBaker will output 100s of small tile images, one for each face, which at the end it will piece together to make the final image, so wait ... it can take quite a long time !
_____________________
Geometry is music frozen...
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-16-2006 13:02
From: Laukosargas Svarog
- Textures must be input mapped to UV. ( not to ORCO or Object etc )

AH! See THAT is my sticking point! I actually WANT to use procedural textures for my skin, not an external image. It is the whole reason I am doing this! I either need something that will render reflections from a single (or multiple prioritized) viewpoints, or I need to be able to fake it by using the vector normals as the texture coordinates (which SHOULDN'T depend on camera position as far as I know; certainly two normal renders seem to show the same colors at the same mesh positions no matter where I put the camera). It seems that neither BRayBaker nor the built-in Texture Baker can do this.

I will show you. Here is a normal Blender render before baking (just the head is easier for me to demo ATM):

(Click to enlarge; again for full size depending on your screen resolution.)


Note that this is NOT done using actual reflections or specular highlights: both are disabled/set to zero in the material! It is PURELY a procedural texture based on vertex normal coordinates. If it is done based on object/global positional coordinates instead, it doesn't look nearly so, "reflective" (this one looks even better with decent OSA, but I'm just demoing the setup and the problem here).

Here is the texture that results from a run of BRayBaker (3 and 3.4 both give the same result, and yes I am using Blender 2.42):

(Click to enlarge; again for full size depending on your screen resolution.)


Crazy huh? I can reduce/eliminate the blue background issues with OSA (and touch it up later for the rest), but the issue of the faces never matching up never goes away no matter how I fiddle with the material, the lighting, the render settings, the size of the tiles, etc.). Here is a Blender render after the bake:

(Click to enlarge; again for full size depending on your screen resolution.)


Bummer, eh?
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-16-2006 13:14
I'll post another pre-bake render to demonstrate the fact that the highlights are on the same part of the mesh despite a significant difference in camera position (thus BRayBaker should THEORETICALLY work):

(Click to enlarge; again for full size depending on your screen resolution)
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-16-2006 13:26
From: Laukosargas Svarog
If you write your own, would you consider open sourcing it so we can all benefit ?

Probably, yeah. It would be in either C++ or Java. I wish I could make my own Blender plugin, but I don't think at this point I want to take the time to learn Python and the Blender API.
Laukosargas Svarog
Angel ?
Join date: 18 Aug 2004
Posts: 1,304
08-16-2006 19:36
From: someone
AH! See THAT is my sticking point! I actually WANT to use procedural textures for my skin, not an external image. It is the whole reason I am doing this!


I'm going to stick my neck on the block here because I'm probably wrong, I'm not pretending to be any kind of super user...

It looks like when you use procedural textures and not images it doesn't work properly! Why it should be any different than using an image I can't imagine. Perhaps this is a bug in Blender 2.42. :(

It might be worth asking around on the Blender discussion boards ?
_____________________
Geometry is music frozen...
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-17-2006 04:42
From: Laukosargas Svarog
It might be worth asking around on the Blender discussion boards ?

I did, and it turns out Blender's Normal mapping doesn't use the vertex normals as they appear in the mesh. It uses vertex normals relative to the camera. BRayBaker thus can't use them because it moves the camera for every face, and the built-in Texture Baker can't use them because the vertex normal always points toward the camera in the UV space. :rolleyes:

Here's the Blender forum thread: http://blenderartists.org/forum/showthread.php?t=74994

I guess I MAY first write a utility that simply takes the vertex normals and saves them in a UV mapping as colors (this will work quite well as a standalone utility because it can take the OBJ file alone as its input--it doesn't need to know camera position, lighting, etc.). I'm not very confident that will work well though, as it seems you can't completely REPLACE the texture coordinates of later texture channels; you can only influence them SLIGHTLY (despite putting the warp factor all the way to the right). :mad:
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-31-2006 09:40
Update
Even my vertex normal baker didn't work with the bakers available for Blender (can't use textures to RELIABLY and EFFECTIVELY change texture coordinates for later channels, the built-in baker calculates only one color per face, etc.). I had to write a full texture baker and my own procedural textures complete with an Improved Perlin Noise algorithm. It works great except that I have to later remove all the seams by hand (I'm thinking about POSSIBLY enhancing the algorithm to fill the gaps...). Anyway, I am considering open-sourcing it, but don't ask me about the timeframe if I do. Heh.