Chicken, an Egg exporter for Blender 2.49 and lower

Hi, psiberpunk!

I have a feature request. The latest version of panda3D is going to support normal maps, gloss maps, and glow maps. I’d like it if your exporter could export these things.

As you know, textures can currently have ‘modes’ like modulate, decal, blend, and so forth. This latest release is adding new modes:

M_normal
M_gloss
M_glow
M_height
M_normal_height
M_modulate_gloss
M_modulate_glow

So here’s the deal: a normal map is an RGB texture. Height, gloss, and glow maps are alpha-channel only textures. The last three types are ‘packed’ types in which the RGB channels serve one purpose (ie, normal map or color map) and the alpha channel serves a different purpose (glow, gloss, or height).

Also, don’t forget that panda has the ability to combine an RGB image file and a black-and-white image file into a single texture at load time, by specifying it right in the egg file. This is particularly useful for normal_height, modulate_gloss, and modulate_glow textures.

Oh yeah! I forgot.

height maps are for parallax mapping.
gloss maps are used as a multiplier against the material specular color.
glow maps - I don’t know what these are going to do yet. But it has something to do with HDR, like in the Tron demo.

Okay, that is an interesting request and I’ll be sure to keep it in mind. However, I have a question, since I’ve never really seen the exporters for the other content creation tools (3dsmax and maya), how are these features implemented or planned to be implemented for the respective exporters? What is the user required to do for these texture modes to be exported into the egg file? Are they translated somehow from the materials? I did some of that for Chicken 1.0 but I’m unsure if I can translate all these new modes in a way that makes sense from current Blender materials.

Please excuse me if I’m wrong, as I’m more a newcomer than a seasoned panda/blender modeller, but here’s my question:

Are blender textures export into panda working? I tried to do the job with chicken but didn’t do the job and I had to manage it by modifying the .egg with notepad, maybe I didn’t do it right but if it was not me (If it was, then please can you help and say how), it would be nice that you get the textures in panda as you see them in blender

Thanks

I’m certain it works in some cases, but it might fail with some configurations I guess. Obviously it always fails if your textures are packed in the .blend file. Otherwise I was under the impression that it worked correctly.
Paths are exported as relative if they are relative in your .blend file (and as absolute otherwise). Perhaps this can cause you trouble if your .egg file is loaded from a folder that doesn’t preserve this relative location to the textures.

Can you give me an example of a texture path from your .blend file, what Chicken saved in the .egg file and what you had to correct it to?

I think I didn’t explain my problem very well. The texture itself was exported and no problem with that, but the layout (number of repeats of the texture in the object) does not get translated into the egg.

This is a dummy example so I think it’s no need to post the .blend (but I can if you think it will help)

This is a blender render 8 repeats X and 8 repeats Y

This is the egg of chicken :unamused: no repeats

Thanks for your concern

I’m afraid I never did get around to writing code to translate that sort of thing from Blender to Egg syntax. I guess I thought it was low priority since you’d only have to edit the egg file in one place per texture, then I must have forgotten about it altogether since no one ever asked for it.

So psiberpunk - you were asking how normal mapping is supposed to work in an exporter. In maya, the first step is you just apply a normal map to the model. That’s just something you can do in Maya. The exporter detects if a normal map is applied to the model, and if so, it creates a texture entry that looks like this:

<Texture> my_normal_map {
  layingrock-n.jpg
  <Scalar> format { rgb }
  <Scalar> wrapu { repeat }
  <Scalar> wrapv { repeat }
  <Scalar> minfilter { linear_mipmap_linear }
  <Scalar> magfilter { linear }
  <Scalar> envtype { normal }     // LOOK HERE!!!
}

So it’s just like any other texture entry, except that it contains that line with the envtype normal.

Now, as for gloss maps: panda is using the convention that gloss values should be in an alpha-format texture, or packed into the alpha-channel of some other texture. A gloss map looks like this:

<Texture> my_gloss_map {
  layingrock-g.jpg
  <Scalar> format { alpha }    // LOOK HERE!!!
  <Scalar> wrapu { repeat }
  <Scalar> wrapv { repeat }
  <Scalar> minfilter { linear_mipmap_linear }
  <Scalar> magfilter { linear }
  <Scalar> envtype { gloss }     // LOOK HERE!!!
}

It’s also possible to pack a standard color map and a gloss map together into a single texture - the color data in the (RGB) channels, and the gloss in the alpha channel:

<Texture> my_color_gloss_map {
  layingrock.jpg
  <Scalar> alpha-filename { layingrock-g.jpg } // LOOK HERE!!!
  <Scalar> format { rgba }    // LOOK HERE!!!
  <Scalar> wrapu { repeat }
  <Scalar> wrapv { repeat }
  <Scalar> minfilter { linear_mipmap_linear }
  <Scalar> magfilter { linear }
  <Scalar> envtype { modulate_gloss }     // LOOK HERE!!!
}

So to understand this, you first have to get over your preconception that ‘alpha’ means ‘opacity.’ Alpha can mean opacity, but it doesn’t have to. Alpha can be used for anything at all. In this case, we’re using alpha to indicate glossy regions of the texture. So we’ve created two JPGs, one color jpg (layingrock) and one black-and-white (layingrock-g). When panda loads it, it merges them into a single RGBA texture with layingrock-g in the alpha channel. The ‘envtype’ says that this RGBA texture is supposed to be used as a modulate_gloss map - ie, the RGB parts are supposed to be used to modulate the color value, and the A is supposed to control glossiness.

