PDA

View Full Version : Can the surface baking camera be used for this?



Mipmap
06-25-2007, 08:11 PM
I'm trying to figure out if the surface baking camera is suitable for baking a completely surfaced game object. I've figured out how to use it to render sky box\sphere textures for games, so given the recent discussion about games in another thread I thought I'd try this.

All I really wanted to do here was surface the object like any other Lightwave object I would make, (colors, texture maps, etc.) then light it and bake the entire thing to the UV map. I wanted everything from the way it looked in a normal render to be baked into the object texture.

Part of the object is glass, so I'd also wanted the specular to be baked in just how it was seen through the camera so the specular would look good when seen from the angle that the player will see it.

The old surface baker seems completely unfit for this. I've been messing with the surface baking camera and can't really see at the moment how this can be done.

I have 4 choices for the direction reference, and all of them give me errors one place or the other. The camera origin will give me the correct specular baked in that I want, but it seems that any polygons which aren't facing the camera don't show up and my scene backdrop color appears in the baked image instead.

The Test Object:
http://home.comcast.net/~to-ryan/bottle/bottle.jpg

My Settings:
http://home.comcast.net/~to-ryan/bottle/bottle2.jpg

The object selected as the Mesh is the object you see in the first image which I am trying to bake.

Here are the different direction references I tried:

Polygon Normal:
http://home.comcast.net/~to-ryan/bottle/bottle3.jpg

Smoothed Normal:
http://home.comcast.net/~to-ryan/bottle/bottle4.jpg

Mesh Origin:
http://home.comcast.net/~to-ryan/bottle/bottle5.jpg

Camera Position:
http://home.comcast.net/~to-ryan/bottle/bottle6.jpg

As you can see they all look pretty messed up. The camera position setting gets the right specular appearance for what part of it does show up correctly. The strange polygonal artifacts that show up I have been able to get most of them to go away by adjusting the "Offset from Surface" setting. However if I do this too much then new ones begin to appear before the existing ones are gone.

Another thing I have thought of to try was putting a clone of my object inside itself with the polygons inverted facing the mesh of the copy I am trying to bake, and then use that cloned\inverted one as my mesh. That didn't really seem to work for me either, so at the moment I am stumped.

Can this actually be done? Or is this tool just not intended\capable of just rendering an object as it is seen to a texture? In this case there are no surroundings I am trying to capture to a UV. It is just the object itself I am trying to get rendered into its own UVs while maintaining the specular appearance as seen from the view of the camera.

G M D THREE
06-25-2007, 09:23 PM
How does your UV look like? Do you have any polygons on top of each other in the UV? Usually that causes messy renders when using baking cam.

An other trick you could consider is render your bottle from the front and project the render back on the bottle making the whole bottle one surface 100% lum and 0% defuse.

///

scenicdave
06-26-2007, 02:33 AM
Hi Mipmap,
The problem is with the UV map. In Modeler make a new uv map, (atlas is perfect for this) and reference this map in the baking camera.

Layout will render the bottle according to these uv coords. You'll get a horrible looking image of polys that will perfectly map back to your object. UV border is a pixel control to add a little more to the polys in case of black lines appearing at low resolutions.

In surfacing, apply this image to the object using the new UV atlas map. It's fast, easy and very useful. Ambient occlusions in particular really benefit from this workflow.

regards
Dave Tracey
Sydney

Mipmap
06-26-2007, 12:47 PM
I made an Atlas UV on the bottle and tried rendering it again and this is what I got:

http://home.comcast.net/~to-ryan/bottle/bottle7.jpghttp://home.comcast.net/~to-ryan/bottle/bottle8.jpg

Some of it comes out right, but then other stuff comes out completely messed up. It seems like only the stuff facing the camera appears to come out the right way, and then everything else is showing the background color of the scene, which is white. If I go to the image viewer and switch it to show the alpha, everything that showed my backdrop color is black in the alpha, so its not even there.

If I move the camera to the opposite side of the bottle, then my render will have the much of the area that was being rendered in the last shot white, and new parts are rendered. So it does seem to be only showing me what the camera can see, rather than just baking the entire objects surface to the UV map.

dpont
06-26-2007, 01:01 PM
Select "Smoothed Normal" instead of "Camera Position" for
Direction Reference in SB panel.

Denis.

Mipmap
06-26-2007, 01:20 PM
If I do that all the errors of rendering the backdrop color go away except for the some of the artifacts showing up on the cloth. I can get some of these errors to shrink a little by adjusting the offset but some remain, and if I do make the offset higher than 400um then new errors begin to appear in other places.

The other problem there is by using smoothed normals most of the reflection and specular lighting doesn't seem to show up, and what does show of them shows in the incorrect spot. I was wanting to have that lighting baked in as if you are viewing it from the front.

scenicdave
06-26-2007, 01:34 PM
It seems like only the stuff facing the camera appears to come out the right way,

Hi MipMap,
Isn't this what you want though?
regards
Dave Tracey
Sydney

Mipmap
06-26-2007, 01:49 PM
This is a test to see how I can use this for making video game objects.

