Render to screen buffer vs. to texture problem

Started by
15 comments, last by serumas 7 years, 11 months ago

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

Advertisement

If you don't render the image into the texture, is your texture actually showing up as orange?

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

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.

[Edit - never mind, sorry, misread the problem]

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.

Can you post the pixel shader you are using? and the code where you clear the render target?

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.

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....

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.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

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?

This topic is closed to new replies.

Advertisement