Jump to content

[SOLVED] WidgetSprite blending in DirectX and OpenGL


photo

Recommended Posts

I have a WidgetSprite with 2 layers.

 

Layer 0 has normal RGB texture which acts as the minimap and layer1 has R8 texture which acts as the fog of war.

The layer 1 blending function is set to Src = GUI_BLEND_ZERO and Dst = GUI_BLEND_SRC_COLOR.

 

The blending works as expected in Directx9 renderer but in OpenGL it is giving a reddish shade.

 

Below is the sample code to reproduce:

 

Gui gui;
WidgetSprite sprite;
int init()
{
gui = engine.getGui();
sprite = new WidgetSprite( gui );
sprite.addLayer();
sprite.setLayerTexture( 0, "window_01.png" );
sprite.setLayerTexture( 1, "FoW.tga" );
sprite.setLayerBlendFunc( 1, GUI_BLEND_ZERO, GUI_BLEND_SRC_COLOR );
gui.addChild( sprite, GUI_ALIGN_OVERLAP );
return 1;
}
int shutdown()
{
return 1;
}
int update()
{
return 1;
}

 

PS: I couldn't attach the R8 texture file which is in TGA format.

post-322-0-84306800-1350561709_thumb.png

post-322-0-57063100-1350561720_thumb.png

Link to comment

@frustum - this particular texture which used to be R8 is updated quite frequently (it encodes the Fog of War data for our game). We had made this R8 to save on bandwidth, esp. on older GPUs. Now that it's RGB8 it would probably take thrice the bandwidth, causing a stutter. Is there any optimization that you'd suggest? Alternatively, does Unigine support some true L8 image type which can be used as low-bandwidth grayscale?

 

Thanks!

Link to comment
  • 2 weeks later...

Ashwin, RGB is just a trifle more expensive. But if it will become a bottleneck in your game, you can create a custom shader that replicates R channel data into G and B.

Link to comment
×
×
  • Create New...