
글에 사용된 모든 그림과 내용은 직접 작성한 것입니다.
[유튜브 영상]
[깃허브 보러가기]
https://github.com/Chang-Jin-Lee/D3D11-AliceTutorial/tree/main/25_ToonShading_Outline
[풀리퀘 보러가기]
https://github.com/Chang-Jin-Lee/D3D11-AliceTutorial/pull/50
D3D11에서 툰 쉐이더 코드를 공유하고 fbx, pmx, obj 모델에 적용한 결과를 보여주기 위함
float4 ambientTerm = g_Material.ambient * g_DirLight.ambient;
const int kSteps = 5;
float q = (kSteps > 1) ? floor(theta * (kSteps - 1) + 0.5f) / (kSteps - 1) : theta;
float4 toonDiffuse = kd * (ambientTerm + q * g_DirLight.diffuse);
float3 H = normalize(L + V);
float NdotH = saturate(dot(N, H));
float specBand = smoothstep(0.85f, 0.95f, NdotH) * step(0.0f, NdotL);
float4 toonSpec = specBand * g_Material.specular * g_DirLight.specular;
if (g_ShadingMode == 5)
{
const int kSteps = 5;
float q = (kSteps > 1) ? floor(theta * (kSteps - 1) + 0.5f) / (kSteps - 1) : theta;
float4 toonDiffuse = kd * (ambientTerm + q * g_DirLight.diffuse);
float3 H = normalize(L + V);
float NdotH = saturate(dot(N, H));
float specBand = smoothstep(0.85f, 0.95f, NdotH) * step(0.0f, NdotL);
float4 toonSpec = specBand * g_Material.specular * g_DirLight.specular;
float4 outCol = toonDiffuse + toonSpec;
outCol.a = alphaTex;
return outCol;
}
| All Shader Collection |
|---|
| Unlit | Lambert | BlinnPhong |
|---|---|---|
| Phong | TextureOnly | ToonShading | ToonShading + outline |
|---|---|---|---|