글의 요약 설명 부분. 150자를 적어주세요. 글의 요약 설명 부분. 150자를 적어주세요. 글의 요약 설명 부분. 150자를 적어주세요. 글의 요약 설명 부분. 150자를 적어주세요. 글의 요약 설명 부분. 150자를 적어주세요. 글의 요약 설명 부분. 150자입니다

 

목차

     

     


     

     

    Normal Mapping

     

    Shader
      Light.fx
    Lighting.fx
    Render.fx
    PointLighting.fx
    SpotLighting.fx
    NormalMapping.fx
    Framework
      Meshes
      Mesh.h - VertexTextureNormalTangent 추가
    MeshCylinder.cpp - vertex.tangent, MeshVertex 추가
    MeshGrid.cpp - vertex.tangent, MeshVertex 추가
    MeshSphere.cpp - vertex.tangent, MeshVertex 추가
    ModelEditor
      Writer
      Converter.cpp
      ExportFile.cpp
    UnitTest
      Lighting
      NormalMappingDemo.h.cpp

     

    tangent는 u방향에 Mapping 시키는게 정석적인 방법이다.


     

    Light.fx

     

    Light.fx 변경사항

    더보기
    void NormalMapping(float2 uv, float3 normal, float3 tangent, SamplerState samp)
    {
        float4 map = NormalMap.Sample(samp, uv);
        
        [flatten]
        if (any(map.rgb) == false)
            return;
    
        
        float3 coord = map.rgb * 2.0f - 1.0f; //-1 ~ +1
        
        
        //탄젠트 공간
        float3 N = normalize(normal); //Z
        float3 T = normalize(tangent - dot(tangent, N) * N); //X
        //float3 T = tangent;
        //float3 T = float3(1, 0, 0);
        float3 B = cross(N, T); //Y
        
        float3x3 TBN = float3x3(T, B, N);
        
        coord = mul(coord, TBN);
        
        Material.Diffuse *= saturate(dot(-GlobalLight.Direction, coord));
    }
    
    void NormalMapping(float2 uv, float3 normal, float3 tangent)
    {
        NormalMapping(uv, normal, tangent, LinearSampler);
    }

     

     


     

     

    Render.fx

     

    Render.fx

    더보기
    float4 PS_Sky(MeshOutput input) : SV_Target
    {
        return SkyCubeMap.Sample(LinearSampler, input.oPosition);
    }
    
    
    struct VertexMesh
    {
        float4 Position : Position;
        float2 Uv : Uv;
        float3 Normal : Normal;
        float3 Tangent : Tangent;
        
        matrix Transform : Inst1_Transform;
        float4 Color : Inst2_Color;
    };
    
    
    #define VS_GENERATE \
    output.oPosition = input.Position.xyz; \
    \
    output.Position = WorldPosition(input.Position); \
    output.wPosition = output.Position.xyz; \
    output.Position = ViewProjection(output.Position); \
    output.wvpPosition = output.Position; \
    output.wvpPosition_Sub = output.Position; \
    \
    output.sPosition = WorldPosition(input.Position); \
    output.sPosition = mul(output.sPosition, ShadowView); \
    output.sPosition = mul(output.sPosition, ShadowProjection); \
    \
    output.Normal = WorldNormal(input.Normal); \
    output.Tangent = WorldTangent(input.Tangent); \
    \
    output.Uv = input.Uv; \
    output.Color = input.Color;
    
    
    struct DepthOutput
    {
        float4 Position : SV_Position;
        float4 sPosition : Position1;
    };
    
    float4 PS_Depth(DepthOutput input) : SV_Target
    {
        float depth = input.Position.z / input.Position.w;
        
        return float4(depth, depth, depth, 1.0f);
    }
    
    #define VS_DEPTH_GENERATE \
    output.Position = WorldPosition(input.Position); \
    output.Position = mul(output.Position, ShadowView); \
    output.Position = mul(output.Position, ShadowProjection); \
    \
    output.sPosition = output.Position;
    
    
    void SetMeshWorld(inout matrix world, VertexMesh input)
    {
        world = input.Transform;
    }
    
    MeshOutput VS_Mesh(VertexMesh input)
    {
        MeshOutput output;
        
        SetMeshWorld(World, input);
        VS_GENERATE
        
        return output;
    }
    
    DepthOutput VS_Depth_Mesh(VertexMesh input)
    {
        DepthOutput output;
        
        SetMeshWorld(World, input);
        VS_DEPTH_GENERATE
        
        return output;
    }
    
    
    struct VertexModel
    {
        float4 Position : Position;
        float2 Uv : Uv;
        float3 Normal : Normal;
        float3 Tangent : Tangent;
        float4 BlendIndices : BlendIndices;
        float4 BlendWeights : BlendWeights;
        
        uint InstanceID : SV_InstanceID;
        
        matrix Transform : Inst1_Transform;
        float4 Color : Inst2_Color;
    };
    
    Texture2DArray TransformsMap;
    #define MAX_MODEL_TRANSFORMS 250
    
    cbuffer CB_Bone
    {
        //matrix BoneTransforms[MAX_MODEL_TRANSFORMS];
        
        uint BoneIndex;
    };
    
    void SetModelWorld(inout matrix world, VertexModel input)
    {
        //world = mul(BoneTransforms[BoneIndex], world);
        
        float4 m0 = TransformsMap.Load(int4(BoneIndex * 4 + 0, input.InstanceID, 0, 0));
        float4 m1 = TransformsMap.Load(int4(BoneIndex * 4 + 1, input.InstanceID, 0, 0));
        float4 m2 = TransformsMap.Load(int4(BoneIndex * 4 + 2, input.InstanceID, 0, 0));
        float4 m3 = TransformsMap.Load(int4(BoneIndex * 4 + 3, input.InstanceID, 0, 0));
        
        matrix transform = matrix(m0, m1, m2, m3);
        world = mul(transform, input.Transform);
    }
    
    MeshOutput VS_Model(VertexModel input)
    {
        MeshOutput output;
        
        SetModelWorld(World, input);
        VS_GENERATE
        
        return output;
    }
    
    DepthOutput VS_Depth_Model(VertexModel input)
    {
        DepthOutput output;
        
        SetModelWorld(World, input);
        VS_DEPTH_GENERATE
        
        return output;
    }
    
    
    #define MAX_MODEL_KEYFRAMES 500
    #define MAX_MODEL_INSTANCE 500
    
    struct AnimationFrame
    {
        int Clip;
    
        uint CurrFrame;
        uint NextFrame;
    
        float Time;
        float Running;
    
        float3 Padding;
    };
    
    struct TweenFrame
    {
        float TakeTime;
        float TweenTime;
        float RunningTime;
        float Padding;
    
        AnimationFrame Curr;
        AnimationFrame Next;
    };
    
    cbuffer CB_TweenFrame
    {
        TweenFrame TweenFrames[MAX_MODEL_INSTANCE];
    };
    
    void SetTweenWorld(inout matrix world, VertexModel input)
    {
        float indices[4] = { input.BlendIndices.x, input.BlendIndices.y, input.BlendIndices.z, input.BlendIndices.w };
        float weights[4] = { input.BlendWeights.x, input.BlendWeights.y, input.BlendWeights.z, input.BlendWeights.w };
        
        
        int clip[2];
        int currFrame[2];
        int nextFrame[2];
        float time[2];
        
        clip[0] = TweenFrames[input.InstanceID].Curr.Clip;
        currFrame[0] = TweenFrames[input.InstanceID].Curr.CurrFrame;
        nextFrame[0] = TweenFrames[input.InstanceID].Curr.NextFrame;
        time[0] = TweenFrames[input.InstanceID].Curr.Time;
        
        clip[1] = TweenFrames[input.InstanceID].Next.Clip;
        currFrame[1] = TweenFrames[input.InstanceID].Next.CurrFrame;
        nextFrame[1] = TweenFrames[input.InstanceID].Next.NextFrame;
        time[1] = TweenFrames[input.InstanceID].Next.Time;
        
        
        
        float4 c0, c1, c2, c3;
        float4 n0, n1, n2, n3;
        
        matrix curr = 0, next = 0;
        matrix currAnim = 0;
        matrix nextAnim = 0;
        
        matrix transform = 0;
        
        [unroll(4)]
        for (int i = 0; i < 4; i++)
        {
            c0 = TransformsMap.Load(int4(indices[i] * 4 + 0, currFrame[0], clip[0], 0));
            c1 = TransformsMap.Load(int4(indices[i] * 4 + 1, currFrame[0], clip[0], 0));
            c2 = TransformsMap.Load(int4(indices[i] * 4 + 2, currFrame[0], clip[0], 0));
            c3 = TransformsMap.Load(int4(indices[i] * 4 + 3, currFrame[0], clip[0], 0));
            curr = matrix(c0, c1, c2, c3);
            
            n0 = TransformsMap.Load(int4(indices[i] * 4 + 0, nextFrame[0], clip[0], 0));
            n1 = TransformsMap.Load(int4(indices[i] * 4 + 1, nextFrame[0], clip[0], 0));
            n2 = TransformsMap.Load(int4(indices[i] * 4 + 2, nextFrame[0], clip[0], 0));
            n3 = TransformsMap.Load(int4(indices[i] * 4 + 3, nextFrame[0], clip[0], 0));
            next = matrix(n0, n1, n2, n3);
            
            currAnim = lerp(curr, next, time[0]);
            
            
            [flatten]
            if (clip[1] > -1)
            {
                c0 = TransformsMap.Load(int4(indices[i] * 4 + 0, currFrame[1], clip[1], 0));
                c1 = TransformsMap.Load(int4(indices[i] * 4 + 1, currFrame[1], clip[1], 0));
                c2 = TransformsMap.Load(int4(indices[i] * 4 + 2, currFrame[1], clip[1], 0));
                c3 = TransformsMap.Load(int4(indices[i] * 4 + 3, currFrame[1], clip[1], 0));
                curr = matrix(c0, c1, c2, c3);
            
                n0 = TransformsMap.Load(int4(indices[i] * 4 + 0, nextFrame[1], clip[1], 0));
                n1 = TransformsMap.Load(int4(indices[i] * 4 + 1, nextFrame[1], clip[1], 0));
                n2 = TransformsMap.Load(int4(indices[i] * 4 + 2, nextFrame[1], clip[1], 0));
                n3 = TransformsMap.Load(int4(indices[i] * 4 + 3, nextFrame[1], clip[1], 0));
                next = matrix(n0, n1, n2, n3);
            
                nextAnim = lerp(curr, next, time[1]);
                
                currAnim = lerp(currAnim, nextAnim, TweenFrames[input.InstanceID].TweenTime);
            }
            
            
            transform += mul(weights[i], currAnim);
        }
        
        world = mul(transform, input.Transform);
    }
    
    struct BlendFrame
    {
        uint Mode;
        float Alpha;
        float2 Padding;
        
        AnimationFrame Clip[3];
    };
    
    cbuffer CB_BlendFrame
    {
        BlendFrame BlendFrames[MAX_MODEL_INSTANCE];
    };
    
    void SetBlendWorld(inout matrix world, VertexModel input)
    {
        float indices[4] = { input.BlendIndices.x, input.BlendIndices.y, input.BlendIndices.z, input.BlendIndices.w };
        float weights[4] = { input.BlendWeights.x, input.BlendWeights.y, input.BlendWeights.z, input.BlendWeights.w };
        
        
        float4 c0, c1, c2, c3;
        float4 n0, n1, n2, n3;
        
        matrix curr = 0, next = 0;
        matrix currAnim[3];
        matrix anim = 0;
        matrix transform = 0;
        
        BlendFrame frame = BlendFrames[input.InstanceID];
        
        [unroll(4)]
        for (int i = 0; i < 4; i++)
        {
            [unroll(3)]
            for (int k = 0; k < 3; k++)
            {
                c0 = TransformsMap.Load(int4(indices[i] * 4 + 0, frame.Clip[k].CurrFrame, frame.Clip[k].Clip, 0));
                c1 = TransformsMap.Load(int4(indices[i] * 4 + 1, frame.Clip[k].CurrFrame, frame.Clip[k].Clip, 0));
                c2 = TransformsMap.Load(int4(indices[i] * 4 + 2, frame.Clip[k].CurrFrame, frame.Clip[k].Clip, 0));
                c3 = TransformsMap.Load(int4(indices[i] * 4 + 3, frame.Clip[k].CurrFrame, frame.Clip[k].Clip, 0));
                curr = matrix(c0, c1, c2, c3);
            
                n0 = TransformsMap.Load(int4(indices[i] * 4 + 0, frame.Clip[k].NextFrame, frame.Clip[k].Clip, 0));
                n1 = TransformsMap.Load(int4(indices[i] * 4 + 1, frame.Clip[k].NextFrame, frame.Clip[k].Clip, 0));
                n2 = TransformsMap.Load(int4(indices[i] * 4 + 2, frame.Clip[k].NextFrame, frame.Clip[k].Clip, 0));
                n3 = TransformsMap.Load(int4(indices[i] * 4 + 3, frame.Clip[k].NextFrame, frame.Clip[k].Clip, 0));
                next = matrix(n0, n1, n2, n3);
            
                currAnim[k] = lerp(curr, next, frame.Clip[k].Time);
            }
           
            int clipA = (int) frame.Alpha;
            int clipB = clipA + 1;
            
            float alpha = frame.Alpha;
            if (alpha >= 1.0f)
            {
                alpha = frame.Alpha - 1.0f;
                
                if (frame.Alpha >= 2.0f)
                {
                    clipA = 1;
                    clipB = 2;
                }
            }
            
            anim = lerp(currAnim[clipA], currAnim[clipB], alpha);
            
            transform += mul(weights[i], anim);
        }
        
        world = mul(transform, input.Transform);
    }
    
    MeshOutput VS_Animation(VertexModel input)
    {
        MeshOutput output;
        
        if (BlendFrames[input.InstanceID].Mode == 0)
            SetTweenWorld(World, input);
        else
            SetBlendWorld(World, input);
        
        VS_GENERATE
        
        return output;
    }
    
    DepthOutput VS_Depth_Animation(VertexModel input)
    {
        DepthOutput output;
        
        if (BlendFrames[input.InstanceID].Mode == 0)
            SetTweenWorld(World, input);
        else
            SetBlendWorld(World, input);
        
        VS_DEPTH_GENERATE
        
        return output;
    }

    Tagent를 넣어준다.

    • struct VertexMesh
      • float3 Tangent : Tangent;
    • output.Tangent = WorldTangent(input.Tangent)\
    • float3 WorldTangent(float3 tangent) { return mul(tangent, (float3x3) World); }
    • struct MeshOutput
      • float3 Tangent: Tangent;

     


     

    NormalMapping.fx

     

    NormalMapping.fx

    더보기
    #include "00_Global.fx"
    #include "00_Light.fx"
    #include "00_Render.fx"
    
    uint Selected = 3;
    
    float4 PS(MeshOutput input) : SV_Target
    {
        Material.Diffuse = float4(1, 1, 1, 1);
        
        if (Selected == 0)
        {
            //Texture(Material.Diffuse, DiffuseMap, input.Uv);
        }
        else if (Selected == 1)
        {
            NormalMapping(input.Uv, input.Normal, input.Tangent);
        }
        else if (Selected == 2)
        {
            Texture(Material.Diffuse, DiffuseMap, input.Uv);
        }
        else if (Selected == 3)
        {
            Texture(Material.Diffuse, DiffuseMap, input.Uv);
            NormalMapping(input.Uv, input.Normal, input.Tangent);
        }
    
        
        //Texture(Material.Diffuse, DiffuseMap, input.Uv);
        Texture(Material.Specular, SpecularMap, input.Uv);
        
        
        MaterialDesc output = MakeMaterial();
        MaterialDesc result = MakeMaterial();
        
        ComputeLight(output, input.Normal, input.wPosition);
        AddMaterial(result, output);
        
        //ComputePointLight(output, input.Normal, input.wPosition);
        //AddMaterial(result, output);
        
        //ComputeSpotLight(output, input.Normal, input.wPosition);
        //AddMaterial(result, output);
        
        return float4(MaterialToColor(result), 1.0f);
    }
    
    technique11 T0
    {
        P_VP(P0, VS_Mesh, PS)
        P_VP(P1, VS_Model, PS)
        P_VP(P2, VS_Animation, PS)
    }

     

     


     

     

    Normal Mapping Demo

     

    NormalMappingDemo.h

    더보기
    #pragma once
    #include "Systems/IExecute.h"
    
    class NormalMappingDemo : public IExecute
    {
    public:
    	virtual void Initialize() override;
    	virtual void Ready() override {}
    	virtual void Destroy() override {}
    	virtual void Update() override;
    	virtual void PreRender() override {}
    	virtual void Render() override;
    	virtual void PostRender() override {}
    	virtual void ResizeScreen() override {}
    
    private:
    	void Mesh();
    	void Airplane();
    	void Kachujin();
    	void KachujinCollider();
    	void KachujinWeapon();
    	void PointLighting();
    	void SpotLighting();
    
    	void Pass(UINT mesh, UINT model, UINT anim);
    
    private:
    	Shader* shader;
    
    	CubeSky* sky;
    
    	Material* floor;
    	Material* stone;
    	Material* brick;
    	Material* wall;
    
    	MeshRender* cube;
    	MeshRender* cylinder;
    	MeshRender* sphere;
    	MeshRender* grid;
    
    	ModelRender* airplane = NULL;
    
    
    	ModelAnimator* kachujin = NULL;
    	Transform* colliderInitTransforms;
    	ColliderObject** colliders;
    
    	ModelRender* weapon = NULL;
    	Transform* weaponInitTransform;
    
    	vector<MeshRender *> meshes;
    	vector<ModelRender *> models;
    	vector<ModelAnimator *> animators;
    };

     

     

    NormalMappingDemo.cpp

    더보기
    #include "stdafx.h"
    #include "NormalMappingDemo.h"
    
    void NormalMappingDemo::Initialize()
    {
    	Context::Get()->GetCamera()->RotationDegree(20, 0, 0);
    	Context::Get()->GetCamera()->Position(1, 36, -85);
    
    
    	shader = new Shader(L"82_NormalMapping.fxo");
    
    
    	sky = new CubeSky(L"Environment/GrassCube1024.dds");
    	
    	Mesh();
    	Airplane();
    	
    	Kachujin();
    	KachujinCollider();
    	KachujinWeapon();
    
    	PointLighting();
    	SpotLighting();
    }
    
    void NormalMappingDemo::Update()
    {
    	static UINT selected = 0;
    	ImGui::InputInt("NormalMap Selected", (int *)&selected);
    	selected %= 4;
    
    	shader->AsScalar("Selected")->SetInt(selected);
    
    
    	sky->Update();
    
    	cube->Update();
    	grid->Update();
    	cylinder->Update();
    	sphere->Update();
    
    	airplane->Update();
    	kachujin->Update();
    
    	Matrix worlds[MAX_MODEL_TRANSFORMS];
    	for (UINT i = 0; i < kachujin->GetTransformCount(); i++)
    	{
    		kachujin->GetAttachTransform(i, worlds);
    		weapon->GetTransform(i)->World(weaponInitTransform->World() * worlds[40]);
    	}
    
    	weapon->UpdateTransforms();
    	weapon->Update();
    }
    
    void NormalMappingDemo::Render()
    {
    	sky->Render();
    
    	
    	Pass(0, 1, 2);
    
    	wall->Render();
    	sphere->Render();
    
    	brick->Render();
    	cylinder->Render();
    
    	stone->Render();
    	cube->Render();
    
    	floor->Render();
    	grid->Render();
    
    	airplane->Render();
    	
    	kachujin->Render();
    	weapon->Render();
    }
    
    void NormalMappingDemo::Mesh()
    {
    	//Create Material
    	{
    		floor = new Material(shader);
    		floor->DiffuseMap("Floor.png");
    		floor->Specular(1, 1, 1, 20);
    		floor->SpecularMap("Floor_Specular.png");
    		floor->NormalMap("Floor_Normal.png");
    		
    		stone = new Material(shader);
    		stone->DiffuseMap("Stones.png");
    		stone->Specular(1, 1, 1, 20);
    		stone->SpecularMap("Stones_Specular.png");
    		stone->Emissive(0.15f, 0.15f, 0.15f, 0.3f);
    		stone->NormalMap("Stones_Normal.png");
    
    		
    		brick = new Material(shader);
    		brick->DiffuseMap("Bricks.png");
    		brick->Specular(1, 0.3f, 0.3f, 20);
    		brick->SpecularMap("Bricks_Specular.png");
    		brick->Emissive(0.15f, 0.15f, 0.15f, 0.3f);
    		brick->NormalMap("Bricks_Normal.png");
    
    		wall = new Material(shader);
    		wall->DiffuseMap("Wall.png");
    		wall->Specular(1, 1, 1, 20);
    		wall->SpecularMap("Wall_Specular.png");
    		wall->Emissive(0.15f, 0.15f, 0.15f, 0.3f);
    		wall->NormalMap("Wall_Normal.png");
    	}
    
    	//Create Mesh
    	{
    		Transform* transform = NULL;
    
    		cube = new MeshRender(shader, new MeshCube());
    		transform = cube->AddTransform();
    		transform->Position(0, 5, 0);
    		transform->Scale(20, 10, 20);
    
    		grid = new MeshRender(shader, new MeshGrid(5, 5));
    		transform = grid->AddTransform();
    		transform->Position(0, 0, 0);
    		transform->Scale(12, 1, 12);
    
    		cylinder = new MeshRender(shader, new MeshCylinder(0.5f, 3.0f, 20, 20));
    		sphere = new MeshRender(shader, new MeshSphere(0.5f, 20, 20));
    		for (UINT i = 0; i < 5; i++)
    		{
    			transform = cylinder->AddTransform();
    			transform->Position(-30, 6, -15.0f + (float)i * 15.0f);
    			transform->Scale(5, 5, 5);
    
    			transform = cylinder->AddTransform();
    			transform->Position(30, 6, -15.0f + (float)i * 15.0f);
    			transform->Scale(5, 5, 5);
    
    
    			transform = sphere->AddTransform();
    			transform->Position(-30, 15.5f, -15.0f + (float)i * 15.0f);
    			transform->Scale(5, 5, 5);
    
    			transform = sphere->AddTransform();
    			transform->Position(30, 15.5f, -15.0f + (float)i * 15.0f);
    			transform->Scale(5, 5, 5);
    		}
    	}
    
    	sphere->UpdateTransforms();
    	cylinder->UpdateTransforms();
    	cube->UpdateTransforms();
    	grid->UpdateTransforms();
    
    	meshes.push_back(sphere);
    	meshes.push_back(cylinder);
    	meshes.push_back(cube);
    	meshes.push_back(grid);
    }
    
    void NormalMappingDemo::Airplane()
    {
    	airplane = new ModelRender(shader);
    	airplane->ReadMesh(L"B787/Airplane");
    	airplane->ReadMaterial(L"B787/Airplane");
    
    	Transform* transform = airplane->AddTransform();
    	transform->Position(2.0f, 9.91f, 2.0f);
    	transform->Scale(0.004f, 0.004f, 0.004f);
    	airplane->UpdateTransforms();
    
    	models.push_back(airplane);
    }
    
    void NormalMappingDemo::Kachujin()
    {
    	kachujin = new ModelAnimator(shader);
    	kachujin->ReadMesh(L"Kachujin/Mesh");
    	kachujin->ReadMaterial(L"Kachujin/Mesh");
    	kachujin->ReadClip(L"Kachujin/Sword And Shield Idle");
    	kachujin->ReadClip(L"Kachujin/Sword And Shield Walk");
    	kachujin->ReadClip(L"Kachujin/Sword And Shield Run");
    	kachujin->ReadClip(L"Kachujin/Sword And Shield Slash");
    	kachujin->ReadClip(L"Kachujin/Salsa Dancing");
    
    
    	Transform* transform = NULL;
    
    	transform = kachujin->AddTransform();
    	transform->Position(0, 0, -30);
    	transform->Scale(0.075f, 0.075f, 0.075f);
    	kachujin->PlayTweenMode(0, 0, 1.0f);
    
    	transform = kachujin->AddTransform();
    	transform->Position(-15, 0, -30);
    	transform->Scale(0.075f, 0.075f, 0.075f);
    	kachujin->PlayTweenMode(1, 1, 1.0f);
    
    	transform = kachujin->AddTransform();
    	transform->Position(-30, 0, -30);
    	transform->Scale(0.075f, 0.075f, 0.075f);
    	kachujin->PlayTweenMode(2, 2, 0.75f);
    
    	transform = kachujin->AddTransform();
    	transform->Position(15, 0, -30);
    	transform->Scale(0.075f, 0.075f, 0.075f);
    	kachujin->PlayBlendMode(3, 0, 1, 2);
    	kachujin->SetBlendAlpha(3, 1.5f);
    
    	transform = kachujin->AddTransform();
    	transform->Position(30, 0, -32.5f);
    	transform->Scale(0.075f, 0.075f, 0.075f);
    	kachujin->PlayTweenMode(4, 4, 0.75f);
    
    	kachujin->UpdateTransforms();
    
    	animators.push_back(kachujin);
    }
    
    void NormalMappingDemo::KachujinCollider()
    {
    	UINT count = kachujin->GetTransformCount();
    	colliders = new  ColliderObject*[count];
    
    	colliderInitTransforms = new Transform();
    	colliderInitTransforms->Position(-2.9f, 1.45f, -50.0f);
    	colliderInitTransforms->Scale(5, 5, 75);
    
    	for (UINT i = 0; i < count; i++)
    	{
    		colliders[i] = new ColliderObject();
    
    		//colliders[i]->Init = new Transform();
    		//colliders[i]->Init->Position(0, 0, 0);
    		//colliders[i]->Init->Scale(10, 30, 10);
    
    		colliders[i]->Transform = new Transform();
    		//colliders[i]->Collider = new Collider(colliders[i]->Transform, colliders[i]->Init);
    		colliders[i]->Collider = new Collider(colliders[i]->Transform, colliderInitTransforms);
    	}
    }
    
    void NormalMappingDemo::KachujinWeapon()
    {
    	weapon = new ModelRender(shader);
    	weapon->ReadMesh(L"Weapon/Sword");
    	weapon->ReadMaterial(L"Weapon/Sword");
    
    	UINT count = kachujin->GetTransformCount();
    	for (UINT i = 0; i < count; i++)
    		weapon->AddTransform();
    
    	weapon->UpdateTransforms();
    	models.push_back(weapon);
    
    	
    	weaponInitTransform = new Transform();
    	weaponInitTransform->Position(-2.9f, 1.45f, -6.45f);
    	weaponInitTransform->Scale(0.5f, 0.5f, 0.75f);
    	weaponInitTransform->Rotation(0, 0, 1);
    }
    
    void NormalMappingDemo::PointLighting()
    {
    	PointLight light;
    	light =
    	{
    		Color(0.0f, 0.0f, 0.0f, 1.0f), //Ambient
    		Color(0.0f, 0.0f, 1.0f, 1.0f), //Diffuse
    		Color(0.0f, 0.0f, 0.7f, 1.0f), //Specular
    		Color(0.0f, 0.0f, 0.7f, 1.0f), //Emissive
    		Vector3(-30, 10, -30), 5.0f, 0.9f
    	};
    	Lighting::Get()->AddPointLight(light);
    
    	light =
    	{
    		Color(0.0f, 0.0f, 0.0f, 1.0f),
    		Color(1.0f, 0.0f, 0.0f, 1.0f),
    		Color(0.6f, 0.2f, 0.0f, 1.0f),
    		Color(0.6f, 0.3f, 0.0f, 1.0f),
    		Vector3(15, 10, -30), 10.0f, 0.3f
    	};
    	Lighting::Get()->AddPointLight(light);
    
    	light =
    	{
    		Color(0.0f, 0.0f, 0.0f, 1.0f), //Ambient
    		Color(0.0f, 1.0f, 0.0f, 1.0f), //Diffuse
    		Color(0.0f, 0.7f, 0.0f, 1.0f), //Specular
    		Color(0.0f, 0.7f, 0.0f, 1.0f), //Emissive
    		Vector3(-5, 1, -17.5f), 5.0f, 0.9f
    	};
    	Lighting::Get()->AddPointLight(light);
    
    	light =
    	{
    		Color(0.0f, 0.0f, 0.0f, 1.0f),
    		Color(0.0f, 0.0f, 1.0f, 1.0f),
    		Color(0.0f, 0.0f, 0.7f, 1.0f),
    		Color(0.0f, 0.0f, 0.7f, 1.0f),
    		Vector3(-10, 1, -17.5f), 5.0f, 0.9f
    	};
    	Lighting::Get()->AddPointLight(light);
    }
    
    void NormalMappingDemo::SpotLighting()
    {
    	SpotLight light;
    	light =
    	{
    		Color(0.3f, 1.0f, 0.0f, 1.0f),
    		Color(0.7f, 1.0f, 0.0f, 1.0f),
    		Color(0.3f, 1.0f, 0.0f, 1.0f),
    		Color(0.3f, 1.0f, 0.0f, 1.0f),
    		Vector3(-15, 20, -30), 25.0f,
    		Vector3(0, -1, 0), 30.0f, 0.4f
    	};
    	Lighting::Get()->AddSpotLight(light);
    
    	light =
    	{
    		Color(1.0f, 0.2f, 0.9f, 1.0f),
    		Color(1.0f, 0.2f, 0.9f, 1.0f),
    		Color(1.0f, 0.2f, 0.9f, 1.0f),
    		Color(1.0f, 0.2f, 0.9f, 1.0f),
    		Vector3(0, 20, -30), 30.0f,
    		Vector3(0, -1, 0), 40.0f, 0.55f
    	};
    	Lighting::Get()->AddSpotLight(light);
    }
    
    void NormalMappingDemo::Pass(UINT mesh, UINT model, UINT anim)
    {
    	for (MeshRender* temp : meshes)
    		temp->Pass(mesh);
    
    	for (ModelRender* temp : models)
    		temp->Pass(model);
    
    	for (ModelAnimator* temp : animators)
    		temp->Pass(anim);
    }

     

     


     

     

    실행화면