Building Textures in engine and applying to a sprite
by Jonathan Brockman · in Torque 2D Professional · 11/14/2014 (8:34 am) · 3 replies
Hello!
So, our my quest to optimize, we have decided to move our lightmap and LOS stuff into the engine. We currently render light levels and FOVS usign a composite sprite of varying alpha values. This works, but is tremendously slow, especially when we want to refresh the whole thing (day/night cycles).
So, my desire it to generate a lightmap texture in engine, and then apply as a single sprite, with alpha values already calculated.
I have generated the texture, and it exists as a bitmapPNG, though I can not figure out how to convert this into a useable asset that I can apply to a sprite without writing to the hard drive and then reading it right back (which is not an option).
Can anyone give me some pointers?
So, our my quest to optimize, we have decided to move our lightmap and LOS stuff into the engine. We currently render light levels and FOVS usign a composite sprite of varying alpha values. This works, but is tremendously slow, especially when we want to refresh the whole thing (day/night cycles).
So, my desire it to generate a lightmap texture in engine, and then apply as a single sprite, with alpha values already calculated.
I have generated the texture, and it exists as a bitmapPNG, though I can not figure out how to convert this into a useable asset that I can apply to a sprite without writing to the hard drive and then reading it right back (which is not an option).
Can anyone give me some pointers?
#2
Yeah, that's exactly what I ended up doing. The only downside is I need to regenerate the image quite frequently and I'm encountering a crash if I tell the engine to persist the image so I can modify it, though I haven't looked too closely at that yet.
That said, it is an order of magnitude faster then the old way, so I am quite pleased!
11/19/2014 (5:35 am)
Hey Richard,Yeah, that's exactly what I ended up doing. The only downside is I need to regenerate the image quite frequently and I'm encountering a crash if I tell the engine to persist the image so I can modify it, though I haven't looked too closely at that yet.
That said, it is an order of magnitude faster then the old way, so I am quite pleased!
#3
Or - what if you load a "blank" image from disk so that the resource manager has a properly added texture object and work in that?
Just thinking out loud....
11/21/2014 (12:49 pm)
Sweet! Does it not like adding it as a private asset? Private assets were intended to provide a "scratch pad" asset for use in asset editors - a left-over from 3SS.Or - what if you load a "blank" image from disk so that the resource manager has a properly added texture object and work in that?
Just thinking out loud....
Torque Owner Richard Ranft
Roostertail Games