Skip to content

Commit

Permalink
Added shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
matt77hias committed Jan 30, 2017
1 parent 5aad737 commit 129b997
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
28 changes: 28 additions & 0 deletions MAGE/MAGE.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,34 @@
<ClCompile Include="MAGE\src\ui\combo_box.cpp" />
<ClCompile Include="MAGE\src\ui\main_window.cpp" />
</ItemGroup>
<ItemGroup>
<FxCompile Include="MAGE\shaders\effect.fx">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</FxCompile>
<FxCompile Include="MAGE\shaders\effect_PS.hlsl">
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">PS</EntryPointName>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">PS</EntryPointName>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">PS</EntryPointName>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">PS</EntryPointName>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="MAGE\shaders\effect_VS.hlsl">
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">VS</EntryPointName>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">VS</EntryPointName>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">VS</EntryPointName>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">VS</EntryPointName>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
</FxCompile>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{28DC5FAC-C856-43E1-828E-BEAA8A0E2CE4}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
Expand Down
14 changes: 14 additions & 0 deletions MAGE/MAGE.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
<Filter Include="Source Files\math">
<UniqueIdentifier>{bbd248c9-b157-44c4-a8ef-94435c108be9}</UniqueIdentifier>
</Filter>
<Filter Include="Shader Files">
<UniqueIdentifier>{edf15e17-27ed-4e39-a6ba-25499d2f4a45}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MAGE\src\collection\collection.hpp">
Expand Down Expand Up @@ -390,4 +393,15 @@
<Filter>Source Files\math</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<FxCompile Include="MAGE\shaders\effect.fx">
<Filter>Shader Files</Filter>
</FxCompile>
<FxCompile Include="MAGE\shaders\effect_PS.hlsl">
<Filter>Shader Files</Filter>
</FxCompile>
<FxCompile Include="MAGE\shaders\effect_VS.hlsl">
<Filter>Shader Files</Filter>
</FxCompile>
</ItemGroup>
</Project>
47 changes: 47 additions & 0 deletions MAGE/MAGE/shaders/effect.fx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//--------------------------------------------------------------------------------------
// Constant buffers
//--------------------------------------------------------------------------------------
Texture2D diffuse_texture : register(t0);
SamplerState linear_sample : register(s0);

cbuffer cb_camera : register(b0) {
matrix world_to_view;
matrix view_to_projection;
};

cbuffer cb_model : register(b1) {
matrix model_to_world;
}

//-----------------------------------------------------------------------------
// Input structures
//-----------------------------------------------------------------------------
struct VS_INPUT {
float4 p : POSITION;
float3 n : NORMAL;
float2 tex : TEXCOORD0;
};

struct PS_INPUT {
float4 p : SV_POSITION;
float2 tex : TEXCOORD0;
};

//-----------------------------------------------------------------------------
// Vertex Shader
//-----------------------------------------------------------------------------
PS_INPUT VS(VS_INPUT input) {
PS_INPUT output = (PS_INPUT)0;
output.p = mul(input.p, model_to_world);
output.p = mul(output.p, world_to_view);
output.p = mul(output.p, view_to_projection);
output.tex = input.tex;
return output;
}

//-----------------------------------------------------------------------------
// Pixel Shader
//-----------------------------------------------------------------------------
float4 PS(PS_INPUT input) : SV_Target{
return diffuse_texture.Sample(linear_sample, input.tex);
}
1 change: 1 addition & 0 deletions MAGE/MAGE/shaders/effect_PS.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "effect.fx"
1 change: 1 addition & 0 deletions MAGE/MAGE/shaders/effect_VS.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "effect.fx"

0 comments on commit 129b997

Please sign in to comment.