본문 바로가기
Shader

Unlit Standard Particle shader blending

by 대마왕J 2018. 9. 24.

#elif defined(_COLORADDSUBDIFF_ON)

#define fragColorMode(i) \

    albedo.rgb = albedo.rgb + i.color.rgb * _ColorAddSubDiff.x; \

    albedo.rgb = lerp(albedo.rgb, abs(albedo.rgb), _ColorAddSubDiff.y); \

    albedo.a *= i.color.a;


add모드일때 

 material.SetVector("_ColorAddSubDiff", new Vector4(1.0f, 0.0f, 0.0f, 0.0f));


Subtractive 모드일때 

material.SetVector("_ColorAddSubDiff", new Vector4(-1.0f, 0.0f, 0.0f, 0.0f));


Difference 모드일때

material.SetVector("_ColorAddSubDiff", new Vector4(-1.0f, 1.0f, 0.0f, 0.0f));


이므로 


add 모드일때 

  albedo.rgb = albedo.rgb + i.color.rgb * 1; \

  albedo.rgb = lerp(albedo.rgb, abs(albedo.rgb), 0); \

  albedo.a *= i.color.a;



Subtractive 모드일때 

  albedo.rgb = albedo.rgb + i.color.rgb * -1; \

  albedo.rgb = lerp(albedo.rgb, abs(albedo.rgb), 0); \

  albedo.a *= i.color.a;



Difference 모드일때 

  albedo.rgb = albedo.rgb + i.color.rgb * -1; \

  albedo.rgb = lerp(albedo.rgb, abs(albedo.rgb), 1); \

  albedo.a *= i.color.a;



반응형

댓글