Game/MMD
Bloom + Emmisive (2)
newpolaris
2017. 10. 18. 14:57
항상 소스 코드 까보는 고생후에 검색어를 변경하면 글이 찾아진다.
http://ttmayrin.tistory.com/39
Material의 Emissive 항목을 Bloom buffer 에 그리면 된단다.
시작 emissive를 color에 더하지 않았을 적
Autolumious 적용시 - specular 값을 flag로 emissive로 바꿔줌
Bloom 의 thresh-hold을 낮출 경우
emissive - Float3(1,1,1)
별도의 emissive buffer - diffuse 곱을 하지 않고 그대로 넘김
별도의 emissive buffer - diffuse 곱
AutoLuminious 의 경우, 한번더 render pass 를 수행한다.
Out.Color = MaterialDiffuse;
Out.Color.a = materialAlpha;
Out.Color.rgb += MaterialEmmisive / 2;
Out.Color.rgb *= 0.5;
Out.Color.rgb = IsEmittion ? Out.Color.rgb : float3(0,0,0);
후에
static bool IsEmittion = (SPECULAR_BASE < SpecularPower)/* && (SpecularPower <= (SPECULAR_BASE + 100))*/ && (length(MaterialSpecular) < 0.01);
static float EmittionPower0 = IsEmittion ? ((SpecularPower - SPECULAR_BASE) / 7.0) : 1;
static float EmittionPower1 = EmittionPower0 * (LightUp * 2 + 1.0) * pow(400, LightUpE) * (1.0 - LightOff);
상수를 곱해주는 형식이나
일반 bloom에 적용할 경우 color 값이 적게 잡혀 흐릿하게 나오게 된다.
ray-mmd 의 emmisive 의 경우 deferred rendering을 적용하였는데,
투명일 경우, color 에 더한 후,
float4 MRT3 = tex2Dlod(Gbuffer3Map, float4(coord, 0, 0));
float4 MRT4 = tex2Dlod(Gbuffer4Map, float4(coord, 0, 0));
float3 emissive0 = DecodeGBufferEmissive(MRT3, MRT4);
float3 emissive1 = material.customDataB * material.customDataA * any(material.lightModel == SHADINGMODELID_EMISSIVE);
lighting += lerp(emissive0, emissive1, MRT8.a);
post effect에서 다시 emissive 를 bloom 에 더해준다
float3 emissive0 = DecodeGBufferEmissive(MRT3, MRT4);
float3 emissive1 = DecodeGBufferEmissive(MRT7, MRT8);
bloom += max(0.0, lerp(emissive0, emissive1, MRT8.a) - 1.0);
return float4(bloom, 0);