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)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

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

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
GameChoi

Choi Programming

[Direct11] 18. EX App Program - Texture Box
C++ Algorithm & Study/Game Math & DirectX 11

[Direct11] 18. EX App Program - Texture Box

2023. 6. 16. 20:43

1. EX App Program

1.1 Texture Box

1.1.1 Texture Pos & Create

 - 밑의 함수는 Texture 이미지 전체가 입방체의 각 면에 입혀지도록 Texture 좌표들을 적절히 설정

void GeometryGenerator::CreateBox(float width, float height, float depth, MeshData& meshData);

   - 함수의 내용을 잠깐 보자면 입방체의 앞면일 경우 앞면 정점 자료를 채움

float w2 = 0.5f*width; float h2 = 0.5f*height; float d2 = 0.5f*depth;
v[0] = Vertex(-w2, -h2, -d2, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
v[1] = Vertex(-w2, +h2, -d2, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f);
v[2] = Vertex(+w2, +h2, -d2, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f);
v[3] = Vertex(+w2, -h2, -d2, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f);

 - 이전 글에서 사용한 Texture를 생성하는 방식으로 이미지를 불러온 후 SRV를 통해 이미지를 저장

   - 이후 Effect File에 있는 Texture2D의 주소를 받아 데이터 저장

HRESULT hr = ::LoadFromWICFile(L"../Resources/Textures/WoodCrate01.dds", 
			WIC_FLAGS_NONE, &md, img);
hr = ::CreateShaderResourceView(_device.Get(), 
			img.GetImages(), img.GetImageCount(), md, _diffuseMapSRV.GetAddressOf());

1.1.2 Effect File

 - 응용프로그램을 비등방 필터링을 적용하고 순환 모드 적용

SamplerState samAnisotropic
{
	Filter = ANISOTROPIC; MaxAnisotropy = 4;
	AddressU = WRAP; AddressV = WRAP;
};

   - 정점 셰이더로 부터 전달된 데이터로 부터 색상을 필터를 적용시켜 색 지정

float4 PS(VertexOut pin, uniform int gLightCount, uniform bool gUseTexure) : SV_Target
{
	// ...
	float4 texColor = float4(1, 1, 1, 1);
	if (gUseTexure) { texColor = gDiffuseMap.Sample(samAnisotropic, pin.Tex); }
	// ...
}

     - 마지막으로 조명에 의해 변경된 색상 또한 계산을 한 후 색을 입힘

// 조명 계산...
litColor = texColor * (ambient + diffuse) + spec; litColor.a = gMaterial.Diffuse.a * texColor.a;

 - 나머지 코드는 예제 프로그램의 초기 방식을 사용

 

[Direct11] 11. EX App Program - Color Box

1. EX App Program 1.1 Color Box 1.1.1 Geometry Buffer - 색상이 있는 박스를 생성하기 위해 각 정점에 대해 좌표 및 색상 적용 Vertex vertices[] = { { XMFLOAT3(-1.0f, -1.0f, -1.0f), XMFLOAT4((const float*)&Colors::White) }, { XMFLOAT3

choiprogramming.tistory.com

저작자표시 (새창열림)

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

[Direct11] 20. Direct3D Blending - Blending System  (0) 2023.06.17
[Direct11] 19. Direct3D Blending  (0) 2023.06.17
[Direct11] 17. Direct3D Texture - Filter & Mode  (0) 2023.06.16
[Direct11] 16. Direct3D Texture  (0) 2023.06.16
[Direct11] 15. EX App Program - Light System  (0) 2023.06.15
    'C++ Algorithm & Study/Game Math & DirectX 11' 카테고리의 다른 글
    • [Direct11] 20. Direct3D Blending - Blending System
    • [Direct11] 19. Direct3D Blending
    • [Direct11] 17. Direct3D Texture - Filter & Mode
    • [Direct11] 16. Direct3D Texture
    GameChoi
    GameChoi

    티스토리툴바