• Advertisement
Sign in to follow this  

Render to screen buffer vs. to texture problem

This topic is 714 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

what would be so wonderfull if you guys help me to solve this problem.

I cant get why rendering to screen buffers and to texture so differs.

 

Bouth screen and texture formats are identical A8R8G8B8, blending mode and params are exect

SetRenderState( D3DRS_SRCBLEND,  D3DBLEND_SRCALPHA );
SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
but result so differs. Rendering to texture starting to become grey. I could imagine that it for sure could be gray(darker) if

destination would be black. But its not. In bouth cases its filled with bold color with alpha == 1.0

I have tried lots of different params and states, so now iam desperate...

 

dif.jpg

Share this post


Link to post
Share on other sites
Advertisement

Yeah, this is two cases, than i render the same orange texture to screen and to texture , becouse it has alhpa chanel == 1.0 it apears in both cases the same exact color .
There is no problem. Problem is colors with chanle alpha != 1.0; They becomes darker and grey independent on background.

Share this post


Link to post
Share on other sites

Rendering to them doesn't differ, other than the fact you may be actually writing the alpha out to the texture as well. Which can also change what you draw when you draw a texture. 

Share this post


Link to post
Share on other sites

Looks like you're blending it twice...

 

"To screen" is: blend( background1, texture )

"To texture" is: blend( background1, blend( background2, texture ) )

 

Turn off one of those blends and they will look the same.

Share this post


Link to post
Share on other sites

Nahh,

 

bouth cases has blending mode enabled

 

1 case:

 

a) Clear screen with solid color  = ARGB(1, 1, 1, 1) (any solid color)

b) Draw sprite with sprite color  = ARGB(0.3, 1 , 1 , 1)  (D3DRS_SRCBLEND, D3DRS_DESTBLEND as written in topic) (simple shader return textureColor * color;)

 

2 case:

a) Clear screen with solid color  = ARGB(1, 1, 1, 1) (any solid color)

b) Clear render target texture with solid color  = ARGB(1, 1, 1, 1) (all pixels alpha == 1)

c) Render sprite to target texture color  = ARGB(0.3, 1 , 1 , 1)  (D3DRS_SRCBLEND, D3DRS_DESTBLEND as written in topic) (simple shader return textureColor * color;)

d) Render target texture color = ARGB(1, 1, 1, 1) (than i render this texture it has all pixels alpha == 1)

 

problem apears on c). Render target texture has solid color for example yallow, rendering sprite with alpha == 0.3

the new pixel color should be finalColor = targetTexColor * (1 - 0.3) + spriteColor * 0.3 

after that target texture renders to screen srcreeTexColor * 0.0 + renderTargetColor * 1.0

 

So...

 

1 case: screen color = yallow

screen * (1 - 0.3) + sprite * 0.3

 

2 case: target color = yallow , screen color = any

screen * 0 + (target * (1 - 0.3) + sprite * 0.3) * 1.0

 

Should be the same color , but but no....

Share this post


Link to post
Share on other sites

No, hodgman is correct.

d.)Render target texture color = ARGB(1, 1, 1, 1) (than i render this texture it has all pixels alpha == 1)

 

This is wrong. Your target has an alpha channel, and therefore will write to the alpha component. Which in this case will be .3.

If you want to do that properly, createa a render texture as RGB, not ARGB.

Share this post


Link to post
Share on other sites

i can understand what 3 means. 3 of what?

ok target texture has alpha chanel 1   sprite has 0.3  , i render this sprite to texture , what alpha and colors i will get?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement