2013-11-04 2 views
0

혼합 내가 는 OpenGL -

actual = <some color loaded from texture>; 
actual.a *= 0.05; //reduce the alpha to have a more transparent result 

//Front to back blending 
actual.rgb *= actual.a; 
last = (1.0 - last.a) * actual + last; 

PS

의주기에서 혼합 색상의 이런 종류의 raycasting 한이 방정식은 OpenGL은 3 블렌딩 기능을 사용하려면 다시 할 수 있습니까? 목표는

지금까지 나는이 사용하고 자신을 더 qauds를 렌더링함으로써 PS에서 사이클을 제거하는 것입니다 : glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA),하지만 결과는

편집 다른 같습니다

last = cumulated color (aka. final color)  
actual = current color from texture 
+0

'마지막'과 '실제'가 무엇인지 명확히 설명해 주시겠습니까? 'actual'는 현재 소스 색상이고'last'는 목적지 색상이며, 마지막은 framebuffer의 현재 값입니까? – thokra

+0

@thokra 질문을 편집했습니다. –

답변

0

주요 문제 원본 색을 쉐이더의 알파 값으로 미리 곱해야합니다 (actual.rgb * = actual.a). 난 당신이 혼합에 대한 생각

이 기능을 사용할 수 있습니다 : - : *

last.rgb = actual.a

glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE); 
glBlendEquation(GL_FUNC_ADD): 
+0

이렇게하면 결과가 검은 색이됩니다. –

0

glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) 다음을 사용하여, 당신은 공식처럼이 actual.rgb + (1.0 - actual.a) * last.rgb;

그것은 네 쉐이더 화학식 완전히 다르다 :

actual.rgb * = actual.a;

last = (1.0 - last.a) * actual + last;

다른 결과가 있습니다.