| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <configuration> | ||
| <startup> | ||
| <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
| </startup> | ||
| </configuration> |
| @@ -0,0 +1,147 @@ | ||
|
|
||
| cbuffer cbPerObject { | ||
| float4x4 WorldViewProjection; | ||
| float4x4 World; | ||
| float4x4 gWorldInvTranspose; | ||
| }; | ||
|
|
||
| // new | ||
| cbuffer cbPerObjectPS { | ||
| float3 EyePosition; | ||
| float specExp; | ||
| float specIntensity; | ||
| }; | ||
|
|
||
| cbuffer cbDirLightPS { | ||
| float3 AmbientDown; | ||
| float3 AmbientRange; | ||
| float3 DirToLight; // new | ||
| float3 DirLightColor; // new | ||
| }; | ||
|
|
||
| Texture2D DiffuseTexture; | ||
| SamplerState LinearSampler { | ||
| Filter = MIN_MAG_MIP_LINEAR; | ||
| AddressU = WRAP; | ||
| AddressV = WRAP; | ||
| AddressW = WRAP; | ||
| MaxAnisotropy = 1; | ||
| }; | ||
|
|
||
| struct VS_INPUT { | ||
| float3 Position : POSITION; | ||
| float3 Normal : NORMAL; | ||
| float2 UV : TEXCOORD0; | ||
| }; | ||
|
|
||
| struct VS_OUTPUT { | ||
| float4 Position : SV_POSITION; | ||
| float2 UV : TEXCOORD0; | ||
| float3 Normal : TEXCOORD1; | ||
| float3 WorldPos : TEXCOORD2; // new | ||
| }; | ||
|
|
||
| float4 DepthPrePassVS(float4 Position : POSITION) :SV_POSITION{ | ||
| return mul(Position, WorldViewProjection); | ||
| } | ||
|
|
||
| VS_OUTPUT RenderSceneVS(VS_INPUT input) { | ||
| VS_OUTPUT output; | ||
| float3 vNormalWorldSpace; | ||
| output.Position = mul(float4(input.Position, 1.0f), WorldViewProjection); | ||
|
|
||
| // new | ||
| output.WorldPos = mul(float4(input.Position, 1.0f), World).xyz; | ||
|
|
||
| output.UV = input.UV; | ||
|
|
||
| output.Normal = mul(input.Normal, (float3x3)gWorldInvTranspose); | ||
|
|
||
| return output; | ||
| } | ||
|
|
||
| float3 CalcAmbient(float3 normal, float3 color) { | ||
| float up = normal.y * 0.5 + 0.5; | ||
|
|
||
| float3 ambient = AmbientDown + up * AmbientRange; | ||
|
|
||
| return ambient * color; | ||
| } | ||
|
|
||
| struct Material { | ||
| float3 normal; | ||
| float4 diffuseColor; | ||
| float specExp; | ||
| float specIntensity; | ||
| }; | ||
|
|
||
| Material PrepareMaterial(float3 normal, float2 UV) { | ||
| Material material; | ||
|
|
||
| material.normal = normalize(normal); | ||
| material.diffuseColor = DiffuseTexture.Sample(LinearSampler, UV); | ||
|
|
||
| // gamma correct input texture diffuse color to linear-space | ||
| material.diffuseColor.rgb *= material.diffuseColor.rgb; | ||
|
|
||
| material.specExp = specExp; | ||
| material.specIntensity = specIntensity; | ||
|
|
||
| return material; | ||
| } | ||
|
|
||
| float3 CalcDirectional(float3 position, Material material) { | ||
| // calculate diffuse light | ||
| float NDotL = dot(DirToLight, material.normal); | ||
| float3 finalColor = DirLightColor.rgb * saturate(NDotL); | ||
|
|
||
| // calculate specular light and add to diffuse | ||
| float3 toEye = EyePosition.xyz - position; | ||
| toEye = normalize(toEye); | ||
| float3 halfway = normalize(toEye + DirToLight); | ||
| float NDotH = saturate(dot(halfway, material.normal)); | ||
| finalColor += DirLightColor.rgb * pow(NDotH, material.specExp) * material.specIntensity; | ||
|
|
||
| // scale light color by material color | ||
| return finalColor * material.diffuseColor.rgb; | ||
| } | ||
|
|
||
| float4 DirectionalLightPS(VS_OUTPUT input) :SV_TARGET0{ | ||
| Material material = PrepareMaterial(input.Normal, input.UV); | ||
|
|
||
| float3 finalColor = CalcAmbient(material.normal, material.diffuseColor.rgb); | ||
|
|
||
| finalColor += CalcDirectional(input.WorldPos, material); | ||
|
|
||
| return float4(finalColor, 1.0); | ||
| } | ||
|
|
||
| float4 AmbientLightPS(VS_OUTPUT input) : SV_TARGET0{ | ||
|
|
||
| input.Normal = normalize(input.Normal); | ||
|
|
||
| float3 diffuse = DiffuseTexture.Sample(LinearSampler, input.UV).rgb; | ||
| diffuse *= diffuse; | ||
|
|
||
| float3 ambient = CalcAmbient(input.Normal, diffuse); | ||
| return float4(ambient, 1.0); | ||
| } | ||
|
|
||
| technique11 Ambient { | ||
| pass P0 { | ||
| SetVertexShader(CompileShader(vs_5_0, RenderSceneVS())); | ||
| SetPixelShader(CompileShader(ps_5_0, AmbientLightPS())); | ||
| } | ||
| } | ||
| technique11 DepthPrePass { | ||
| pass P0 { | ||
| SetVertexShader(CompileShader(vs_5_0, RenderSceneVS())); | ||
| SetPixelShader(NULL); | ||
| } | ||
| } | ||
| technique11 Directional { | ||
| pass P0 { | ||
| SetVertexShader(CompileShader(vs_5_0, RenderSceneVS())); | ||
| SetPixelShader(CompileShader(ps_5_0, DirectionalLightPS())); | ||
| } | ||
| } |
| @@ -0,0 +1,15 @@ | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\Models\bunny.sdkmesh | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\Textures\white.dds | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\FX\ForwardLight.fx | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\DirectionalLighting.exe.config | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\DirectionalLighting.exe | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\DirectionalLighting.pdb | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\Core.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\SlimDX.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\SpriteTextRenderer.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\AssimpNet.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\Core.pdb | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\bin\Debug\AssimpNet.xml | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\obj\Debug\DirectionalLighting.csprojResolveAssemblyReference.cache | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\obj\Debug\DirectionalLighting.exe | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\DirectionalLighting\obj\Debug\DirectionalLighting.pdb |
| @@ -0,0 +1,197 @@ | ||
| // | ||
| // FX Version: fx_5_0 | ||
| // | ||
| // 2 local buffer(s) | ||
| // | ||
| cbuffer cbPerObject | ||
| { | ||
| float4x4 WorldViewProjection; // Offset: 0, size: 64 | ||
| float4x4 World; // Offset: 64, size: 64 | ||
| float4x4 gWorldInvTranspose; // Offset: 128, size: 64 | ||
| } | ||
|
|
||
| cbuffer cbDirLightPS | ||
| { | ||
| float3 AmbientDown; // Offset: 0, size: 12 | ||
| float3 AmbientRange; // Offset: 16, size: 12 | ||
| } | ||
|
|
||
| // | ||
| // 2 local object(s) | ||
| // | ||
| Texture2D DiffuseTexture; | ||
| SamplerState LinearSampler | ||
| { | ||
| Filter = uint(MIN_MAG_MIP_LINEAR /* 21 */); | ||
| AddressU = uint(WRAP /* 1 */); | ||
| AddressV = uint(WRAP /* 1 */); | ||
| AddressW = uint(WRAP /* 1 */); | ||
| MaxAnisotropy = uint(1); | ||
| }; | ||
|
|
||
| // | ||
| // 1 groups(s) | ||
| // | ||
| fxgroup | ||
| { | ||
| // | ||
| // 1 technique(s) | ||
| // | ||
| technique11 Ambient | ||
| { | ||
| pass P0 | ||
| { | ||
| VertexShader = asm { | ||
| // | ||
| // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 | ||
| // | ||
| // | ||
| // Buffer Definitions: | ||
| // | ||
| // cbuffer cbPerObject | ||
| // { | ||
| // | ||
| // float4x4 WorldViewProjection; // Offset: 0 Size: 64 | ||
| // float4x4 World; // Offset: 64 Size: 64 [unused] | ||
| // float4x4 gWorldInvTranspose; // Offset: 128 Size: 64 | ||
| // | ||
| // } | ||
| // | ||
| // | ||
| // Resource Bindings: | ||
| // | ||
| // Name Type Format Dim Slot Elements | ||
| // ------------------------------ ---------- ------- ----------- ---- -------- | ||
| // cbPerObject cbuffer NA NA 0 1 | ||
| // | ||
| // | ||
| // | ||
| // Input signature: | ||
| // | ||
| // Name Index Mask Register SysValue Format Used | ||
| // -------------------- ----- ------ -------- -------- ------ ------ | ||
| // POSITION 0 xyz 0 NONE float xyz | ||
| // NORMAL 0 xyz 1 NONE float xyz | ||
| // TEXCOORD 0 xy 2 NONE float xy | ||
| // | ||
| // | ||
| // Output signature: | ||
| // | ||
| // Name Index Mask Register SysValue Format Used | ||
| // -------------------- ----- ------ -------- -------- ------ ------ | ||
| // SV_POSITION 0 xyzw 0 POS float xyzw | ||
| // TEXCOORD 0 xy 1 NONE float xy | ||
| // TEXCOORD 1 xyz 2 NONE float xyz | ||
| // | ||
| vs_5_0 | ||
| dcl_globalFlags refactoringAllowed | ||
| dcl_constantbuffer cb0[11], immediateIndexed | ||
| dcl_input v0.xyz | ||
| dcl_input v1.xyz | ||
| dcl_input v2.xy | ||
| dcl_output_siv o0.xyzw, position | ||
| dcl_output o1.xy | ||
| dcl_output o2.xyz | ||
| dcl_temps 3 | ||
|
|
||
| #line 36 "C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\FX\ForwardLight.fx" | ||
| mov r0.xyz, v0.xyzx | ||
| mov r0.w, l(1.000000) | ||
| dp4 r1.x, r0.xyzw, cb0[0].xyzw // output<0:NaN:Inf> | ||
| dp4 r1.y, r0.xyzw, cb0[1].xyzw // output<1:NaN:Inf> | ||
| dp4 r1.z, r0.xyzw, cb0[2].xyzw // output<2:NaN:Inf> | ||
| dp4 r1.w, r0.xyzw, cb0[3].xyzw // output<3:NaN:Inf> | ||
| mov r0.xy, v2.xyxx // output<4,5> | ||
| dp3 r2.x, v1.xyzx, cb0[8].xyzx // output<6:NaN:Inf> | ||
| dp3 r2.y, v1.xyzx, cb0[9].xyzx // output<7:NaN:Inf> | ||
| dp3 r2.z, v1.xyzx, cb0[10].xyzx // output<8:NaN:Inf> | ||
| mov o0.xyzw, r1.xyzw // RenderSceneVS<0:NaN:Inf,1:NaN:Inf,2:NaN:Inf,3:NaN:Inf> | ||
| mov o2.xyz, r2.xyzx // RenderSceneVS<6:NaN:Inf,7:NaN:Inf,8:NaN:Inf> | ||
| mov o1.xy, r0.xyxx // RenderSceneVS<4,5> | ||
| ret | ||
| // Approximately 14 instruction slots used | ||
|
|
||
| }; | ||
| PixelShader = asm { | ||
| // | ||
| // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 | ||
| // | ||
| // | ||
| // Buffer Definitions: | ||
| // | ||
| // cbuffer cbDirLightPS | ||
| // { | ||
| // | ||
| // float3 AmbientDown; // Offset: 0 Size: 12 | ||
| // float3 AmbientRange; // Offset: 16 Size: 12 | ||
| // | ||
| // } | ||
| // | ||
| // | ||
| // Resource Bindings: | ||
| // | ||
| // Name Type Format Dim Slot Elements | ||
| // ------------------------------ ---------- ------- ----------- ---- -------- | ||
| // LinearSampler sampler NA NA 0 1 | ||
| // DiffuseTexture texture float4 2d 0 1 | ||
| // cbDirLightPS cbuffer NA NA 0 1 | ||
| // | ||
| // | ||
| // | ||
| // Input signature: | ||
| // | ||
| // Name Index Mask Register SysValue Format Used | ||
| // -------------------- ----- ------ -------- -------- ------ ------ | ||
| // SV_POSITION 0 xyzw 0 POS float | ||
| // TEXCOORD 0 xy 1 NONE float xy | ||
| // TEXCOORD 1 xyz 2 NONE float xyz | ||
| // | ||
| // | ||
| // Output signature: | ||
| // | ||
| // Name Index Mask Register SysValue Format Used | ||
| // -------------------- ----- ------ -------- -------- ------ ------ | ||
| // SV_TARGET 0 xyzw 0 TARGET float xyzw | ||
| // | ||
| ps_5_0 | ||
| dcl_globalFlags refactoringAllowed | ||
| dcl_constantbuffer cb0[2], immediateIndexed | ||
| dcl_sampler s0, mode_default | ||
| dcl_resource_texture2d (float,float,float,float) t0 | ||
| dcl_input_ps linear v1.xy | ||
| dcl_input_ps linear v2.xyz | ||
| dcl_output o0.xyzw | ||
| dcl_temps 2 | ||
|
|
||
| #line 55 "C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\FX\ForwardLight.fx" | ||
| dp3 r0.x, v2.xyzx, v2.xyzx | ||
| rsq r0.x, r0.x | ||
| mul r0.x, r0.x, v2.y // input<7:NaN:Inf> | ||
| sample_indexable(texture2d)(float,float,float,float) r0.yzw, v1.xyxx, t0.wxyz, s0 | ||
| mov r0.yzw, r0.yyzw // diffuse<0:Inf,1:Inf,2:Inf> | ||
| mul r0.yzw, r0.yyzw, r0.yyzw // diffuse<0:NaN:Inf,1:NaN:Inf,2:NaN:Inf> | ||
| nop | ||
| mov r0.x, r0.x // normal<1:NaN:Inf> | ||
| mov r0.yzw, r0.yyzw // color<0:NaN:Inf,1:NaN:Inf,2:NaN:Inf> | ||
|
|
||
| #line 46 | ||
| mul r0.x, r0.x, l(0.500000) | ||
| add r0.x, r0.x, l(0.500000) // up<0:NaN:Inf> | ||
| mul r1.xyz, r0.xxxx, cb0[1].xyzx | ||
| add r1.xyz, r1.xyzx, cb0[0].xyzx // ambient<0:NaN:Inf,1:NaN:Inf,2:NaN:Inf> | ||
| mul r0.xyz, r0.yzwy, r1.xyzx // CalcAmbient<0:NaN:Inf,1:NaN:Inf,2:NaN:Inf> | ||
|
|
||
| #line 60 | ||
| mov r0.xyz, r0.xyzx // ambient<0:NaN:Inf,1:NaN:Inf,2:NaN:Inf> | ||
| mov o0.xyz, r0.xyzx // AmbientLightPS<0:NaN:Inf,1:NaN:Inf,2:NaN:Inf> | ||
| mov o0.w, l(1.000000) // AmbientLightPS<3: 1f> | ||
| ret | ||
| // Approximately 18 instruction slots used | ||
|
|
||
| }; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
|
|
| @@ -0,0 +1,69 @@ | ||
| cbuffer cbPerObject { | ||
| float4x4 WorldViewProjection; | ||
| float4x4 World; | ||
| float4x4 gWorldInvTranspose; | ||
| }; | ||
|
|
||
| cbuffer cbDirLightPS { | ||
| float3 AmbientDown; | ||
| float3 AmbientRange; | ||
| }; | ||
|
|
||
| Texture2D DiffuseTexture; | ||
| SamplerState LinearSampler { | ||
| Filter = MIN_MAG_MIP_LINEAR; | ||
| AddressU = WRAP; | ||
| AddressV = WRAP; | ||
| AddressW = WRAP; | ||
| MaxAnisotropy = 1; | ||
| }; | ||
|
|
||
| struct VS_INPUT { | ||
| float3 Position : POSITION; | ||
| float3 Normal : NORMAL; | ||
| float2 UV : TEXCOORD0; | ||
| }; | ||
|
|
||
| struct VS_OUTPUT { | ||
| float4 Position : SV_POSITION; | ||
| float2 UV : TEXCOORD0; | ||
| float3 Normal : TEXCOORD1; | ||
| }; | ||
|
|
||
| VS_OUTPUT RenderSceneVS(VS_INPUT input) { | ||
| VS_OUTPUT output; | ||
| float3 vNormalWorldSpace; | ||
| output.Position = mul(float4(input.Position, 1.0f), WorldViewProjection); | ||
|
|
||
| output.UV = input.UV; | ||
|
|
||
| output.Normal = mul(input.Normal, (float3x3)gWorldInvTranspose); | ||
|
|
||
| return output; | ||
| } | ||
|
|
||
| float3 CalcAmbient(float3 normal, float3 color) { | ||
| float up = normal.y * 0.5 + 0.5; | ||
|
|
||
| float3 ambient = AmbientDown + up * AmbientRange; | ||
|
|
||
| return ambient * color; | ||
| } | ||
|
|
||
| float4 AmbientLightPS(VS_OUTPUT input) : SV_TARGET0{ | ||
|
|
||
| input.Normal = normalize(input.Normal); | ||
|
|
||
| float3 diffuse = DiffuseTexture.Sample(LinearSampler, input.UV).rgb; | ||
| diffuse *= diffuse; | ||
|
|
||
| float3 ambient = CalcAmbient(input.Normal, diffuse); | ||
| return float4(ambient, 1.0); | ||
| } | ||
|
|
||
| technique11 Ambient { | ||
| pass P0 { | ||
| SetVertexShader(CompileShader(vs_5_0, RenderSceneVS())); | ||
| SetPixelShader(CompileShader(ps_5_0, AmbientLightPS())); | ||
| } | ||
| } |
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <configuration> | ||
| <startup> | ||
| <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
| </startup> | ||
| </configuration> |
| @@ -0,0 +1,15 @@ | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\Textures\white.dds | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\Models\bunny.sdkmesh | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\FX\ForwardLight.fx | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\HemisphericalAmbient.exe.config | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\HemisphericalAmbient.exe | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\HemisphericalAmbient.pdb | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\Core.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\SlimDX.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\SpriteTextRenderer.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\AssimpNet.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\Core.pdb | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\bin\Debug\AssimpNet.xml | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\obj\Debug\HemisphericalAmbient.csprojResolveAssemblyReference.cache | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\obj\Debug\HemisphericalAmbient.exe | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\HemisphericalAmbient\obj\Debug\HemisphericalAmbient.pdb |
| @@ -0,0 +1,119 @@ | ||
| #include "ForwardLightCommon.fx" | ||
|
|
||
|
|
||
| cbuffer cbDirLightPS { | ||
| float3 AmbientDown; | ||
| float3 AmbientRange; | ||
| float3 DirToLight; // new | ||
| float3 DirLightColor; // new | ||
| }; | ||
|
|
||
| cbuffer PointLightConstants { | ||
| float3 PointLightPosition; | ||
| float PointLightRangeRcp; | ||
| float3 PointLightColor; | ||
| }; | ||
|
|
||
| float3 CalcAmbient(float3 normal, float3 color) { | ||
| float up = normal.y * 0.5 + 0.5; | ||
|
|
||
| float3 ambient = AmbientDown + up * AmbientRange; | ||
|
|
||
| return ambient * color; | ||
| } | ||
|
|
||
| float3 CalcDirectional(float3 position, Material material) { | ||
| // calculate diffuse light | ||
| float NDotL = dot(DirToLight, material.normal); | ||
| float3 finalColor = DirLightColor.rgb * saturate(NDotL); | ||
|
|
||
| // calculate specular light and add to diffuse | ||
| float3 toEye = EyePosition.xyz - position; | ||
| toEye = normalize(toEye); | ||
| float3 halfway = normalize(toEye + DirToLight); | ||
| float NDotH = saturate(dot(halfway, material.normal)); | ||
| finalColor += DirLightColor.rgb * pow(NDotH, material.specExp) * material.specIntensity; | ||
|
|
||
| // scale light color by material color | ||
| return finalColor * material.diffuseColor.rgb; | ||
| } | ||
|
|
||
| float3 CalcPoint(float3 position, Material material) { | ||
| float3 ToLight = PointLightPosition.xyz - position; | ||
| float3 ToEye = EyePosition.xyz - position; | ||
| float DistToLight = length(ToLight); | ||
|
|
||
| // Phong diffuse | ||
| ToLight /= DistToLight; // Normalize | ||
| float NDotL = saturate(dot(ToLight, material.normal)); | ||
| float3 finalColor = PointLightColor.rgb * NDotL; | ||
|
|
||
| // Blinn specular | ||
| ToEye = normalize(ToEye); | ||
| float3 HalfWay = normalize(ToEye + ToLight); | ||
| float NDotH = saturate(dot(HalfWay, material.normal)); | ||
| finalColor += PointLightColor.rgb * pow(NDotH, material.specExp) * material.specIntensity; | ||
|
|
||
| // Attenuation | ||
| float DistToLightNorm = 1.0 - saturate(DistToLight * PointLightRangeRcp); | ||
| float Attn = DistToLightNorm * DistToLightNorm; | ||
| finalColor *= material.diffuseColor * Attn; | ||
|
|
||
| return finalColor; | ||
| } | ||
|
|
||
| float4 DirectionalLightPS(VS_OUTPUT input) :SV_TARGET0{ | ||
| Material material = PrepareMaterial(input.Normal, input.UV); | ||
|
|
||
| float3 finalColor = CalcAmbient(material.normal, material.diffuseColor.rgb); | ||
|
|
||
| finalColor += CalcDirectional(input.WorldPos, material); | ||
|
|
||
| return float4(finalColor, 1.0); | ||
| } | ||
| float4 PointLightPS(VS_OUTPUT In) : SV_TARGET0 { | ||
| // Prepare the material structure | ||
| Material material = PrepareMaterial(In.Normal, In.UV); | ||
|
|
||
| // Calculate the point light color | ||
| float3 finalColor = CalcPoint(In.WorldPos, material); | ||
|
|
||
| // Return the final color | ||
| return float4(finalColor, 1.0); | ||
| } | ||
|
|
||
| float4 AmbientLightPS(VS_OUTPUT input) : SV_TARGET0{ | ||
|
|
||
| input.Normal = normalize(input.Normal); | ||
|
|
||
| float3 diffuse = DiffuseTexture.Sample(LinearSampler, input.UV).rgb; | ||
| diffuse *= diffuse; | ||
|
|
||
| float3 ambient = CalcAmbient(input.Normal, diffuse); | ||
| return float4(ambient, 1.0); | ||
| } | ||
|
|
||
| technique11 Ambient { | ||
| pass P0 { | ||
| SetVertexShader(CompileShader(vs_5_0, RenderSceneVS())); | ||
| SetPixelShader(CompileShader(ps_5_0, AmbientLightPS())); | ||
| } | ||
| } | ||
| technique11 DepthPrePass { | ||
| pass P0 { | ||
| SetVertexShader(CompileShader(vs_5_0, RenderSceneVS())); | ||
| SetPixelShader(NULL); | ||
| } | ||
| } | ||
| technique11 Directional { | ||
| pass P0 { | ||
| SetVertexShader(CompileShader(vs_5_0, RenderSceneVS())); | ||
| SetPixelShader(CompileShader(ps_5_0, DirectionalLightPS())); | ||
| } | ||
| } | ||
| technique11 Point { | ||
| pass P0 { | ||
| SetVertexShader(CompileShader(vs_5_0, RenderSceneVS())); | ||
| SetPixelShader(CompileShader(ps_5_0, PointLightPS())); | ||
| } | ||
| } |
| @@ -0,0 +1,76 @@ | ||
|
|
||
|
|
||
| cbuffer cbPerObjectVS { | ||
| float4x4 WorldViewProjection; | ||
| float4x4 World; | ||
| float4x4 gWorldInvTranspose; | ||
| }; | ||
|
|
||
| cbuffer cbPerObjectPS { | ||
| float3 EyePosition; | ||
| float specExp; | ||
| float specIntensity; | ||
| }; | ||
|
|
||
| Texture2D DiffuseTexture; | ||
| SamplerState LinearSampler { | ||
| Filter = MIN_MAG_MIP_LINEAR; | ||
| AddressU = WRAP; | ||
| AddressV = WRAP; | ||
| AddressW = WRAP; | ||
| MaxAnisotropy = 1; | ||
| }; | ||
|
|
||
| struct VS_INPUT { | ||
| float3 Position : POSITION; | ||
| float3 Normal : NORMAL; | ||
| float2 UV : TEXCOORD0; | ||
| }; | ||
|
|
||
| struct VS_OUTPUT { | ||
| float4 Position : SV_POSITION; | ||
| float2 UV : TEXCOORD0; | ||
| float3 Normal : TEXCOORD1; | ||
| float3 WorldPos : TEXCOORD2; // new | ||
| }; | ||
|
|
||
| float4 DepthPrePassVS(float4 Position : POSITION) :SV_POSITION{ | ||
| return mul(Position, WorldViewProjection); | ||
| } | ||
|
|
||
| VS_OUTPUT RenderSceneVS(VS_INPUT input) { | ||
| VS_OUTPUT output; | ||
| float3 vNormalWorldSpace; | ||
| output.Position = mul(float4(input.Position, 1.0f), WorldViewProjection); | ||
|
|
||
| // new | ||
| output.WorldPos = mul(float4(input.Position, 1.0f), World).xyz; | ||
|
|
||
| output.UV = input.UV; | ||
|
|
||
| output.Normal = mul(input.Normal, (float3x3)gWorldInvTranspose); | ||
|
|
||
| return output; | ||
| } | ||
|
|
||
| struct Material { | ||
| float3 normal; | ||
| float4 diffuseColor; | ||
| float specExp; | ||
| float specIntensity; | ||
| }; | ||
|
|
||
| Material PrepareMaterial(float3 normal, float2 UV) { | ||
| Material material; | ||
|
|
||
| material.normal = normalize(normal); | ||
| material.diffuseColor = DiffuseTexture.Sample(LinearSampler, UV); | ||
|
|
||
| // gamma correct input texture diffuse color to linear-space | ||
| material.diffuseColor.rgb *= material.diffuseColor.rgb; | ||
|
|
||
| material.specExp = specExp; | ||
| material.specIntensity = specIntensity; | ||
|
|
||
| return material; | ||
| } |
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <configuration> | ||
| <startup> | ||
| <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
| </startup> | ||
| </configuration> |
| @@ -0,0 +1,16 @@ | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\FX\ForwardLight.fx | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\FX\ForwardLightCommon.fx | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\Models\bunny.sdkmesh | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\Textures\white.dds | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\PointLighting.exe.config | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\PointLighting.exe | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\PointLighting.pdb | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\Core.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\SlimDX.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\SpriteTextRenderer.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\AssimpNet.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\Core.pdb | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\bin\Debug\AssimpNet.xml | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\obj\Debug\PointLighting.csprojResolveAssemblyReference.cache | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\obj\Debug\PointLighting.exe | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\PointLighting\obj\Debug\PointLighting.pdb |
| @@ -0,0 +1,257 @@ | ||
| //*************************************************************************************** | ||
| // LightHelper.fx by Frank Luna (C) 2011 All Rights Reserved. | ||
| // | ||
| // Structures and functions for lighting calculations. | ||
| //*************************************************************************************** | ||
|
|
||
| struct DirectionalLight | ||
| { | ||
| float4 Ambient; | ||
| float4 Diffuse; | ||
| float4 Specular; | ||
| float3 Direction; | ||
| float pad; | ||
| }; | ||
|
|
||
| struct PointLight | ||
| { | ||
| float4 Ambient; | ||
| float4 Diffuse; | ||
| float4 Specular; | ||
|
|
||
| float3 Position; | ||
| float Range; | ||
|
|
||
| float3 Att; | ||
| float pad; | ||
| }; | ||
|
|
||
| struct SpotLight | ||
| { | ||
| float4 Ambient; | ||
| float4 Diffuse; | ||
| float4 Specular; | ||
|
|
||
| float3 Position; | ||
| float Range; | ||
|
|
||
| float3 Direction; | ||
| float Spot; | ||
|
|
||
| float3 Att; | ||
| float pad; | ||
| }; | ||
|
|
||
| struct Material | ||
| { | ||
| float4 Ambient; | ||
| float4 Diffuse; | ||
| float4 Specular; // w = SpecPower | ||
| float4 Reflect; | ||
| }; | ||
|
|
||
| //--------------------------------------------------------------------------------------- | ||
| // Computes the ambient, diffuse, and specular terms in the lighting equation | ||
| // from a directional light. We need to output the terms separately because | ||
| // later we will modify the individual terms. | ||
| //--------------------------------------------------------------------------------------- | ||
| void ComputeDirectionalLight(Material mat, DirectionalLight L, | ||
| float3 normal, float3 toEye, | ||
| out float4 ambient, | ||
| out float4 diffuse, | ||
| out float4 spec) | ||
| { | ||
| // Initialize outputs. | ||
| ambient = float4(0.0f, 0.0f, 0.0f, 0.0f); | ||
| diffuse = float4(0.0f, 0.0f, 0.0f, 0.0f); | ||
| spec = float4(0.0f, 0.0f, 0.0f, 0.0f); | ||
|
|
||
| // The light vector aims opposite the direction the light rays travel. | ||
| float3 lightVec = -L.Direction; | ||
|
|
||
| // Add ambient term. | ||
| ambient = mat.Ambient * L.Ambient; | ||
|
|
||
| // Add diffuse and specular term, provided the surface is in | ||
| // the line of site of the light. | ||
|
|
||
| float diffuseFactor = dot(lightVec, normal); | ||
|
|
||
| // Flatten to avoid dynamic branching. | ||
| [flatten] | ||
| if( diffuseFactor > 0.0f ) | ||
| { | ||
| float3 v = reflect(-lightVec, normal); | ||
| float specFactor = pow(max(dot(v, toEye), 0.0f), mat.Specular.w); | ||
|
|
||
| diffuse = diffuseFactor * mat.Diffuse * L.Diffuse; | ||
| spec = specFactor * mat.Specular * L.Specular; | ||
| } | ||
| } | ||
|
|
||
| //--------------------------------------------------------------------------------------- | ||
| // Computes the ambient, diffuse, and specular terms in the lighting equation | ||
| // from a point light. We need to output the terms separately because | ||
| // later we will modify the individual terms. | ||
| //--------------------------------------------------------------------------------------- | ||
| void ComputePointLight(Material mat, PointLight L, float3 pos, float3 normal, float3 toEye, | ||
| out float4 ambient, out float4 diffuse, out float4 spec) | ||
| { | ||
| // Initialize outputs. | ||
| ambient = float4(0.0f, 0.0f, 0.0f, 0.0f); | ||
| diffuse = float4(0.0f, 0.0f, 0.0f, 0.0f); | ||
| spec = float4(0.0f, 0.0f, 0.0f, 0.0f); | ||
|
|
||
| // The vector from the surface to the light. | ||
| float3 lightVec = L.Position - pos; | ||
|
|
||
| // The distance from surface to light. | ||
| float d = length(lightVec); | ||
|
|
||
| // Range test. | ||
| if( d > L.Range ) | ||
| return; | ||
|
|
||
| // Normalize the light vector. | ||
| lightVec /= d; | ||
|
|
||
| // Ambient term. | ||
| ambient = mat.Ambient * L.Ambient; | ||
|
|
||
| // Add diffuse and specular term, provided the surface is in | ||
| // the line of site of the light. | ||
|
|
||
| float diffuseFactor = dot(lightVec, normal); | ||
|
|
||
| // Flatten to avoid dynamic branching. | ||
| [flatten] | ||
| if( diffuseFactor > 0.0f ) | ||
| { | ||
| float3 v = reflect(-lightVec, normal); | ||
| float specFactor = pow(max(dot(v, toEye), 0.0f), mat.Specular.w); | ||
|
|
||
| diffuse = diffuseFactor * mat.Diffuse * L.Diffuse; | ||
| spec = specFactor * mat.Specular * L.Specular; | ||
| } | ||
|
|
||
| // Attenuate | ||
| float att = 1.0f / dot(L.Att, float3(1.0f, d, d*d)); | ||
|
|
||
| diffuse *= att; | ||
| spec *= att; | ||
| } | ||
|
|
||
| //--------------------------------------------------------------------------------------- | ||
| // Computes the ambient, diffuse, and specular terms in the lighting equation | ||
| // from a spotlight. We need to output the terms separately because | ||
| // later we will modify the individual terms. | ||
| //--------------------------------------------------------------------------------------- | ||
| void ComputeSpotLight(Material mat, SpotLight L, float3 pos, float3 normal, float3 toEye, | ||
| out float4 ambient, out float4 diffuse, out float4 spec) | ||
| { | ||
| // Initialize outputs. | ||
| ambient = float4(0.0f, 0.0f, 0.0f, 0.0f); | ||
| diffuse = float4(0.0f, 0.0f, 0.0f, 0.0f); | ||
| spec = float4(0.0f, 0.0f, 0.0f, 0.0f); | ||
|
|
||
| // The vector from the surface to the light. | ||
| float3 lightVec = L.Position - pos; | ||
|
|
||
| // The distance from surface to light. | ||
| float d = length(lightVec); | ||
|
|
||
| // Range test. | ||
| if( d > L.Range ) | ||
| return; | ||
|
|
||
| // Normalize the light vector. | ||
| lightVec /= d; | ||
|
|
||
| // Ambient term. | ||
| ambient = mat.Ambient * L.Ambient; | ||
|
|
||
| // Add diffuse and specular term, provided the surface is in | ||
| // the line of site of the light. | ||
|
|
||
| float diffuseFactor = dot(lightVec, normal); | ||
|
|
||
| // Flatten to avoid dynamic branching. | ||
| [flatten] | ||
| if( diffuseFactor > 0.0f ) | ||
| { | ||
| float3 v = reflect(-lightVec, normal); | ||
| float specFactor = pow(max(dot(v, toEye), 0.0f), mat.Specular.w); | ||
|
|
||
| diffuse = diffuseFactor * mat.Diffuse * L.Diffuse; | ||
| spec = specFactor * mat.Specular * L.Specular; | ||
| } | ||
|
|
||
| // Scale by spotlight factor and attenuate. | ||
| float spot = pow(max(dot(-lightVec, L.Direction), 0.0f), L.Spot); | ||
|
|
||
| // Scale by spotlight factor and attenuate. | ||
| float att = spot / dot(L.Att, float3(1.0f, d, d*d)); | ||
|
|
||
| ambient *= spot; | ||
| diffuse *= att; | ||
| spec *= att; | ||
| } | ||
|
|
||
| //--------------------------------------------------------------------------------------- | ||
| // Transforms a normal map sample to world space. | ||
| //--------------------------------------------------------------------------------------- | ||
| float3 NormalSampleToWorldSpace(float3 normalMapSample, float3 unitNormalW, float3 tangentW) | ||
| { | ||
| // Uncompress each component from [0,1] to [-1,1]. | ||
| float3 normalT = 2.0f*normalMapSample - 1.0f; | ||
|
|
||
| // Build orthonormal basis. | ||
| float3 N = unitNormalW; | ||
| float3 T = normalize(tangentW - dot(tangentW, N)*N); | ||
| float3 B = cross(N, T); | ||
|
|
||
| float3x3 TBN = float3x3(T, B, N); | ||
|
|
||
| // Transform from tangent space to world space. | ||
| float3 bumpedNormalW = mul(normalT, TBN); | ||
|
|
||
| return bumpedNormalW; | ||
| } | ||
|
|
||
| //--------------------------------------------------------------------------------------- | ||
| // Performs shadowmap test to determine if a pixel is in shadow. | ||
| //--------------------------------------------------------------------------------------- | ||
|
|
||
| static const float SMAP_SIZE = 2048.0f; | ||
| static const float SMAP_DX = 1.0f / SMAP_SIZE; | ||
|
|
||
| float CalcShadowFactor(SamplerComparisonState samShadow, | ||
| Texture2D shadowMap, | ||
| float4 shadowPosH) | ||
| { | ||
| // Complete projection by doing division by w. | ||
| shadowPosH.xyz /= shadowPosH.w; | ||
|
|
||
| // Depth in NDC space. | ||
| float depth = shadowPosH.z; | ||
|
|
||
| // Texel size. | ||
| const float dx = SMAP_DX; | ||
|
|
||
| float percentLit = 0.0f; | ||
| const float2 offsets[9] = | ||
| { | ||
| float2(-dx, -dx), float2(0.0f, -dx), float2(dx, -dx), | ||
| float2(-dx, 0.0f), float2(0.0f, 0.0f), float2(dx, 0.0f), | ||
| float2(-dx, +dx), float2(0.0f, +dx), float2(dx, +dx) | ||
| }; | ||
|
|
||
| [unroll] | ||
| for(int i = 0; i < 9; ++i) | ||
| { | ||
| percentLit += shadowMap.SampleCmpLevelZero(samShadow, | ||
| shadowPosH.xy + offsets[i], depth).r; | ||
| } | ||
|
|
||
| return percentLit /= 9.0f; | ||
| } |
| @@ -0,0 +1,6 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <configuration> | ||
| <startup> | ||
| <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
| </startup> | ||
| </configuration> |
| @@ -0,0 +1,17 @@ | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\FX\Basic.fx | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\FX\LightHelper.fx | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\FX\NormalMap.fx | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\Textures\white.dds | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\Models\bunny.sdkmesh | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\SdkMeshLoadingDemo.exe.config | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\SdkMeshLoadingDemo.exe | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\SdkMeshLoadingDemo.pdb | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\Core.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\SlimDX.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\SpriteTextRenderer.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\AssimpNet.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\Core.pdb | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\bin\Debug\AssimpNet.xml | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\obj\Debug\SdkMeshLoadingDemo.csprojResolveAssemblyReference.cache | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\obj\Debug\SdkMeshLoadingDemo.exe | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\SdkMeshLoading\obj\Debug\SdkMeshLoadingDemo.pdb |
| @@ -0,0 +1,119 @@ | ||
| // | ||
| // FX Version: fx_5_0 | ||
| // | ||
| // 1 local buffer(s) | ||
| // | ||
| cbuffer cbPerObject | ||
| { | ||
| float4x4 gWorldViewProj; // Offset: 0, size: 64 | ||
| } | ||
|
|
||
| // | ||
| // 1 groups(s) | ||
| // | ||
| fxgroup | ||
| { | ||
| // | ||
| // 1 technique(s) | ||
| // | ||
| technique11 ColorTech | ||
| { | ||
| pass P0 | ||
| { | ||
| VertexShader = asm { | ||
| // | ||
| // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 | ||
| // | ||
| // | ||
| // Buffer Definitions: | ||
| // | ||
| // cbuffer cbPerObject | ||
| // { | ||
| // | ||
| // float4x4 gWorldViewProj; // Offset: 0 Size: 64 | ||
| // | ||
| // } | ||
| // | ||
| // | ||
| // Resource Bindings: | ||
| // | ||
| // Name Type Format Dim Slot Elements | ||
| // ------------------------------ ---------- ------- ----------- ---- -------- | ||
| // cbPerObject cbuffer NA NA 0 1 | ||
| // | ||
| // | ||
| // | ||
| // Input signature: | ||
| // | ||
| // Name Index Mask Register SysValue Format Used | ||
| // -------------------- ----- ------ -------- -------- ------ ------ | ||
| // POSITION 0 xyz 0 NONE float xyz | ||
| // COLOR 0 xyzw 1 NONE float xyzw | ||
| // | ||
| // | ||
| // Output signature: | ||
| // | ||
| // Name Index Mask Register SysValue Format Used | ||
| // -------------------- ----- ------ -------- -------- ------ ------ | ||
| // SV_POSITION 0 xyzw 0 POS float xyzw | ||
| // COLOR 0 xyzw 1 NONE float xyzw | ||
| // | ||
| vs_4_0 | ||
| dcl_constantbuffer cb0[4], immediateIndexed | ||
| dcl_input v0.xyz | ||
| dcl_input v1.xyzw | ||
| dcl_output_siv o0.xyzw, position | ||
| dcl_output o1.xyzw | ||
| dcl_temps 1 | ||
|
|
||
| #line 17 "C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\FX\color.fx" | ||
| mov r0.xyz, v0.xyzx | ||
| mov r0.w, l(1.000000) | ||
| dp4 o0.x, r0.xyzw, cb0[0].xyzw // VS<0:NaN:Inf> | ||
| dp4 o0.y, r0.xyzw, cb0[1].xyzw // VS<1:NaN:Inf> | ||
| dp4 o0.z, r0.xyzw, cb0[2].xyzw // VS<2:NaN:Inf> | ||
| dp4 o0.w, r0.xyzw, cb0[3].xyzw // VS<3:NaN:Inf> | ||
|
|
||
| #line 20 | ||
| mov o1.xyzw, v1.xyzw // VS<4,5,6,7> | ||
| ret | ||
| // Approximately 8 instruction slots used | ||
|
|
||
| }; | ||
| GeometryShader = NULL; | ||
| PixelShader = asm { | ||
| // | ||
| // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 | ||
| // | ||
| // | ||
| // | ||
| // Input signature: | ||
| // | ||
| // Name Index Mask Register SysValue Format Used | ||
| // -------------------- ----- ------ -------- -------- ------ ------ | ||
| // SV_POSITION 0 xyzw 0 POS float | ||
| // COLOR 0 xyzw 1 NONE float xyzw | ||
| // | ||
| // | ||
| // Output signature: | ||
| // | ||
| // Name Index Mask Register SysValue Format Used | ||
| // -------------------- ----- ------ -------- -------- ------ ------ | ||
| // SV_Target 0 xyzw 0 TARGET float xyzw | ||
| // | ||
| ps_4_0 | ||
| dcl_input_ps linear v1.xyzw | ||
| dcl_output o0.xyzw | ||
|
|
||
| #line 24 "C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\FX\color.fx" | ||
| mov o0.xyzw, v1.xyzw // PS<0,1,2,3> | ||
| ret | ||
| // Approximately 2 instruction slots used | ||
|
|
||
| }; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
|
|
| @@ -0,0 +1,33 @@ | ||
| cbuffer cbPerObject { | ||
| float4x4 gWorldViewProj; | ||
| } | ||
|
|
||
| struct VertexIn { | ||
| float3 PosL : POSITION; | ||
| float4 Color : COLOR; | ||
| }; | ||
|
|
||
| struct VertexOut { | ||
| float4 PosH : SV_POSITION; | ||
| float4 Color: COLOR; | ||
| }; | ||
|
|
||
| VertexOut VS(VertexIn vin){ | ||
| VertexOut vout; | ||
| vout.PosH = mul(float4(vin.PosL, 1.0f), gWorldViewProj); | ||
| vout.Color = vin.Color; | ||
|
|
||
| return vout; | ||
| } | ||
|
|
||
| float4 PS(VertexOut pin) :SV_Target { | ||
| return pin.Color; | ||
| } | ||
|
|
||
| technique11 ColorTech { | ||
| pass P0{ | ||
| SetVertexShader( CompileShader( vs_4_0, VS())); | ||
| SetGeometryShader(NULL); | ||
| SetPixelShader(CompileShader( ps_4_0, PS())); | ||
| } | ||
| } |
| @@ -0,0 +1,26 @@ | ||
| <?xml version="1.0"?> | ||
| <configuration> | ||
| <configSections> | ||
| <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> | ||
| </configSections> | ||
| <startup> | ||
| <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/> | ||
| </startup> | ||
|
|
||
| <log4net> | ||
| <appender name="DebugAppender" type="log4net.Appender.RollingFileAppender"> | ||
| <file value="logs/log-" /> | ||
| <datePattern value="MM.dd.yyyy'.log'" /> | ||
| <staticLogFileName value="false" /> | ||
| <appendToFile value="false" /> | ||
| <maxSizeRollBackups value="10" /> | ||
| <layout type="log4net.Layout.PatternLayout"> | ||
| <conversionPattern value="%date - %-5level %logger-%line %newline	%message%newline" /> | ||
| </layout> | ||
| </appender> | ||
| <root> | ||
| <priority value="ALL" /> | ||
| <appender-ref ref="DebugAppender" /> | ||
| </root> | ||
| </log4net> | ||
| </configuration> |
| @@ -0,0 +1,19 @@ | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\FX\color.fx | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\VoronoiMap.exe.config | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\VoronoiMap.exe | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\VoronoiMap.pdb | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\Algorithms.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\Core.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\log4net.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\SlimDX.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\SpriteTextRenderer.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\AssimpNet.dll | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\Algorithms.pdb | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\Core.pdb | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\log4net.xml | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\bin\Debug\AssimpNet.xml | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\obj\Debug\VoronoiMap.csprojResolveAssemblyReference.cache | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\obj\Debug\VoronoiMap.MainForm.resources | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\obj\Debug\VoronoiMap.csproj.GenerateResource.Cache | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\obj\Debug\VoronoiMap.exe | ||
| C:\Users\Dmitry\Google Drive\code\C#\SpaceshipDrawer\DX11\VoronoiMap\obj\Debug\VoronoiMap.pdb |