I'm stuck with a framerate perf down with getData from a rendertarget, what's your idea, what are the other options I can use ?
I explain my problem : I'm making a board game, the objects or monsters are overflow the board rooms, I use kryton framework to manage light sources, krypton is an efficient 2D pixel shader raycasting engine, I've made Hulls (#blocking light blocks) all around the rooms of my board, but the objects and monsters Texture2D were cutted by the hull shadows of the board sides... So I can't use Krypton to light my monsters
krypton give me a rendertarget of the screen which is a screen light color map If I pick color from center board square, It give me the perfect color to draw my monsters, but with getData it's reaaaallllyy slow.
I'm using this code :
public Color GetLightColorOnPoint(Vector2 position) {
Vector2 v = WorldToScreen(position); return lightManager.GetLightColorAtPoint((int)v.X, (int)v.Y); }public Color LightManagerClass.GetLightColorAtPoint(int x, int y) { Color[] lightPixel = new Color[ 1 ]; Rectangle sourceRectangle = new Rectangle(x, y, 1, 1); //rendertarget2D
this.krypton_SolShadow.mMap.GetData(0, sourceRectangle, lightPixel, 0, 1); return lightPixel[0]; }
(I don't understand well pixel shaders and I don't think you can pick a board square center color and apply it to an entire monster texture2D with the correct offset/zoom of a camera 2D of course and variable texture2D size (a giant vs a rat texture2D size))
with 40 GetData (40 monsters on screen) per draw, the FrameRate slow down to 7 FPS :(, please help