Fixed render errors

This commit is contained in:
lanariel 2013-11-21 23:54:12 +01:00
parent ff1695497f
commit 5abaef6e86
11 changed files with 33058 additions and 36 deletions

Binary file not shown.

Binary file not shown.

View File

@ -143,7 +143,7 @@ namespace Oyster
ID3D11PixelShader* pixel; ID3D11PixelShader* pixel;
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"ps_5_0",0,0,&Shader,&Error))) if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"ps_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error)))
{ {
std::string fel = (char*)Error->GetBufferPointer(); std::string fel = (char*)Error->GetBufferPointer();
Error->Release(); Error->Release();
@ -170,7 +170,7 @@ namespace Oyster
ID3D11GeometryShader* geometry; ID3D11GeometryShader* geometry;
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"gs_5_0",0,0,&Shader,&Error))) if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"gs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error)))
{ {
std::string fel = (char*)Error->GetBufferPointer(); std::string fel = (char*)Error->GetBufferPointer();
Error->Release(); Error->Release();
@ -197,7 +197,7 @@ namespace Oyster
ID3D11VertexShader* vertex; ID3D11VertexShader* vertex;
if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"vs_5_0",0,0,&Shader,&Error))) if(FAILED(D3DCompileFromFile(filename.c_str(),NULL,NULL,ShaderFunction,"vs_5_0",D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION,0,&Shader,&Error)))
{ {
std::string fel = (char*)Error->GetBufferPointer(); std::string fel = (char*)Error->GetBufferPointer();
Error->Release(); Error->Release();

View File

@ -115,7 +115,7 @@ Oyster::Graphics::Render::ModelInfo* OBJReader::toModel()
} }
modelInfo->Indexed = false; modelInfo->Indexed = false;
modelInfo->VertexCount = (int)desc.NumElements; modelInfo->VertexCount = (int)desc.NumElements;
modelInfo->Vertices = *b; modelInfo->Vertices = b;
return modelInfo; return modelInfo;

View File

@ -21,7 +21,7 @@ namespace Oyster
struct ModelInfo struct ModelInfo
{ {
std::vector<ID3D11ShaderResourceView*> Material; std::vector<ID3D11ShaderResourceView*> Material;
Buffer Vertices,Indecies; Buffer *Vertices,*Indecies;
bool Indexed; bool Indexed;
int VertexCount; int VertexCount;
}; };

View File

@ -176,6 +176,11 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</AssemblerOutput>
<AssemblerOutputFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</AssemblerOutputFile>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
</FxCompile> </FxCompile>
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl"> <FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType> <ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>

View File

@ -13,7 +13,7 @@ namespace Oyster
void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection) void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection)
{ {
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,1,1)); Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,0,1));
Core::ShaderManager::SetShaderEffect(Graphics::Render::Resources::obj); Core::ShaderManager::SetShaderEffect(Graphics::Render::Resources::obj);
Preparations::Basic::BindBackBufferRTV(nullptr); Preparations::Basic::BindBackBufferRTV(nullptr);
@ -40,10 +40,10 @@ namespace Oyster
//Set Materials :: NONE //Set Materials :: NONE
models[i].info->Vertices.Apply(); models[i].info->Vertices->Apply();
if(models[i].info->Indexed) if(models[i].info->Indexed)
{ {
models[i].info->Indecies.Apply(); models[i].info->Indecies->Apply();
Oyster::Graphics::Core::deviceContext->DrawIndexed(models[i].info->VertexCount,0,0); Oyster::Graphics::Core::deviceContext->DrawIndexed(models[i].info->VertexCount,0,0);
} }
else else

View File

@ -61,12 +61,12 @@ namespace Oyster
D3D11_RASTERIZER_DESC rdesc; D3D11_RASTERIZER_DESC rdesc;
rdesc.CullMode = D3D11_CULL_NONE; rdesc.CullMode = D3D11_CULL_NONE;
rdesc.FillMode = D3D11_FILL_SOLID; rdesc.FillMode = D3D11_FILL_SOLID;
rdesc.FrontCounterClockwise = true; rdesc.FrontCounterClockwise = false;
rdesc.DepthBias = 0; rdesc.DepthBias = 0;
rdesc.DepthBiasClamp = 0; rdesc.DepthBiasClamp = 0;
rdesc.DepthClipEnable = false; rdesc.DepthClipEnable = true;
rdesc.SlopeScaledDepthBias = 0; rdesc.SlopeScaledDepthBias = 0;
rdesc.ScissorEnable = true; rdesc.ScissorEnable = false;
rdesc.MultisampleEnable = false; rdesc.MultisampleEnable = false;
rdesc.AntialiasedLineEnable = false; rdesc.AntialiasedLineEnable = false;

View File

@ -18,9 +18,11 @@ struct VertexIn
float4 main( VertexIn input ) : SV_POSITION float4 main( VertexIn input ) : SV_POSITION
{ {
return float4(input.pos,1); float4 postTransform = float4(input.pos*0.1f,1);
return mul(float4(input.pos,1), View); postTransform.y += 1.5f;
matrix VP = mul(View, Projection); //return postTransform;
matrix WVP = mul(World, VP); return mul(float4(input.pos*0.1f,1), View);
return mul(WVP, float4(input.pos,1)); //matrix VP = mul(Projection,View);
//matrix WVP = mul(World, VP);
//return mul(VP, float4(input.pos*0.01f,1));
} }

View File

@ -12,6 +12,7 @@
#include "Render\Resources\Resources.h" #include "Render\Resources\Resources.h"
#include "Render\Rendering\Render.h" #include "Render\Rendering\Render.h"
#include "FileLoader\ObjReader.h" #include "FileLoader\ObjReader.h"
#include "Definitions\GraphicalDefinition.h"
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Global Variables // Global Variables
@ -174,33 +175,41 @@ HRESULT InitDirect3D()
/*struct float4 /*struct float4
{ {
float x,y,z,w; float x,y,z,w;
}; };*/
float4 mesh[] = //Oyster::Graphics::Definitions::ObjVertex mesh[] =
{ //{
{-1.0f,1.0f,0.0f,1.0f}, // {Oyster::Math::Vector3(-1,1,0),Oyster::Math::Vector2(0,0),Oyster::Math::Vector3(1,1,0)},
{1.0f,1.0f,0.0f,1.0f}, // {Oyster::Math::Vector3(1,-1,0),Oyster::Math::Vector2(0,0),Oyster::Math::Vector3(1,1,0)},
{1.0f,-1.0f,0.0f,1.0f}, // {Oyster::Math::Vector3(1,1,0),Oyster::Math::Vector2(0,0),Oyster::Math::Vector3(1,1,0)},
}; //};
Oyster::Graphics::Buffer::BUFFER_INIT_DESC desc; //Oyster::Graphics::Buffer::BUFFER_INIT_DESC desc;
desc.ElementSize= sizeof(float4); //desc.ElementSize= sizeof(Oyster::Graphics::Definitions::ObjVertex);
desc.NumElements = 3; //desc.NumElements = 3;
desc.InitData=mesh; //desc.InitData=mesh;
desc.Type = Oyster::Graphics::Buffer::BUFFER_TYPE::VERTEX_BUFFER; //desc.Type = Oyster::Graphics::Buffer::BUFFER_TYPE::VERTEX_BUFFER;
desc.Usage = Oyster::Graphics::Buffer::BUFFER_USAGE::BUFFER_USAGE_IMMUTABLE; //desc.Usage = Oyster::Graphics::Buffer::BUFFER_USAGE::BUFFER_USAGE_IMMUTABLE;
Oyster::Graphics::Buffer b; //Oyster::Graphics::Buffer *b = new Oyster::Graphics::Buffer();;
b.Init(desc); //b->Init(desc);
b.Apply(0);*/
////b.Apply(0);
//Oyster::Graphics::Render::ModelInfo* mi = new Oyster::Graphics::Render::ModelInfo();
//mi->Indexed = false;
//mi->VertexCount = 3;
//mi->Vertices = b;
OBJReader or; OBJReader or;
or.readOBJFile(L"bth.obj"); or.readOBJFile(L"bth.obj");
m->info = or.toModel(); m->info = or.toModel();
//m->info = mi;
m->World = Oyster::Math::Matrix::identity; m->World = Oyster::Math::Matrix::identity;
P = Oyster::Math3D::ProjectionMatrix_Perspective(PI/4,16.0f/9.0f,1,100); P = Oyster::Math3D::ProjectionMatrix_Perspective(PI/4,16.0f/9.0f,1,100);
V = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),Oyster::Math::Float3(0,0,30)).GetInverse(); V = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),Oyster::Math::Float3(0,-1.5f,0.0f)).GetInverse();
return S_OK; return S_OK;
} }
@ -213,11 +222,13 @@ HRESULT Update(float deltaTime)
HRESULT Render(float deltaTime) HRESULT Render(float deltaTime)
{ {
Oyster::Graphics::Render::Rendering::Basic::NewFrame(V,P); Oyster::Graphics::Render::Rendering::Basic::NewFrame(V,P);
/*Oyster::Graphics::Render::Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,1,1)); //Oyster::Graphics::Render::Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,1,1));
Oyster::Graphics::Core::deviceContext->Draw(3,0); //m->info->Vertices->Apply(0);
Oyster::Graphics::Core::swapChain->Present(0,0);*/ //Oyster::Graphics::Core::deviceContext->Draw(3,0);
//Oyster::Graphics::Core::swapChain->Present(0,0);
Oyster::Graphics::Render::Rendering::Basic::RenderScene(m,1); Oyster::Graphics::Render::Rendering::Basic::RenderScene(m,1);

33004
Tester/bth.obj Normal file

File diff suppressed because it is too large Load Diff