View Full Version : Switching textures in shockwave
gordonbaty
03-01-2006, 04:23 PM
I've got a question about textures in Shockwave, and how it relates to W3Ds made in Lightwave:
I want to use 1 model with 3 or 4 textures, whereby the user can choose one of the textures to give it a different 'look'. So what's the best way to do this with LW?
Ideally, I would create a W3D containing the model plus multiple UV maps using Lightwave? Or do you have to create one W3D per UV map and use those to create the textures in Director? Anyone know?
As always, I really appreciate the great advice from you kind chaps.
Gordon
mdoyle
03-02-2006, 09:24 AM
The best way to do it would be to create one w3d with one uv map. Export that. Once in director you will want to swap the image that it uses with the another one. The only problem you ahve is that director will flip your uv's in some way or another so the images which you want to swap with will have to flipped on some axis or mirrored first if that makes sense
mdoyle
03-07-2006, 04:53 AM
HOw did u get on with it?
MentalFish
03-08-2006, 04:43 AM
I have thrown something together that demonstrates two different ways of changing textures dynamically. The most gfx card friendly is to just replace the pixels of the same texture, instead of creating a new texture in memory for each texture that is going to be used. If you are going to use all textures on various models at the same time (all on screen), you have to have all textures loaded/created ofcourse.
mdoyle
03-08-2006, 05:14 AM
It is more gfx card friendly but u get a delay and can have alot slower frame rate. Its because you are swapping between system memory and gxf card memory. If u looked at the stress test thing I put up before it demonstrated that. There are obvious pros and cons to them both, but for things like an animated texture or screen you are better to load them wherease if it was just changing a texture once or twice then perhaps the other way. It all comes down to what spec of pc you are aiming for and the size of textures you want to put in the card
MentalFish
03-08-2006, 07:20 PM
Hmmm, I think you are right, but at the same time, last time I tried the texture replacement script for an animated explosion, I didnt have any noticable lag on my PIII 900 MHz with 256 MB ram and 32 MB geforce MX card (30 frames of explosion)... which i find surprising. I got a slowdown from the amount of asteroids but nothing that I could see, or remember, when the explosion is triggered (either by shooting an asteroid or crashing into one).
An issue I have seen is when you try to dynamically delete and create a new texture for each frame of animation, that creates alot of processing time, but just replacing the image of the texture seems to be rather speedy.
member("3DWorld").texture("anim").image = member("frame10").image
Perhaps you guys can give it a go:
http://petter.ms/forum/space_scene.htm
Shift to accelerate
Ctrl to shoot
Arrow keys to steer (its all a bit tricky :bangwall:)
If your ShockWave plugin is set to obey content settings or atleast manually set to DX 5.2, then you will see some nice glow effects that utilize a DX bug for that additive effect :)
mdoyle
03-09-2006, 05:34 AM
I agree but I have never did the deleteing the texture and adding a new one. The replacing a texture lag only seems to happen if you have a lot going on and you are starting to eat alot of memory. Its just a matter of choosing when to use it or not.
I like your game. You are right it is quite hard!!! =P The lense flare textures are quite nicely done on the engines. I noticed that you are getting your texture pinch at the top and botttom of the sphere of the space bkg. I dunno if u have tried this, but for me to get rid of it (I did this for a sky for an outside scene) Was to create a sky the way you like in whatever format in lightwave without the pinching, then baked the texutre to a cube. If the luminosity/emmissive is up at white in shockwave then u don't see the seems but u get what seems to be a perfect sky.
Here is an example but there is no bottom but all u would need is a white plane. The textures are a bit high but its just a wee example.
Cheers
M
MentalFish
03-09-2006, 07:00 AM
I am using a skysphere instead of a skybox, by doing that I can tile the star texture (512x512) instead of baking out 6 x 1024 textures for one sky box. The most quick and easy way to remove the pinching in the nebulae texture is to add some more black along the areas (top and bottom of texture) where the pinching occurs. I am thinking about adding some nebulae polygon planes, and adding some random positions to them, say 5 to 6 planes, pointing towards the camera.
mdoyle
03-09-2006, 07:06 AM
The textures on that scene where only 5 x 128 textures but they can be reduced, but most of the time I have the luxury of being able to use alot of textures as my minimum spce for my projects are the 1ghz, 64 meg card and 128 meg of ram. Because we are creating a system check tool some of the projects will have varying levels of texture detail, characters, meshes as well as have a distance level of detail so anything up close is as high detail as possible and with good pcs u can have quite good looking scenes as well as the shadows on a 2nd texture layer.
MentalFish
03-09-2006, 07:58 AM
I dont think you would be able to recreate any stars at 128 x 128 resolution on each side of the cube, but perhaps using a skysphere for the stars, and add a skybox, as you have suggested, for a lower resolution of a continous nebulae inside of that with transparency so the stars shine through could be doable. Ill see what I'll be doing, I am using Poetry In Motion at the moment and can easily add several texture layers with different UV coordinates, and as such I have created a skysphere with one UV for the stars, and one for the nebulae and the nebulae is set to be additive on top of the stars, works nicely. The skysphere in that demo is only using one UV and therefor the only way to avoid pinching will be your suggestion or as I suggested to add some more black to the top and bottom of it.
Something that would be cool to do in Lingo, is to create the nebulae dynamically by imaging lingo, mixing and colouring a set of textures into one image and apply it to the scene. Various areas in space have different types of nebulaes, some are blue, some more red and so on... That would save alot of stored graphics, and make the game fast to download... hmmm...
Oh oh oh, check this out, it is eternally cool, using Flash as an interactive texture (think about the possibilities in terms of GUI making):
http://earthwormjim.free.fr/flashcube/
Right cllick to rotate the cube, left click to "access" the Flash
I have made a colour slider thing in Flash once, you can try to paste that one in there:
http://petter.ms/ruf/ruf.swf
Here is an explanation in French:
http://earthwormjim.free.fr/director/tutoriaux/3d_flash_mapping/index.html
Its really cool!!! :thumbsup:
mdoyle
03-09-2006, 08:29 AM
Nice idea for the flash cube but as a gui it would need to well thought out for usability. Thanks for the links!!! :D
Sounds like a good idea for the space would be interested to see your results. YOu might get away with some stars as non moving partices but it could be a hit on performance.
We did both a colour chooser in flash and director. One of them was to pick the colour of a car rather than having to swap textures. We bascially had the base model a colour and used a 2nd texture layer multiplied over it to give the detail. It allowed the players to have any colour they wanted without having to create multiple textures.
For your different uvs, can you actually have one object and use another objects uv from it?? We have been trying to create that but are running into problems. For things like shadows etc we can use the scaled version of the texture so you have it tiled and one with the shadowed uv'd. The is very tedious to creeate especially if you want a while scene built with not polys sharing the same uv space. Is there a way you know that you might be able to either take another w3d's or obj's uv and use its uv co-ordinates (as long as the same amount of points) to apply a 2nd texture? The results we have so far a pretty bad as the exporter doesn't seem to export the points in the same space or order every time.
MentalFish
03-09-2006, 09:06 AM
Well, I wasnt thinking of a Flash cube necessarily, but rather using Flash to create all GUI/HUD elements instead of doing the manual texture swapping of selfdefined overlays and such, inside of Director. I just find it way easier to create 2D GUI's in Flash.
The multiple UV was in Poetry In Motion, not Director, but yes it is possible with multiple UV's by either making an OBJ parser or comparing two W3D models with eachother, and make a UV transfer script that base its copying of UV's from one model to the other by comparing the position of the vertecies. You have to make some tolerance snap values in the script too. While other have, I havent made such a script yet myself, and I haven't decided if I am going to either (beacuse of Poetry In Motion supporting it natively).
Want to make a collaborative project? Lets see if we can come up with a UV copy script between 2 identical models but with different UV's...?
mdoyle
03-09-2006, 09:31 AM
Is poetry in motion an engine? Do u have a link to it so I can have a look at it?
We did have a mess about with an obj parser before that kind of work and managed to get uv co-rodinates but we couldn't get them matching up as I said before. We never had tolerance snap values so that might be the answer we were looking for. I will see if I can find the file as it was a while ago and it was done in a morning and it was a bit messy code just really a quick research thing but we hit a brick wall so it was put by for a while. Hopefully will still have it sitting somewhere :D I would be interested in trying to create a script that can do this and if it could be between w3d's rather than obj's that would be even better. It could make shadowing a w3d world so much faster without having to be so careful with uv mapping and scaling etc.
Let me know how you would like to go about this
M
mdoyle
03-09-2006, 09:43 AM
Was also thinking do you think if it worked there could be a way to actualmorphs? With the parser we tried to create morph targets to do things like eye animations or other shape changes but thats when we realised that either obj's or w3d's don't have points created in the exact same order once save from lightwave which gave horrible results for morphs. It could be another possibility that would save bone animations. Whether it would be a bigger hit on performance or not I am not but the possibilities of character animations etc would be great in shockwave
Here is a character I had created recently for shockwave with animations, but eye morphs could help a geat deal. I did have eyes animating with eyelids but because some graphics cards have horrible clipping results with close together objects then the characters with eyes and eyelids looked scary as the model sometimes flickered through. Just unrar and run the exe. Its a previewer we made to test character animations. Just save the base model with textures in the top level, and the animtions in the layer underneath. It provides buttons to swap between
mdoyle
03-09-2006, 09:50 AM
Up loaed never worked,
try this link :D
Click Here (http://www.junction-18.com/mark/BonesPreview/BonesPreview.zip)
MentalFish
03-09-2006, 05:24 PM
Is poetry in motion an engine? Do u have a link to it so I can have a look at it?
Yes sr, it suuure is:
http://forums.cgsociety.org/showthread.php?p=3278934
ftp://ftp.newtek.com/multimedia/movies/Pim/pimdemo.avi
Its javascript based (JS1.5), so no class based object orientation yet, but still very capable. Its going to be the best thing that happens in 2006 :)
PIM even has its own multiplayer engine, and it is way simpler to set up than ShockWave Multiuser Server!
walfridson
03-10-2006, 03:49 AM
Hey Petter, what are the req specs for PIM. Opengl 2.0?
MentalFish
03-10-2006, 04:44 AM
The requirements are low, but for it to use all the bells and whistles it needs OGL 2.0
mdoyle
03-10-2006, 05:04 AM
Am in the process of reading that cg talk thread. Went right back to the start. Can it really do all that director does? I mean we need to write to scorm compliant data bases and used in lms's etc I would need it to basically do everything tat director does.
Still reading so maybe find the answers out soon.
Wots your thoughts on creating that uv script still?
MentalFish
03-10-2006, 05:19 AM
I am still up for the UV script :)
PIM does not do everything that Director does, yet, but it will. With the developer Enki the situation is like this: "Enki, have you seen the multiuser server technology that Director comes with?", a few weeks later i get a virtual poke on the shoulder, "PIM has built in multiuser server now", I spend a few minutes on it and have a multiuser test up and running... its crazy :)
I am keeping a paralell use of Director and PIM for still some time, as I think these are the most viable solutions in the time to come. Adobe owning Macromedia now will most likely give us an up to date Director, while PIM will provide all the cutting edge visuals and 3D engine today with more traditional features coming over time.
mdoyle
03-10-2006, 05:23 AM
Just finished reading the thread. THat seems fantastic for visual stuff
So pim does not support integrattion with Flash and its difficuilt to create dynamic content? Is the multi user aspec easy to work with? Does it have a full physics engine yet? Will there be streaming options in the web based versions for animated maps etc, or just streaming of content in general?
In the forum none of the .exe links are working anymore. Do you still have copies of them to have a look at?
Am quite interested in this product. Alot of work I do could just get done in this, doesn't seem like everything but at least some of it.
Pretty cool.
gordonbaty
03-11-2006, 02:17 PM
Guys, thanks for the info on using textures - and PIM!
I asked originally because I couldn't find any clear info on how to switch textures in the books I have. You have both made it very clear for me, I really appreciate it. Although Shockwave is new for me and you seem to be light years ahead...
I didn't totally understand how you described it, but I liked what you said about layering textures in Director so that you have a texture on top of a colour. I want people to be able to pick the colour of their model, and I had thought I would need one texture per colour. It would be way cool if they could choose the colour from a large palette.
Thanks guys... you're a help and an inspiration.
MentalFish
03-12-2006, 08:36 AM
So pim does not support integrattion with Flash and its difficuilt to create dynamic content?
Not difficult, just different.
Is the multi user aspec easy to work with?
1/10th of what it takes compared to SW multi user server.
Does it have a full physics engine yet?
Stay tuned :D
Will there be streaming options in the web based versions for animated maps etc, or just streaming of content in general?
I am not sure how it handles that issue.
In the forum none of the .exe links are working anymore. Do you still have copies of them to have a look at?
I didnt save them all, but this one use specular and bump mapping:
http://petter.ms/forum/victoria_test_anim.zip
mdoyle
03-13-2006, 04:31 AM
Will have a look about for the old colour chooser we did with the car and its layer and show u how its done gordonbaty. Unfortunately shockwave is diffictuilt engine to work with as you can't do most things which a current engine can do. Its just trying to work out the best way to use it as best as you can. I don't know what petterms thinks but I think basically we have taken shockwave as far as it can on how good things can look. Obviously if its for a highspec machine etc then u can have high textures etc but really the limits on lighting shaders, textures etc will only allow u to go so far.
MentalFish
03-13-2006, 06:41 AM
mdoyle: You got a PM
mdoyle
03-13-2006, 07:04 AM
sent u one back :D
walfridson
03-14-2006, 06:50 AM
Stay tuned :D
Oh, in first release? :)
I didnt save them all, but this one use specular and bump mapping:
http://petter.ms/forum/victoria_test_anim.zip
Tried it on a p4 with geforce 4. 5 fps... Lowpoly ala shockwave stuff performes better I hope? ;)
mdoyle
03-14-2006, 06:54 AM
I think the character was vitcoria from poser which in herself is in the region of 100 000 polygons plus you have to add teh texture memory on top of that. Shockwave with 100 000 polygons with a bone rig moving those bones and even adding the textures and lighting on top of that. I don't even know if shockwave could export that as one single file. I might be wrong but thats what it looks like to me
dsdsdsdsd
10-01-2007, 10:01 PM
petterms, would you please elaborate:
The most gfx card friendly is to just replace the pixels of the same texture
I want to apply baked image textures to shockwave models; I do not want to export the baked textures as a part of the .w3d because of filesize;
rather, I want to export the models ( from LW ) without any texture and then have lingo download the appropriate baked_texture.jpg;
ofcourse the problem is getting the baked texture, which is intended for a uv map, to align correctly;
I suppose that possibly I could simply copypixel from cast member baked_texture.jpg to my_bare_model.shaderlist[1].texturelist[1].image;
PROBLEM: how would I define the destination rectangle for the copypixel method?
thanks
dsdsdsdsd
mdoyle
10-02-2007, 04:29 AM
Hey
I don't think that would work with your method.
I don't export bake textures with my model either. What I do is export a single w3d with a colour image for use online or on the CD. I also export a seperate w3d with the baked texture image applied. Afterwards I work out uv co ords relative to the vertice positions so I know which uv point is whic. This is so I can create a txt file that stores the uv data and vertices between the colour map and the baked map. After that is saved on runtime I apply the data to the 2nd texture layer with the baked shadow map multiplied over it.
dsdsdsdsd
10-02-2007, 12:01 PM
mdoyle, hello;
work out uv co ords
in LW? in Director?
relative to the vertice positions
is this Director's meshdeform modifier
create a txt file that stores the uv data and vertices between the colour map and the baked map
create the textfile using LScript in LW or using Lingo at runtime?
are you aware of any tutorials on these issues;
thanks for your time
Shannon
Chicago
mdoyle
10-02-2007, 12:18 PM
Its all done in director using the w3d's. All you do is export you base models out of lightwave and director does the rest.
You will need to render/bake your light maps first
Here is a link to a tutorial that kind of explains what I mean better.
http://www.dubane.com/cons/max2004/helpers/lightmapping.html
mdoyle
10-02-2007, 12:23 PM
Oh forgot to say. That your lightmap needs to be flipped vertically when applied in shockave.
I also found that once you get it working. The time is getting a good render to bake the lightmaps. With a bit of time etc you can get half decent results
(some are shown further down this link)
http://www.newtek.com/forums/showthread.php?t=60648
dsdsdsdsd
10-02-2007, 01:03 PM
mdoyle, thanks for the tutorial link;
he is creating two w3d's: one with geometry only and one with geometry&textures;
it seems as if this would defeat the purpose;
the goal is:
1 - to have a small .dcr filesize for quick delivery over the internet;
2 - once shockwave movie begins, to download all baked-texture jpgs quickly;
3 - once jpgs are downloaded, to apply/map them to their appropriate model;
am I missing something?
mdoyle
10-02-2007, 01:12 PM
You can still do it that way.
Basically what you are asking for is similar to what I do.
I create 2 w3d's.
The first one is the colour mapped one. You can export this with proper textures but I export it with just a plain 2px x 2px white texture thus keeping the file size down small
The 2nd one will have the shadow maps applied.
In director you can get the the uv co ords from the 2nd w3d as explained in the tutorial. Once this is done you can load the data from the txt file on runtime (as opposed to the 2nd w3d) and apply it to the 2nd texture layer. The first texture layer will have the downloaded colour maps applied.
So in the end you are downloading:
1 w3d (small)
1 txt file (with uv data)
1 dcr file
Colourmaps
Lightmaps.
Does this make sense?
dsdsdsdsd
10-02-2007, 01:48 PM
mdoyle, thanks for your patience;
when you say lightmap/colormap, do you mean the actual UV map in LW
50930
or
do you mean jpgs such as this, generated by LW,
50929
as far the tutorial, where did the author find this method: generateLightMap()? he uses it to create 1 txt file (with uv data)
my Director v9 does not support generateLightMap() or getLightmap();
dsdsdsdsd
mdoyle
10-02-2007, 01:57 PM
The colourmap = the coloured texture on the model ie brick or concrete. The jpg.
The lightmap = the baked texture map created by the render the jpg.
will have a look at some code when I get into work tomorrow see if I can find any
dsdsdsdsd
10-02-2007, 02:06 PM
aha;
thanks
MentalFish
10-03-2007, 04:52 AM
Hey dudes, I am working on a text format that may save us alot of trouble. Instead of the "merging" of two w3d, it seems like a viable option to just build the model from scratch using a text file with all the vertecies, polygons and both uv sets. It takes Director only three seconds to build a mesh with 100.000 polys on my neighbours machine here, so a low res model should be really quick. The text file is smaller than a W3D! If only there was a ShockWave safe ZIP xtra available, it would have been super slick.
mdoyle
10-03-2007, 04:56 AM
I see what you mean now. The generateLightMap() and getLightMap() functions aren't native to director . you have to do that part yourself. The link I gave you before was misleading.
THe basic idea is to loop through the vertices/uv co-ords of the color map and find the matching vertice/uv co-ord in the shadow map. w3d exported never exports 2 models in the same vertice order so you have to do a loop throught the shadow map to find the correct vertice. after building the second uv layer you can save to a file. At runtime you can download the file and apply the uv layer again without the lengty processing step.
mdoyle
10-03-2007, 05:01 AM
Hey dudes, I am working on a text format that may save us alot of trouble. Instead of the "merging" of two w3d, it seems like a viable option to just build the model from scratch using a text file with all the vertecies, polygons and both uv sets. It takes Director only three seconds to build a mesh with 100.000 polys on my neighbours machine here, so a low res model should be really quick. The text file is smaller than a W3D! If only there was a ShockWave safe ZIP xtra available, it would have been super slick.
A text file surely cannot be smaller than a w3d? Just text file for the shadow on a w3d is huge. One of my programmers is looking to work out how to save as binary instead of text.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.