The goal would be to have everything baked to the objects UVs so that after rendering it I have a complete, finished texture. So what I wanted was for the texture to look correct when the render output is applied onto the object's UVs as a color texture, and viewed from any angle.

If I use any setting other than "Camera Position", my specular highlights are in the wrong spot because I want them in the same location as they are seen from the camera's view. The reflections also don't seem to show quite as much on other settings as well.

In an ideal situation I'd just completely surface an object in Lightwave until it looked just right, and then I would bake out the color information, minus any bump mapping I did. Then I would bake out the bump information as a normal map. In that situation the lighting would be done by the game, but I also want to be able to bake textures with lighting prerendered into them, because certain small nonimportant items, or background items could give better performance by not being lit in real time, plus I might also want to use such objects as scene objects when using the surface baking camera to bake a set of sky environment textures.

dpont
06-26-2007, 01:55 PM
Do you want to animate the camera in the game?
In this case you should not bake the specular
hilight or reflection !?
And if you have a standing camera you don't need
the back side of the bottle.

Denis.

dpont
06-26-2007, 02:06 PM
You could also try to save different buffers in a psd,
i.e specular with SB camera pos to specular Buffer,
and SB smoothed normal to raw color Buffer...

Denis.

Mipmap
06-26-2007, 02:12 PM
This scene is only to make a texture for the object. The camera position is only important because I wanted the specular baked in the same spot the camera sees it. So if a player in the game views the bottle from the front, where the label is, then the specular looks correct.

If its for an object that will not have any kind of real time lighting or specular done in the game, having some fake specular in a well planned out spot looks better than none at all.

scenicdave
06-26-2007, 02:39 PM
This scene is only to make a texture for the object. The camera position is only important because I wanted the specular baked in the same spot the camera sees it. So if a player in the game views the bottle from the front, where the label is, then the specular looks correct.

If its for an object that will not have any kind of real time lighting or specular done in the game, having some fake specular in a well planned out spot looks better than none at all.
Hi Mipmap,
In all truth, this something you might just have to figure out for yourself. Maybe comp something in Photoshop, but the basic idea of making a good UV map (there should be no overlapping polygons) first is how you use the baking camera. Maybe a cylindrical uv map, then hell, just paint the spec in Photoshop (I mean it's just a bottle and you have a good rendered reference on how the spec should look)
regards
Dave Tracey
Sydney

Mipmap
06-26-2007, 03:41 PM
Yeah I can always paint it in, I was mainly trying to avoid it in favor it a render-only solution because if this was something I decided to adopt as a method of making game objects, I really wouldn't want to have to do that on an object that is far more complicated than a glass bottle.

After some messing around and doing things that seem like too much work given that I think there should just be a "render to texture" function that just bakes the whatever you want to a texture, I was able to get this to render out:

http://home.comcast.net/~to-ryan/bottle/bottle9.jpg

The UVs aren't super neat or anything, like there is a split on the upper label, but this whole thing was just a test to see if it was possible.

Since rendering from the camera position doesn't give me the complete surface despite giving correct specular appearances, I moved one of the lights in my scene until it lit the front sort of like how it was seen from the camera view.

The artifacts on the rag actually turned out to be due to non planar polygons. After tripling them it was fine. That threw me because they looked fine in normal renders. I keep it all quads with my game models for many reasons, but in this case it didn't matter that I tripled it because this object is only for the sake of rendering a texture.

My only real problem left at this point is that the rendered texture seems to be rendering a pixel inside of the UVs or something, because I get this black seam on the UV edges:

http://home.comcast.net/~to-ryan/bottle/bottle10.jpg

scenicdave
06-26-2007, 04:10 PM
Hi MipMap,
The black line on the UV joins can be fixed by using the UV border control. It's a pixel width dial, so set it to 1 to add a 1 pixel border around each uv island; works well.

Hey, how about this for a workflow: bake the entire surface to an atlas uv using the smoothed or polygon normal (which won't have any spec or reflection), then turn your diffuse down to zero on the whole object and bake again using the camera position. This should render just the spec and refl.
Comp these two images in Photoshop.
Would this suit?
regards
Dave Tracey
Sydney

Mipmap
06-26-2007, 07:30 PM
I got some white 1 pixel wide specks and short lines appearing in a few places when I widened it by 1 pixel with the UV border control, but otherwise it worked. I suppose those little pixel errors are easy enough to clean up in Photoshop. (anti aliasing doesn't fix them)

As for the workflow suggestion. I'm can't really use atlas because while using a really high res texture map of an atlas one can be fine for rendering\animations and stuff, for games I need to take advantage of as much of the space as I can, and also normal maps (if used) in games I think have a chance of sometimes causing little noticeable lines on the edges of UVs. So the fewer fragments in a UV map the better.

As for the reflection and specular, they show up on smoothed normal, just in the wrong spot. So I think by making a specular only light, or a similar trick to that, I can move it around to eventually get the angle I want. In the case of a bottle it was a very specific shine I wanted. Most other objects I don't think it would be as big of a problem to get what I want.

I just wish Fprime would render the surface baking camera so that I could quickly see where my shine was appearing.

jameswillmott
06-26-2007, 07:35 PM
FPrime 3 should be able to render the baking camera.