Jump to content

Load Texture in Viewer memory cache with Alpha = 0 ?


chrixbed
 Share

You are about to reply to a thread that has been inactive for 114 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm making a particle show and I want to have my guess to pre-load the texture I'm using in their viewer cache. So I made a simple cube that flips all the textures used with my particles so the viewer has it in memory at the time to play the particle and avoid the big white square.

Question: If I set my alpha to 0, is it still gone a work to load the texture in viewer memory?

here is my code:

string TEXTURE;
integer INDEX;
integer TOTAL;
integer toggle;
float gap = 0.2;
default
{
    touch_start(integer total_number)
    {
        toggle = !toggle;
        if(toggle){
		llSetAlpha(0, ALL_SIDES); // Where I set the Alpha
		TOTAL = llGetInventoryNumber( INVENTORY_TEXTURE );
           	INDEX = 0;
         	llSetTimerEvent(gap);
        }
        else
            llSetTimerEvent(0.0);
    }
    
    timer()
    {
        TEXTURE = llGetInventoryName(INVENTORY_TEXTURE, INDEX );
        llSetTexture(TEXTURE, ALL_SIDES);
        if (INDEX >= TOTAL-1)
        {    INDEX = 0;
            return;
        }
        INDEX ++;
    }
    
    changed(integer change)
    {
        if (change & CHANGED_INVENTORY)         
        {
            llSetTimerEvent(0.0);
            TOTAL = llGetInventoryNumber( INVENTORY_TEXTURE );
            INDEX = 0;
            llSetTimerEvent(gap);
        }
    }
}

 

Edited by chrixbed
  • Like 1
Link to comment
Share on other sites

Yes and no: textures on fully transparent faces are loaded (at least if the object is "seen", not sure what would happen if it was completely hidden inside something else) and cached, and as long as the texture is still on the object, you can be relatively certain it'll stay loaded and ready for particle use.

If you just cycle the textures like your example, though, they will get cached but since they're no longer being used after they get swapped out, they'll get soon unloaded. This means they'll have to be fetched again -- this time from the cache -- and there still will be a period of gray boxes instead of your desired particles, just a shorter one. The textures need to stay on the object to be more certain they're available for particles with as few unsightly loading delays as possible.

  • Thanks 1
Link to comment
Share on other sites

On 1/13/2024 at 4:44 AM, Frionil Fang said:

Yes and no: textures on fully transparent faces are loaded (at least if the object is "seen", not sure what would happen if it was completely hidden inside something else) and cached, and as long as the texture is still on the object, you can be relatively certain it'll stay loaded and ready for particle use.

Are you sure?  I rather clearly remember having problems of this sort back in the early 2010's (and have avoided it ever since), while doing a "picture fade" by having the front face shift between transparent and opaque.  My solution at the time, was to click the face back slightly from either fully opaque, or fully transparent (like, 1-99%, rather than 0-100%), a second before the transition, so the texture has a chance to load — and it seemed to happen at both ends.

Things may have changed since then — I can imagine viewers having added a "low priority" texture queue, or something, which is why I'm asking too (also, having been mostly text-bound for the last half a decade).  I do also recall textures not loading on fully contained (unseen) objects, due to occlusion culling.

Link to comment
Share on other sites

8 hours ago, Bleuhazenfurfle said:

Are you sure? 

I tested it with an alt present who certainly had not seen some random textures: I put them on a 100% transparent cube, which would emit them as particles on click. The textures were immediately available whether they were on the object upon the alt's arrival, or changed via the script before firing the particles. If I turned off the "preload" part, using a new texture resulted in gray loading particles.

That's just one data point though, maybe there's situations where a 100% transparent object is optimized away. I think I've had my distrust about it in the past too and left some texture cachers at minimum alpha instead of 0.

  • Like 2
Link to comment
Share on other sites

FWIW, In some cases, an inconspicuous face that's color is set to black, or just a prim that's small and inside something else non-transparent, can serve the same role as a face that's completely transparent.

  • Like 4
Link to comment
Share on other sites

I've created multi-prim objects with each prim taking up the same area (like a "layer"), for waterfall and rushing water effects and each "layer" having a different transparency. If I understand correctly, the same approach should work for a "preload" if some layers (or all layers) are 100% transparent. 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 114 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...