GameChoi
Choi Programming
GameChoi
전체 방문자
오늘
어제
  • 분류 전체보기 (468)
    • C++ Algorithm & Study (184)
      • C++ & Algorithm Strategies (45)
      • Game Math & DirectX 11 (72)
      • Server + UE5 (29)
      • Lyra Clone Coding (37)
    • Create Game (284)
      • [Window API] Game Client & .. (55)
      • [DirectX] DirectX 2D & 3D (155)
      • [UE5] BLUEPRINT & C++ (74)
    • odds and ends (0)
      • English (0)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • GAME Client
  • Player State
  • Network Worker
  • Direct11
  • protobuf
  • Player Move Packet
  • client
  • Other Character
  • session
  • Direct3D
  • server
  • core
  • job queue
  • c++
  • Game Room
  • Algorithm Strategies
  • UE5
  • RPG Game
  • Game Server
  • Destination Move Packet

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
GameChoi

Choi Programming

[Direct11] 15. EX App Program - Light System
C++ Algorithm & Study/Game Math & DirectX 11

[Direct11] 15. EX App Program - Light System

2023. 6. 15. 19:08

1. Ex App Program

1.1 Light System

1.1.1 Effect File

 - 물체로 부터 전달된 빛을 이용하여 픽셀 셰이더로 부터 계산 (계산방식은 이전 Direct3D 글의 코드를 사용)

struct Material { float4 Ambient; float4 Diffuse; float4 Specular; float4 Reflect; };

   - Vertex Shader로 부터 전달된 값들을 이용하여 평행광, 점광, 점적광의 빛을 사용하여 물체에게 전달

ComputeDirectionalLight(gMaterial, gDirLight, pin.NormalW, toEyeW, A, D, S);
ambient += A; diffuse += D; spec += S;
ComputePointLight(gMaterial, gPointLight, pin.PosW, pin.NormalW, toEyeW, A, D, S);
ambient += A; diffuse += D; spec += S;
ComputeSpotLight(gMaterial, gSpotLight, pin.PosW, pin.NormalW, toEyeW, A, D, S);
ambient += A; diffuse += D; spec += S;

1.1.2 C++ 응용 프로그램

 - 위에서 생성한 값들을 사용하여야 하므로 세게의 광원을 생성하여 초기화

DirectionalLight _dirLight; PointLight _pointLight; SpotLight _spotLight;
// Directional light.
_dirLight.Ambient = XMFLOAT4(0.2f, 0.2f, 0.2f, 1.0f);
_dirLight.Diffuse = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
_dirLight.Specular = XMFLOAT4(0.5f, 0.5f, 0.5f, 1.0f);
_dirLight.Direction = XMFLOAT3(0.57735f, -0.57735f, 0.57735f);

// Point light
_pointLight.Ambient = XMFLOAT4(0.3f, 0.3f, 0.3f, 1.0f);
_pointLight.Diffuse = XMFLOAT4(0.7f, 0.7f, 0.7f, 1.0f);
_pointLight.Specular = XMFLOAT4(0.7f, 0.7f, 0.7f, 1.0f);
_pointLight.Att = XMFLOAT3(0.0f, 0.1f, 0.0f);
_pointLight.Range = 25.0f;

// Spot light
_spotLight.Ambient = XMFLOAT4(0.0f, 0.0f, 0.0f, 1.0f);
_spotLight.Diffuse = XMFLOAT4(1.0f, 1.0f, 0.0f, 1.0f);
_spotLight.Specular = XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f);
_spotLight.Att = XMFLOAT3(1.0f, 0.0f, 0.0f);
_spotLight.Spot = 96.0f;
_spotLight.Range = 10000.0f;

  - 위의 광원들을 확인하기 위해 땅을 생성하여 값 생성

Material _landMat;
_landMat.Ambient = XMFLOAT4(0.48f, 0.77f, 0.46f, 1.0f);
_landMat.Diffuse = XMFLOAT4(0.48f, 0.77f, 0.46f, 1.0f);
_landMat.Specular = XMFLOAT4(0.2f, 0.2f, 0.2f, 16.0f);

     - 마지막으로 이전 코드를 붙여 사용하게 된다면 광원에 대해 물체가 어떻게 출력되는 지 확인 가능

 

[Direct11] 12. EX App Program - Hills

1. EX App Program 1.1 Hills 1.1.1 Create Grid Vertex - xz 평면에 격자 생성, m × n개인 격자는 (m - 1) × (n - 1)개의 낱칸으로 이루어짐 - 각 낱간은 두 개의 삼각형으로 구성되며 총 2배의 삼각형이 필요 - 격자의

choiprogramming.tistory.com

저작자표시 (새창열림)

'C++ Algorithm & Study > Game Math & DirectX 11' 카테고리의 다른 글

[Direct11] 17. Direct3D Texture - Filter & Mode  (0) 2023.06.16
[Direct11] 16. Direct3D Texture  (0) 2023.06.16
[Direct11] 14. Lighting System - Directional & Point & Spot Light  (0) 2023.06.15
[Direct11] 13. Lighting System - Diffuse & Ambient & Specular Light  (0) 2023.06.15
[Direct11] 12. EX App Program - Hills  (1) 2023.06.14
    'C++ Algorithm & Study/Game Math & DirectX 11' 카테고리의 다른 글
    • [Direct11] 17. Direct3D Texture - Filter & Mode
    • [Direct11] 16. Direct3D Texture
    • [Direct11] 14. Lighting System - Directional & Point & Spot Light
    • [Direct11] 13. Lighting System - Diffuse & Ambient & Specular Light
    GameChoi
    GameChoi

    티스토리툴바