There are also glow maps (like gloss) and modulate_glow maps.

just asking out of curiosity (and due to the fact that animation would be ways easier to do with the new chicken version so…)
is there any rough dates for when we can expect the first versions of chicken 2.0 ??

if donations are of any help say so^^ i still have some bucks (~40€ )on my paypal account^ would invest them into the new modifier thing. so ik-solvers with external targets and things like copyLocation/rotation modifiers on bones. (shape keys are not of intrest for me)
i can provide animated sample-models for testing if you are in need of some.

greetings
thomas e

Good thing you asked. I can’t believe how quickly time goes by.
The truth is I have a full-time job (unlike when I made Chicken 1.0) and I don’t have much spare time to work on this, and when I do have spare time I find it hard to feel motivated to do so.

I’m flattered that you offered a donation but frankly I doubt I could give you your money’s worth given current circumstances.

So, I’m afraid my best ETA is going to be the infamous “when it’s done”.

I will say this however, if you can explain what you need precisely by providing a .blend file and describing your desired output, and it’s not too much work maybe I can just hack it into 1.0 and release a 1.1 that meets your demands. It doesn’t sound like you need the whole 2.0 feature set.

psiberpunk, we love you for your chicken exporter - i use it all the time!

basically. all i need is to export the model-animation (armature) as it shows up in the blender editor.
you mentioned that the blender guys fixed up something so you could access the raw data of the complete-modifiered armature. if that would be possible to get i wouldn’t mind clearing my paypal account for it :slight_smile:
most importantly would be that armatures which are animated with IK-solver AND an target-object for the solver are exported correctly.
if it happens that all other modifiers automatically would work. even better :slight_smile:
have a testmodel here -> http://home.arcor.de/positiveelectron/files/project-files/cat-char001-animChicken2-3.blend.tar.gz
if you need something cleaner . like a bended stick or so let me know :slight_smile:

psiberpunk, I really appreciate the efforts that you put in for us, blender users.

Thank you so much :smiley:

Kind regards,
broken_sword…

Me too! Psiberpunk, I use your exporter, and it is excellent! Thank you for this work and for all your efforts.

@psiberpunk:
i fiddled around a little and found a way to actually get the correct matrices of bones. with all constraints applied.

thanges really are minor… just 4 lines :slight_smile: 2 added 2 changed

starting on line 795 of chicken 1.0 :

		
		srbIMatPrev = IDENTITY

		###### adding stuff to get access to the currentFrame
		scn = Blender.Scene.GetCurrent() #added
		context = scn.getRenderingContext() #added
		###### done with preparing change frames

		for f in xrange(minframe,maxframe+1):

			context.currentFrame(f) #added
			scn.update(1) #added

			#i dunno if we really have to use update(1) for FULL update.. 
			#maybe update(0) works aswell. dont ask me :)
			#armature.evaluatePose(f)  #removoed
			#armature.getPose().update()   #removed
			# and updating the full scene instead of the armature.

			pbones = armature.getPose().bones
			if srb:

really minor change. but takes all constraints of the armature into account. like copy rotation/location aswell as propper export of ik-solvers with external target opbjects and so on… happy animating!
@psiberpunk can you merge it into the chicken svn?

edit:fixed some code-indentation typos^^

@ Thomas:

I’d love to give it a go~! (After changes applied to SVN) :smiley:

Thank you.

Kind Regards,
Broken_Sword

for those who absoutely cant wait:
a small demo-model + animation demonstrating external motion targets on ik-solvers and look-at constraits aswell as copy rotation/location
http://home.arcor.de/positiveelectron/files/project-files/neneko-demo.blend.tar.gz
and my modified chicken.py for those who wanna actually export it.
http://home.arcor.de/positiveelectron/files/project-files/chicken_export1.0_anim-fixed.py

have fun :slight_smile:
ps: textures are packed in blender. to see the model textured you have to unpack them first or else chicken wont be able to export them at all.

I’ve merged your changes with the latest SVN revision and tried them out, but I haven’t yet committed it to the repository, because the last SVN revision had some problems and unfinished features. I’ll finish that off, commit and post a release on the site. I’ll update this post and provide a link when I’m finished. I’ll also update the test model while I’m at it.

Thanks, ThomaEgi for this fix, and everyone else who showed their support for this project.

after playing around with this I’ve found that it’s pretty easy to use the new shader generator with Chicken’s eggs. You have to modify some lines in the textures to get the glow maps etc.

I’ve got a question though- I’ve built a model, I’ve painted the model and I’ve got a normal map that I want to apply as well. I know how to do this with Blender.

The issue I have is that in this case each polygon has multiple texture information- there is the regular texture data, then the glow map (which is built into the alpha channel of my texture) but now I want to add a normal map to the polygons. I have the normal map in RGB format.

My question is- Can I have multiple textures as a TRef on a given polygon?

if so- can chicken be modified to pick up the normalmap texture- in the current situation I have to would have to add the line { normalmap} to each polygon- which gives impractical pretty fast. I’ve tried doing it with macros on my text-editor but it hasn’t worked.

Certainly. The egg syntax document describes all of the ins and outs of multiple textures in an egg file.

I have achieved this trick with a text editor in the past by doing something like Find: “” Replace: “ { my-other-texture } ”. In other words, let both TRef’s be on the same line. Text editors are pretty good at making changes to a single line, and the egg syntax doesn’t require that the TRef’s be on different lines.

David