Study/Directx 10

방향성광원, 점광원

붕대마음 2010. 5. 15. 20:22
반응형
이번엔 거의 할 부분이 없군.

float diffuseColor;
 [branch] switch(lightType)
 {
 case 1: // dir light
  diffuseColor = saturate(dot(input.normal, - lightdirection);
  break;
  
 case 2: // point light
  diffuseColor = saturate(dot(input.normal, normalize(lightPosition - input.worldPos)));
  break;
 
 default: // no light
  diffuseColor = 1;
 }
 
 [branch] if(textureOn)
 {
  return texDiffuse.Sample(texureSampler, input.tex) * diffuseColor;
 }
 else
 {
  return diffuseColor;
 }
그나마 옵션에 따라 동적 분기 분할 하는 이정도가 이 예제의 다인듯.