Fading from one texture to another.
Blitz3D Forums/Blitz3D Programming/Fading from one texture to another.
| ||
Let's say I have a cube which has a texture on it. I then have another texture which I load sperately. Now I want to gradually switch between the two textures so as one fades away the other one becomes more prominent. So they would both hit alpha 0.5 at the same time. I know I can multi texture to get both textures on the same object at the same time but how can you adjust the alpha of a texture on the fly (i.e. fast enough to do in realtime). I tried EntityAlpha but as expected it doesn't work for textures. Anyone done this already? Thanks, Darkheart |
| ||
You might be best to use 2 cubes and just fade out the one with a lower entity order (or nearest/largest one or whatever). |
| ||
why not do to copies of the same entitye1 = loadentity("terminator1_1.x") ; this uses one textured e2 = loadentity("terminator1_2.x") ; different textured for i#=0 to 1 step .02 entityalpha e1,i entityalpha e2,1-i next does this help at all? |
| ||
Maybe two cubes with different textures ? Fade one out and the other in - Would double the polycount though ! |
| ||
That's the funniest cross-post I've seen in a while. Three people making the same suggestion at the same time! |
| ||
I already thought of that but (and not having a go at anyone here) I rejected it as a clumsy and wasteful solution. Particularly when I want to use it as part of the morphing for my exporter and there could be 1000's of verts needing to be changed every frame too. Surely it must be possible to load 2 different texture layers and increase the alpha on one layer while decreasing the alpha on the other layer. Thus giving the impression of a smooth transition. Darkheart |
| ||
Surely it must be possible to load 2 different texture layers and increase the alpha on one layer while decreasing the alpha on the other layer. No. There is no way to adjust the alpha level of a texture. You need to do as suggested above, manipulate the textures directly using the WritePixelFast command, or make an animated texture that takes care of the transition. Fredborg |
| ||
Oo, now that is a shame. I wonder if this would make a good feature request, or if it's another of those things that just aren't possible under DX? |
| ||
There is one way (in theory). Using multitexturing you could create a small (you'll need to check for minimum texture size the card supports first) alpha texture and use it as a "mask" to blend between the two images. Additionally you could create a "shade" of colors and scroll that. Depending on your UVW mapping this technique might not work. It'll work for a cube just fine tho'. I'm pretty sure I did something to this effect a long time ago, I'm not entirely sure I ever got the effect *I* wanted, but I think I stubled onto a solution to your problem. Sorry I can't be more helpful. I'll try and see if I can come up with some code tomorrow (a.k.a. later today). Right now I'm wasted, and need sleep. Later. |
| ||
I guess that would work... but wouldn't you need at least 3 levels of hardware multitexturing supported on the video card? I imagine blitz's simulated multitexturing (using extra geometry) wouldn't cut it in this case. |
| ||
Anthony Blitz doesn't simulate multitexturing unless there is no hardware support for multitexturing (which AFAIK all cards have had for AGES). If there is hardware support for multitexturing Blitz uses it, at least according to the docs. "Enables or disables hardware multitexturing. Multitexturing is a technique used to display more than one texture on an object at once. Sometimes, 3D hardware has built-in support for this, so that using two textures or more per object will not be any slower than using just one. However, some cards have problems dealing with hardware multitexturing, and for these situations you have the option of disabling it. When hardware texturing isn't being used, Blitz3D will use its own software technique, which involves duplicating objects that just have one texture each." I think going with the writepixel fast is going to be my best solution ATM although it's a slow clumsy way to do this. As for a 512x512 texturing I will have to do 262144 loops just to change the alpha by one increment, each time the same increment for every pixel. That's a crazy way to have to do something as simple as this. Darkheart |
| ||
Yes, but the point is that a card that can do hardware multitexturing can't do an UNLIMITED amount of hardware multitexturing. My card can only do 2 textures in hardware. FDs method would require 3 textures in hardware to work. Only the newer 3d cards can do this. |
| ||
You cannot set the alpha of a texture layer. You can however make an entity with two surfaces and change the alpha of the second surface. The number of vertices has no effect on the speed of changing the alpha of an entire surface at once, you just adjust the brush and repaint it. |