port from perforce
This commit is contained in:
294
nordlicht2015-intro/data.rocket
Normal file
294
nordlicht2015-intro/data.rocket
Normal file
@@ -0,0 +1,294 @@
|
||||
<sync rows="276">
|
||||
<tracks>
|
||||
<track name="cameraPosition_x">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="64" interpolation="2" value="0"/>
|
||||
<key row="80" interpolation="2" value="5"/>
|
||||
<key row="95" interpolation="0" value="0"/>
|
||||
<key row="96" interpolation="2" value="-0.5"/>
|
||||
<key row="104" interpolation="2" value="0.4"/>
|
||||
<key row="120" interpolation="2" value="-0.2"/>
|
||||
<key row="127" interpolation="0" value="0"/>
|
||||
<key row="128" interpolation="0" value="0"/>
|
||||
<key row="144" interpolation="2" value="0"/>
|
||||
<key row="159" interpolation="0" value="-3"/>
|
||||
<key row="160" interpolation="2" value="3"/>
|
||||
<key row="176" interpolation="0" value="-2"/>
|
||||
<key row="191" interpolation="0" value="-2"/>
|
||||
<key row="192" interpolation="2" value="3"/>
|
||||
<key row="200" interpolation="2" value="-1"/>
|
||||
<key row="216" interpolation="2" value="-1"/>
|
||||
<key row="224" interpolation="0" value="-2"/>
|
||||
<key row="232" interpolation="2" value="-2"/>
|
||||
<key row="248" interpolation="2" value="5"/>
|
||||
<key row="256" interpolation="2" value="8"/>
|
||||
</track>
|
||||
<track name="cameraPosition_y">
|
||||
<key row="0" interpolation="0" value="2"/>
|
||||
<key row="24" interpolation="2" value="2"/>
|
||||
<key row="32" interpolation="0" value="10"/>
|
||||
<key row="64" interpolation="0" value="1.5"/>
|
||||
<key row="96" interpolation="2" value="1"/>
|
||||
<key row="112" interpolation="2" value="0"/>
|
||||
<key row="127" interpolation="0" value="0"/>
|
||||
<key row="128" interpolation="3" value="0"/>
|
||||
<key row="160" interpolation="2" value="5"/>
|
||||
<key row="168" interpolation="2" value="0.5"/>
|
||||
<key row="191" interpolation="0" value="1"/>
|
||||
<key row="192" interpolation="0" value="1"/>
|
||||
<key row="212" interpolation="2" value="1"/>
|
||||
<key row="216" interpolation="2" value="2"/>
|
||||
<key row="224" interpolation="2" value="3"/>
|
||||
<key row="232" interpolation="0" value="1"/>
|
||||
<key row="248" interpolation="2" value="1"/>
|
||||
<key row="256" interpolation="0" value="2"/>
|
||||
</track>
|
||||
<track name="cameraPosition_z">
|
||||
<key row="0" interpolation="0" value="5"/>
|
||||
<key row="32" interpolation="2" value="5"/>
|
||||
<key row="56" interpolation="0" value="50"/>
|
||||
<key row="64" interpolation="2" value="5"/>
|
||||
<key row="80" interpolation="2" value="0"/>
|
||||
<key row="95" interpolation="0" value="-5"/>
|
||||
<key row="96" interpolation="1" value="8"/>
|
||||
<key row="127" interpolation="0" value="-3"/>
|
||||
<key row="128" interpolation="3" value="0"/>
|
||||
<key row="159" interpolation="0" value="-10"/>
|
||||
<key row="160" interpolation="0" value="5"/>
|
||||
<key row="168" interpolation="2" value="5"/>
|
||||
<key row="191" interpolation="0" value="-5.5"/>
|
||||
<key row="192" interpolation="2" value="-4"/>
|
||||
<key row="208" interpolation="2" value="-5"/>
|
||||
<key row="232" interpolation="2" value="-12"/>
|
||||
<key row="240" interpolation="2" value="-11.5"/>
|
||||
<key row="256" interpolation="2" value="-14"/>
|
||||
<key row="271" interpolation="0" value="-13"/>
|
||||
</track>
|
||||
<track name="cameraCenter_x">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="96" interpolation="0" value="0"/>
|
||||
<key row="128" interpolation="0" value="0"/>
|
||||
<key row="160" interpolation="0" value="0"/>
|
||||
<key row="192" interpolation="2" value="-3"/>
|
||||
<key row="204" interpolation="2" value="3"/>
|
||||
<key row="212" interpolation="0" value="-3"/>
|
||||
<key row="216" interpolation="2" value="-3"/>
|
||||
<key row="224" interpolation="2" value="3"/>
|
||||
<key row="232" interpolation="2" value="9"/>
|
||||
<key row="248" interpolation="2" value="0"/>
|
||||
<key row="256" interpolation="2" value="-5"/>
|
||||
<key row="271" interpolation="0" value="10"/>
|
||||
</track>
|
||||
<track name="cameraCenter_y">
|
||||
<key row="0" interpolation="0" value="-1"/>
|
||||
<key row="64" interpolation="0" value="-5"/>
|
||||
<key row="96" interpolation="0" value="1"/>
|
||||
<key row="112" interpolation="2" value="1"/>
|
||||
<key row="127" interpolation="0" value="0"/>
|
||||
<key row="128" interpolation="1" value="5"/>
|
||||
<key row="159" interpolation="0" value="3"/>
|
||||
<key row="160" interpolation="1" value="0"/>
|
||||
<key row="168" interpolation="2" value="0.5"/>
|
||||
<key row="191" interpolation="0" value="0"/>
|
||||
<key row="192" interpolation="0" value="0.5"/>
|
||||
<key row="212" interpolation="2" value="0.5"/>
|
||||
<key row="216" interpolation="2" value="1.5"/>
|
||||
<key row="224" interpolation="0" value="0.5"/>
|
||||
<key row="240" interpolation="2" value="0.5"/>
|
||||
<key row="248" interpolation="2" value="6"/>
|
||||
<key row="271" interpolation="0" value="0"/>
|
||||
</track>
|
||||
<track name="cameraCenter_z">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="32" interpolation="2" value="0"/>
|
||||
<key row="56" interpolation="0" value="40"/>
|
||||
<key row="64" interpolation="0" value="0"/>
|
||||
<key row="96" interpolation="1" value="0"/>
|
||||
<key row="127" interpolation="0" value="-10"/>
|
||||
<key row="128" interpolation="0" value="0"/>
|
||||
<key row="160" interpolation="2" value="0"/>
|
||||
<key row="168" interpolation="0" value="-4"/>
|
||||
<key row="192" interpolation="0" value="0"/>
|
||||
<key row="208" interpolation="2" value="0"/>
|
||||
<key row="216" interpolation="2" value="-5"/>
|
||||
<key row="232" interpolation="2" value="-10"/>
|
||||
<key row="244" interpolation="2" value="10"/>
|
||||
<key row="252" interpolation="2" value="-5"/>
|
||||
<key row="271" interpolation="0" value="-20"/>
|
||||
</track>
|
||||
<track name="cameraUp_x">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="96" interpolation="2" value="0.1"/>
|
||||
<key row="112" interpolation="2" value="-0.1"/>
|
||||
<key row="120" interpolation="0" value="0"/>
|
||||
<key row="128" interpolation="0" value="0"/>
|
||||
<key row="160" interpolation="0" value="0"/>
|
||||
<key row="192" interpolation="0" value="0"/>
|
||||
</track>
|
||||
<track name="cameraUp_y">
|
||||
<key row="0" interpolation="0" value="1"/>
|
||||
<key row="96" interpolation="0" value="1"/>
|
||||
<key row="128" interpolation="1" value="0"/>
|
||||
<key row="160" interpolation="0" value="1"/>
|
||||
<key row="192" interpolation="0" value="1"/>
|
||||
</track>
|
||||
<track name="cameraUp_z">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="96" interpolation="0" value="0"/>
|
||||
<key row="128" interpolation="1" value="-1"/>
|
||||
<key row="160" interpolation="0" value="0"/>
|
||||
<key row="192" interpolation="0" value="0"/>
|
||||
</track>
|
||||
<track name="lightDir_x">
|
||||
<key row="96" interpolation="0" value="-0.5"/>
|
||||
<key row="192" interpolation="0" value="0.5"/>
|
||||
</track>
|
||||
<track name="lightDir_y">
|
||||
<key row="96" interpolation="0" value="0.5"/>
|
||||
<key row="192" interpolation="0" value="1"/>
|
||||
</track>
|
||||
<track name="lightDir_z">
|
||||
<key row="96" interpolation="0" value="1"/>
|
||||
<key row="192" interpolation="0" value="-1"/>
|
||||
</track>
|
||||
<track name="fade">
|
||||
<key row="0" interpolation="1" value="0"/>
|
||||
<key row="8" interpolation="0" value="0.5"/>
|
||||
<key row="62" interpolation="1" value="0.5"/>
|
||||
<key row="63" interpolation="1" value="0"/>
|
||||
<key row="64" interpolation="1" value="0"/>
|
||||
<key row="65" interpolation="1" value="0.5"/>
|
||||
<key row="88" interpolation="1" value="0.5"/>
|
||||
<key row="96" interpolation="1" value="0"/>
|
||||
<key row="104" interpolation="0" value="0.5"/>
|
||||
<key row="125" interpolation="1" value="0.5"/>
|
||||
<key row="127" interpolation="0" value="1"/>
|
||||
<key row="128" interpolation="1" value="1"/>
|
||||
<key row="136" interpolation="0" value="0.5"/>
|
||||
<key row="158" interpolation="1" value="0.5"/>
|
||||
<key row="159" interpolation="0" value="0"/>
|
||||
<key row="160" interpolation="1" value="0"/>
|
||||
<key row="161" interpolation="0" value="0.5"/>
|
||||
<key row="190" interpolation="1" value="0.5"/>
|
||||
<key row="191" interpolation="0" value="1"/>
|
||||
<key row="192" interpolation="1" value="1"/>
|
||||
<key row="194" interpolation="0" value="0.5"/>
|
||||
<key row="272" interpolation="1" value="0.5"/>
|
||||
<key row="275" interpolation="0" value="0"/>
|
||||
</track>
|
||||
<track name="fontFade">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="8" interpolation="1" value="0"/>
|
||||
<key row="47" interpolation="0" value="2"/>
|
||||
<key row="96" interpolation="0" value="0"/>
|
||||
</track>
|
||||
<track name="scene">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="96" interpolation="0" value="1"/>
|
||||
<key row="128" interpolation="0" value="2"/>
|
||||
<key row="160" interpolation="0" value="3"/>
|
||||
<key row="192" interpolation="0" value="4"/>
|
||||
</track>
|
||||
<track name="fogAmount">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="96" interpolation="0" value="1"/>
|
||||
<key row="128" interpolation="0" value="1"/>
|
||||
</track>
|
||||
<track name="gridBorderColor_x">
|
||||
<key row="0" interpolation="3" value="0"/>
|
||||
<key row="32" interpolation="0" value="2"/>
|
||||
<key row="63" interpolation="1" value="2"/>
|
||||
<key row="64" interpolation="0" value="0.1"/>
|
||||
</track>
|
||||
<track name="gridBorderColor_y">
|
||||
<key row="0" interpolation="3" value="0.1"/>
|
||||
<key row="32" interpolation="0" value="0.6"/>
|
||||
<key row="63" interpolation="1" value="0.6"/>
|
||||
<key row="64" interpolation="0" value="0.1"/>
|
||||
</track>
|
||||
<track name="gridBorderColor_z">
|
||||
<key row="0" interpolation="3" value="1"/>
|
||||
<key row="32" interpolation="0" value="0"/>
|
||||
<key row="63" interpolation="1" value="0"/>
|
||||
<key row="64" interpolation="0" value="0.1"/>
|
||||
</track>
|
||||
<track name="gridFaceColor_x">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="63" interpolation="1" value="0"/>
|
||||
<key row="64" interpolation="0" value="0.22"/>
|
||||
</track>
|
||||
<track name="gridFaceColor_y">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="63" interpolation="1" value="0"/>
|
||||
<key row="64" interpolation="0" value="0.21"/>
|
||||
</track>
|
||||
<track name="gridFaceColor_z">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="63" interpolation="1" value="0"/>
|
||||
<key row="64" interpolation="0" value="0.2"/>
|
||||
</track>
|
||||
<track name="gridLineTime">
|
||||
<key row="0" interpolation="1" value="0"/>
|
||||
<key row="63" interpolation="0" value="4"/>
|
||||
<key row="64" interpolation="1" value="0"/>
|
||||
<key row="96" interpolation="0" value="2"/>
|
||||
</track>
|
||||
<track name="glowParams_x">
|
||||
<key row="0" interpolation="0" value="0.1"/>
|
||||
<key row="29" interpolation="3" value="0.1"/>
|
||||
<key row="32" interpolation="0" value="0.2"/>
|
||||
<key row="64" interpolation="1" value="0.2"/>
|
||||
<key row="96" interpolation="0" value="0.5"/>
|
||||
<key row="192" interpolation="0" value="0.4"/>
|
||||
</track>
|
||||
<track name="glowParams_y">
|
||||
<key row="0" interpolation="0" value="0.6"/>
|
||||
<key row="64" interpolation="1" value="0.6"/>
|
||||
<key row="96" interpolation="0" value="0.4"/>
|
||||
<key row="192" interpolation="0" value="0.1"/>
|
||||
</track>
|
||||
<track name="glowParams_z">
|
||||
<key row="0" interpolation="0" value="0.6"/>
|
||||
<key row="29" interpolation="3" value="0.6"/>
|
||||
<key row="32" interpolation="0" value="1"/>
|
||||
<key row="64" interpolation="1" value="0.5"/>
|
||||
<key row="96" interpolation="0" value="0.2"/>
|
||||
<key row="192" interpolation="0" value="0.1"/>
|
||||
</track>
|
||||
<track name="glowParams_w">
|
||||
<key row="0" interpolation="0" value="0.6"/>
|
||||
<key row="29" interpolation="3" value="0.6"/>
|
||||
<key row="32" interpolation="2" value="4"/>
|
||||
<key row="40" interpolation="0" value="2"/>
|
||||
<key row="64" interpolation="1" value="2"/>
|
||||
<key row="96" interpolation="0" value="0.2"/>
|
||||
<key row="192" interpolation="0" value="0.5"/>
|
||||
</track>
|
||||
<track name="contrast">
|
||||
<key row="0" interpolation="0" value="1"/>
|
||||
<key row="96" interpolation="0" value="2"/>
|
||||
<key row="128" interpolation="0" value="1"/>
|
||||
<key row="160" interpolation="0" value="1"/>
|
||||
<key row="192" interpolation="0" value="1.5"/>
|
||||
</track>
|
||||
<track name="_padding"/>
|
||||
<track name="_padding_z"/>
|
||||
<track name="cameraPosition_w">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="96" interpolation="0" value="0"/>
|
||||
</track>
|
||||
<track name="cameraCenter_w">
|
||||
<key row="0" interpolation="0" value="0"/>
|
||||
<key row="96" interpolation="0" value="0"/>
|
||||
</track>
|
||||
<track name="_padding_y"/>
|
||||
<track name="_padding_x"/>
|
||||
<track name="lightDir_w"/>
|
||||
<track name="cameraUp_w">
|
||||
<key row="96" interpolation="0" value="0"/>
|
||||
</track>
|
||||
<track name="gridBorderColor_w"/>
|
||||
<track name="gridFaceColor_w"/>
|
||||
</tracks>
|
||||
<bookmarks/>
|
||||
</sync>
|
||||
BIN
nordlicht2015-intro/lib/mesh_Debug.lib
Normal file
BIN
nordlicht2015-intro/lib/mesh_Debug.lib
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/lib/mesh_Release.lib
Normal file
BIN
nordlicht2015-intro/lib/mesh_Release.lib
Normal file
Binary file not shown.
129
nordlicht2015-intro/nordlicht2015-intro.sln
Normal file
129
nordlicht2015-intro/nordlicht2015-intro.sln
Normal file
@@ -0,0 +1,129 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "intro", "src\intro\intro.vcxproj", "{EC001821-5569-4BB5-87B3-20CB8FF9137B}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF} = {6D00EB12-7129-482A-8011-F187F20345DF}
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327} = {E8F53E16-D2D5-4D17-A0BB-35C202253327}
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931} = {930621BA-75BE-49FE-80DE-E75E7DC06931}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tool", "src\tool\tool.csproj", "{6D00EB12-7129-482A-8011-F187F20345DF}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931} = {930621BA-75BE-49FE-80DE-E75E7DC06931}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "shc", "src\shc\shc.csproj", "{930621BA-75BE-49FE-80DE-E75E7DC06931}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mesh", "src\mesh\mesh.vcxproj", "{E8F53E16-D2D5-4D17-A0BB-35C202253327}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Authoring|Mixed Platforms = Authoring|Mixed Platforms
|
||||
Authoring|Win32 = Authoring|Win32
|
||||
Compress|Mixed Platforms = Compress|Mixed Platforms
|
||||
Compress|Win32 = Compress|Win32
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Mixed Platforms = Release|Mixed Platforms
|
||||
Release|Win32 = Release|Win32
|
||||
ShaderDebug|Mixed Platforms = ShaderDebug|Mixed Platforms
|
||||
ShaderDebug|Win32 = ShaderDebug|Win32
|
||||
Video|Mixed Platforms = Video|Mixed Platforms
|
||||
Video|Win32 = Video|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Authoring|Mixed Platforms.ActiveCfg = Authoring|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Authoring|Mixed Platforms.Build.0 = Authoring|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Authoring|Win32.ActiveCfg = Authoring|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Authoring|Win32.Build.0 = Authoring|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Compress|Mixed Platforms.ActiveCfg = Compress|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Compress|Mixed Platforms.Build.0 = Compress|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Compress|Win32.ActiveCfg = Compress|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Compress|Win32.Build.0 = Compress|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Debug|Mixed Platforms.ActiveCfg = ShaderDebug|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Debug|Mixed Platforms.Build.0 = ShaderDebug|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Debug|Win32.ActiveCfg = ShaderDebug|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Debug|Win32.Build.0 = ShaderDebug|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Release|Win32.Build.0 = Release|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.ShaderDebug|Mixed Platforms.ActiveCfg = ShaderDebug|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.ShaderDebug|Mixed Platforms.Build.0 = ShaderDebug|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.ShaderDebug|Win32.ActiveCfg = ShaderDebug|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.ShaderDebug|Win32.Build.0 = ShaderDebug|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Video|Mixed Platforms.ActiveCfg = Video|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Video|Mixed Platforms.Build.0 = Video|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Video|Win32.ActiveCfg = Video|Win32
|
||||
{EC001821-5569-4BB5-87B3-20CB8FF9137B}.Video|Win32.Build.0 = Video|Win32
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Authoring|Mixed Platforms.ActiveCfg = Authoring|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Authoring|Mixed Platforms.Build.0 = Authoring|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Authoring|Win32.ActiveCfg = Authoring|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Compress|Mixed Platforms.ActiveCfg = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Compress|Mixed Platforms.Build.0 = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Compress|Win32.ActiveCfg = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Debug|Mixed Platforms.ActiveCfg = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Debug|Mixed Platforms.Build.0 = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Debug|Win32.ActiveCfg = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Release|Mixed Platforms.ActiveCfg = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Release|Mixed Platforms.Build.0 = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Release|Win32.ActiveCfg = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.ShaderDebug|Mixed Platforms.ActiveCfg = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.ShaderDebug|Mixed Platforms.Build.0 = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.ShaderDebug|Win32.ActiveCfg = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Video|Mixed Platforms.ActiveCfg = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Video|Mixed Platforms.Build.0 = Void|Any CPU
|
||||
{6D00EB12-7129-482A-8011-F187F20345DF}.Video|Win32.ActiveCfg = Void|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Authoring|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Authoring|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Authoring|Win32.ActiveCfg = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Compress|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Compress|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Compress|Win32.ActiveCfg = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Debug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Release|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Release|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Release|Win32.ActiveCfg = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.ShaderDebug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.ShaderDebug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.ShaderDebug|Win32.ActiveCfg = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Video|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Video|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{930621BA-75BE-49FE-80DE-E75E7DC06931}.Video|Win32.ActiveCfg = Debug|Any CPU
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Authoring|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Authoring|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Authoring|Win32.ActiveCfg = Release|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Authoring|Win32.Build.0 = Release|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Compress|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Compress|Mixed Platforms.Build.0 = Release|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Compress|Win32.ActiveCfg = Release|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Compress|Win32.Build.0 = Release|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Debug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Release|Mixed Platforms.ActiveCfg = Release|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Release|Mixed Platforms.Build.0 = Release|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Release|Win32.Build.0 = Release|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.ShaderDebug|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.ShaderDebug|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.ShaderDebug|Win32.ActiveCfg = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.ShaderDebug|Win32.Build.0 = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Video|Mixed Platforms.ActiveCfg = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Video|Mixed Platforms.Build.0 = Debug|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Video|Win32.ActiveCfg = Release|Win32
|
||||
{E8F53E16-D2D5-4D17-A0BB-35C202253327}.Video|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
nordlicht2015-intro/packages/AvalonEdit.5.0.2/AvalonEdit.5.0.2.nupkg
vendored
Normal file
BIN
nordlicht2015-intro/packages/AvalonEdit.5.0.2/AvalonEdit.5.0.2.nupkg
vendored
Normal file
Binary file not shown.
33
nordlicht2015-intro/packages/AvalonEdit.5.0.2/AvalonEdit.5.0.2.nuspec
vendored
Normal file
33
nordlicht2015-intro/packages/AvalonEdit.5.0.2/AvalonEdit.5.0.2.nuspec
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>AvalonEdit</id>
|
||||
<version>5.0.2</version>
|
||||
<authors>Daniel Grunwald</authors>
|
||||
<owners>Daniel Grunwald</owners>
|
||||
<licenseUrl>http://opensource.org/licenses/MIT</licenseUrl>
|
||||
<projectUrl>http://www.avalonedit.net/</projectUrl>
|
||||
<iconUrl>http://community.sharpdevelop.net/blogs/mattward/SharpDevelop.png</iconUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>AvalonEdit is the WPF-based text editor used in SharpDevelop. There are two builds of AvalonEdit included in this package. One that targets .NET 4.0 and one that targets .NET 3.5.</description>
|
||||
<summary>AvalonEdit is the WPF-based text editor used in SharpDevelop</summary>
|
||||
<releaseNotes>* License changed from LGPL to MIT
|
||||
* New Feature: Hide mouse cursor while typing (enabled by default)
|
||||
* New Feature: Highlight current line (disabled by default)
|
||||
* New Feature: Overstrike mode (disabled by default)
|
||||
* New Feature: 'underline' attribute in syntax highlighting definitions
|
||||
* AvalonEdit now raises the WPF DataObject attached events on clipboard and drag'n'drop operations.
|
||||
* Encoding detection now distinguishes between UTF-8 with BOM and UTF-8 without BOM. This prevents AvalonEdit from adding the BOM to existing UTF-8 files.
|
||||
* Improved handling of grapheme clusters. A base character followed by a combining mark is now treated as a single character by the caret movement logic.
|
||||
* Added RichText, RichTextModel and RichTextColorizer.
|
||||
* Renamed the VB highlighting mode from "VBNET" to "VB"
|
||||
* Changed IHighlighter API in order to support SharpDevelop's semantic C# highlighter
|
||||
* The regex-based highlighting engine was moved into its own class (HighlightingEngine) to be separated from the state-tracking logic in DocumentHighlighter.
|
||||
* Add FileName property to TextDocument class.
|
||||
* DocumentChangeEventArgs.RemovedText/InsertedText are now of type ITextSource instead of string.
|
||||
* The error-tolerant XML parser included with AvalonEdit was removed. An improved version of this parser is part of the NRefactory 5 project.
|
||||
* Removed some obsolete APIs.</releaseNotes>
|
||||
<language>en-US</language>
|
||||
<tags>WPF Text Editor SharpDevelop AvalonEdit</tags>
|
||||
</metadata>
|
||||
</package>
|
||||
BIN
nordlicht2015-intro/packages/AvalonEdit.5.0.2/lib/Net35/ICSharpCode.AvalonEdit.dll
vendored
Normal file
BIN
nordlicht2015-intro/packages/AvalonEdit.5.0.2/lib/Net35/ICSharpCode.AvalonEdit.dll
vendored
Normal file
Binary file not shown.
9939
nordlicht2015-intro/packages/AvalonEdit.5.0.2/lib/Net35/ICSharpCode.AvalonEdit.xml
vendored
Normal file
9939
nordlicht2015-intro/packages/AvalonEdit.5.0.2/lib/Net35/ICSharpCode.AvalonEdit.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
nordlicht2015-intro/packages/AvalonEdit.5.0.2/lib/Net40/ICSharpCode.AvalonEdit.dll
vendored
Normal file
BIN
nordlicht2015-intro/packages/AvalonEdit.5.0.2/lib/Net40/ICSharpCode.AvalonEdit.dll
vendored
Normal file
Binary file not shown.
9939
nordlicht2015-intro/packages/AvalonEdit.5.0.2/lib/Net40/ICSharpCode.AvalonEdit.xml
vendored
Normal file
9939
nordlicht2015-intro/packages/AvalonEdit.5.0.2/lib/Net40/ICSharpCode.AvalonEdit.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
nordlicht2015-intro/packages/repositories.config
Normal file
4
nordlicht2015-intro/packages/repositories.config
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<repositories>
|
||||
<repository path="..\src\tool\packages.config" />
|
||||
</repositories>
|
||||
58
nordlicht2015-intro/readme.txt
Normal file
58
nordlicht2015-intro/readme.txt
Normal file
@@ -0,0 +1,58 @@
|
||||
Alcatraz 8kode
|
||||
=========
|
||||
|
||||
A framework for developing 8k intros.
|
||||
|
||||
Initial setup:
|
||||
1) Start Visual Studio 2013 and open 8kode.sln
|
||||
2) Right click your solution and choose "Set StartUp Projects..."
|
||||
3) Under Common Properties -> Startup Project, choose "Multiple startup projects"
|
||||
4) Set both "intro" and "tool" to Start.
|
||||
5) Click "OK"
|
||||
6) Set your build configuration to "Authoring"
|
||||
7) Hit F5 and enjoy.
|
||||
|
||||
Interface:
|
||||
8kode's interface is very similar to Blender 2.5.
|
||||
If you're unfamiliar with it, please have a look at http://vimeo.com/19628478 starting from 1:59
|
||||
You can set up multiple views of the same data, and you can split, resize and merge views as you need.
|
||||
Layouts can be saved and loaded using the Layouts menu.
|
||||
|
||||
Intro navigation:
|
||||
You can move through time by clicking and dragging in the Audio view.
|
||||
The seek positions snap to intro "scenes".
|
||||
A scene is defined by SOUND_TICKS_PER_SCENE * SAMPLES_PER_TICK samples.
|
||||
The preconfigured SOUND_TICKS_PER_SCENE is 64 ticks and SAMPLES_PER_TICK is provided by 4klang.h
|
||||
|
||||
File and folder structure:
|
||||
The intro coder musn't take care of the src\intro\framework folder.
|
||||
Shaders are inside src\intro\shaders, intro code is inside src\intro\intro.
|
||||
Put your intro init code in src\intro\intro\init.h and your per-frame code in src\intro\intro\update.h.
|
||||
Variables and such can be put in src\intro\intro\data.h
|
||||
|
||||
Shader compiler tool (shc):
|
||||
8kode comes with a shader preprocessor. It has 2 main purposes:
|
||||
1) Resolve all #includes, so that Ctrl+Alt+Test's shader minifier can minify everything together
|
||||
2) Automatically generate C++ code with ready-to-use DirectX shader pointers
|
||||
In order to have autogenerated shader pointers, you can use an [EntryPoint(foo)] attribute on your HLSL function.
|
||||
This will signal shc that this function is an entry point, and it will create a corresponding IID3D11FooShader* pointer.
|
||||
Obviously you should replace foo with the correct shader profile name (e.g. vs, ps, cs).
|
||||
Example:
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
[entrypoint(cs)]
|
||||
void colorPattern(uint3 id:SV_DispatchThreadID)
|
||||
{
|
||||
float2 resolution;
|
||||
out0.GetDimensions(resolution.x, resolution.y);
|
||||
out0[id.xy] = float4(id.xy / resolution, 0.5, 1.0);
|
||||
}
|
||||
|
||||
When compiling with shc, it will generate corresponding code and provide a ID3D11ComputeShader* cs_colorPattern pointer.
|
||||
The coder can use that pointer immediately in the intro code.
|
||||
8kode's authoring tool allows instant shader compilation with the shortcut Ctrl+Enter. It invokes shc, which in turn:
|
||||
1) generates intro\framework\shaders_shc.h, containing all entry point shader pointers and compile code for the intro
|
||||
2) runs Ctrl+Alt+Test's shader minifier and outputs the minified shader to intro\framework\intro_hlsl.h
|
||||
3) recompiles every entry point that was present at the last intro compile time. If entry points changed, a tool restart is required.
|
||||
All shader compilation errors are marked in the code view as line decorations. Hovering over marked lines will display a tooltip
|
||||
with the errors in that line.
|
||||
13
nordlicht2015-intro/src/intro/crinkler.html
Normal file
13
nordlicht2015-intro/src/intro/crinkler.html
Normal file
File diff suppressed because one or more lines are too long
7
nordlicht2015-intro/src/intro/export.mtl
Normal file
7
nordlicht2015-intro/src/intro/export.mtl
Normal file
@@ -0,0 +1,7 @@
|
||||
newmtl -1
|
||||
Ka 0.0 0.0 0.0
|
||||
Kd 1.0 1.0 1.0
|
||||
Ks 1.0 1.0 1.0
|
||||
Ns 16.0
|
||||
illum 0
|
||||
map_Kd -1.png
|
||||
51756
nordlicht2015-intro/src/intro/export.obj
Normal file
51756
nordlicht2015-intro/src/intro/export.obj
Normal file
File diff suppressed because it is too large
Load Diff
1612
nordlicht2015-intro/src/intro/framework/4klang.asm
Normal file
1612
nordlicht2015-intro/src/intro/framework/4klang.asm
Normal file
File diff suppressed because it is too large
Load Diff
22
nordlicht2015-intro/src/intro/framework/4klang.h
Normal file
22
nordlicht2015-intro/src/intro/framework/4klang.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// some useful song defines for 4klang
|
||||
#define SAMPLE_RATE 44100
|
||||
#define BPM 110.000000
|
||||
#define MAX_INSTRUMENTS 10
|
||||
#define MAX_PATTERNS 69
|
||||
#define PATTERN_SIZE_SHIFT 4
|
||||
#define PATTERN_SIZE (1 << PATTERN_SIZE_SHIFT)
|
||||
#define MAX_TICKS (MAX_PATTERNS*PATTERN_SIZE)
|
||||
#define SAMPLES_PER_TICK 6013
|
||||
#define MAX_SAMPLES (SAMPLES_PER_TICK*MAX_TICKS)
|
||||
#define POLYPHONY 2
|
||||
#define FLOAT_32BIT
|
||||
#define SAMPLE_TYPE float
|
||||
|
||||
#define WINDOWS_OBJECT
|
||||
|
||||
// declaration of the external synth render function, you'll always need that
|
||||
extern "C" void __stdcall _4klang_render(void*);
|
||||
// declaration of the external envelope buffer. access only if you're song was exported with that option
|
||||
extern "C" float _4klang_envelope_buffer;
|
||||
// declaration of the external note buffer. access only if you're song was exported with that option
|
||||
extern "C" int _4klang_note_buffer;
|
||||
1000
nordlicht2015-intro/src/intro/framework/4klang.inc
Normal file
1000
nordlicht2015-intro/src/intro/framework/4klang.inc
Normal file
File diff suppressed because it is too large
Load Diff
BIN
nordlicht2015-intro/src/intro/framework/8klang.merge
Normal file
BIN
nordlicht2015-intro/src/intro/framework/8klang.merge
Normal file
Binary file not shown.
563
nordlicht2015-intro/src/intro/framework/authoring.h
Normal file
563
nordlicht2015-intro/src/intro/framework/authoring.h
Normal file
@@ -0,0 +1,563 @@
|
||||
#pragma once
|
||||
|
||||
#include <Shlwapi.h>
|
||||
#include "mutexlock.h"
|
||||
|
||||
struct SharedMemoryToolType
|
||||
{
|
||||
int WindowLeft;
|
||||
int WindowTop;
|
||||
int WindowWidth;
|
||||
int WindowHeight;
|
||||
int MaxSamples;
|
||||
int SampleSize;
|
||||
int SamplesPerTick;
|
||||
int TicksPerScene;
|
||||
float IntroPosition;
|
||||
int AudioRenderPosition;
|
||||
int SeekToScene;
|
||||
bool KeepAlive;
|
||||
HWND introHandle;
|
||||
HWND analysisHandle;
|
||||
bool UseMinifiedShader;
|
||||
};
|
||||
|
||||
static D3D11_TEXTURE1D_DESC histogramTextureDesc =
|
||||
{
|
||||
256,
|
||||
1,
|
||||
1,
|
||||
DXGI_FORMAT_R32G32B32A32_FLOAT,
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_UNORDERED_ACCESS,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
static D3D11_TEXTURE1D_DESC histogramStagingTextureDesc =
|
||||
{
|
||||
256,
|
||||
1,
|
||||
1,
|
||||
DXGI_FORMAT_R32G32B32A32_FLOAT,
|
||||
D3D11_USAGE_STAGING,
|
||||
0,
|
||||
D3D11_CPU_ACCESS_READ,
|
||||
0
|
||||
};
|
||||
|
||||
static D3D11_TEXTURE1D_DESC histogramBucketTextureDesc =
|
||||
{
|
||||
257,
|
||||
1,
|
||||
1,
|
||||
DXGI_FORMAT_R32_UINT,
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_UNORDERED_ACCESS,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
static D3D11_TEXTURE2D_DESC paradeVectorScopeBucketTextureDesc =
|
||||
{
|
||||
257,
|
||||
256,
|
||||
1,
|
||||
1,
|
||||
DXGI_FORMAT_R32_UINT,
|
||||
{ 1, 0 },
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_UNORDERED_ACCESS,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
static D3D11_TEXTURE2D_DESC paradeTextureDesc =
|
||||
{
|
||||
256,
|
||||
256,
|
||||
1,
|
||||
1,
|
||||
DXGI_FORMAT_R8G8B8A8_UINT,
|
||||
{ 1, 0 },
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_UNORDERED_ACCESS,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
static D3D11_TEXTURE2D_DESC paradeStagingTextureDesc =
|
||||
{
|
||||
256,
|
||||
256,
|
||||
1,
|
||||
1,
|
||||
DXGI_FORMAT_R8G8B8A8_UINT,
|
||||
{ 1, 0 },
|
||||
D3D11_USAGE_STAGING,
|
||||
0,
|
||||
D3D11_CPU_ACCESS_READ,
|
||||
0
|
||||
};
|
||||
|
||||
static D3D11_TEXTURE2D_DESC vectorScopeTextureDesc =
|
||||
{
|
||||
256,
|
||||
256,
|
||||
1,
|
||||
1,
|
||||
DXGI_FORMAT_R8G8B8A8_UINT,
|
||||
{ 1, 0 },
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_UNORDERED_ACCESS,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
static D3D11_TEXTURE2D_DESC vectorScopeStagingTextureDesc =
|
||||
{
|
||||
256,
|
||||
256,
|
||||
1,
|
||||
1,
|
||||
DXGI_FORMAT_R8G8B8A8_UINT,
|
||||
{ 1, 0 },
|
||||
D3D11_USAGE_STAGING,
|
||||
0,
|
||||
D3D11_CPU_ACCESS_READ,
|
||||
0
|
||||
};
|
||||
|
||||
static D3D11_UNORDERED_ACCESS_VIEW_DESC histogramUAVdesc =
|
||||
{
|
||||
DXGI_FORMAT_R32G32B32A32_FLOAT,
|
||||
D3D11_UAV_DIMENSION_TEXTURE1D,
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static D3D11_UNORDERED_ACCESS_VIEW_DESC histogramBucketUAVdesc =
|
||||
{
|
||||
DXGI_FORMAT_R32_UINT,
|
||||
D3D11_UAV_DIMENSION_TEXTURE1D,
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static D3D11_UNORDERED_ACCESS_VIEW_DESC paradeUAVdesc =
|
||||
{
|
||||
DXGI_FORMAT_R8G8B8A8_UINT,
|
||||
D3D11_UAV_DIMENSION_TEXTURE2D,
|
||||
{ 0, 1 }
|
||||
};
|
||||
|
||||
static D3D11_UNORDERED_ACCESS_VIEW_DESC paradeVectorScopeBucketUAVdesc =
|
||||
{
|
||||
DXGI_FORMAT_R32_UINT,
|
||||
D3D11_UAV_DIMENSION_TEXTURE2D,
|
||||
{ 0, 1 }
|
||||
};
|
||||
|
||||
static D3D11_UNORDERED_ACCESS_VIEW_DESC vectorScopeUAVdesc =
|
||||
{
|
||||
DXGI_FORMAT_R8G8B8A8_UINT,
|
||||
D3D11_UAV_DIMENSION_TEXTURE2D,
|
||||
{ 0, 1 }
|
||||
};
|
||||
|
||||
static D3D11_SHADER_RESOURCE_VIEW_DESC analysisSRVdesc =
|
||||
{
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
D3D11_SRV_DIMENSION_TEXTURE2D,
|
||||
{ 0, 1 }
|
||||
};
|
||||
|
||||
static SharedMemoryToolType* SharedMemoryTool;
|
||||
static char* SharedImage;
|
||||
static HANDLE AudioFileMapping;
|
||||
static HANDLE ImageFileMapping;
|
||||
static HANDLE HistogramFileMapping;
|
||||
static HANDLE ParadeFileMapping;
|
||||
static HANDLE VectorscopeFileMapping;
|
||||
static HANDLE SharedMemoryFileMapping;
|
||||
static bool playMusic;
|
||||
static long musicStartOffset;
|
||||
static HANDLE SharedMemoryMutex;
|
||||
static D3D11_TEXTURE2D_DESC analysisDesc;
|
||||
static ID3D11Texture2D* resolvedTexture;
|
||||
static ID3D11Texture2D* stagingTexture;
|
||||
static ID3D11Texture1D* histogramTexture;
|
||||
static ID3D11Texture1D* histogramRedBucketTexture;
|
||||
static ID3D11Texture1D* histogramGreenBucketTexture;
|
||||
static ID3D11Texture1D* histogramBlueBucketTexture;
|
||||
static ID3D11Texture1D* histogramStagingTexture;
|
||||
static ID3D11Texture2D* paradeRedBucketTexture;
|
||||
static ID3D11Texture2D* paradeGreenBucketTexture;
|
||||
static ID3D11Texture2D* paradeBlueBucketTexture;
|
||||
static ID3D11Texture2D* paradeAlphaBucketTexture;
|
||||
static ID3D11Texture2D* paradeTexture;
|
||||
static ID3D11Texture2D* paradeStagingTexture;
|
||||
static ID3D11Texture2D* vectorScopeBucketTexture;
|
||||
static ID3D11Texture2D* vectorScopeTexture;
|
||||
static ID3D11Texture2D* vectorScopeStagingTexture;
|
||||
static ID3D11ComputeShader* csHistogramGather;
|
||||
static ID3D11ComputeShader* csHistogramMaximum;
|
||||
static ID3D11ComputeShader* csHistogramSpread;
|
||||
static ID3D11ComputeShader* csParadeVectorscopeGather;
|
||||
static ID3D11ComputeShader* csParadeVectorscopeMaximum;
|
||||
static ID3D11ComputeShader* csParadeVectorscopeSpread;
|
||||
static ID3D11UnorderedAccessView* histogramUAV;
|
||||
static ID3D11UnorderedAccessView* histogramRedBucketUAV;
|
||||
static ID3D11UnorderedAccessView* histogramGreenBucketUAV;
|
||||
static ID3D11UnorderedAccessView* histogramBlueBucketUAV;
|
||||
static ID3D11UnorderedAccessView* paradeUAV;
|
||||
static ID3D11UnorderedAccessView* paradeRedBucketUAV;
|
||||
static ID3D11UnorderedAccessView* paradeGreenBucketUAV;
|
||||
static ID3D11UnorderedAccessView* paradeBlueBucketUAV;
|
||||
static ID3D11UnorderedAccessView* paradeAlphaBucketUAV;
|
||||
static ID3D11UnorderedAccessView* vectorScopeUAV;
|
||||
static ID3D11UnorderedAccessView* vectorScopeBucketUAV;
|
||||
static ID3D11ShaderResourceView* analysisSRV;
|
||||
static D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
static float* histogram;
|
||||
static float* parade;
|
||||
static float* vectorscope;
|
||||
static HANDLE hShaderErrorPipe;
|
||||
|
||||
extern "C" int _4klang_current_tick;
|
||||
|
||||
float AuthoringGetIntroPosition()
|
||||
{
|
||||
float time = SoundGetIntroPosition();
|
||||
return time + musicStartOffset / (float)(SAMPLES_PER_TICK * SOUND_TICKS_PER_SCENE);
|
||||
}
|
||||
|
||||
void AuthoringInit()
|
||||
{
|
||||
MutexLock("IntroAuthorMutex");
|
||||
|
||||
Log("IntroInit");
|
||||
SharedMemoryFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(SharedMemoryToolType), "IntroAuthor");
|
||||
AudioFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(SAMPLE_TYPE)* MAX_SAMPLES * 2, "IntroAudio");
|
||||
ImageFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4 * SCREENWIDTH * SCREENHEIGHT, "IntroImage");
|
||||
HistogramFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4 * 4 * 256, "IntroHistogram");
|
||||
ParadeFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4 * 256 * 256, "IntroParade");
|
||||
VectorscopeFileMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4 * 256 * 256, "IntroVectorscope");
|
||||
|
||||
SharedMemoryTool = (SharedMemoryToolType*)MapViewOfFile(SharedMemoryFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(SharedMemoryToolType));
|
||||
soundBuffer = (SAMPLE_TYPE*)MapViewOfFile(AudioFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(SAMPLE_TYPE)* MAX_SAMPLES * 2);
|
||||
SharedImage = (char*)MapViewOfFile(ImageFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 4 * SCREENWIDTH * SCREENHEIGHT);
|
||||
histogram = (float*)MapViewOfFile(HistogramFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 4 * 4 * 256);
|
||||
parade = (float*)MapViewOfFile(ParadeFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 4 * 256 * 256);
|
||||
vectorscope = (float*)MapViewOfFile(VectorscopeFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 4 * 256 * 256);
|
||||
|
||||
WaveHDR.lpData = (LPSTR)soundBuffer;
|
||||
|
||||
RECT rect;
|
||||
GetWindowRect(windowHandle, &rect);
|
||||
SharedMemoryTool->WindowLeft = rect.left;
|
||||
SharedMemoryTool->WindowTop = rect.top;
|
||||
SharedMemoryTool->WindowWidth = rect.right - rect.left - 16;
|
||||
SharedMemoryTool->WindowHeight = rect.bottom - rect.top - 39;
|
||||
SharedMemoryTool->MaxSamples = MAX_SAMPLES;
|
||||
SharedMemoryTool->SampleSize = sizeof(SAMPLE_TYPE);
|
||||
SharedMemoryTool->SamplesPerTick = SAMPLES_PER_TICK;
|
||||
SharedMemoryTool->TicksPerScene = SOUND_TICKS_PER_SCENE;
|
||||
SharedMemoryTool->SeekToScene = -1;
|
||||
SharedMemoryTool->KeepAlive = true;
|
||||
SharedMemoryTool->UseMinifiedShader = true;
|
||||
|
||||
backBufferTexture->GetDesc(&analysisDesc);
|
||||
analysisDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
analysisDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
analysisDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
analysisDesc.SampleDesc.Count = 1;
|
||||
device->CreateTexture2D(&analysisDesc, NULL, &resolvedTexture);
|
||||
|
||||
analysisDesc.Usage = D3D11_USAGE_STAGING;
|
||||
analysisDesc.BindFlags = 0;
|
||||
analysisDesc.CPUAccessFlags |= D3D11_CPU_ACCESS_READ;
|
||||
device->CreateTexture2D(&analysisDesc, NULL, &stagingTexture);
|
||||
device->CreateShaderResourceView(resolvedTexture, &analysisSRVdesc, &analysisSRV);
|
||||
|
||||
device->CreateTexture1D(&histogramTextureDesc, NULL, &histogramTexture);
|
||||
device->CreateTexture1D(&histogramBucketTextureDesc, NULL, &histogramRedBucketTexture);
|
||||
device->CreateTexture1D(&histogramBucketTextureDesc, NULL, &histogramGreenBucketTexture);
|
||||
device->CreateTexture1D(&histogramBucketTextureDesc, NULL, &histogramBlueBucketTexture);
|
||||
device->CreateUnorderedAccessView(histogramTexture, &histogramUAVdesc, &histogramUAV);
|
||||
device->CreateUnorderedAccessView(histogramRedBucketTexture, &histogramBucketUAVdesc, &histogramRedBucketUAV);
|
||||
device->CreateUnorderedAccessView(histogramGreenBucketTexture, &histogramBucketUAVdesc, &histogramGreenBucketUAV);
|
||||
device->CreateUnorderedAccessView(histogramBlueBucketTexture, &histogramBucketUAVdesc, &histogramBlueBucketUAV);
|
||||
device->CreateTexture1D(&histogramStagingTextureDesc, NULL, &histogramStagingTexture);
|
||||
|
||||
device->CreateTexture2D(¶deVectorScopeBucketTextureDesc, NULL, ¶deRedBucketTexture);
|
||||
device->CreateTexture2D(¶deVectorScopeBucketTextureDesc, NULL, ¶deGreenBucketTexture);
|
||||
device->CreateTexture2D(¶deVectorScopeBucketTextureDesc, NULL, ¶deBlueBucketTexture);
|
||||
device->CreateTexture2D(¶deVectorScopeBucketTextureDesc, NULL, ¶deAlphaBucketTexture);
|
||||
device->CreateTexture2D(¶deVectorScopeBucketTextureDesc, NULL, &vectorScopeBucketTexture);
|
||||
|
||||
device->CreateTexture2D(¶deTextureDesc, NULL, ¶deTexture);
|
||||
device->CreateTexture2D(¶deStagingTextureDesc, NULL, ¶deStagingTexture);
|
||||
device->CreateTexture2D(&vectorScopeTextureDesc, NULL, &vectorScopeTexture);
|
||||
device->CreateTexture2D(&vectorScopeStagingTextureDesc, NULL, &vectorScopeStagingTexture);
|
||||
|
||||
device->CreateUnorderedAccessView(paradeRedBucketTexture, ¶deVectorScopeBucketUAVdesc, ¶deRedBucketUAV);
|
||||
device->CreateUnorderedAccessView(paradeGreenBucketTexture, ¶deVectorScopeBucketUAVdesc, ¶deGreenBucketUAV);
|
||||
device->CreateUnorderedAccessView(paradeBlueBucketTexture, ¶deVectorScopeBucketUAVdesc, ¶deBlueBucketUAV);
|
||||
device->CreateUnorderedAccessView(paradeAlphaBucketTexture, ¶deVectorScopeBucketUAVdesc, ¶deAlphaBucketUAV);
|
||||
device->CreateUnorderedAccessView(vectorScopeBucketTexture, ¶deVectorScopeBucketUAVdesc, &vectorScopeBucketUAV);
|
||||
device->CreateUnorderedAccessView(vectorScopeTexture, &vectorScopeUAVdesc, &vectorScopeUAV);
|
||||
device->CreateUnorderedAccessView(paradeTexture, ¶deUAVdesc, ¶deUAV);
|
||||
|
||||
static char shaderPath[MAX_PATH];
|
||||
static char exePath[MAX_PATH];
|
||||
static char* shaderCode;
|
||||
static size_t shaderLength;
|
||||
|
||||
GetModuleFileName(NULL, exePath, MAX_PATH);
|
||||
PathRemoveFileSpec(exePath);
|
||||
|
||||
PathCombine(shaderPath, exePath, "histogramGather.cso");
|
||||
SimpleReadFile(shaderPath, &shaderCode, &shaderLength);
|
||||
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csHistogramGather);
|
||||
|
||||
PathCombine(shaderPath, exePath, "histogramMaximum.cso");
|
||||
SimpleReadFile(shaderPath, &shaderCode, &shaderLength);
|
||||
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csHistogramMaximum);
|
||||
|
||||
PathCombine(shaderPath, exePath, "histogramSpread.cso");
|
||||
SimpleReadFile(shaderPath, &shaderCode, &shaderLength);
|
||||
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csHistogramSpread);
|
||||
|
||||
PathCombine(shaderPath, exePath, "paradeVectorscopeGather.cso");
|
||||
SimpleReadFile(shaderPath, &shaderCode, &shaderLength);
|
||||
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csParadeVectorscopeGather);
|
||||
|
||||
PathCombine(shaderPath, exePath, "paradeVectorscopeMaximum.cso");
|
||||
SimpleReadFile(shaderPath, &shaderCode, &shaderLength);
|
||||
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csParadeVectorscopeMaximum);
|
||||
|
||||
PathCombine(shaderPath, exePath, "paradeVectorscopeSpread.cso");
|
||||
SimpleReadFile(shaderPath, &shaderCode, &shaderLength);
|
||||
device->CreateComputeShader(shaderCode, shaderLength, NULL, &csParadeVectorscopeSpread);
|
||||
|
||||
while (1)
|
||||
{
|
||||
auto pipeName = "\\\\.\\pipe\\8kode";
|
||||
hShaderErrorPipe = CreateFileA(
|
||||
pipeName, // pipe name
|
||||
GENERIC_WRITE |
|
||||
GENERIC_WRITE, // read/write access
|
||||
0, // no sharing
|
||||
NULL, // default security attributes
|
||||
OPEN_EXISTING, // opens existing pipe
|
||||
0, // default attributes
|
||||
NULL); // no template file
|
||||
|
||||
// Break if the pipe handle is valid.
|
||||
if (hShaderErrorPipe != INVALID_HANDLE_VALUE)
|
||||
break;
|
||||
|
||||
// Exit if an error other than ERROR_PIPE_BUSY occurs.
|
||||
DWORD error;
|
||||
if (error = GetLastError() != ERROR_PIPE_BUSY)
|
||||
{
|
||||
Error("Could not open pipe");
|
||||
}
|
||||
|
||||
// All pipe instances are busy, so wait for 2 seconds.
|
||||
if (WaitNamedPipe(pipeName, 2000))
|
||||
{
|
||||
printf("Could not open pipe: 2 second wait timed out.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool audio_IsPaused = false;
|
||||
|
||||
void SoundSeekToRow(void *d, int row)
|
||||
{
|
||||
if (row < 0)
|
||||
row = 0;
|
||||
|
||||
musicStartOffset = row * (long)(SAMPLES_PER_TICK * SOUND_TICKS_PER_SCENE) / SYNC_ROWS_PER_SCENE;
|
||||
|
||||
WaveHDR.lpData = (LPSTR)(float*)(soundBuffer + musicStartOffset * 2);
|
||||
WaveHDR.dwBufferLength = (MAX_SAMPLES - musicStartOffset) * sizeof(SAMPLE_TYPE) * 2;
|
||||
|
||||
//send buffer to waveOut
|
||||
waveOutReset(hWaveOut);
|
||||
waveOutPrepareHeader(hWaveOut, &WaveHDR, sizeof(WaveHDR));
|
||||
waveOutWrite(hWaveOut, &WaveHDR, sizeof(WaveHDR));
|
||||
|
||||
//put on pause
|
||||
if (audio_IsPaused)
|
||||
waveOutPause(hWaveOut);
|
||||
}
|
||||
|
||||
void SoundSeekToScene(void *d, int scene)
|
||||
{
|
||||
SoundSeekToRow(d, scene * SYNC_ROWS_PER_SCENE);
|
||||
}
|
||||
|
||||
void SoundPause(void *d, int iPause)
|
||||
{
|
||||
// Check if there is change of current play/pause state?
|
||||
if (audio_IsPaused != (bool)iPause)
|
||||
{
|
||||
// Assign new state
|
||||
audio_IsPaused = (bool)iPause;
|
||||
|
||||
// Change audio play state
|
||||
if (audio_IsPaused)
|
||||
waveOutPause(hWaveOut);
|
||||
else
|
||||
waveOutRestart(hWaveOut);
|
||||
}
|
||||
}
|
||||
|
||||
int SoundIsPlaying(void *d)
|
||||
{
|
||||
return (int)!audio_IsPaused;
|
||||
}
|
||||
|
||||
struct sync_cb usync_cb =
|
||||
{
|
||||
SoundPause,
|
||||
SoundSeekToRow,
|
||||
SoundIsPlaying
|
||||
};
|
||||
|
||||
void *usync_data = NULL;
|
||||
|
||||
bool AuthoringUpdate()
|
||||
{
|
||||
SharedMemoryTool->IntroPosition = AuthoringGetIntroPosition();
|
||||
SharedMemoryTool->AudioRenderPosition = _4klang_current_tick * SAMPLES_PER_TICK;
|
||||
SetWindowPos(windowHandle, 0, SharedMemoryTool->WindowLeft, SharedMemoryTool->WindowTop, SharedMemoryTool->WindowWidth + 16, SharedMemoryTool->WindowHeight + 39, 0);
|
||||
|
||||
static ID3D11Buffer* empty[16];
|
||||
|
||||
context->CSSetConstantBuffers(0, 8, empty);
|
||||
context->VSSetConstantBuffers(0, 8, empty);
|
||||
context->GSSetConstantBuffers(0, 8, empty);
|
||||
context->HSSetConstantBuffers(0, 8, empty);
|
||||
context->DSSetConstantBuffers(0, 8, empty);
|
||||
context->PSSetConstantBuffers(0, 8, empty);
|
||||
|
||||
context->ResolveSubresource(resolvedTexture, 0, backBufferTexture, 0, analysisDesc.Format);
|
||||
context->CopyResource(stagingTexture, resolvedTexture);
|
||||
context->Map(stagingTexture, 0, D3D11_MAP_READ, 0, &mappedResource);
|
||||
memcpy(SharedImage, mappedResource.pData, 4 * SCREENWIDTH * SCREENHEIGHT);
|
||||
context->Unmap(stagingTexture, 0);
|
||||
|
||||
static ID3D11UnorderedAccessView* histogramUAVs[] =
|
||||
{
|
||||
backBufferUAV,
|
||||
histogramRedBucketUAV,
|
||||
histogramGreenBucketUAV,
|
||||
histogramBlueBucketUAV,
|
||||
histogramUAV,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
static ID3D11UnorderedAccessView* paradeVectorscopeUAVs[] =
|
||||
{
|
||||
backBufferUAV,
|
||||
paradeRedBucketUAV,
|
||||
paradeGreenBucketUAV,
|
||||
paradeBlueBucketUAV,
|
||||
paradeAlphaBucketUAV,
|
||||
vectorScopeBucketUAV,
|
||||
paradeUAV,
|
||||
vectorScopeUAV
|
||||
};
|
||||
|
||||
static UINT zero[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
context->ClearUnorderedAccessViewUint(histogramRedBucketUAV, zero);
|
||||
context->ClearUnorderedAccessViewUint(histogramGreenBucketUAV, zero);
|
||||
context->ClearUnorderedAccessViewUint(histogramBlueBucketUAV, zero);
|
||||
context->ClearUnorderedAccessViewUint(vectorScopeBucketUAV, zero);
|
||||
context->ClearUnorderedAccessViewUint(paradeRedBucketUAV, zero);
|
||||
context->ClearUnorderedAccessViewUint(paradeGreenBucketUAV, zero);
|
||||
context->ClearUnorderedAccessViewUint(paradeBlueBucketUAV, zero);
|
||||
context->ClearUnorderedAccessViewUint(paradeAlphaBucketUAV, zero);
|
||||
|
||||
context->CSSetShaderResources(0, 1, &analysisSRV);
|
||||
|
||||
context->OMSetRenderTargets(1, (ID3D11RenderTargetView* const *)zero, NULL);
|
||||
context->CSSetUnorderedAccessViews(0, 8, histogramUAVs, NULL);
|
||||
context->CSSetShader(csHistogramGather, NULL, 0);
|
||||
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
|
||||
context->CSSetShader(csHistogramMaximum, NULL, 0);
|
||||
context->Dispatch(16, 1, 1);
|
||||
context->CSSetShader(csHistogramSpread, NULL, 0);
|
||||
context->Dispatch(16, 1, 1);
|
||||
|
||||
context->CSSetUnorderedAccessViews(0, 8, paradeVectorscopeUAVs, NULL);
|
||||
context->CSSetShader(csParadeVectorscopeGather, NULL, 0);
|
||||
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
|
||||
context->CSSetShader(csParadeVectorscopeMaximum, NULL, 0);
|
||||
context->Dispatch(16, 16, 1);
|
||||
context->CSSetShader(csParadeVectorscopeSpread, NULL, 0);
|
||||
context->Dispatch(16, 16, 1);
|
||||
|
||||
context->CSSetShaderResources(0, 1, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->CSSetUnorderedAccessViews(0, 8, (ID3D11UnorderedAccessView* const *)zero, NULL);
|
||||
|
||||
context->CopyResource(histogramStagingTexture, histogramTexture);
|
||||
context->Map(histogramStagingTexture, 0, D3D11_MAP_READ, 0, &mappedResource);
|
||||
memcpy(histogram, mappedResource.pData, 4 * 4 * 256);
|
||||
context->Unmap(histogramStagingTexture, 0);
|
||||
|
||||
context->CopyResource(paradeStagingTexture, paradeTexture);
|
||||
context->Map(paradeStagingTexture, 0, D3D11_MAP_READ, 0, &mappedResource);
|
||||
memcpy(parade, mappedResource.pData, 4 * 256 * 256);
|
||||
context->Unmap(paradeStagingTexture, 0);
|
||||
|
||||
context->CopyResource(vectorScopeStagingTexture, vectorScopeTexture);
|
||||
context->Map(vectorScopeStagingTexture, 0, D3D11_MAP_READ, 0, &mappedResource);
|
||||
memcpy(vectorscope, mappedResource.pData, 4 * 256 * 256);
|
||||
context->Unmap(vectorScopeStagingTexture, 0);
|
||||
|
||||
if (::WaitForSingleObject(shaderCompileEvent, 0) == WAIT_OBJECT_0)
|
||||
{
|
||||
::Sleep(100);
|
||||
FrameworkShadersCompile();
|
||||
}
|
||||
|
||||
if (SharedMemoryTool->SeekToScene != -1)
|
||||
{
|
||||
auto scene = SharedMemoryTool->SeekToScene;
|
||||
SharedMemoryTool->SeekToScene = -1;
|
||||
SoundSeekToScene(NULL, scene);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AuthoringDispose()
|
||||
{
|
||||
usync_export();
|
||||
|
||||
Log("AuthoringDispose");
|
||||
|
||||
UnmapViewOfFile(SharedMemoryTool);
|
||||
UnmapViewOfFile(soundBuffer);
|
||||
UnmapViewOfFile(SharedImage);
|
||||
UnmapViewOfFile(histogram);
|
||||
UnmapViewOfFile(parade);
|
||||
UnmapViewOfFile(vectorscope);
|
||||
|
||||
CloseHandle(SharedMemoryFileMapping);
|
||||
CloseHandle(AudioFileMapping);
|
||||
CloseHandle(ImageFileMapping);
|
||||
CloseHandle(HistogramFileMapping);
|
||||
CloseHandle(ParadeFileMapping);
|
||||
CloseHandle(VectorscopeFileMapping);
|
||||
|
||||
CloseHandle(SharedMemoryMutex);
|
||||
}
|
||||
265
nordlicht2015-intro/src/intro/framework/directx.h
Normal file
265
nordlicht2015-intro/src/intro/framework/directx.h
Normal file
@@ -0,0 +1,265 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d11.h>
|
||||
|
||||
#define DEPTH_STENCIL
|
||||
#define RASTERIZER_STATE
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define D3D_DEVICE_FLAGS 0
|
||||
//#define D3D_DEVICE_FLAGS D3D11_CREATE_DEVICE_DEBUG
|
||||
#else
|
||||
#define D3D_DEVICE_FLAGS 0
|
||||
#endif
|
||||
|
||||
#pragma bss_seg(".directxBss")
|
||||
static ID3D11Device* device;
|
||||
static ID3D11DeviceContext* context;
|
||||
static IDXGISwapChain* swapChain;
|
||||
static ID3D11Texture2D* backBufferTexture;
|
||||
static ID3D11UnorderedAccessView* backBufferUAV;
|
||||
static ID3D11RenderTargetView* backBufferRTV;
|
||||
static ID3D11BlendState* alphaBlendState;
|
||||
|
||||
#ifdef RASTERIZER_STATE
|
||||
#pragma bss_seg(".rsBss")
|
||||
static ID3D11RasterizerState* rsSolidCullNone;
|
||||
static ID3D11RasterizerState* rsSolidCullBack;
|
||||
|
||||
#pragma data_seg(".rsSolidCullNoneDesc")
|
||||
static D3D11_RASTERIZER_DESC rsSolidCullNoneDesc =
|
||||
{
|
||||
D3D11_FILL_SOLID,
|
||||
D3D11_CULL_NONE,
|
||||
FALSE,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
TRUE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE
|
||||
};
|
||||
|
||||
#pragma data_seg(".rsSolidCullBackDesc")
|
||||
static D3D11_RASTERIZER_DESC rsSolidCullBackDesc =
|
||||
{
|
||||
D3D11_FILL_SOLID,
|
||||
D3D11_CULL_BACK,
|
||||
FALSE,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
TRUE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef DEPTH_STENCIL
|
||||
|
||||
#pragma bss_seg(".dsBss")
|
||||
static ID3D11DepthStencilState* depthStencilState;
|
||||
static ID3D11DepthStencilState* noDepthWriteStencilState;
|
||||
static ID3D11Texture2D* depthStencilBuffer;
|
||||
static ID3D11DepthStencilView* depthStencilView;
|
||||
static ID3D11ShaderResourceView* depthStencilSRV;
|
||||
|
||||
#pragma data_seg(".depthStencilBufferDesc")
|
||||
static D3D11_TEXTURE2D_DESC depthStencilBufferDesc =
|
||||
{
|
||||
SCREENWIDTH,
|
||||
SCREENHEIGHT,
|
||||
1,
|
||||
1,
|
||||
DXGI_FORMAT_R32_TYPELESS,
|
||||
{
|
||||
1,
|
||||
0
|
||||
},
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
#pragma data_seg(".depthStencilDesc")
|
||||
static D3D11_DEPTH_STENCIL_DESC depthStencilDesc =
|
||||
{
|
||||
TRUE,
|
||||
D3D11_DEPTH_WRITE_MASK_ALL,
|
||||
D3D11_COMPARISON_LESS,
|
||||
FALSE,
|
||||
D3D11_DEFAULT_STENCIL_READ_MASK,
|
||||
D3D11_DEFAULT_STENCIL_WRITE_MASK,
|
||||
{
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_COMPARISON_ALWAYS
|
||||
},
|
||||
{
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_COMPARISON_ALWAYS
|
||||
}
|
||||
};
|
||||
|
||||
#pragma data_seg(".noDepthWriteStencilDesc")
|
||||
static D3D11_DEPTH_STENCIL_DESC noDepthWriteStencilDesc =
|
||||
{
|
||||
TRUE,
|
||||
D3D11_DEPTH_WRITE_MASK_ZERO,
|
||||
D3D11_COMPARISON_LESS,
|
||||
FALSE,
|
||||
D3D11_DEFAULT_STENCIL_READ_MASK,
|
||||
D3D11_DEFAULT_STENCIL_WRITE_MASK,
|
||||
{
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_COMPARISON_ALWAYS
|
||||
},
|
||||
{
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_STENCIL_OP_KEEP,
|
||||
D3D11_COMPARISON_ALWAYS
|
||||
}
|
||||
};
|
||||
|
||||
#pragma data_seg(".depthStencilViewDesc")
|
||||
static D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc =
|
||||
{
|
||||
DXGI_FORMAT_D32_FLOAT,
|
||||
D3D11_DSV_DIMENSION_TEXTURE2D,
|
||||
0
|
||||
};
|
||||
|
||||
#pragma data_seg(".depthStencilSrvDesc")
|
||||
static D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilSrvDesc =
|
||||
{
|
||||
DXGI_FORMAT_R32_FLOAT,
|
||||
D3D11_SRV_DIMENSION_TEXTURE2D,
|
||||
{
|
||||
0,
|
||||
1
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#pragma data_seg(".backBufferUAVdesc")
|
||||
static D3D11_UNORDERED_ACCESS_VIEW_DESC backBufferUAVdesc =
|
||||
{
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
D3D11_UAV_DIMENSION_TEXTURE2D,
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
#pragma data_seg(".backBufferRTVdesc")
|
||||
static D3D11_RENDER_TARGET_VIEW_DESC backBufferRTVdesc =
|
||||
{
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
D3D11_RTV_DIMENSION_TEXTURE2D,
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
#pragma data_seg(".viewPort")
|
||||
static D3D11_VIEWPORT viewPort =
|
||||
{
|
||||
0, 0, SCREENWIDTH, SCREENHEIGHT, 0, 1
|
||||
};
|
||||
|
||||
#pragma data_seg(".directxFeatureLevel")
|
||||
static D3D_FEATURE_LEVEL featureLevel[] = { D3D_FEATURE_LEVEL_11_0 };
|
||||
|
||||
#pragma data_seg(".directxSwapChainDesc")
|
||||
static DXGI_SWAP_CHAIN_DESC swapChainDesc =
|
||||
{
|
||||
{
|
||||
SCREENWIDTH,
|
||||
SCREENHEIGHT,
|
||||
{
|
||||
0, 1
|
||||
},
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED,
|
||||
DXGI_MODE_SCALING_UNSPECIFIED
|
||||
},
|
||||
{
|
||||
1, 0
|
||||
},
|
||||
DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS,
|
||||
1,
|
||||
0,
|
||||
WINDOWED,
|
||||
DXGI_SWAP_EFFECT_DISCARD,
|
||||
0
|
||||
};
|
||||
|
||||
#pragma data_seg(".directxBackBufferMSDesc")
|
||||
static D3D11_TEXTURE2D_DESC backBufferMSDesc =
|
||||
{
|
||||
SCREENWIDTH, SCREENHEIGHT, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
{ 4, 0 }, D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE,
|
||||
0, 0
|
||||
};
|
||||
|
||||
#pragma data_seg(".swapChainViewport")
|
||||
static D3D11_VIEWPORT swapChainViewport =
|
||||
{
|
||||
0.0f,
|
||||
0.0f,
|
||||
1,
|
||||
1,
|
||||
0.0f,
|
||||
1.0f,
|
||||
};
|
||||
|
||||
#pragma data_seg(".alphaBlendDesc")
|
||||
static D3D11_BLEND_DESC alphaBlendDesc =
|
||||
{
|
||||
FALSE,
|
||||
FALSE,
|
||||
{
|
||||
true,
|
||||
D3D11_BLEND_SRC_ALPHA,
|
||||
D3D11_BLEND_INV_SRC_ALPHA,
|
||||
D3D11_BLEND_OP_ADD,
|
||||
D3D11_BLEND_ZERO,
|
||||
D3D11_BLEND_ZERO,
|
||||
D3D11_BLEND_OP_ADD,
|
||||
D3D11_COLOR_WRITE_ENABLE_ALL
|
||||
}
|
||||
};
|
||||
|
||||
#pragma code_seg(".directxInit")
|
||||
INLINE void DirectXInit()
|
||||
{
|
||||
Log("DirectXInit");
|
||||
swapChainDesc.OutputWindow = windowHandle;
|
||||
CHECK(D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, D3D_DEVICE_FLAGS, featureLevel, 1, D3D11_SDK_VERSION, &swapChainDesc, &swapChain, &device, NULL, &context));
|
||||
CHECK(swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBufferTexture));
|
||||
CHECK(device->CreateUnorderedAccessView(backBufferTexture, &backBufferUAVdesc, &backBufferUAV));
|
||||
CHECK(device->CreateRenderTargetView(backBufferTexture, &backBufferRTVdesc, &backBufferRTV));
|
||||
CHECK(device->CreateBlendState(&alphaBlendDesc, &alphaBlendState));
|
||||
swapChain->Present(1, 0);
|
||||
|
||||
#ifdef DEPTH_STENCIL
|
||||
device->CreateDepthStencilState(&depthStencilDesc, &depthStencilState);
|
||||
device->CreateDepthStencilState(&noDepthWriteStencilDesc, &noDepthWriteStencilState);
|
||||
|
||||
device->CreateTexture2D(&depthStencilBufferDesc, NULL, &depthStencilBuffer);
|
||||
device->CreateDepthStencilView(depthStencilBuffer, &depthStencilViewDesc, &depthStencilView);
|
||||
device->CreateShaderResourceView(depthStencilBuffer, &depthStencilSrvDesc, &depthStencilSRV);
|
||||
#endif
|
||||
|
||||
#ifdef RASTERIZER_STATE
|
||||
device->CreateRasterizerState(&rsSolidCullNoneDesc, &rsSolidCullNone);
|
||||
device->CreateRasterizerState(&rsSolidCullBackDesc, &rsSolidCullBack);
|
||||
#endif
|
||||
}
|
||||
146
nordlicht2015-intro/src/intro/framework/framework.h
Normal file
146
nordlicht2015-intro/src/intro/framework/framework.h
Normal file
@@ -0,0 +1,146 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef _DEBUG
|
||||
#define INLINE __forceinline
|
||||
#else
|
||||
#define INLINE
|
||||
#endif
|
||||
|
||||
#define VC_EXTRALEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include "log.h"
|
||||
#include "window.h"
|
||||
#include "directx.h"
|
||||
#include "4klang.h"
|
||||
#include "sound.h"
|
||||
#include "video.h"
|
||||
|
||||
#pragma bss_seg(".shadersbss")
|
||||
static void* shaderCode;
|
||||
static size_t shaderSize;
|
||||
|
||||
#if AUTHORING | VIDEO
|
||||
bool CompileShader_Authoring(char* entryPoint, char* profile);
|
||||
#define CompileShader(entryPoint, profile) { if (!CompileShader_Authoring(entryPoint, profile)) return; }
|
||||
#else
|
||||
void CompileShader_Release(char* entryPoint, char* profile);
|
||||
#define CompileShader(entryPoint, profile) CompileShader_Release(entryPoint, profile)
|
||||
#endif
|
||||
|
||||
#include "sync/usync.h"
|
||||
#include "shaders_shc.h"
|
||||
|
||||
#pragma code_seg(".introforward")
|
||||
void IntroInit();
|
||||
void IntroUpdate(float _introPosition);
|
||||
|
||||
#if AUTHORING | VIDEO
|
||||
static HANDLE shaderCompileEvent;
|
||||
|
||||
void SimpleReadFile(char* path, char** content, size_t* length)
|
||||
{
|
||||
FILE* shaderFile;
|
||||
auto error = fopen_s(&shaderFile, path, "rb");
|
||||
fseek(shaderFile, 0, SEEK_END);
|
||||
*length = ftell(shaderFile);
|
||||
*content = new char[*length];
|
||||
fseek(shaderFile, 0, SEEK_SET);
|
||||
fread_s(*content, *length, sizeof(char), *length, shaderFile);
|
||||
fclose(shaderFile);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef AUTHORING
|
||||
#include "authoring.h"
|
||||
#endif
|
||||
|
||||
#include "shaders.h"
|
||||
|
||||
INLINE void FrameworkInit()
|
||||
{
|
||||
Log("FrameworkInit");
|
||||
WindowInit();
|
||||
DirectXInit();
|
||||
ShadersInit();
|
||||
SyncInit();
|
||||
|
||||
#ifdef AUTHORING
|
||||
AuthoringInit();
|
||||
#endif
|
||||
|
||||
FrameworkShadersCompile();
|
||||
SoundInit();
|
||||
IntroInit();
|
||||
SoundPlay();
|
||||
|
||||
#ifdef AUTHORING
|
||||
SoundPause(NULL, (int)true);
|
||||
#endif
|
||||
|
||||
#ifdef VIDEO
|
||||
VideoInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
INLINE float FrameworkGetIntroPosition()
|
||||
{
|
||||
#ifdef AUTHORING
|
||||
return AuthoringGetIntroPosition();
|
||||
#elif VIDEO
|
||||
return VideoGetPosition();
|
||||
#else
|
||||
return SoundGetIntroPosition();
|
||||
#endif
|
||||
}
|
||||
|
||||
INLINE void FrameworkUpdate()
|
||||
{
|
||||
#ifdef VIDEO
|
||||
float t = VideoGetPosition();
|
||||
#else
|
||||
float t = FrameworkGetIntroPosition();
|
||||
#endif
|
||||
|
||||
SyncUpdate(t);
|
||||
|
||||
#ifdef AUTHORING
|
||||
if (AuthoringUpdate())
|
||||
{
|
||||
IntroUpdate(t);
|
||||
}
|
||||
#else
|
||||
IntroUpdate(t);
|
||||
#endif
|
||||
|
||||
#ifdef VIDEO
|
||||
VideoUpdate();
|
||||
#endif
|
||||
}
|
||||
|
||||
INLINE void FrameworkDispose()
|
||||
{
|
||||
Log("FrameworkDispose");
|
||||
#ifdef AUTHORING
|
||||
AuthoringDispose();
|
||||
#endif
|
||||
|
||||
#ifdef VIDEO
|
||||
VideoDispose();
|
||||
#endif
|
||||
}
|
||||
|
||||
static const float introLength = (float)MAX_SAMPLES / (float)(SAMPLES_PER_TICK * SOUND_TICKS_PER_SCENE);
|
||||
|
||||
INLINE bool FrameworkContinueExecuting()
|
||||
{
|
||||
#ifndef AUTHORING
|
||||
if (FrameworkGetIntroPosition() >= introLength)
|
||||
return false;
|
||||
|
||||
return !GetAsyncKeyState(VK_ESCAPE);
|
||||
#else
|
||||
return SharedMemoryTool->KeepAlive;
|
||||
#endif
|
||||
}
|
||||
1104
nordlicht2015-intro/src/intro/framework/intro_hlsl.h
Normal file
1104
nordlicht2015-intro/src/intro/framework/intro_hlsl.h
Normal file
File diff suppressed because it is too large
Load Diff
67
nordlicht2015-intro/src/intro/framework/log.h
Normal file
67
nordlicht2015-intro/src/intro/framework/log.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef _DEBUG
|
||||
|
||||
#define Log(text)
|
||||
#define Warn(text)
|
||||
#define Error(text)
|
||||
#define CHECK(hresult) hresult
|
||||
|
||||
#else
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void Log(char* _text, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, _text);
|
||||
vprintf(_text, args);
|
||||
va_end(args);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void Warn(char* _text)
|
||||
{
|
||||
HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
GetConsoleScreenBufferInfo(hstdout, &csbi);
|
||||
|
||||
SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
|
||||
OutputDebugString("WARNING: ");
|
||||
OutputDebugString(_text);
|
||||
OutputDebugString("\n");
|
||||
Log(_text);
|
||||
|
||||
SetConsoleTextAttribute(hstdout, csbi.wAttributes);
|
||||
}
|
||||
|
||||
void Error(char* _text)
|
||||
{
|
||||
HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
GetConsoleScreenBufferInfo(hstdout, &csbi);
|
||||
|
||||
SetConsoleTextAttribute(hstdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
|
||||
OutputDebugString("ERROR: ");
|
||||
OutputDebugString(_text);
|
||||
OutputDebugString("\n");
|
||||
Log(_text);
|
||||
SetConsoleTextAttribute(hstdout, csbi.wAttributes);
|
||||
}
|
||||
|
||||
void CHECK(HRESULT _hResult)
|
||||
{
|
||||
if (_hResult != S_OK)
|
||||
{
|
||||
HLOCAL pBuffer;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, _hResult, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&pBuffer, 512, NULL);
|
||||
Error((char*)pBuffer);
|
||||
DebugBreak();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
1713
nordlicht2015-intro/src/intro/framework/merged.hlsl
Normal file
1713
nordlicht2015-intro/src/intro/framework/merged.hlsl
Normal file
File diff suppressed because it is too large
Load Diff
20
nordlicht2015-intro/src/intro/framework/mutexlock.h
Normal file
20
nordlicht2015-intro/src/intro/framework/mutexlock.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
struct MutexLock
|
||||
{
|
||||
public:
|
||||
MutexLock(const char* _mutexName)
|
||||
{
|
||||
m_MutexHandle = CreateMutex(NULL, FALSE, _mutexName);
|
||||
while (WaitForSingleObject(m_MutexHandle, 500) != WAIT_OBJECT_0)
|
||||
::Sleep(1);
|
||||
}
|
||||
|
||||
virtual ~MutexLock()
|
||||
{
|
||||
CloseHandle(m_MutexHandle);
|
||||
}
|
||||
|
||||
private:
|
||||
HANDLE m_MutexHandle;
|
||||
};
|
||||
1120
nordlicht2015-intro/src/intro/framework/patterns.dbg
Normal file
1120
nordlicht2015-intro/src/intro/framework/patterns.dbg
Normal file
File diff suppressed because it is too large
Load Diff
142
nordlicht2015-intro/src/intro/framework/shaders.h
Normal file
142
nordlicht2015-intro/src/intro/framework/shaders.h
Normal file
@@ -0,0 +1,142 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3dcompiler.h>
|
||||
|
||||
#pragma bss_seg(".shadersbss")
|
||||
static ID3DBlob* shaderBlob;
|
||||
static ID3DBlob* errorBlob;
|
||||
static pD3DCompile d3dCompile;
|
||||
|
||||
#pragma data_seg(".d3dcompiler")
|
||||
static char d3dcompiler[] = "d3dcompiler_47.dll";
|
||||
|
||||
#pragma data_seg(".minifiedShader")
|
||||
#include "intro_hlsl.h"
|
||||
|
||||
#if AUTHORING | VIDEO
|
||||
|
||||
#include <Shlwapi.h>
|
||||
#include <process.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static char g_sMonitoredShaderPath[MAX_PATH];
|
||||
static __time64_t shaderChangedDate;
|
||||
|
||||
DWORD WINAPI filemon(void* args)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
_finddata_t fdata;
|
||||
long hfile = _findfirst(g_sMonitoredShaderPath, &fdata);
|
||||
if (hfile != -1)
|
||||
{
|
||||
if (fdata.time_write != shaderChangedDate)
|
||||
{
|
||||
shaderChangedDate = fdata.time_write;
|
||||
::SetEvent(shaderCompileEvent);
|
||||
}
|
||||
_findclose(hfile);
|
||||
}
|
||||
::Sleep(100);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
INLINE void ShadersInit()
|
||||
{
|
||||
HINSTANCE hl = LoadLibrary(d3dcompiler);
|
||||
if (!hl)
|
||||
{
|
||||
d3dcompiler[13] = '3';
|
||||
hl = LoadLibrary(d3dcompiler);
|
||||
}
|
||||
d3dCompile = (pD3DCompile)GetProcAddress(hl, "D3DCompile");
|
||||
|
||||
#if AUTHORING | VIDEO
|
||||
static char exePath[MAX_PATH];
|
||||
GetModuleFileName(NULL, exePath, MAX_PATH);
|
||||
PathRemoveFileSpec(exePath);
|
||||
PathCombine(g_sMonitoredShaderPath, exePath, "..\\src\\intro\\framework\\merged.hlsl");
|
||||
|
||||
_finddata_t fdata;
|
||||
long hfile = _findfirst(g_sMonitoredShaderPath, &fdata);
|
||||
if (hfile != -1)
|
||||
{
|
||||
shaderChangedDate = fdata.time_write;
|
||||
_findclose(hfile);
|
||||
}
|
||||
|
||||
shaderCompileEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("WriteEvent"));
|
||||
SetThreadPriority((HANDLE)CreateThread(0, 0, &filemon, 0, 0, 0), THREAD_PRIORITY_BELOW_NORMAL);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if AUTHORING | VIDEO
|
||||
#pragma code_seg(".CompileShaderA")
|
||||
bool CompileShader_Authoring(char* entryPoint, char* profile)
|
||||
{
|
||||
SimpleReadFile((char*)g_sMonitoredShaderPath, (char**)&shaderCode, &shaderSize);
|
||||
d3dCompile(shaderCode, shaderSize, g_sMonitoredShaderPath, NULL, NULL, entryPoint, profile, D3DCOMPILE_DEBUG, 0, &shaderBlob, &errorBlob);
|
||||
if (errorBlob != NULL)
|
||||
{
|
||||
auto error = (char*)errorBlob->GetBufferPointer();
|
||||
if (shaderBlob != NULL)
|
||||
{
|
||||
Warn(error);
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(error);
|
||||
}
|
||||
|
||||
DWORD cbSize = strlen(error);
|
||||
DWORD cbWritten = 0;
|
||||
|
||||
#ifdef AUTHORING
|
||||
WriteFile(
|
||||
hShaderErrorPipe, // pipe handle
|
||||
&cbSize, // message
|
||||
sizeof(DWORD), // message length
|
||||
&cbWritten, // bytes written
|
||||
NULL); // not overlapped
|
||||
|
||||
WriteFile(
|
||||
hShaderErrorPipe, // pipe handle
|
||||
error, // message
|
||||
cbSize, // message length
|
||||
&cbWritten, // bytes written
|
||||
NULL); // not overlapped
|
||||
#endif
|
||||
|
||||
if (shaderBlob == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
shaderSize = shaderBlob->GetBufferSize();
|
||||
shaderCode = shaderBlob->GetBufferPointer();
|
||||
return true;
|
||||
};
|
||||
#endif
|
||||
|
||||
#pragma code_seg(".CompileShaderR")
|
||||
void CompileShader_Release(char* entryPoint, char* profile)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
d3dCompile(merged_hlsl, sizeof(merged_hlsl), NULL, NULL, NULL, entryPoint, profile, 0, 0, &shaderBlob, &errorBlob);
|
||||
if (errorBlob != NULL)
|
||||
{
|
||||
auto error = errorBlob->GetBufferPointer();
|
||||
Error((char*)error);
|
||||
}
|
||||
#else
|
||||
d3dCompile(merged_hlsl, sizeof(merged_hlsl), NULL, NULL, NULL, entryPoint, profile, 0, 0, &shaderBlob, 0);
|
||||
#endif
|
||||
|
||||
shaderSize = shaderBlob->GetBufferSize();
|
||||
shaderCode = shaderBlob->GetBufferPointer();
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
Texture2D<float4> in0 : register(u0);
|
||||
RWTexture1D<uint> histogramBucketR : register(u1);
|
||||
RWTexture1D<uint> histogramBucketG : register(u2);
|
||||
RWTexture1D<uint> histogramBucketB : register(u3);
|
||||
RWTexture1D<float4> histogramOut : register(u4);
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
void main(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
int3 iPixel = in0[id.xy].rgb * 255.0f;
|
||||
|
||||
InterlockedAdd(histogramBucketR[iPixel.r], 1);
|
||||
InterlockedAdd(histogramBucketG[iPixel.g], 1);
|
||||
InterlockedAdd(histogramBucketB[iPixel.b], 1);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
Texture2D<float4> in0 : register(u0);
|
||||
RWTexture1D<uint> histogramBucketR : register(u1);
|
||||
RWTexture1D<uint> histogramBucketG : register(u2);
|
||||
RWTexture1D<uint> histogramBucketB : register(u3);
|
||||
RWTexture1D<float4> histogramOut : register(u4);
|
||||
|
||||
[numthreads(16, 1, 1)]
|
||||
void main(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
InterlockedMax(histogramBucketR[256], histogramBucketR[id.x]);
|
||||
InterlockedMax(histogramBucketG[256], histogramBucketG[id.x]);
|
||||
InterlockedMax(histogramBucketB[256], histogramBucketB[id.x]);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
Texture2D<float4> in0 : register(u0);
|
||||
RWTexture1D<uint> histogramBucketR : register(u1);
|
||||
RWTexture1D<uint> histogramBucketG : register(u2);
|
||||
RWTexture1D<uint> histogramBucketB : register(u3);
|
||||
RWTexture1D<float4> histogramOut : register(u4);
|
||||
|
||||
[numthreads(16, 1, 1)]
|
||||
void main(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
histogramOut[id.x] = float4(
|
||||
log(1.0 + histogramBucketR[id.x]) / log(1.0 + histogramBucketR[256]),
|
||||
log(1.0 + histogramBucketG[id.x]) / log(1.0 + histogramBucketG[256]),
|
||||
log(1.0 + histogramBucketB[id.x]) / log(1.0 + histogramBucketB[256]), 0.0f);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
Texture2D<float4> in0 : register(u0);
|
||||
RWTexture2D<uint> paradeBucketR : register(u1);
|
||||
RWTexture2D<uint> paradeBucketG : register(u2);
|
||||
RWTexture2D<uint> paradeBucketB : register(u3);
|
||||
RWTexture2D<uint> paradeBucketA : register(u4);
|
||||
RWTexture2D<uint> vectorScopeBucket : register(u5);
|
||||
RWTexture2D<uint4> paradeOut : register(u6);
|
||||
RWTexture2D<uint4> vectorScopeOut : register(u7);
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
void main(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
float3 pixel = in0[id.xy].rgb;
|
||||
int3 iPixel = pixel * 255.0f;
|
||||
float luminance = dot(pixel, float3(0.2126f, 0.7152f, 0.0722f));
|
||||
float2 f = float2(0.492f, 0.877f) * (pixel.br - luminance);
|
||||
int2 uv = min(255, max(0, 128 * (1 + f / float2(0.436f, 0.615f))));
|
||||
|
||||
float2 resolution;
|
||||
in0.GetDimensions(resolution.x, resolution.y);
|
||||
int paradeCoord = (id.x * 255.0f) / resolution.x;
|
||||
|
||||
InterlockedAdd(paradeBucketR[int2(paradeCoord, 255 - iPixel.r)], 1);
|
||||
InterlockedAdd(paradeBucketG[int2(paradeCoord, 255 - iPixel.g)], 1);
|
||||
InterlockedAdd(paradeBucketB[int2(paradeCoord, 255 - iPixel.b)], 1);
|
||||
InterlockedAdd(paradeBucketA[int2(paradeCoord, 255 - (uint)(255.0f * luminance))], 1);
|
||||
InterlockedAdd(vectorScopeBucket[uv], 1);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
Texture2D<float4> in0 : register(u0);
|
||||
RWTexture2D<uint> paradeBucketR : register(u1);
|
||||
RWTexture2D<uint> paradeBucketG : register(u2);
|
||||
RWTexture2D<uint> paradeBucketB : register(u3);
|
||||
RWTexture2D<uint> paradeBucketA : register(u4);
|
||||
RWTexture2D<uint> vectorScopeBucket : register(u5);
|
||||
RWTexture2D<uint4> paradeOut : register(u6);
|
||||
RWTexture2D<uint4> vectorScopeOut : register(u7);
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
void main(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
InterlockedMax(paradeBucketR[uint2(256, 0)], paradeBucketR[id.xy]);
|
||||
InterlockedMax(paradeBucketG[uint2(256, 0)], paradeBucketG[id.xy]);
|
||||
InterlockedMax(paradeBucketB[uint2(256, 0)], paradeBucketB[id.xy]);
|
||||
InterlockedMax(paradeBucketA[uint2(256, 0)], paradeBucketA[id.xy]);
|
||||
InterlockedMax(vectorScopeBucket[uint2(256, 0)], vectorScopeBucket[id.xy]);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
Texture2D<float4> in0 : register(u0);
|
||||
RWTexture2D<uint> paradeBucketR : register(u1);
|
||||
RWTexture2D<uint> paradeBucketG : register(u2);
|
||||
RWTexture2D<uint> paradeBucketB : register(u3);
|
||||
RWTexture2D<uint> paradeBucketA : register(u4);
|
||||
RWTexture2D<uint> vectorScopeBucket : register(u5);
|
||||
RWTexture2D<uint4> paradeOut : register(u6);
|
||||
RWTexture2D<uint4> vectorScopeOut : register(u7);
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
void main( uint3 id : SV_DispatchThreadID )
|
||||
{
|
||||
paradeOut[id.xy] = uint4(
|
||||
255.0f * log(1.0f + paradeBucketR[id.xy]) / log(1.0f + paradeBucketR[uint2(256, 0)]),
|
||||
255.0f * log(1.0f + paradeBucketG[id.xy]) / log(1.0f + paradeBucketG[uint2(256, 0)]),
|
||||
255.0f * log(1.0f + paradeBucketB[id.xy]) / log(1.0f + paradeBucketB[uint2(256, 0)]),
|
||||
255.0f * log(1.0f + paradeBucketA[id.xy]) / log(1.0f + paradeBucketA[uint2(256, 0)]));
|
||||
|
||||
float luminance = 1.0f - max(0.0f, min(1.0f, log(1.0f + vectorScopeBucket[id.xy]) / log(1.0f + vectorScopeBucket[uint2(256, 0)])));
|
||||
float2 f = (id.xy - 128.0f) / 128.0f;
|
||||
if (length(f) > 1)
|
||||
luminance = 0.0f;
|
||||
|
||||
float2 uv = ((id.xy / 128.0f) - 1.0f) * float2(0.436f, 0.615f);
|
||||
|
||||
float3 _a = float3(0, -0.3950f, 2.03252f);
|
||||
float3 _b = float3(1.14025f, -0.581f, 0);
|
||||
uint3 rgb = luminance * 255.0f * min(1, max(0, (0.5f + uv.x * _a + uv.y * _b)));
|
||||
|
||||
vectorScopeOut[id.xy] = uint4(rgb, 255);
|
||||
}
|
||||
252
nordlicht2015-intro/src/intro/framework/shaders_shc.h
Normal file
252
nordlicht2015-intro/src/intro/framework/shaders_shc.h
Normal file
@@ -0,0 +1,252 @@
|
||||
#pragma once
|
||||
// WARNING: This file is autogenerated by shc. Do not edit
|
||||
|
||||
#pragma data_seg(".cs_5_0")
|
||||
static char cs_5_0[] = "cs_5_0";
|
||||
|
||||
#pragma data_seg(".vs_5_0")
|
||||
static char vs_5_0[] = "vs_5_0";
|
||||
|
||||
#pragma data_seg(".gs_5_0")
|
||||
static char gs_5_0[] = "gs_5_0";
|
||||
|
||||
#pragma data_seg(".ds_5_0")
|
||||
static char ds_5_0[] = "ds_5_0";
|
||||
|
||||
#pragma data_seg(".hs_5_0")
|
||||
static char hs_5_0[] = "hs_5_0";
|
||||
|
||||
#pragma data_seg(".ps_5_0")
|
||||
static char ps_5_0[] = "ps_5_0";
|
||||
|
||||
#pragma bss_seg(".shaderbss")
|
||||
static ID3D11ComputeShader* cs_Sample;
|
||||
static ID3D11ComputeShader* cs_Copy;
|
||||
static ID3D11ComputeShader* csBlurH;
|
||||
static ID3D11ComputeShader* csBlurV;
|
||||
static ID3D11ComputeShader* csMerge;
|
||||
static ID3D11ComputeShader* csDT1;
|
||||
static ID3D11ComputeShader* csDT2;
|
||||
static ID3D11ComputeShader* cs_gridline;
|
||||
static ID3D11VertexShader* vs_gridline;
|
||||
static ID3D11GeometryShader* gs_gridline;
|
||||
static ID3D11PixelShader* ps_gridline;
|
||||
static ID3D11VertexShader* vs_mesh;
|
||||
static ID3D11InputLayout* il_mesh;
|
||||
static ID3D11PixelShader* ps_mesh;
|
||||
static ID3D11VertexShader* vs_terrain;
|
||||
static ID3D11GeometryShader* gs_terrain;
|
||||
static ID3D11ComputeShader* cs_stone;
|
||||
static ID3D11VertexShader* vs_Sun;
|
||||
static ID3D11PixelShader* ps_Sun;
|
||||
static ID3D11ComputeShader* cs_Postprocess;
|
||||
static ID3D11VertexShader* vs_Raymarching;
|
||||
static ID3D11PixelShader* ps_Raymarching;
|
||||
static ID3D11ComputeShader* cs_Ssao;
|
||||
static ID3D11VertexShader* vs_ParticlesFlock;
|
||||
static ID3D11GeometryShader* gs_Particles;
|
||||
static ID3D11PixelShader* ps_Particles;
|
||||
static ID3D11ComputeShader* cs_Noise3d;
|
||||
static ID3D11ComputeShader* cs_VolumetricFog;
|
||||
|
||||
#pragma data_seg(".meshInputLayoutDesc")
|
||||
extern D3D11_INPUT_ELEMENT_DESC meshInputLayoutDesc[3];
|
||||
|
||||
#pragma code_seg(".FrameworkShadersCompile")
|
||||
INLINE void FrameworkShadersCompile()
|
||||
{
|
||||
CompileShader("cs_Sample", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &cs_Sample);
|
||||
CompileShader("cs_Copy", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &cs_Copy);
|
||||
CompileShader("csBlurH", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &csBlurH);
|
||||
CompileShader("csBlurV", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &csBlurV);
|
||||
CompileShader("csMerge", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &csMerge);
|
||||
CompileShader("csDT1", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &csDT1);
|
||||
CompileShader("csDT2", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &csDT2);
|
||||
CompileShader("cs_gridline", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &cs_gridline);
|
||||
CompileShader("vs_gridline", vs_5_0);
|
||||
device->CreateVertexShader(shaderCode, shaderSize, NULL, &vs_gridline);
|
||||
CompileShader("gs_gridline", gs_5_0);
|
||||
device->CreateGeometryShader(shaderCode, shaderSize, NULL, &gs_gridline);
|
||||
CompileShader("ps_gridline", ps_5_0);
|
||||
device->CreatePixelShader(shaderCode, shaderSize, NULL, &ps_gridline);
|
||||
CompileShader("mesh", vs_5_0);
|
||||
device->CreateVertexShader(shaderCode, shaderSize, NULL, &vs_mesh);
|
||||
device->CreateInputLayout(meshInputLayoutDesc, 3, shaderCode, shaderSize, &il_mesh);
|
||||
CompileShader("ps_mesh", ps_5_0);
|
||||
device->CreatePixelShader(shaderCode, shaderSize, NULL, &ps_mesh);
|
||||
CompileShader("vs_terrain", vs_5_0);
|
||||
device->CreateVertexShader(shaderCode, shaderSize, NULL, &vs_terrain);
|
||||
CompileShader("gs_terrain", gs_5_0);
|
||||
device->CreateGeometryShader(shaderCode, shaderSize, NULL, &gs_terrain);
|
||||
CompileShader("cs_stone", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &cs_stone);
|
||||
CompileShader("vs_Sun", vs_5_0);
|
||||
device->CreateVertexShader(shaderCode, shaderSize, NULL, &vs_Sun);
|
||||
CompileShader("ps_Sun", ps_5_0);
|
||||
device->CreatePixelShader(shaderCode, shaderSize, NULL, &ps_Sun);
|
||||
CompileShader("cs_Postprocess", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &cs_Postprocess);
|
||||
CompileShader("vs_Raymarching", vs_5_0);
|
||||
device->CreateVertexShader(shaderCode, shaderSize, NULL, &vs_Raymarching);
|
||||
CompileShader("ps_Raymarching", ps_5_0);
|
||||
device->CreatePixelShader(shaderCode, shaderSize, NULL, &ps_Raymarching);
|
||||
CompileShader("cs_Ssao", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &cs_Ssao);
|
||||
CompileShader("vs_ParticlesFlock", vs_5_0);
|
||||
device->CreateVertexShader(shaderCode, shaderSize, NULL, &vs_ParticlesFlock);
|
||||
CompileShader("gs_Particles", gs_5_0);
|
||||
device->CreateGeometryShader(shaderCode, shaderSize, NULL, &gs_Particles);
|
||||
CompileShader("ps_Particles", ps_5_0);
|
||||
device->CreatePixelShader(shaderCode, shaderSize, NULL, &ps_Particles);
|
||||
CompileShader("cs_Noise3d", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &cs_Noise3d);
|
||||
CompileShader("cs_VolumetricFog", cs_5_0);
|
||||
device->CreateComputeShader(shaderCode, shaderSize, NULL, &cs_VolumetricFog);
|
||||
}
|
||||
|
||||
struct ST
|
||||
{
|
||||
float cameraPosition_x;
|
||||
float cameraPosition_y;
|
||||
float cameraPosition_z;
|
||||
float cameraPosition_w;
|
||||
float cameraCenter_x;
|
||||
float cameraCenter_y;
|
||||
float cameraCenter_z;
|
||||
float cameraCenter_w;
|
||||
float cameraUp_x;
|
||||
float cameraUp_y;
|
||||
float cameraUp_z;
|
||||
float cameraUp_w;
|
||||
float lightDir_x;
|
||||
float lightDir_y;
|
||||
float lightDir_z;
|
||||
float lightDir_w;
|
||||
float fade;
|
||||
float fontFade;
|
||||
float scene;
|
||||
float fogAmount;
|
||||
float gridBorderColor_x;
|
||||
float gridBorderColor_y;
|
||||
float gridBorderColor_z;
|
||||
float gridBorderColor_w;
|
||||
float gridFaceColor_x;
|
||||
float gridFaceColor_y;
|
||||
float gridFaceColor_z;
|
||||
float gridFaceColor_w;
|
||||
float glowParams_x;
|
||||
float glowParams_y;
|
||||
float glowParams_z;
|
||||
float glowParams_w;
|
||||
float gridLineTime;
|
||||
float contrast;
|
||||
float _padding_x;
|
||||
float _padding_y;
|
||||
};
|
||||
|
||||
#define SYNC_TYPE_NAME ST
|
||||
#define SYNC_VAR_NAME s_ST
|
||||
|
||||
#pragma bss_seg(".syncbss")
|
||||
static SYNC_TYPE_NAME SYNC_VAR_NAME;
|
||||
|
||||
#pragma code_seg(".SyncInit")
|
||||
INLINE void SyncInit()
|
||||
{
|
||||
if (usync_init() < 0)
|
||||
return;
|
||||
|
||||
#ifndef SYNC_PLAYER
|
||||
usync_get_val(cameraPosition_x);
|
||||
usync_get_val(cameraPosition_y);
|
||||
usync_get_val(cameraPosition_z);
|
||||
usync_get_val(cameraPosition_w);
|
||||
usync_get_val(cameraCenter_x);
|
||||
usync_get_val(cameraCenter_y);
|
||||
usync_get_val(cameraCenter_z);
|
||||
usync_get_val(cameraCenter_w);
|
||||
usync_get_val(cameraUp_x);
|
||||
usync_get_val(cameraUp_y);
|
||||
usync_get_val(cameraUp_z);
|
||||
usync_get_val(cameraUp_w);
|
||||
usync_get_val(lightDir_x);
|
||||
usync_get_val(lightDir_y);
|
||||
usync_get_val(lightDir_z);
|
||||
usync_get_val(lightDir_w);
|
||||
usync_get_val(fade);
|
||||
usync_get_val(fontFade);
|
||||
usync_get_val(scene);
|
||||
usync_get_val(fogAmount);
|
||||
usync_get_val(gridBorderColor_x);
|
||||
usync_get_val(gridBorderColor_y);
|
||||
usync_get_val(gridBorderColor_z);
|
||||
usync_get_val(gridBorderColor_w);
|
||||
usync_get_val(gridFaceColor_x);
|
||||
usync_get_val(gridFaceColor_y);
|
||||
usync_get_val(gridFaceColor_z);
|
||||
usync_get_val(gridFaceColor_w);
|
||||
usync_get_val(glowParams_x);
|
||||
usync_get_val(glowParams_y);
|
||||
usync_get_val(glowParams_z);
|
||||
usync_get_val(glowParams_w);
|
||||
usync_get_val(gridLineTime);
|
||||
usync_get_val(contrast);
|
||||
usync_get_val(_padding_x);
|
||||
usync_get_val(_padding_y);
|
||||
usync_update(0.0f, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
INLINE void SyncUpdate(float t)
|
||||
{
|
||||
#ifndef SYNC_PLAYER
|
||||
usync_update(t * SYNC_ROWS_PER_SCENE, NULL);
|
||||
SYNC_VAR_NAME.cameraPosition_x = usync_get_val(cameraPosition_x);
|
||||
SYNC_VAR_NAME.cameraPosition_y = usync_get_val(cameraPosition_y);
|
||||
SYNC_VAR_NAME.cameraPosition_z = usync_get_val(cameraPosition_z);
|
||||
SYNC_VAR_NAME.cameraPosition_w = usync_get_val(cameraPosition_w);
|
||||
SYNC_VAR_NAME.cameraCenter_x = usync_get_val(cameraCenter_x);
|
||||
SYNC_VAR_NAME.cameraCenter_y = usync_get_val(cameraCenter_y);
|
||||
SYNC_VAR_NAME.cameraCenter_z = usync_get_val(cameraCenter_z);
|
||||
SYNC_VAR_NAME.cameraCenter_w = usync_get_val(cameraCenter_w);
|
||||
SYNC_VAR_NAME.cameraUp_x = usync_get_val(cameraUp_x);
|
||||
SYNC_VAR_NAME.cameraUp_y = usync_get_val(cameraUp_y);
|
||||
SYNC_VAR_NAME.cameraUp_z = usync_get_val(cameraUp_z);
|
||||
SYNC_VAR_NAME.cameraUp_w = usync_get_val(cameraUp_w);
|
||||
SYNC_VAR_NAME.lightDir_x = usync_get_val(lightDir_x);
|
||||
SYNC_VAR_NAME.lightDir_y = usync_get_val(lightDir_y);
|
||||
SYNC_VAR_NAME.lightDir_z = usync_get_val(lightDir_z);
|
||||
SYNC_VAR_NAME.lightDir_w = usync_get_val(lightDir_w);
|
||||
SYNC_VAR_NAME.fade = usync_get_val(fade);
|
||||
SYNC_VAR_NAME.fontFade = usync_get_val(fontFade);
|
||||
SYNC_VAR_NAME.scene = usync_get_val(scene);
|
||||
SYNC_VAR_NAME.fogAmount = usync_get_val(fogAmount);
|
||||
SYNC_VAR_NAME.gridBorderColor_x = usync_get_val(gridBorderColor_x);
|
||||
SYNC_VAR_NAME.gridBorderColor_y = usync_get_val(gridBorderColor_y);
|
||||
SYNC_VAR_NAME.gridBorderColor_z = usync_get_val(gridBorderColor_z);
|
||||
SYNC_VAR_NAME.gridBorderColor_w = usync_get_val(gridBorderColor_w);
|
||||
SYNC_VAR_NAME.gridFaceColor_x = usync_get_val(gridFaceColor_x);
|
||||
SYNC_VAR_NAME.gridFaceColor_y = usync_get_val(gridFaceColor_y);
|
||||
SYNC_VAR_NAME.gridFaceColor_z = usync_get_val(gridFaceColor_z);
|
||||
SYNC_VAR_NAME.gridFaceColor_w = usync_get_val(gridFaceColor_w);
|
||||
SYNC_VAR_NAME.glowParams_x = usync_get_val(glowParams_x);
|
||||
SYNC_VAR_NAME.glowParams_y = usync_get_val(glowParams_y);
|
||||
SYNC_VAR_NAME.glowParams_z = usync_get_val(glowParams_z);
|
||||
SYNC_VAR_NAME.glowParams_w = usync_get_val(glowParams_w);
|
||||
SYNC_VAR_NAME.gridLineTime = usync_get_val(gridLineTime);
|
||||
SYNC_VAR_NAME.contrast = usync_get_val(contrast);
|
||||
SYNC_VAR_NAME._padding_x = usync_get_val(_padding_x);
|
||||
SYNC_VAR_NAME._padding_y = usync_get_val(_padding_y);
|
||||
#else
|
||||
usync_update(t * SYNC_ROWS_PER_SCENE, (float*)&SYNC_VAR_NAME);
|
||||
#endif
|
||||
}
|
||||
|
||||
80
nordlicht2015-intro/src/intro/framework/sound.h
Normal file
80
nordlicht2015-intro/src/intro/framework/sound.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#pragma once
|
||||
|
||||
#define SOUND_TICKS_PER_SCENE 16
|
||||
#define SYNC_ROWS_PER_SCENE 4
|
||||
|
||||
#include <mmsystem.h>
|
||||
#include <mmreg.h>
|
||||
|
||||
#pragma bss_seg(".audio_bss")
|
||||
#ifdef AUTHORING
|
||||
static SAMPLE_TYPE* soundBuffer;
|
||||
#else
|
||||
static SAMPLE_TYPE soundBuffer[MAX_SAMPLES * 2];
|
||||
#endif
|
||||
static HWAVEOUT hWaveOut;
|
||||
|
||||
#pragma data_seg(".wavehdr")
|
||||
#ifndef RELEASE
|
||||
WAVEHDR WaveHDR =
|
||||
{
|
||||
(LPSTR)soundBuffer,
|
||||
MAX_SAMPLES*sizeof(SAMPLE_TYPE)* 2,
|
||||
0, 0, 0, 0, 0, 0
|
||||
};
|
||||
#else
|
||||
WAVEHDR WaveHDR =
|
||||
{
|
||||
(LPSTR)soundBuffer,
|
||||
MAX_SAMPLES*sizeof(SAMPLE_TYPE) * 2,
|
||||
0, 0, WHDR_PREPARED, 0, 0, 0
|
||||
};
|
||||
#endif
|
||||
|
||||
#pragma data_seg(".wavefmt")
|
||||
WAVEFORMATEX WaveFMT =
|
||||
{
|
||||
#ifdef FLOAT_32BIT
|
||||
WAVE_FORMAT_IEEE_FLOAT,
|
||||
#else
|
||||
WAVE_FORMAT_PCM,
|
||||
#endif
|
||||
2, // channels
|
||||
SAMPLE_RATE, // samples per sec
|
||||
SAMPLE_RATE*sizeof(SAMPLE_TYPE)* 2, // bytes per sec
|
||||
sizeof(SAMPLE_TYPE)* 2, // block alignment;
|
||||
sizeof(SAMPLE_TYPE)* 8, // bits per sample
|
||||
0 // extension not needed
|
||||
};
|
||||
|
||||
#pragma data_seg(".mmtime")
|
||||
static MMTIME mmtime =
|
||||
{
|
||||
TIME_SAMPLES
|
||||
};
|
||||
|
||||
INLINE float SoundGetIntroPosition()
|
||||
{
|
||||
waveOutGetPosition(hWaveOut, &mmtime, sizeof(MMTIME));
|
||||
return mmtime.u.sample / (float)(SAMPLES_PER_TICK * SOUND_TICKS_PER_SCENE);
|
||||
}
|
||||
|
||||
#pragma code_seg(".initsnd")
|
||||
INLINE void SoundInit()
|
||||
{
|
||||
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)_4klang_render, soundBuffer, 0, 0);
|
||||
}
|
||||
|
||||
#pragma code_seg(".playsnd")
|
||||
INLINE void SoundPlay()
|
||||
{
|
||||
#ifndef VIDEO
|
||||
::Sleep(1024);// give the 4klang render call some time
|
||||
|
||||
waveOutOpen(&hWaveOut, -1, &WaveFMT, 0, 0, 0);
|
||||
#ifndef RELEASE
|
||||
waveOutPrepareHeader(hWaveOut, &WaveHDR, 0x20);
|
||||
#endif
|
||||
waveOutWrite(hWaveOut, &WaveHDR, 0x20);
|
||||
#endif
|
||||
}
|
||||
899
nordlicht2015-intro/src/intro/framework/sync-data.h
Normal file
899
nordlicht2015-intro/src/intro/framework/sync-data.h
Normal file
@@ -0,0 +1,899 @@
|
||||
#ifndef SYNC_DATA_H
|
||||
#define SYNC_DATA_H
|
||||
|
||||
enum sync_tracks {
|
||||
SYNC_TRACK_cameraPosition_x = 0,
|
||||
SYNC_TRACK_cameraPosition_y = 1,
|
||||
SYNC_TRACK_cameraPosition_z = 2,
|
||||
SYNC_TRACK_cameraPosition_w = 3,
|
||||
SYNC_TRACK_cameraCenter_x = 4,
|
||||
SYNC_TRACK_cameraCenter_y = 5,
|
||||
SYNC_TRACK_cameraCenter_z = 6,
|
||||
SYNC_TRACK_cameraCenter_w = 7,
|
||||
SYNC_TRACK_cameraUp_x = 8,
|
||||
SYNC_TRACK_cameraUp_y = 9,
|
||||
SYNC_TRACK_cameraUp_z = 10,
|
||||
SYNC_TRACK_cameraUp_w = 11,
|
||||
SYNC_TRACK_lightDir_x = 12,
|
||||
SYNC_TRACK_lightDir_y = 13,
|
||||
SYNC_TRACK_lightDir_z = 14,
|
||||
SYNC_TRACK_lightDir_w = 15,
|
||||
SYNC_TRACK_fade = 16,
|
||||
SYNC_TRACK_fontFade = 17,
|
||||
SYNC_TRACK_scene = 18,
|
||||
SYNC_TRACK_fogAmount = 19,
|
||||
SYNC_TRACK_gridBorderColor_x = 20,
|
||||
SYNC_TRACK_gridBorderColor_y = 21,
|
||||
SYNC_TRACK_gridBorderColor_z = 22,
|
||||
SYNC_TRACK_gridBorderColor_w = 23,
|
||||
SYNC_TRACK_gridFaceColor_x = 24,
|
||||
SYNC_TRACK_gridFaceColor_y = 25,
|
||||
SYNC_TRACK_gridFaceColor_z = 26,
|
||||
SYNC_TRACK_gridFaceColor_w = 27,
|
||||
SYNC_TRACK_glowParams_x = 28,
|
||||
SYNC_TRACK_glowParams_y = 29,
|
||||
SYNC_TRACK_glowParams_z = 30,
|
||||
SYNC_TRACK_glowParams_w = 31,
|
||||
SYNC_TRACK_gridLineTime = 32,
|
||||
SYNC_TRACK_contrast = 33,
|
||||
SYNC_TRACK__padding_x = 34,
|
||||
SYNC_TRACK__padding_y = 35,
|
||||
SYNC_TRACK_COUNT = 36
|
||||
};
|
||||
|
||||
static const unsigned short sync_data_offset[SYNC_TRACK_COUNT] = {
|
||||
0, /* track: cameraPosition_x */
|
||||
21, /* track: cameraPosition_y */
|
||||
39, /* track: cameraPosition_z */
|
||||
58, /* track: cameraPosition_w */
|
||||
60, /* track: cameraCenter_x */
|
||||
73, /* track: cameraCenter_y */
|
||||
90, /* track: cameraCenter_z */
|
||||
106, /* track: cameraCenter_w */
|
||||
108, /* track: cameraUp_x */
|
||||
115, /* track: cameraUp_y */
|
||||
120, /* track: cameraUp_z */
|
||||
125, /* track: cameraUp_w */
|
||||
126, /* track: lightDir_x */
|
||||
128, /* track: lightDir_y */
|
||||
130, /* track: lightDir_z */
|
||||
132, /* track: lightDir_w */
|
||||
132, /* track: fade */
|
||||
155, /* track: fontFade */
|
||||
159, /* track: scene */
|
||||
164, /* track: fogAmount */
|
||||
167, /* track: gridBorderColor_x */
|
||||
171, /* track: gridBorderColor_y */
|
||||
175, /* track: gridBorderColor_z */
|
||||
179, /* track: gridBorderColor_w */
|
||||
179, /* track: gridFaceColor_x */
|
||||
182, /* track: gridFaceColor_y */
|
||||
185, /* track: gridFaceColor_z */
|
||||
188, /* track: gridFaceColor_w */
|
||||
188, /* track: glowParams_x */
|
||||
194, /* track: glowParams_y */
|
||||
198, /* track: glowParams_z */
|
||||
204, /* track: glowParams_w */
|
||||
211, /* track: gridLineTime */
|
||||
215, /* track: contrast */
|
||||
220, /* track: _padding_x */
|
||||
220, /* track: _padding_y */
|
||||
};
|
||||
|
||||
static const unsigned char sync_data_count[SYNC_TRACK_COUNT] = {
|
||||
21, /* track: cameraPosition_x */
|
||||
18, /* track: cameraPosition_y */
|
||||
19, /* track: cameraPosition_z */
|
||||
2, /* track: cameraPosition_w */
|
||||
13, /* track: cameraCenter_x */
|
||||
17, /* track: cameraCenter_y */
|
||||
16, /* track: cameraCenter_z */
|
||||
2, /* track: cameraCenter_w */
|
||||
7, /* track: cameraUp_x */
|
||||
5, /* track: cameraUp_y */
|
||||
5, /* track: cameraUp_z */
|
||||
1, /* track: cameraUp_w */
|
||||
2, /* track: lightDir_x */
|
||||
2, /* track: lightDir_y */
|
||||
2, /* track: lightDir_z */
|
||||
0, /* track: lightDir_w */
|
||||
23, /* track: fade */
|
||||
4, /* track: fontFade */
|
||||
5, /* track: scene */
|
||||
3, /* track: fogAmount */
|
||||
4, /* track: gridBorderColor_x */
|
||||
4, /* track: gridBorderColor_y */
|
||||
4, /* track: gridBorderColor_z */
|
||||
0, /* track: gridBorderColor_w */
|
||||
3, /* track: gridFaceColor_x */
|
||||
3, /* track: gridFaceColor_y */
|
||||
3, /* track: gridFaceColor_z */
|
||||
0, /* track: gridFaceColor_w */
|
||||
6, /* track: glowParams_x */
|
||||
4, /* track: glowParams_y */
|
||||
6, /* track: glowParams_z */
|
||||
7, /* track: glowParams_w */
|
||||
4, /* track: gridLineTime */
|
||||
5, /* track: contrast */
|
||||
0, /* track: _padding_x */
|
||||
0, /* track: _padding_y */
|
||||
};
|
||||
|
||||
static const unsigned short sync_data_rows[] = {
|
||||
/* track: cameraPosition_x */
|
||||
0,
|
||||
64,
|
||||
80,
|
||||
95,
|
||||
96,
|
||||
104,
|
||||
120,
|
||||
127,
|
||||
128,
|
||||
144,
|
||||
159,
|
||||
160,
|
||||
176,
|
||||
191,
|
||||
192,
|
||||
200,
|
||||
216,
|
||||
224,
|
||||
232,
|
||||
248,
|
||||
256,
|
||||
/* track: cameraPosition_y */
|
||||
0,
|
||||
24,
|
||||
32,
|
||||
64,
|
||||
96,
|
||||
112,
|
||||
127,
|
||||
128,
|
||||
160,
|
||||
168,
|
||||
191,
|
||||
192,
|
||||
212,
|
||||
216,
|
||||
224,
|
||||
232,
|
||||
248,
|
||||
256,
|
||||
/* track: cameraPosition_z */
|
||||
0,
|
||||
32,
|
||||
56,
|
||||
64,
|
||||
80,
|
||||
95,
|
||||
96,
|
||||
127,
|
||||
128,
|
||||
159,
|
||||
160,
|
||||
168,
|
||||
191,
|
||||
192,
|
||||
208,
|
||||
232,
|
||||
240,
|
||||
256,
|
||||
271,
|
||||
/* track: cameraPosition_w */
|
||||
0,
|
||||
96,
|
||||
/* track: cameraCenter_x */
|
||||
0,
|
||||
96,
|
||||
128,
|
||||
160,
|
||||
192,
|
||||
204,
|
||||
212,
|
||||
216,
|
||||
224,
|
||||
232,
|
||||
248,
|
||||
256,
|
||||
271,
|
||||
/* track: cameraCenter_y */
|
||||
0,
|
||||
64,
|
||||
96,
|
||||
112,
|
||||
127,
|
||||
128,
|
||||
159,
|
||||
160,
|
||||
168,
|
||||
191,
|
||||
192,
|
||||
212,
|
||||
216,
|
||||
224,
|
||||
240,
|
||||
248,
|
||||
271,
|
||||
/* track: cameraCenter_z */
|
||||
0,
|
||||
32,
|
||||
56,
|
||||
64,
|
||||
96,
|
||||
127,
|
||||
128,
|
||||
160,
|
||||
168,
|
||||
192,
|
||||
208,
|
||||
216,
|
||||
232,
|
||||
244,
|
||||
252,
|
||||
271,
|
||||
/* track: cameraCenter_w */
|
||||
0,
|
||||
96,
|
||||
/* track: cameraUp_x */
|
||||
0,
|
||||
96,
|
||||
112,
|
||||
120,
|
||||
128,
|
||||
160,
|
||||
192,
|
||||
/* track: cameraUp_y */
|
||||
0,
|
||||
96,
|
||||
128,
|
||||
160,
|
||||
192,
|
||||
/* track: cameraUp_z */
|
||||
0,
|
||||
96,
|
||||
128,
|
||||
160,
|
||||
192,
|
||||
/* track: cameraUp_w */
|
||||
96,
|
||||
/* track: lightDir_x */
|
||||
96,
|
||||
192,
|
||||
/* track: lightDir_y */
|
||||
96,
|
||||
192,
|
||||
/* track: lightDir_z */
|
||||
96,
|
||||
192,
|
||||
/* track: lightDir_w */
|
||||
/* track: fade */
|
||||
0,
|
||||
8,
|
||||
62,
|
||||
63,
|
||||
64,
|
||||
65,
|
||||
88,
|
||||
96,
|
||||
104,
|
||||
125,
|
||||
127,
|
||||
128,
|
||||
136,
|
||||
158,
|
||||
159,
|
||||
160,
|
||||
161,
|
||||
190,
|
||||
191,
|
||||
192,
|
||||
194,
|
||||
272,
|
||||
275,
|
||||
/* track: fontFade */
|
||||
0,
|
||||
8,
|
||||
47,
|
||||
96,
|
||||
/* track: scene */
|
||||
0,
|
||||
96,
|
||||
128,
|
||||
160,
|
||||
192,
|
||||
/* track: fogAmount */
|
||||
0,
|
||||
96,
|
||||
128,
|
||||
/* track: gridBorderColor_x */
|
||||
0,
|
||||
32,
|
||||
63,
|
||||
64,
|
||||
/* track: gridBorderColor_y */
|
||||
0,
|
||||
32,
|
||||
63,
|
||||
64,
|
||||
/* track: gridBorderColor_z */
|
||||
0,
|
||||
32,
|
||||
63,
|
||||
64,
|
||||
/* track: gridBorderColor_w */
|
||||
/* track: gridFaceColor_x */
|
||||
0,
|
||||
63,
|
||||
64,
|
||||
/* track: gridFaceColor_y */
|
||||
0,
|
||||
63,
|
||||
64,
|
||||
/* track: gridFaceColor_z */
|
||||
0,
|
||||
63,
|
||||
64,
|
||||
/* track: gridFaceColor_w */
|
||||
/* track: glowParams_x */
|
||||
0,
|
||||
29,
|
||||
32,
|
||||
64,
|
||||
96,
|
||||
192,
|
||||
/* track: glowParams_y */
|
||||
0,
|
||||
64,
|
||||
96,
|
||||
192,
|
||||
/* track: glowParams_z */
|
||||
0,
|
||||
29,
|
||||
32,
|
||||
64,
|
||||
96,
|
||||
192,
|
||||
/* track: glowParams_w */
|
||||
0,
|
||||
29,
|
||||
32,
|
||||
40,
|
||||
64,
|
||||
96,
|
||||
192,
|
||||
/* track: gridLineTime */
|
||||
0,
|
||||
63,
|
||||
64,
|
||||
96,
|
||||
/* track: contrast */
|
||||
0,
|
||||
96,
|
||||
128,
|
||||
160,
|
||||
192,
|
||||
/* track: _padding_x */
|
||||
/* track: _padding_y */
|
||||
};
|
||||
|
||||
static const float sync_data_values[] = {
|
||||
/* track: cameraPosition_x */
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
5.000000f,
|
||||
0.000000f,
|
||||
-0.500000f,
|
||||
0.400000f,
|
||||
-0.200000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
-3.000000f,
|
||||
3.000000f,
|
||||
-2.000000f,
|
||||
-2.000000f,
|
||||
3.000000f,
|
||||
-1.000000f,
|
||||
-1.000000f,
|
||||
-2.000000f,
|
||||
-2.000000f,
|
||||
5.000000f,
|
||||
8.000000f,
|
||||
/* track: cameraPosition_y */
|
||||
2.000000f,
|
||||
2.000000f,
|
||||
10.000000f,
|
||||
1.500000f,
|
||||
1.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
5.000000f,
|
||||
0.500000f,
|
||||
1.000000f,
|
||||
1.000000f,
|
||||
1.000000f,
|
||||
2.000000f,
|
||||
3.000000f,
|
||||
1.000000f,
|
||||
1.000000f,
|
||||
2.000000f,
|
||||
/* track: cameraPosition_z */
|
||||
5.000000f,
|
||||
5.000000f,
|
||||
50.000000f,
|
||||
5.000000f,
|
||||
0.000000f,
|
||||
-5.000000f,
|
||||
8.000000f,
|
||||
-3.000000f,
|
||||
0.000000f,
|
||||
-10.000000f,
|
||||
5.000000f,
|
||||
5.000000f,
|
||||
-5.500000f,
|
||||
-4.000000f,
|
||||
-5.000000f,
|
||||
-12.000000f,
|
||||
-11.500000f,
|
||||
-14.000000f,
|
||||
-13.000000f,
|
||||
/* track: cameraPosition_w */
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
/* track: cameraCenter_x */
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
-3.000000f,
|
||||
3.000000f,
|
||||
-3.000000f,
|
||||
-3.000000f,
|
||||
3.000000f,
|
||||
9.000000f,
|
||||
0.000000f,
|
||||
-5.000000f,
|
||||
10.000000f,
|
||||
/* track: cameraCenter_y */
|
||||
-1.000000f,
|
||||
-5.000000f,
|
||||
1.000000f,
|
||||
1.000000f,
|
||||
0.000000f,
|
||||
5.000000f,
|
||||
3.000000f,
|
||||
0.000000f,
|
||||
0.500000f,
|
||||
0.000000f,
|
||||
0.500000f,
|
||||
0.500000f,
|
||||
1.500000f,
|
||||
0.500000f,
|
||||
0.500000f,
|
||||
6.000000f,
|
||||
0.000000f,
|
||||
/* track: cameraCenter_z */
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
40.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
-10.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
-4.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
-5.000000f,
|
||||
-10.000000f,
|
||||
10.000000f,
|
||||
-5.000000f,
|
||||
-20.000000f,
|
||||
/* track: cameraCenter_w */
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
/* track: cameraUp_x */
|
||||
0.000000f,
|
||||
0.100000f,
|
||||
-0.100000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
/* track: cameraUp_y */
|
||||
1.000000f,
|
||||
1.000000f,
|
||||
0.000000f,
|
||||
1.000000f,
|
||||
1.000000f,
|
||||
/* track: cameraUp_z */
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
-1.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
/* track: cameraUp_w */
|
||||
0.000000f,
|
||||
/* track: lightDir_x */
|
||||
-0.500000f,
|
||||
0.500000f,
|
||||
/* track: lightDir_y */
|
||||
0.500000f,
|
||||
1.000000f,
|
||||
/* track: lightDir_z */
|
||||
1.000000f,
|
||||
-1.000000f,
|
||||
/* track: lightDir_w */
|
||||
/* track: fade */
|
||||
0.000000f,
|
||||
0.500000f,
|
||||
0.500000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.500000f,
|
||||
0.500000f,
|
||||
0.000000f,
|
||||
0.500000f,
|
||||
0.500000f,
|
||||
1.000000f,
|
||||
1.000000f,
|
||||
0.500000f,
|
||||
0.500000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.500000f,
|
||||
0.500000f,
|
||||
1.000000f,
|
||||
1.000000f,
|
||||
0.500000f,
|
||||
0.500000f,
|
||||
0.000000f,
|
||||
/* track: fontFade */
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
2.000000f,
|
||||
0.000000f,
|
||||
/* track: scene */
|
||||
0.000000f,
|
||||
1.000000f,
|
||||
2.000000f,
|
||||
3.000000f,
|
||||
4.000000f,
|
||||
/* track: fogAmount */
|
||||
0.000000f,
|
||||
1.000000f,
|
||||
1.000000f,
|
||||
/* track: gridBorderColor_x */
|
||||
0.000000f,
|
||||
2.000000f,
|
||||
2.000000f,
|
||||
0.100000f,
|
||||
/* track: gridBorderColor_y */
|
||||
0.100000f,
|
||||
0.600000f,
|
||||
0.600000f,
|
||||
0.100000f,
|
||||
/* track: gridBorderColor_z */
|
||||
1.000000f,
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.100000f,
|
||||
/* track: gridBorderColor_w */
|
||||
/* track: gridFaceColor_x */
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.220000f,
|
||||
/* track: gridFaceColor_y */
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.210000f,
|
||||
/* track: gridFaceColor_z */
|
||||
0.000000f,
|
||||
0.000000f,
|
||||
0.200000f,
|
||||
/* track: gridFaceColor_w */
|
||||
/* track: glowParams_x */
|
||||
0.100000f,
|
||||
0.100000f,
|
||||
0.200000f,
|
||||
0.200000f,
|
||||
0.500000f,
|
||||
0.400000f,
|
||||
/* track: glowParams_y */
|
||||
0.600000f,
|
||||
0.600000f,
|
||||
0.400000f,
|
||||
0.100000f,
|
||||
/* track: glowParams_z */
|
||||
0.600000f,
|
||||
0.600000f,
|
||||
1.000000f,
|
||||
0.500000f,
|
||||
0.200000f,
|
||||
0.100000f,
|
||||
/* track: glowParams_w */
|
||||
0.600000f,
|
||||
0.600000f,
|
||||
4.000000f,
|
||||
2.000000f,
|
||||
2.000000f,
|
||||
0.200000f,
|
||||
0.500000f,
|
||||
/* track: gridLineTime */
|
||||
0.000000f,
|
||||
4.000000f,
|
||||
0.000000f,
|
||||
2.000000f,
|
||||
/* track: contrast */
|
||||
1.000000f,
|
||||
2.000000f,
|
||||
1.000000f,
|
||||
1.000000f,
|
||||
1.500000f,
|
||||
/* track: _padding_x */
|
||||
/* track: _padding_y */
|
||||
};
|
||||
|
||||
static const unsigned char sync_data_type[] = {
|
||||
/* track: cameraPosition_x */
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
/* track: cameraPosition_y */
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
3,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
/* track: cameraPosition_z */
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
3,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
/* track: cameraPosition_w */
|
||||
0,
|
||||
0,
|
||||
/* track: cameraCenter_x */
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
/* track: cameraCenter_y */
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
/* track: cameraCenter_z */
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
/* track: cameraCenter_w */
|
||||
0,
|
||||
0,
|
||||
/* track: cameraUp_x */
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
/* track: cameraUp_y */
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
/* track: cameraUp_z */
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
/* track: cameraUp_w */
|
||||
0,
|
||||
/* track: lightDir_x */
|
||||
0,
|
||||
0,
|
||||
/* track: lightDir_y */
|
||||
0,
|
||||
0,
|
||||
/* track: lightDir_z */
|
||||
0,
|
||||
0,
|
||||
/* track: lightDir_w */
|
||||
/* track: fade */
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/* track: fontFade */
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
/* track: scene */
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
/* track: fogAmount */
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
/* track: gridBorderColor_x */
|
||||
3,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/* track: gridBorderColor_y */
|
||||
3,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/* track: gridBorderColor_z */
|
||||
3,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/* track: gridBorderColor_w */
|
||||
/* track: gridFaceColor_x */
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/* track: gridFaceColor_y */
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/* track: gridFaceColor_z */
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/* track: gridFaceColor_w */
|
||||
/* track: glowParams_x */
|
||||
0,
|
||||
3,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
/* track: glowParams_y */
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
/* track: glowParams_z */
|
||||
0,
|
||||
3,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
/* track: glowParams_w */
|
||||
0,
|
||||
3,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
/* track: gridLineTime */
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
/* track: contrast */
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
/* track: _padding_x */
|
||||
/* track: _padding_y */
|
||||
};
|
||||
|
||||
#endif /* !defined(SYNC_DATA_H) */
|
||||
123
nordlicht2015-intro/src/intro/framework/sync/base.h
Normal file
123
nordlicht2015-intro/src/intro/framework/sync/base.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/* Copyright (C) 2007-2010 Erik Faye-Lund and Egbert Teeselink
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
|
||||
#ifndef SYNC_BASE_H
|
||||
#define SYNC_BASE_H
|
||||
|
||||
/* configure inline keyword */
|
||||
#if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) && !defined(__cplusplus)
|
||||
#if defined(_MSC_VER) || defined(__GNUC__) || defined(__SASC)
|
||||
#define inline __inline
|
||||
#else
|
||||
/* compiler does not support inline, make function static instead */
|
||||
#define inline static
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* configure lacking CRT features */
|
||||
#ifdef _MSC_VER
|
||||
#define strdup _strdup
|
||||
#define snprintf _snprintf
|
||||
/* int is 32-bit for both x86 and x64 */
|
||||
typedef unsigned int uint32_t;
|
||||
#define UINT32_MAX UINT_MAX
|
||||
#elif defined(__GNUC__)
|
||||
#include <stdint.h>
|
||||
#elif defined(M68000)
|
||||
typedef unsigned int uint32_t;
|
||||
#endif
|
||||
|
||||
/* configure socket-stack */
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <limits.h>
|
||||
#include <Shlwapi.h>
|
||||
#elif defined(USE_AMITCP)
|
||||
#include <sys/socket.h>
|
||||
#include <proto/exec.h>
|
||||
#include <proto/socket.h>
|
||||
#include <netdb.h>
|
||||
#define SOCKET int
|
||||
#define INVALID_SOCKET -1
|
||||
#define select(n,r,w,e,t) WaitSelect(n,r,w,e,t,0)
|
||||
#define closesocket(x) CloseSocket(x)
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#define SOCKET int
|
||||
#define INVALID_SOCKET -1
|
||||
#define closesocket(x) close(x)
|
||||
#endif
|
||||
|
||||
#define CLIENT_GREET "hello, synctracker!"
|
||||
#define SERVER_GREET "hello, demo!"
|
||||
|
||||
enum {
|
||||
SET_KEY = 0,
|
||||
DELETE_KEY = 1,
|
||||
GET_TRACK = 2,
|
||||
SET_ROW = 3,
|
||||
PAUSE = 4,
|
||||
SAVE_TRACKS = 5
|
||||
};
|
||||
|
||||
static inline int socket_poll(SOCKET socket)
|
||||
{
|
||||
struct timeval to = { 0, 0 };
|
||||
fd_set fds;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4127)
|
||||
#endif
|
||||
FD_SET(socket, &fds);
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
return select((int)socket + 1, &fds, NULL, NULL, &to) > 0;
|
||||
}
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
static inline int xsend(SOCKET s, const void *buf, size_t len, int flags)
|
||||
{
|
||||
#ifdef WIN32
|
||||
assert(len <= INT_MAX);
|
||||
return send(s, (const char *)buf, (int)len, flags) != (int)len;
|
||||
#else
|
||||
return send(s, (const char *)buf, len, flags) != len;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int xrecv(SOCKET s, void *buf, size_t len, int flags)
|
||||
{
|
||||
#ifdef WIN32
|
||||
assert(len <= INT_MAX);
|
||||
return recv(s, (char *)buf, (int)len, flags) != (int)len;
|
||||
#else
|
||||
return recv(s, (char *)buf, len, flags) != len;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef NEED_STRDUP
|
||||
static inline char *rocket_strdup(const char *str)
|
||||
{
|
||||
char *ret = malloc(strlen(str) + 1);
|
||||
if (ret)
|
||||
strcpy(ret, str);
|
||||
return ret;
|
||||
}
|
||||
#define strdup rocket_strdup
|
||||
#endif
|
||||
|
||||
#endif /* SYNC_BASE_H */
|
||||
33
nordlicht2015-intro/src/intro/framework/sync/data.cpp
Normal file
33
nordlicht2015-intro/src/intro/framework/sync/data.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2007-2008 Erik Faye-Lund and Egbert Teeselink
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
|
||||
#include "data.h"
|
||||
|
||||
void sync_data_deinit(struct sync_data *d)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)d->num_tracks; ++i) {
|
||||
free(d->tracks[i]->name);
|
||||
free(d->tracks[i]->keys);
|
||||
free(d->tracks[i]);
|
||||
}
|
||||
free(d->tracks);
|
||||
}
|
||||
|
||||
int sync_create_track(struct sync_data *d, const char *name)
|
||||
{
|
||||
struct sync_track *t;
|
||||
assert(sync_find_track(d, name) < 0);
|
||||
|
||||
t = (sync_track*)malloc(sizeof(*t));
|
||||
t->name = strdup(name);
|
||||
t->keys = NULL;
|
||||
t->num_keys = 0;
|
||||
|
||||
d->num_tracks++;
|
||||
d->tracks = (sync_track**)realloc(d->tracks, sizeof(d->tracks[0]) * d->num_tracks);
|
||||
d->tracks[d->num_tracks - 1] = t;
|
||||
|
||||
return (int)d->num_tracks - 1;
|
||||
}
|
||||
28
nordlicht2015-intro/src/intro/framework/sync/data.h
Normal file
28
nordlicht2015-intro/src/intro/framework/sync/data.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2007-2010 Erik Faye-Lund and Egbert Teeselink
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
|
||||
#ifndef SYNC_DATA_H
|
||||
#define SYNC_DATA_H
|
||||
|
||||
#include "track.h"
|
||||
|
||||
struct sync_data {
|
||||
struct sync_track **tracks;
|
||||
size_t num_tracks;
|
||||
};
|
||||
|
||||
static inline int sync_find_track(const struct sync_data *data,
|
||||
const char *name)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)data->num_tracks; ++i)
|
||||
if (!strcmp(name, data->tracks[i]->name))
|
||||
return i;
|
||||
return -1; /* not found */
|
||||
}
|
||||
|
||||
void sync_data_deinit(struct sync_data *);
|
||||
int sync_create_track(struct sync_data *, const char *);
|
||||
|
||||
#endif /* SYNC_DATA_H */
|
||||
359
nordlicht2015-intro/src/intro/framework/sync/device.cpp
Normal file
359
nordlicht2015-intro/src/intro/framework/sync/device.cpp
Normal file
@@ -0,0 +1,359 @@
|
||||
/* Copyright (C) 2007-2008 Erik Faye-Lund and Egbert Teeselink
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
|
||||
#include "device.h"
|
||||
#include "sync.h"
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
static const char *sync_track_path(const char *base, const char *name)
|
||||
{
|
||||
static char temp[FILENAME_MAX];
|
||||
strncpy(temp, base, sizeof(temp) - 1);
|
||||
temp[sizeof(temp) - 1] = '\0';
|
||||
strncat(temp, "_", sizeof(temp) - 1);
|
||||
strncat(temp, name, sizeof(temp) - 1);
|
||||
strncat(temp, ".track", sizeof(temp) - 1);
|
||||
return temp;
|
||||
}
|
||||
|
||||
#ifndef SYNC_PLAYER
|
||||
|
||||
#ifdef USE_AMITCP
|
||||
static struct Library *socket_base = NULL;
|
||||
#endif
|
||||
|
||||
static SOCKET server_connect(const char *host, unsigned short nport)
|
||||
{
|
||||
struct hostent *he;
|
||||
struct sockaddr_in sa;
|
||||
char greet[128], **ap;
|
||||
SOCKET sock = INVALID_SOCKET;
|
||||
|
||||
#ifdef WIN32
|
||||
static int need_init = 1;
|
||||
if (need_init) {
|
||||
WSADATA wsa;
|
||||
if (WSAStartup(MAKEWORD(2, 0), &wsa))
|
||||
return INVALID_SOCKET;
|
||||
need_init = 0;
|
||||
}
|
||||
#elif defined(USE_AMITCP)
|
||||
if (!socket_base) {
|
||||
socket_base = OpenLibrary("bsdsocket.library", 4);
|
||||
if (!socket_base)
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
#endif
|
||||
|
||||
he = gethostbyname(host);
|
||||
if (!he)
|
||||
return INVALID_SOCKET;
|
||||
|
||||
for (ap = he->h_addr_list; *ap; ++ap) {
|
||||
sa.sin_family = he->h_addrtype;
|
||||
sa.sin_port = htons(nport);
|
||||
memcpy(&sa.sin_addr, *ap, he->h_length);
|
||||
|
||||
sock = socket(he->h_addrtype, SOCK_STREAM, 0);
|
||||
if (sock == INVALID_SOCKET)
|
||||
continue;
|
||||
|
||||
if (connect(sock, (struct sockaddr *)&sa, sizeof(sa)) >= 0)
|
||||
break;
|
||||
|
||||
closesocket(sock);
|
||||
sock = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
if (sock == INVALID_SOCKET)
|
||||
return INVALID_SOCKET;
|
||||
|
||||
if (xsend(sock, CLIENT_GREET, strlen(CLIENT_GREET), 0) ||
|
||||
xrecv(sock, greet, strlen(SERVER_GREET), 0))
|
||||
return INVALID_SOCKET;
|
||||
|
||||
if (!strncmp(SERVER_GREET, greet, strlen(SERVER_GREET)))
|
||||
return sock;
|
||||
|
||||
closesocket(sock);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void sync_set_io_cb(struct sync_device *d, struct sync_io_cb *cb)
|
||||
{
|
||||
d->io_cb.open = cb->open;
|
||||
d->io_cb.read = cb->read;
|
||||
d->io_cb.close = cb->close;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
struct sync_device *sync_create_device(const char *base)
|
||||
{
|
||||
struct sync_device *d = (sync_device*)malloc(sizeof(*d));
|
||||
if (!d)
|
||||
return NULL;
|
||||
|
||||
d->base = strdup(base);
|
||||
if (!d->base) {
|
||||
free(d);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
d->data.tracks = NULL;
|
||||
d->data.num_tracks = 0;
|
||||
|
||||
#ifndef SYNC_PLAYER
|
||||
d->row = -1;
|
||||
d->sock = INVALID_SOCKET;
|
||||
#else
|
||||
d->io_cb.open = (LPFNCBOPEN)fopen;
|
||||
d->io_cb.read = (LPFNCBREAD)fread;
|
||||
d->io_cb.close = (LPFNCBCLOSE)fclose;
|
||||
#endif
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
void sync_destroy_device(struct sync_device *d)
|
||||
{
|
||||
free(d->base);
|
||||
sync_data_deinit(&d->data);
|
||||
free(d);
|
||||
|
||||
#if defined(USE_AMITCP) && !defined(SYNC_PLAYER)
|
||||
if (socket_base) {
|
||||
CloseLibrary(socket_base);
|
||||
socket_base = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SYNC_PLAYER
|
||||
|
||||
static int get_track_data(struct sync_device *d, struct sync_track *t)
|
||||
{
|
||||
int i;
|
||||
void *fp = d->io_cb.open(sync_track_path(d->base, t->name), "rb");
|
||||
if (!fp)
|
||||
return -1;
|
||||
|
||||
d->io_cb.read(&t->num_keys, sizeof(size_t), 1, fp);
|
||||
t->keys = (track_key*)malloc(sizeof(struct track_key) * t->num_keys);
|
||||
if (!t->keys)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < (int)t->num_keys; ++i) {
|
||||
struct track_key *key = t->keys + i;
|
||||
char type;
|
||||
d->io_cb.read(&key->row, sizeof(int), 1, fp);
|
||||
d->io_cb.read(&key->value, sizeof(float), 1, fp);
|
||||
d->io_cb.read(&type, sizeof(char), 1, fp);
|
||||
key->type = (enum key_type)type;
|
||||
}
|
||||
|
||||
d->io_cb.close(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int save_track(const struct sync_track *t, const char *path)
|
||||
{
|
||||
int i;
|
||||
FILE *fp = fopen(path, "wb");
|
||||
if (!fp)
|
||||
return -1;
|
||||
|
||||
fwrite(&t->num_keys, sizeof(size_t), 1, fp);
|
||||
for (i = 0; i < (int)t->num_keys; ++i) {
|
||||
char type = (char)t->keys[i].type;
|
||||
fwrite(&t->keys[i].row, sizeof(int), 1, fp);
|
||||
fwrite(&t->keys[i].value, sizeof(float), 1, fp);
|
||||
fwrite(&type, sizeof(char), 1, fp);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sync_save_tracks(const struct sync_device *d)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < (int)d->data.num_tracks; ++i) {
|
||||
const struct sync_track *t = d->data.tracks[i];
|
||||
save_track(t, sync_track_path(d->base, t->name));
|
||||
}
|
||||
}
|
||||
|
||||
static int get_track_data(struct sync_device *d, struct sync_track *t)
|
||||
{
|
||||
unsigned char cmd = GET_TRACK;
|
||||
uint32_t name_len;
|
||||
|
||||
assert(strlen(t->name) <= UINT32_MAX);
|
||||
name_len = htonl((uint32_t)strlen(t->name));
|
||||
|
||||
/* send request data */
|
||||
if (xsend(d->sock, (char *)&cmd, 1, 0) ||
|
||||
xsend(d->sock, (char *)&name_len, sizeof(name_len), 0) ||
|
||||
xsend(d->sock, t->name, (int)strlen(t->name), 0))
|
||||
{
|
||||
closesocket(d->sock);
|
||||
d->sock = INVALID_SOCKET;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int handle_set_key_cmd(SOCKET sock, struct sync_data *data)
|
||||
{
|
||||
uint32_t track, row;
|
||||
union {
|
||||
float f;
|
||||
uint32_t i;
|
||||
} v;
|
||||
struct track_key key;
|
||||
unsigned char type;
|
||||
|
||||
if (xrecv(sock, (char *)&track, sizeof(track), 0) ||
|
||||
xrecv(sock, (char *)&row, sizeof(row), 0) ||
|
||||
xrecv(sock, (char *)&v.i, sizeof(v.i), 0) ||
|
||||
xrecv(sock, (char *)&type, 1, 0))
|
||||
return -1;
|
||||
|
||||
track = ntohl(track);
|
||||
v.i = ntohl(v.i);
|
||||
|
||||
key.row = ntohl(row);
|
||||
key.value = v.f;
|
||||
|
||||
assert(type < KEY_TYPE_COUNT);
|
||||
assert(track < data->num_tracks);
|
||||
key.type = (enum key_type)type;
|
||||
return sync_set_key(data->tracks[track], &key);
|
||||
}
|
||||
|
||||
static int handle_del_key_cmd(SOCKET sock, struct sync_data *data)
|
||||
{
|
||||
uint32_t track, row;
|
||||
|
||||
if (xrecv(sock, (char *)&track, sizeof(track), 0) ||
|
||||
xrecv(sock, (char *)&row, sizeof(row), 0))
|
||||
return -1;
|
||||
|
||||
track = ntohl(track);
|
||||
row = ntohl(row);
|
||||
|
||||
assert(track < data->num_tracks);
|
||||
return sync_del_key(data->tracks[track], row);
|
||||
}
|
||||
|
||||
int sync_connect(struct sync_device *d, const char *host, unsigned short port)
|
||||
{
|
||||
int i;
|
||||
if (d->sock != INVALID_SOCKET)
|
||||
closesocket(d->sock);
|
||||
|
||||
d->sock = server_connect(host, port);
|
||||
if (d->sock == INVALID_SOCKET)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < (int)d->data.num_tracks; ++i) {
|
||||
free(d->data.tracks[i]->keys);
|
||||
d->data.tracks[i]->keys = NULL;
|
||||
d->data.tracks[i]->num_keys = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)d->data.num_tracks; ++i) {
|
||||
if (get_track_data(d, d->data.tracks[i])) {
|
||||
closesocket(d->sock);
|
||||
d->sock = INVALID_SOCKET;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sync_update(struct sync_device *d, int row, struct sync_cb *cb,
|
||||
void *cb_param)
|
||||
{
|
||||
if (d->sock == INVALID_SOCKET)
|
||||
return -1;
|
||||
|
||||
/* look for new commands */
|
||||
while (socket_poll(d->sock)) {
|
||||
unsigned char cmd = 0, flag;
|
||||
uint32_t row;
|
||||
if (xrecv(d->sock, (char *)&cmd, 1, 0))
|
||||
goto sockerr;
|
||||
|
||||
switch (cmd) {
|
||||
case SET_KEY:
|
||||
if (handle_set_key_cmd(d->sock, &d->data))
|
||||
goto sockerr;
|
||||
break;
|
||||
case DELETE_KEY:
|
||||
if (handle_del_key_cmd(d->sock, &d->data))
|
||||
goto sockerr;
|
||||
break;
|
||||
case SET_ROW:
|
||||
if (xrecv(d->sock, (char *)&row, sizeof(row), 0))
|
||||
goto sockerr;
|
||||
if (cb && cb->set_row)
|
||||
cb->set_row(cb_param, ntohl(row));
|
||||
break;
|
||||
case PAUSE:
|
||||
if (xrecv(d->sock, (char *)&flag, 1, 0))
|
||||
goto sockerr;
|
||||
if (cb && cb->pause)
|
||||
cb->pause(cb_param, flag);
|
||||
break;
|
||||
case SAVE_TRACKS:
|
||||
sync_save_tracks(d);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "unknown cmd: %02x\n", cmd);
|
||||
goto sockerr;
|
||||
}
|
||||
}
|
||||
|
||||
if (cb && cb->is_playing && cb->is_playing(cb_param)) {
|
||||
if (d->row != row && d->sock != INVALID_SOCKET) {
|
||||
unsigned char cmd = SET_ROW;
|
||||
uint32_t nrow = htonl(row);
|
||||
if (xsend(d->sock, (char*)&cmd, 1, 0) ||
|
||||
xsend(d->sock, (char*)&nrow, sizeof(nrow), 0))
|
||||
goto sockerr;
|
||||
d->row = row;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
sockerr:
|
||||
closesocket(d->sock);
|
||||
d->sock = INVALID_SOCKET;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
const struct sync_track *sync_get_track(struct sync_device *d,
|
||||
const char *name)
|
||||
{
|
||||
struct sync_track *t;
|
||||
int idx = sync_find_track(&d->data, name);
|
||||
if (idx >= 0)
|
||||
return d->data.tracks[idx];
|
||||
|
||||
idx = sync_create_track(&d->data, name);
|
||||
t = d->data.tracks[idx];
|
||||
|
||||
get_track_data(d, t);
|
||||
return t;
|
||||
}
|
||||
23
nordlicht2015-intro/src/intro/framework/sync/device.h
Normal file
23
nordlicht2015-intro/src/intro/framework/sync/device.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/* Copyright (C) 2007-2008 Erik Faye-Lund and Egbert Teeselink
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
|
||||
#ifndef SYNC_DEVICE_H
|
||||
#define SYNC_DEVICE_H
|
||||
|
||||
#include "data.h"
|
||||
#include "sync.h"
|
||||
|
||||
struct sync_device {
|
||||
char *base;
|
||||
struct sync_data data;
|
||||
|
||||
#ifndef SYNC_PLAYER
|
||||
int row;
|
||||
SOCKET sock;
|
||||
#else
|
||||
struct sync_io_cb io_cb;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* SYNC_DEVICE_H */
|
||||
47
nordlicht2015-intro/src/intro/framework/sync/sync.h
Normal file
47
nordlicht2015-intro/src/intro/framework/sync/sync.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* Copyright (C) 2010 Erik Faye-Lund and Egbert Teeselink
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
|
||||
#ifndef SYNC_H
|
||||
#define SYNC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct sync_device;
|
||||
struct sync_track;
|
||||
|
||||
struct sync_device *sync_create_device(const char *);
|
||||
void sync_destroy_device(struct sync_device *);
|
||||
|
||||
#ifndef SYNC_PLAYER
|
||||
struct sync_cb {
|
||||
void (*pause)(void *, int);
|
||||
void (*set_row)(void *, int);
|
||||
int (*is_playing)(void *);
|
||||
};
|
||||
#define SYNC_DEFAULT_PORT 1338
|
||||
int sync_connect(struct sync_device *, const char *, unsigned short);
|
||||
int sync_update(struct sync_device *, int, struct sync_cb *, void *);
|
||||
void sync_save_tracks(const struct sync_device *);
|
||||
#else /* defined(SYNC_PLAYER) */
|
||||
typedef void *(*LPFNCBOPEN)(const char *filename, const char *mode);
|
||||
typedef size_t(*LPFNCBREAD)(void *ptr, size_t size, size_t nitems, void *stream);
|
||||
typedef int(*LPFNCBCLOSE)(void *stream);
|
||||
struct sync_io_cb {
|
||||
LPFNCBOPEN open;
|
||||
LPFNCBREAD read;
|
||||
LPFNCBCLOSE close;
|
||||
};
|
||||
void sync_set_io_cb(struct sync_device *d, struct sync_io_cb *cb);
|
||||
#endif /* defined(SYNC_PLAYER) */
|
||||
|
||||
const struct sync_track *sync_get_track(struct sync_device *, const char *);
|
||||
double sync_get_val(const struct sync_track *, double);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !defined(SYNC_H) */
|
||||
128
nordlicht2015-intro/src/intro/framework/sync/track.cpp
Normal file
128
nordlicht2015-intro/src/intro/framework/sync/track.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
/* Copyright (C) 2010 Erik Faye-Lund and Egbert Teeselink
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.141926
|
||||
#endif
|
||||
|
||||
#include "sync.h"
|
||||
#include "track.h"
|
||||
#include "base.h"
|
||||
|
||||
static double key_linear(const struct track_key k[2], double row)
|
||||
{
|
||||
double t = (row - k[0].row) / (k[1].row - k[0].row);
|
||||
return k[0].value + (k[1].value - k[0].value) * t;
|
||||
}
|
||||
|
||||
static double key_smooth(const struct track_key k[2], double row)
|
||||
{
|
||||
double t = (row - k[0].row) / (k[1].row - k[0].row);
|
||||
t = t * t * (3 - 2 * t);
|
||||
return k[0].value + (k[1].value - k[0].value) * t;
|
||||
}
|
||||
|
||||
static double key_ramp(const struct track_key k[2], double row)
|
||||
{
|
||||
double t = (row - k[0].row) / (k[1].row - k[0].row);
|
||||
t = pow(t, 2.0);
|
||||
return k[0].value + (k[1].value - k[0].value) * t;
|
||||
}
|
||||
|
||||
double sync_get_val(const struct sync_track *t, double row)
|
||||
{
|
||||
int idx, irow;
|
||||
|
||||
/* If we have no keys at all, return a constant 0 */
|
||||
if (!t->num_keys)
|
||||
return 0.0f;
|
||||
|
||||
irow = (int)floor(row);
|
||||
idx = key_idx_floor(t, irow);
|
||||
|
||||
/* at the edges, return the first/last value */
|
||||
if (idx < 0)
|
||||
return t->keys[0].value;
|
||||
if (idx > (int)t->num_keys - 2)
|
||||
return t->keys[t->num_keys - 1].value;
|
||||
|
||||
/* interpolate according to key-type */
|
||||
switch (t->keys[idx].type) {
|
||||
case KEY_STEP:
|
||||
return t->keys[idx].value;
|
||||
case KEY_LINEAR:
|
||||
return key_linear(t->keys + idx, row);
|
||||
case KEY_SMOOTH:
|
||||
return key_smooth(t->keys + idx, row);
|
||||
case KEY_RAMP:
|
||||
return key_ramp(t->keys + idx, row);
|
||||
default:
|
||||
assert(0);
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
int sync_find_key(const struct sync_track *t, int row)
|
||||
{
|
||||
int lo = 0, hi = t->num_keys;
|
||||
|
||||
/* binary search, t->keys is sorted by row */
|
||||
while (lo < hi) {
|
||||
int mi = (lo + hi) / 2;
|
||||
assert(mi != hi);
|
||||
|
||||
if (t->keys[mi].row < row)
|
||||
lo = mi + 1;
|
||||
else if (t->keys[mi].row > row)
|
||||
hi = mi;
|
||||
else
|
||||
return mi; /* exact hit */
|
||||
}
|
||||
assert(lo == hi);
|
||||
|
||||
/* return first key after row, negated and biased (to allow -0) */
|
||||
return -lo - 1;
|
||||
}
|
||||
|
||||
#ifndef SYNC_PLAYER
|
||||
int sync_set_key(struct sync_track *t, const struct track_key *k)
|
||||
{
|
||||
int idx = sync_find_key(t, k->row);
|
||||
if (idx < 0) {
|
||||
/* no exact hit, we need to allocate a new key */
|
||||
void *tmp;
|
||||
idx = -idx - 1;
|
||||
tmp = realloc(t->keys, sizeof(struct track_key) *
|
||||
(t->num_keys + 1));
|
||||
if (!tmp)
|
||||
return -1;
|
||||
t->num_keys++;
|
||||
t->keys = (track_key*)tmp;
|
||||
memmove(t->keys + idx + 1, t->keys + idx,
|
||||
sizeof(struct track_key) * (t->num_keys - idx - 1));
|
||||
}
|
||||
t->keys[idx] = *k;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sync_del_key(struct sync_track *t, int pos)
|
||||
{
|
||||
void *tmp;
|
||||
int idx = sync_find_key(t, pos);
|
||||
assert(idx >= 0);
|
||||
memmove(t->keys + idx, t->keys + idx + 1,
|
||||
sizeof(struct track_key) * (t->num_keys - idx - 1));
|
||||
assert(t->keys);
|
||||
tmp = realloc(t->keys, sizeof(struct track_key) *
|
||||
(t->num_keys - 1));
|
||||
if (t->num_keys != 1 && !tmp)
|
||||
return -1;
|
||||
t->num_keys--;
|
||||
t->keys = (track_key*)tmp;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
51
nordlicht2015-intro/src/intro/framework/sync/track.h
Normal file
51
nordlicht2015-intro/src/intro/framework/sync/track.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* Copyright (C) 2007-2010 Erik Faye-Lund and Egbert Teeselink
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
|
||||
#ifndef SYNC_TRACK_H
|
||||
#define SYNC_TRACK_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "base.h"
|
||||
|
||||
enum key_type {
|
||||
KEY_STEP, /* stay constant */
|
||||
KEY_LINEAR, /* lerp to the next value */
|
||||
KEY_SMOOTH, /* smooth curve to the next value */
|
||||
KEY_RAMP,
|
||||
KEY_TYPE_COUNT
|
||||
};
|
||||
|
||||
struct track_key {
|
||||
int row;
|
||||
float value;
|
||||
enum key_type type;
|
||||
};
|
||||
|
||||
struct sync_track {
|
||||
char *name;
|
||||
struct track_key *keys;
|
||||
int num_keys;
|
||||
};
|
||||
|
||||
int sync_find_key(const struct sync_track *, int);
|
||||
static inline int key_idx_floor(const struct sync_track *t, int row)
|
||||
{
|
||||
int idx = sync_find_key(t, row);
|
||||
if (idx < 0)
|
||||
idx = -idx - 2;
|
||||
return idx;
|
||||
}
|
||||
|
||||
#ifndef SYNC_PLAYER
|
||||
int sync_set_key(struct sync_track *, const struct track_key *);
|
||||
int sync_del_key(struct sync_track *, int);
|
||||
static inline int is_key_frame(const struct sync_track *t, int row)
|
||||
{
|
||||
return sync_find_key(t, row) >= 0;
|
||||
}
|
||||
|
||||
#endif /* !defined(SYNC_PLAYER) */
|
||||
|
||||
#endif /* SYNC_TRACK_H */
|
||||
171
nordlicht2015-intro/src/intro/framework/sync/usync.cpp
Normal file
171
nordlicht2015-intro/src/intro/framework/sync/usync.cpp
Normal file
@@ -0,0 +1,171 @@
|
||||
#include "usync.h"
|
||||
#include <math.h>
|
||||
//#include <Shlwapi.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef SYNC_PLAYER
|
||||
|
||||
static int usync_rows[SYNC_TRACK_COUNT];
|
||||
float usync_values[SYNC_TRACK_COUNT];
|
||||
|
||||
void usync_update(float t, float* targetvalues)
|
||||
{
|
||||
int i; float row = t;
|
||||
for (i = 0; i < SYNC_TRACK_COUNT; ++i) {
|
||||
int pos;
|
||||
float mag, x, a, b, c, d;
|
||||
|
||||
/* empty tracks should not be neccesary! */
|
||||
if (!sync_data_count[i]) {
|
||||
targetvalues[i] = 0.0f;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* step forward until we're at the right key-frame */
|
||||
while (usync_rows[i] < (sync_data_count[i] - 1) &&
|
||||
row >= sync_data_rows[sync_data_offset[i] + usync_rows[i] + 1]) {
|
||||
usync_rows[i]++;
|
||||
}
|
||||
|
||||
pos = usync_rows[i] + sync_data_offset[i];
|
||||
|
||||
/* we need a segment to interpolate over */
|
||||
if (usync_rows[i] == sync_data_count[i] - 1) {
|
||||
targetvalues[i] = sync_data_values[pos];
|
||||
continue;
|
||||
}
|
||||
|
||||
/* prepare coefficients for interpolation */
|
||||
a = sync_data_values[pos];
|
||||
mag = sync_data_values[pos + 1] - sync_data_values[pos];
|
||||
switch (sync_data_type[pos]) {
|
||||
case 0:
|
||||
b = c = d = 0.0f;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
b = mag;
|
||||
c = d = 0.0f;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
b = 0.0f;
|
||||
c = 3 * mag;
|
||||
d = -2 * mag;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
b = d = 0.0f;
|
||||
c = mag;
|
||||
break;
|
||||
}
|
||||
|
||||
/* evaluate function */
|
||||
x = (t - sync_data_rows[pos]) / (sync_data_rows[pos + 1] - sync_data_rows[pos]);
|
||||
targetvalues[i] = a + (b + (c + d * x) * x) * x;
|
||||
}
|
||||
}
|
||||
|
||||
#else /* !defined(SYNC_PLAYER) */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "sync.h"
|
||||
#include "device.h"
|
||||
|
||||
struct sync_device *usync_dev;
|
||||
float usync_time = 0;
|
||||
|
||||
void usync_update(float t, float* targetValues)
|
||||
{
|
||||
usync_time = t;
|
||||
sync_update(usync_dev, (int)floor(t), &usync_cb, usync_data);
|
||||
}
|
||||
|
||||
int usync_init(void)
|
||||
{
|
||||
usync_dev = sync_create_device("sync");
|
||||
return sync_connect(usync_dev, "localhost", SYNC_DEFAULT_PORT);
|
||||
}
|
||||
|
||||
void usync_export(void)
|
||||
{
|
||||
if (usync_dev == 0)
|
||||
return;
|
||||
|
||||
int i, j;
|
||||
int offset = 0;
|
||||
static char exePath[MAX_PATH];
|
||||
static char syncPath[MAX_PATH];
|
||||
GetModuleFileName(NULL, exePath, MAX_PATH);
|
||||
PathRemoveFileSpecA(exePath);
|
||||
PathCombineA(syncPath, exePath, "..\\src\\intro\\framework\\sync-data.h");
|
||||
FILE *fp = fopen(syncPath, "w");
|
||||
|
||||
if (!fp)
|
||||
return;
|
||||
|
||||
/* header-guard */
|
||||
fputs("#ifndef SYNC_DATA_H\n#define SYNC_DATA_H\n\n", fp);
|
||||
|
||||
fputs("enum sync_tracks {\n", fp);
|
||||
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
|
||||
struct sync_track *t = usync_dev->data.tracks[i];
|
||||
fprintf(fp, "\tSYNC_TRACK_%s = %d,\n", t->name, i);
|
||||
}
|
||||
fprintf(fp, "\tSYNC_TRACK_COUNT = %d\n", usync_dev->data.num_tracks);
|
||||
fputs("};\n\n", fp);
|
||||
|
||||
fputs("static const unsigned short sync_data_offset[SYNC_TRACK_COUNT] = {\n", fp);
|
||||
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
|
||||
struct sync_track *t = usync_dev->data.tracks[i];
|
||||
fprintf(fp, "\t%d, /* track: %s */\n", offset, t->name);
|
||||
offset += t->num_keys;
|
||||
}
|
||||
fputs("};\n\n", fp);
|
||||
|
||||
fputs("static const unsigned char sync_data_count[SYNC_TRACK_COUNT] = {\n", fp);
|
||||
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
|
||||
struct sync_track *t = usync_dev->data.tracks[i];
|
||||
fprintf(fp, "\t%d, /* track: %s */\n", t->num_keys, t->name);
|
||||
}
|
||||
fputs("};\n\n", fp);
|
||||
|
||||
fputs("static const unsigned short sync_data_rows[] = {\n", fp);
|
||||
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
|
||||
struct sync_track *t = usync_dev->data.tracks[i];
|
||||
fprintf(fp, "\t/* track: %s */\n", t->name);
|
||||
for (j = 0; j < t->num_keys; ++j)
|
||||
fprintf(fp, "\t%d,\n", t->keys[j].row);
|
||||
}
|
||||
fputs("};\n\n", fp);
|
||||
|
||||
fputs("static const float sync_data_values[] = {\n", fp);
|
||||
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
|
||||
struct sync_track *t = usync_dev->data.tracks[i];
|
||||
fprintf(fp, "\t/* track: %s */\n", t->name);
|
||||
for (j = 0; j < t->num_keys; ++j)
|
||||
fprintf(fp, "\t%.6ff,\n", t->keys[j].value);
|
||||
}
|
||||
fputs("};\n\n", fp);
|
||||
|
||||
fputs("static const unsigned char sync_data_type[] = {\n", fp);
|
||||
for (i = 0; i < usync_dev->data.num_tracks; ++i) {
|
||||
struct sync_track *t = usync_dev->data.tracks[i];
|
||||
fprintf(fp, "\t/* track: %s */\n", t->name);
|
||||
for (j = 0; j < t->num_keys; ++j)
|
||||
fprintf(fp, "\t%d,\n", t->keys[j].type);
|
||||
}
|
||||
fputs("};\n\n", fp);
|
||||
|
||||
fputs("#endif /* !defined(SYNC_DATA_H) */\n", fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
42
nordlicht2015-intro/src/intro/framework/sync/usync.h
Normal file
42
nordlicht2015-intro/src/intro/framework/sync/usync.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef USYNC_H
|
||||
#define USYNC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef SYNC_PLAYER
|
||||
|
||||
#include "../sync-data.h"
|
||||
extern float usync_values[SYNC_TRACK_COUNT];
|
||||
|
||||
/* tiny api */
|
||||
#define usync_init() 0
|
||||
void usync_update(float t, float* targetValues);
|
||||
#define usync_get_val(x) usync_values[ SYNC_TRACK_##x ]
|
||||
#define usync_export()
|
||||
|
||||
#else /* !defined(SYNC_PLAYER) */
|
||||
|
||||
#include "sync.h"
|
||||
|
||||
extern struct sync_device *usync_dev;
|
||||
extern float usync_time;
|
||||
|
||||
int usync_init(void);
|
||||
void usync_update(float t, float* targetValues);
|
||||
#define usync_get_val(track) sync_get_val(sync_get_track(usync_dev, #track), usync_time)
|
||||
void usync_export(void);
|
||||
|
||||
/* implement these yourself */
|
||||
extern struct sync_cb usync_cb;
|
||||
extern void *usync_data;
|
||||
|
||||
#endif /* !defined(SYNC_PLAYER) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !defined(USYNC_H) */
|
||||
156
nordlicht2015-intro/src/intro/framework/video.h
Normal file
156
nordlicht2015-intro/src/intro/framework/video.h
Normal file
@@ -0,0 +1,156 @@
|
||||
#ifdef VIDEO
|
||||
#include <vfw.h>
|
||||
|
||||
#define FPS 24
|
||||
#define MOTION_BLUR 1
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PAVISTREAM m_ps;
|
||||
PAVISTREAM m_psCompressed;
|
||||
PAVISTREAM m_psAudio;
|
||||
AVISTREAMINFO m_strhdr;
|
||||
AVICOMPRESSOPTIONS m_opts;
|
||||
PAVIFILE m_pfile;
|
||||
BITMAPINFOHEADER m_alpbi;
|
||||
} AVIWRITER;
|
||||
|
||||
static D3D11_TEXTURE2D_DESC videoStagingTextureDesc =
|
||||
{
|
||||
SCREENWIDTH,
|
||||
SCREENHEIGHT,
|
||||
1,
|
||||
1,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
{ 1, 0 },
|
||||
D3D11_USAGE_STAGING,
|
||||
0,
|
||||
D3D11_CPU_ACCESS_READ,
|
||||
0
|
||||
};
|
||||
|
||||
#pragma bss_seg(".videobss")
|
||||
static AVIWRITER avi;
|
||||
static int frame = 0;
|
||||
static ID3D11Texture2D* videoStagingTexture;
|
||||
static byte buffer[3 * SCREENWIDTH * SCREENHEIGHT];
|
||||
static int tempBuffer[3 * SCREENWIDTH * SCREENHEIGHT];
|
||||
|
||||
#pragma code_seg(".VideoInit")
|
||||
void VideoInit()
|
||||
{
|
||||
AVIFileInit();
|
||||
CHECK(AVIFileOpen(&avi.m_pfile, "intro.avi", OF_WRITE | OF_CREATE, NULL));
|
||||
|
||||
memset(&avi.m_strhdr, 0, sizeof(avi.m_strhdr));
|
||||
avi.m_strhdr.fccType = streamtypeVIDEO;
|
||||
avi.m_strhdr.fccHandler = 0;
|
||||
avi.m_strhdr.dwScale = 1;
|
||||
avi.m_strhdr.dwRate = FPS;
|
||||
avi.m_strhdr.dwSuggestedBufferSize = 0;// 3 * SCREENWIDTH * SCREENHEIGHT;
|
||||
SetRect(&avi.m_strhdr.rcFrame, 0, 0, SCREENWIDTH, SCREENHEIGHT);
|
||||
|
||||
CHECK(AVIFileCreateStream(avi.m_pfile, &avi.m_ps, &avi.m_strhdr));
|
||||
|
||||
memset(&avi.m_strhdr, 0, sizeof(avi.m_strhdr));
|
||||
avi.m_strhdr.fccType = streamtypeAUDIO;
|
||||
avi.m_strhdr.dwScale = WaveFMT.nBlockAlign;
|
||||
avi.m_strhdr.dwRate = WaveFMT.nSamplesPerSec * WaveFMT.nBlockAlign;
|
||||
avi.m_strhdr.dwSampleSize = WaveFMT.nBlockAlign;
|
||||
avi.m_strhdr.dwQuality = (DWORD)-1;
|
||||
SetRect(&avi.m_strhdr.rcFrame, 0, 0, SCREENWIDTH, SCREENHEIGHT);
|
||||
|
||||
CHECK(AVIFileCreateStream(avi.m_pfile, &avi.m_psAudio, &avi.m_strhdr));
|
||||
CHECK(AVIStreamSetFormat(avi.m_psAudio, 0, &WaveFMT, sizeof(WAVEFORMATEX)));
|
||||
|
||||
auto ops = &avi.m_opts;
|
||||
if (AVISaveOptions(windowHandle, 0, 1, &avi.m_ps, &ops) == FALSE)
|
||||
{
|
||||
ExitProcess(0);
|
||||
}
|
||||
|
||||
CHECK(AVIMakeCompressedStream(&avi.m_psCompressed, avi.m_ps, &avi.m_opts, NULL));
|
||||
|
||||
memset(&avi.m_alpbi, 0, sizeof(avi.m_alpbi));
|
||||
avi.m_alpbi.biSize = sizeof(avi.m_alpbi);
|
||||
avi.m_alpbi.biWidth = SCREENWIDTH;
|
||||
avi.m_alpbi.biHeight = SCREENHEIGHT;
|
||||
avi.m_alpbi.biPlanes = 1;
|
||||
avi.m_alpbi.biBitCount = 24;
|
||||
avi.m_alpbi.biCompression = BI_RGB;
|
||||
|
||||
CHECK(AVIStreamSetFormat(avi.m_psCompressed, 0, &avi.m_alpbi, sizeof(avi.m_alpbi)));
|
||||
|
||||
CHECK(device->CreateTexture2D(&videoStagingTextureDesc, NULL, &videoStagingTexture));
|
||||
}
|
||||
|
||||
#pragma code_seg(".VideoGetPosition")
|
||||
float VideoGetPosition()
|
||||
{
|
||||
float seconds = (float)frame / (float)(FPS * MOTION_BLUR);
|
||||
float samples = seconds * SAMPLE_RATE;
|
||||
float ticks = samples / (float)SAMPLES_PER_TICK;
|
||||
return ticks / SOUND_TICKS_PER_SCENE;
|
||||
}
|
||||
|
||||
#pragma code_seg(".VideoUpdate")
|
||||
void VideoUpdate()
|
||||
{
|
||||
static D3D11_MAPPED_SUBRESOURCE videoMappedSubresource;
|
||||
|
||||
context->CopyResource(videoStagingTexture, backBufferTexture);
|
||||
context->Map(videoStagingTexture, 0, D3D11_MAP_READ, 0, &videoMappedSubresource);
|
||||
|
||||
auto introPtr = (byte*)videoMappedSubresource.pData;
|
||||
for (int y = 0; y < SCREENHEIGHT; ++y)
|
||||
{
|
||||
auto vy = SCREENHEIGHT - y - 1;
|
||||
for (int x = 0; x < SCREENWIDTH; ++x)
|
||||
{
|
||||
for (int c = 0; c < 4; ++c)
|
||||
{
|
||||
byte color = *introPtr++;
|
||||
if (c < 3)
|
||||
{
|
||||
auto vc = 2 - c;
|
||||
auto vidx = vc + 3 * (x + SCREENWIDTH * vy);
|
||||
tempBuffer[vidx] += color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
context->Unmap(videoStagingTexture, 0);
|
||||
|
||||
if ((frame++ % MOTION_BLUR) == 0)
|
||||
{
|
||||
auto videoPtr = (byte*)buffer;
|
||||
auto tempPtr = (int*)tempBuffer;
|
||||
for (int i = 0; i < SCREENWIDTH * SCREENHEIGHT * 3; ++i)
|
||||
{
|
||||
*videoPtr++ = (byte)(*tempPtr / MOTION_BLUR);
|
||||
*tempPtr++ = 0;
|
||||
}
|
||||
|
||||
auto realFrame = (frame - 1) / MOTION_BLUR;
|
||||
char message[128];
|
||||
sprintf_s(message, "Frame %d/%d...", realFrame, FPS * MAX_SAMPLES / SAMPLE_RATE);
|
||||
Log(message);
|
||||
CHECK(AVIStreamWrite(avi.m_psCompressed, realFrame, 1, buffer, 3 * SCREENWIDTH * SCREENHEIGHT, AVIIF_KEYFRAME, NULL, NULL));
|
||||
}
|
||||
}
|
||||
|
||||
#pragma code_seg(".VideoDispose")
|
||||
void VideoDispose()
|
||||
{
|
||||
auto const extraSamples = 0;// SOUND_TICKS_PER_SCENE * SAMPLES_PER_TICK / 4;
|
||||
static SAMPLE_TYPE audioBuffer[2 * (MAX_SAMPLES + extraSamples)];
|
||||
memcpy(audioBuffer + extraSamples * 2, WaveHDR.lpData, WaveHDR.dwBufferLength);
|
||||
AVIStreamWrite(avi.m_psAudio, 0, MAX_SAMPLES + extraSamples, audioBuffer, WaveHDR.dwBufferLength + extraSamples * sizeof(SAMPLE_TYPE) * 2, 0, NULL, NULL);
|
||||
|
||||
AVIStreamClose(avi.m_ps);
|
||||
AVIStreamClose(avi.m_psCompressed);
|
||||
AVIStreamClose(avi.m_psAudio);
|
||||
AVIFileClose(avi.m_pfile);
|
||||
AVIFileExit();
|
||||
}
|
||||
#endif
|
||||
89
nordlicht2015-intro/src/intro/framework/window.h
Normal file
89
nordlicht2015-intro/src/intro/framework/window.h
Normal file
@@ -0,0 +1,89 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef SCREENWIDTH
|
||||
#define SCREENWIDTH 1280
|
||||
#endif
|
||||
|
||||
#ifndef SCREENHEIGHT
|
||||
#define SCREENHEIGHT 720
|
||||
#endif
|
||||
|
||||
#ifndef WINDOWED
|
||||
#define WINDOWED FALSE
|
||||
#endif
|
||||
|
||||
#pragma bss_seg(".windowbss")
|
||||
static float windowWidth = SCREENWIDTH;
|
||||
static float windowHeight = SCREENHEIGHT;
|
||||
static float aspectRatio = windowWidth / windowHeight;
|
||||
static HWND windowHandle;
|
||||
|
||||
#ifdef VIDEO
|
||||
#define windowTitle "Intro (rendering to video)"
|
||||
#endif
|
||||
|
||||
#ifdef RELEASE
|
||||
#define windowTitle "Intro (release)"
|
||||
#endif
|
||||
|
||||
#ifdef SHADERDEBUG
|
||||
#define windowTitle "Intro (shader debug)"
|
||||
#endif
|
||||
|
||||
#ifdef AUTHORING
|
||||
#define windowTitle "Intro (authoring)"
|
||||
#endif
|
||||
|
||||
#ifndef windowTitle
|
||||
#define windowTitle "Intro (unknown configuration)"
|
||||
#endif
|
||||
|
||||
#ifndef COMPRESS
|
||||
#undef WINDOWED
|
||||
#define WINDOWED TRUE
|
||||
#endif
|
||||
|
||||
#pragma code_seg(".windowInit")
|
||||
INLINE void WindowInit()
|
||||
{
|
||||
Log("WindowInit");
|
||||
#ifdef RELEASE
|
||||
windowHandle = CreateWindowExA(0, (LPCSTR)0x0000C019, 0, WS_POPUP | WS_VISIBLE | WS_MAXIMIZE, 0, 0, windowWidth + 16, windowHeight + 39, 0, 0, 0, 0);
|
||||
ShowCursor(false);
|
||||
#else
|
||||
WNDCLASSEX wndclass;
|
||||
wndclass.cbSize = sizeof(wndclass);
|
||||
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
|
||||
wndclass.lpfnWndProc = (WNDPROC)DefWindowProc;
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hInstance = NULL;
|
||||
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||
wndclass.lpszMenuName = NULL;
|
||||
wndclass.lpszClassName = "IntroWindowClass";
|
||||
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||
|
||||
RegisterClassEx(&wndclass);
|
||||
#ifndef AUTHORING
|
||||
windowHandle = CreateWindowExA(0,
|
||||
wndclass.lpszClassName,
|
||||
windowTitle,
|
||||
WS_EX_APPWINDOW,
|
||||
GetSystemMetrics(SM_CXSCREEN) - windowWidth - 16,
|
||||
0,
|
||||
windowWidth + 16,
|
||||
windowHeight + 39,
|
||||
NULL,
|
||||
NULL,
|
||||
GetModuleHandle(NULL),
|
||||
NULL
|
||||
);
|
||||
ShowWindow(windowHandle, SW_NORMAL);
|
||||
SetWindowPos(windowHandle, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
#else
|
||||
windowHandle = CreateWindowExA(0, wndclass.lpszClassName, windowTitle, 0, 0, 0, SCREENWIDTH + 16, SCREENHEIGHT + 39, 0, 0, GetModuleHandle(NULL), 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
BIN
nordlicht2015-intro/src/intro/intro.suo
Normal file
BIN
nordlicht2015-intro/src/intro/intro.suo
Normal file
Binary file not shown.
743
nordlicht2015-intro/src/intro/intro.vcxproj
Normal file
743
nordlicht2015-intro/src/intro/intro.vcxproj
Normal file
@@ -0,0 +1,743 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Authoring|Win32">
|
||||
<Configuration>Authoring</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="ShaderDebug|Win32">
|
||||
<Configuration>ShaderDebug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Compress|Win32">
|
||||
<Configuration>Compress</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Video|Win32">
|
||||
<Configuration>Video</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{EC001821-5569-4BB5-87B3-20CB8FF9137B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>ConsoleApplication1</RootNamespace>
|
||||
<ProjectName>intro</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Video|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Video|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(Configuration)</TargetName>
|
||||
<ExecutablePath>$(SolutionDir)\tools;$(ExecutablePath)</ExecutablePath>
|
||||
<LibraryPath>$(SolutionDir)lib\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(Configuration)</TargetName>
|
||||
<ExecutablePath>$(SolutionDir)\tools;$(ExecutablePath)</ExecutablePath>
|
||||
<LibraryPath>$(SolutionDir)lib\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(Configuration)</TargetName>
|
||||
<ExecutablePath>$(SolutionDir)\tools;$(ExecutablePath)</ExecutablePath>
|
||||
<LibraryPath>$(SolutionDir)lib\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(Configuration)</TargetName>
|
||||
<ExecutablePath>$(SolutionDir)\tools;$(ExecutablePath)</ExecutablePath>
|
||||
<LibraryPath>$(SolutionDir)lib\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)bin\</OutDir>
|
||||
<IntDir>$(SolutionDir)obj\$(Configuration)\$(ProjectName)\</IntDir>
|
||||
<TargetName>$(ProjectName)_$(Configuration)</TargetName>
|
||||
<ExecutablePath>$(SolutionDir)\tools;$(ExecutablePath)</ExecutablePath>
|
||||
<LibraryPath>$(SolutionDir)lib\;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>SHADERDEBUG;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>dxgi.lib;d3d11.lib;mesh_Debug.lib;D3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
<CustomBuildStep>
|
||||
<Command>
|
||||
</Command>
|
||||
</CustomBuildStep>
|
||||
<CustomBuildStep>
|
||||
<Message>
|
||||
</Message>
|
||||
<Outputs>
|
||||
</Outputs>
|
||||
<Inputs>
|
||||
</Inputs>
|
||||
</CustomBuildStep>
|
||||
<ProjectReference>
|
||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
||||
</ProjectReference>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>VIDEO;WIN32;SYNC_PLAYER;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>dxgi.lib;d3d11.lib;mesh_Debug.lib;D3dcompiler.lib;winmm.lib;vfw32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
<CustomBuildStep>
|
||||
<Command>
|
||||
</Command>
|
||||
</CustomBuildStep>
|
||||
<CustomBuildStep>
|
||||
<Message>
|
||||
</Message>
|
||||
<Outputs>
|
||||
</Outputs>
|
||||
<Inputs>
|
||||
</Inputs>
|
||||
</CustomBuildStep>
|
||||
<ProjectReference>
|
||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
||||
</ProjectReference>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>AUTHORING;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>dxgi.lib;d3d11.lib;mesh_Debug.lib;dxguid.lib;D3dcompiler.lib;winmm.lib;Shlwapi.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<EntryPointSymbol>
|
||||
</EntryPointSymbol>
|
||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
<CustomBuildStep>
|
||||
<Command>
|
||||
</Command>
|
||||
</CustomBuildStep>
|
||||
<CustomBuildStep>
|
||||
<Message>
|
||||
</Message>
|
||||
<Outputs>
|
||||
</Outputs>
|
||||
<Inputs>
|
||||
</Inputs>
|
||||
</CustomBuildStep>
|
||||
<ProjectReference>
|
||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
||||
</ProjectReference>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>COMPRESS;RELEASE;WIN32;NDEBUG;SYNC_PLAYER;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DebugInformationFormat Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">None</DebugInformationFormat>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Size</FavorSizeOrSpeed>
|
||||
<OmitFramePointers Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</OmitFramePointers>
|
||||
<WholeProgramOptimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</WholeProgramOptimization>
|
||||
<ExceptionHandling Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExceptionHandling>
|
||||
<RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MultiThreadedDLL</RuntimeLibrary>
|
||||
<BufferSecurityCheck Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</BufferSecurityCheck>
|
||||
<FloatingPointModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Fast</FloatingPointModel>
|
||||
<DebugInformationFormat>None</DebugInformationFormat>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
||||
<AdditionalOptions>/QIfist %(AdditionalOptions)</AdditionalOptions>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>dxgi.lib;d3d11.lib;mesh_Release.lib;D3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalOptions>/CRINKLER /TRANSFORM:CALLS /COMPMODE:FAST /HASHTRIES:10 /HASHSIZE:256 /ORDERTRIES:200 /UNSAFEIMPORT /REPORT:crinkler.html /PROGRESSGUI %(AdditionalOptions)</AdditionalOptions>
|
||||
<EntryPointSymbol>main</EntryPointSymbol>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
<CustomBuildStep>
|
||||
<Command>
|
||||
</Command>
|
||||
</CustomBuildStep>
|
||||
<CustomBuildStep>
|
||||
<Message>
|
||||
</Message>
|
||||
<Outputs>
|
||||
</Outputs>
|
||||
<Inputs>
|
||||
</Inputs>
|
||||
</CustomBuildStep>
|
||||
<ProjectReference>
|
||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
||||
</ProjectReference>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<PreprocessorDefinitions>RELEASE;WIN32;SYNC_PLAYER;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<ExceptionHandling>false</ExceptionHandling>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
||||
<StringPooling>true</StringPooling>
|
||||
<AdditionalOptions>/QIfist %(AdditionalOptions)</AdditionalOptions>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>dxgi.lib;d3d11.lib;mesh_Release.lib;dxguid.lib;D3dcompiler.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
<CustomBuildStep>
|
||||
<Command>
|
||||
</Command>
|
||||
</CustomBuildStep>
|
||||
<CustomBuildStep>
|
||||
<Message>
|
||||
</Message>
|
||||
<Outputs>
|
||||
</Outputs>
|
||||
<Inputs>
|
||||
</Inputs>
|
||||
</CustomBuildStep>
|
||||
<ProjectReference>
|
||||
<LinkLibraryDependencies>false</LinkLibraryDependencies>
|
||||
</ProjectReference>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="framework\sync\data.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="framework\sync\device.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="framework\sync\track.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="framework\sync\usync.cpp" />
|
||||
<ClCompile Include="main.cpp">
|
||||
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">All</AssemblerOutput>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">false</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework\4klang.h" />
|
||||
<ClInclude Include="framework\authoring.h" />
|
||||
<ClInclude Include="framework\directx.h" />
|
||||
<ClInclude Include="framework\framework.h" />
|
||||
<ClInclude Include="framework\intro_hlsl.h" />
|
||||
<ClInclude Include="framework\log.h" />
|
||||
<ClInclude Include="framework\mutexlock.h" />
|
||||
<ClInclude Include="framework\shaders.h" />
|
||||
<ClInclude Include="framework\shaders_shc.h" />
|
||||
<ClInclude Include="framework\sync-data.h" />
|
||||
<ClInclude Include="framework\sync\base.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync\data.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync\device.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync\sync.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync\track.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync\usync.h" />
|
||||
<ClInclude Include="framework\video.h" />
|
||||
<ClInclude Include="framework\window.h" />
|
||||
<ClInclude Include="intro\data.h" />
|
||||
<ClInclude Include="framework\sound.h" />
|
||||
<ClInclude Include="intro\intro.h" />
|
||||
<ClInclude Include="intro\RenderMesh.h" />
|
||||
<ClInclude Include="intro\update.h" />
|
||||
<ClInclude Include="intro\functions.h" />
|
||||
<ClInclude Include="intro\init.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="framework\4klang.asm">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">yasm -f win32 -o "$(IntermediateOutputPath)framework\4klang.obj" "$(ProjectDir)framework\4klang.asm"</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compiling 4klang...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">$(IntermediateOutputPath)framework\4klang.obj</Outputs>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">$(ProjectDir)framework\4klang.inc</AdditionalInputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">yasm -f win32 -o "$(IntermediateOutputPath)framework\4klang.obj" "$(ProjectDir)framework\4klang.asm"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">yasm -f win32 -o "$(IntermediateOutputPath)framework\4klang.obj" "$(ProjectDir)framework\4klang.asm"</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compiling 4klang...</Message>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compiling 4klang...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">$(IntermediateOutputPath)framework\4klang.obj</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(IntermediateOutputPath)framework\4klang.obj</Outputs>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">$(ProjectDir)framework\4klang.inc</AdditionalInputs>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)framework\4klang.inc</AdditionalInputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">yasm -f win32 -o "$(IntermediateOutputPath)framework\4klang.obj" "$(ProjectDir)framework\4klang.asm"</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compiling 4klang...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">$(IntermediateOutputPath)framework\4klang.obj</Outputs>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">$(ProjectDir)framework\4klang.inc</AdditionalInputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">yasm -D AUTHORING -f win32 -o "$(IntermediateOutputPath)framework\4klang.obj" "$(ProjectDir)framework\4klang.asm"</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compiling 4klang...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">$(IntermediateOutputPath)framework\4klang.obj</Outputs>
|
||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">$(ProjectDir)framework\4klang.inc</AdditionalInputs>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="framework\4klang.inc" />
|
||||
<None Include="shaders\lib\blur.hlsl" />
|
||||
<None Include="shaders\lib\distance-transform.hlsl" />
|
||||
<None Include="shaders\lib\fxaa311.hlsl">
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\grid-lines.hlsl" />
|
||||
<None Include="shaders\lib\lighting.hlsl">
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\material.hlsl">
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\ogl2dx.hlsl">
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\postprocessing.hlsl">
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\rt.hlsl">
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\sdf.hlsl">
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\utils.hlsl">
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="shaders\intro.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">$(TargetDir)shc "%(FullPath)" "$(ProjectDir)framework\intro_hlsl.h" "$(ProjectDir)framework\shaders_shc.h" "$(ProjectDir)framework\merged.hlsl"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(TargetDir)shc "%(FullPath)" "$(ProjectDir)framework\intro_hlsl.h" "$(ProjectDir)framework\shaders_shc.h" "$(ProjectDir)framework\merged.hlsl"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">$(TargetDir)shc "%(FullPath)" "$(ProjectDir)framework\intro_hlsl.h" "$(ProjectDir)framework\shaders_shc.h" "$(ProjectDir)framework\merged.hlsl"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">$(TargetDir)shc "%(FullPath)" "$(ProjectDir)framework\intro_hlsl.h" "$(ProjectDir)framework\shaders_shc.h" "$(ProjectDir)framework\merged.hlsl"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">$(TargetDir)shc "%(FullPath)" "$(ProjectDir)framework\intro_hlsl.h" "$(ProjectDir)framework\shaders_shc.h" "$(ProjectDir)framework\merged.hlsl"</Command>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compiling intro.hlsl...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">$(ProjectDir)framework\shaders_shc.h;$(ProjectDir)framework\intro_hlsl.h;$(ProjectDir)framework\merged.hlsl;%(Outputs)</Outputs>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compiling intro.hlsl...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)framework\shaders_shc.h;$(ProjectDir)framework\intro_hlsl.h;$(ProjectDir)framework\merged.hlsl;%(Outputs)</Outputs>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compiling intro.hlsl...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">$(ProjectDir)framework\shaders_shc.h;$(ProjectDir)framework\intro_hlsl.h;$(ProjectDir)framework\merged.hlsl;%(Outputs)</Outputs>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compiling intro.hlsl...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">$(ProjectDir)framework\shaders_shc.h;$(ProjectDir)framework\intro_hlsl.h;$(ProjectDir)framework\merged.hlsl;%(Outputs)</Outputs>
|
||||
<Message Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compiling intro.hlsl...</Message>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">$(ProjectDir)framework\shaders_shc.h;$(ProjectDir)framework\intro_hlsl.h;$(ProjectDir)framework\merged.hlsl;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<FxCompile Include="framework\merged.hlsl">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">true</ExcludedFromBuild>
|
||||
</FxCompile>
|
||||
<FxCompile Include="framework\shaders\histogramGather.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
|
||||
</FxCompile>
|
||||
<FxCompile Include="framework\shaders\histogramSpread.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
|
||||
</FxCompile>
|
||||
<FxCompile Include="framework\shaders\histogramMaximum.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
|
||||
</FxCompile>
|
||||
<FxCompile Include="framework\shaders\paradeVectorscopeGather.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
|
||||
</FxCompile>
|
||||
<FxCompile Include="framework\shaders\paradeVectorscopeMaximum.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
|
||||
</FxCompile>
|
||||
<FxCompile Include="framework\shaders\paradeVectorscopeSpread.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">5.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">5.0</ShaderModel>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</EnableDebuggingInformation>
|
||||
<DisableOptimizations Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</DisableOptimizations>
|
||||
<EnableDebuggingInformation Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">true</EnableDebuggingInformation>
|
||||
</FxCompile>
|
||||
<None Include="shaders\lib\volumetric-fog.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\particles.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\ssao.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\raymarching.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\postprocess.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\textures.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\mesh.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\lib\shared.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\parts\shared.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\parts\part2.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
<None Include="shaders\parts\part1.hlsl">
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Video|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='ShaderDebug|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Compress|Win32'">4.0</ShaderModel>
|
||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">Compute</ShaderType>
|
||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Authoring|Win32'">4.0</ShaderModel>
|
||||
<FileType>Document</FileType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\mesh\mesh.vcxproj">
|
||||
<Project>{e8f53e16-d2d5-4d17-a0bb-35c202253327}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
153
nordlicht2015-intro/src/intro/intro.vcxproj.filters
Normal file
153
nordlicht2015-intro/src/intro/intro.vcxproj.filters
Normal file
@@ -0,0 +1,153 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="framework\sync\data.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="framework\sync\device.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="framework\sync\track.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="framework\sync\usync.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework\framework.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="intro\data.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="intro\init.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="intro\functions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\authoring.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="intro\update.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\directx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sound.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\4klang.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\window.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\log.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="intro\intro.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\mutexlock.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\shaders.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\intro_hlsl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\shaders_shc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync-data.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync\base.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync\data.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync\device.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync\sync.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync\track.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\sync\usync.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="framework\video.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="intro\RenderMesh.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="framework\4klang.inc">
|
||||
<Filter>Header Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\lib\fxaa311.hlsl" />
|
||||
<None Include="shaders\lib\lighting.hlsl" />
|
||||
<None Include="shaders\lib\material.hlsl" />
|
||||
<None Include="shaders\lib\ogl2dx.hlsl" />
|
||||
<None Include="shaders\lib\postprocessing.hlsl" />
|
||||
<None Include="shaders\lib\rt.hlsl" />
|
||||
<None Include="shaders\lib\sdf.hlsl" />
|
||||
<None Include="shaders\lib\utils.hlsl" />
|
||||
<None Include="shaders\parts\shared.hlsl" />
|
||||
<None Include="shaders\parts\part2.hlsl" />
|
||||
<None Include="shaders\parts\part1.hlsl" />
|
||||
<None Include="shaders\lib\blur.hlsl" />
|
||||
<None Include="shaders\lib\distance-transform.hlsl" />
|
||||
<None Include="shaders\lib\grid-lines.hlsl" />
|
||||
<None Include="shaders\lib\shared.hlsl" />
|
||||
<None Include="shaders\lib\textures.hlsl" />
|
||||
<None Include="shaders\lib\mesh.hlsl" />
|
||||
<None Include="shaders\lib\ssao.hlsl" />
|
||||
<None Include="shaders\lib\raymarching.hlsl" />
|
||||
<None Include="shaders\lib\postprocess.hlsl" />
|
||||
<None Include="shaders\lib\volumetric-fog.hlsl" />
|
||||
<None Include="shaders\lib\particles.hlsl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="framework\4klang.asm">
|
||||
<Filter>Source Files</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="shaders\intro.hlsl" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<FxCompile Include="framework\shaders\histogramSpread.hlsl" />
|
||||
<FxCompile Include="framework\shaders\paradeVectorscopeSpread.hlsl" />
|
||||
<FxCompile Include="framework\shaders\histogramMaximum.hlsl" />
|
||||
<FxCompile Include="framework\shaders\paradeVectorscopeMaximum.hlsl" />
|
||||
<FxCompile Include="framework\shaders\paradeVectorscopeGather.hlsl" />
|
||||
<FxCompile Include="framework\shaders\histogramGather.hlsl" />
|
||||
<FxCompile Include="framework\merged.hlsl" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
6
nordlicht2015-intro/src/intro/intro.vcxproj.user
Normal file
6
nordlicht2015-intro/src/intro/intro.vcxproj.user
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
96
nordlicht2015-intro/src/intro/intro/RenderMesh.h
Normal file
96
nordlicht2015-intro/src/intro/intro/RenderMesh.h
Normal file
@@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
#pragma data_seg(".meshVertexBufferDesc")
|
||||
static D3D11_BUFFER_DESC meshVertexBufferDesc =
|
||||
{
|
||||
0,
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_VERTEX_BUFFER,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
#pragma data_seg(".meshIndexBufferDesc")
|
||||
static D3D11_BUFFER_DESC meshIndexBufferDesc =
|
||||
{
|
||||
0,
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_INDEX_BUFFER,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
#pragma bss_seg(".meshBss")
|
||||
static float vertices[1024 * 1024 * 40];
|
||||
static UINT indices[1024 * 1024];
|
||||
static D3D11_SUBRESOURCE_DATA initialData;
|
||||
|
||||
#pragma code_seg(".RenderMesh")
|
||||
struct RenderMesh
|
||||
{
|
||||
public:
|
||||
struct MeshVIn
|
||||
{
|
||||
Vector3 pos;
|
||||
Vector4 uv;
|
||||
Vector3 normal;
|
||||
};
|
||||
|
||||
void Create(Mesh* _mesh)
|
||||
{
|
||||
_mesh->SetUVByMaterialId();
|
||||
auto meshVertices = _mesh->GetVertices();
|
||||
auto meshIndices = _mesh->GetIndices();
|
||||
|
||||
MeshVIn* vertex = (MeshVIn*)vertices;
|
||||
for (const auto& v : meshVertices)
|
||||
{
|
||||
vertex->pos = v->Position;
|
||||
vertex->uv = v->UV;
|
||||
vertex->normal = v->GetNormal();
|
||||
++vertex;
|
||||
}
|
||||
|
||||
UINT* index = indices;
|
||||
for (const auto& idx : meshIndices)
|
||||
{
|
||||
*index++ = idx;
|
||||
}
|
||||
|
||||
initialData.pSysMem = vertices;
|
||||
initialData.SysMemPitch = initialData.SysMemSlicePitch = meshVertexBufferDesc.ByteWidth = sizeof(MeshVIn) * meshVertices.Count();
|
||||
device->CreateBuffer(&meshVertexBufferDesc, &initialData, &VertexBuffer);
|
||||
|
||||
initialData.pSysMem = indices;
|
||||
initialData.SysMemPitch = initialData.SysMemSlicePitch = meshIndexBufferDesc.ByteWidth = sizeof(int) * meshIndices.Count();
|
||||
device->CreateBuffer(&meshIndexBufferDesc, &initialData, &IndexBuffer);
|
||||
|
||||
IndexCount = meshIndices.Count();
|
||||
Created = true;
|
||||
};
|
||||
|
||||
void Render()
|
||||
{
|
||||
UINT stride = sizeof(MeshVIn);
|
||||
UINT offset = 0;
|
||||
|
||||
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
context->IASetInputLayout(il_mesh);
|
||||
context->IASetVertexBuffers(0, 1, &VertexBuffer, &stride, &offset);
|
||||
context->IASetIndexBuffer(IndexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||
context->VSSetShader(vs_mesh, NULL, 0);
|
||||
context->GSSetShader(NULL, NULL, 0);
|
||||
context->DrawIndexed(IndexCount, 0, 0);
|
||||
context->IASetInputLayout(NULL);
|
||||
context->IASetVertexBuffers(0, 1, (ID3D11Buffer* const*)&offset, &stride, &offset);
|
||||
context->IASetIndexBuffer(NULL, DXGI_FORMAT_R32_UINT, 0);
|
||||
context->VSSetShader(NULL, NULL, 0);
|
||||
};
|
||||
|
||||
bool Created;
|
||||
ID3D11Buffer* VertexBuffer;
|
||||
ID3D11Buffer* IndexBuffer;
|
||||
UINT IndexCount;
|
||||
};
|
||||
211
nordlicht2015-intro/src/intro/intro/data.h
Normal file
211
nordlicht2015-intro/src/intro/intro/data.h
Normal file
@@ -0,0 +1,211 @@
|
||||
#pragma once
|
||||
|
||||
#define FONT_WIDTH 1792
|
||||
#define FONT_HEIGHT 256
|
||||
#define FONT_SIZE 500
|
||||
|
||||
// types
|
||||
struct TEXTURE_2D_SRV_UAV_RTV
|
||||
{
|
||||
ID3D11Texture2D* TEX;
|
||||
ID3D11ShaderResourceView* SRV;
|
||||
ID3D11UnorderedAccessView* UAV;
|
||||
ID3D11RenderTargetView* RTV;
|
||||
};
|
||||
|
||||
#pragma bss_seg(".introbss")
|
||||
static HFONT font;
|
||||
static ID3D11Texture3D* noiseTex3d;
|
||||
static ID3D11ShaderResourceView* noiseTex3dSRV;
|
||||
static ID3D11UnorderedAccessView* noiseTex3dUAV;
|
||||
static ID3D11Buffer* constantBuffers[2];
|
||||
static TEXTURE_2D_SRV_UAV_RTV tempTexture;
|
||||
static TEXTURE_2D_SRV_UAV_RTV tempTexture2;
|
||||
static TEXTURE_2D_SRV_UAV_RTV stone;
|
||||
static TEXTURE_2D_SRV_UAV_RTV gridTex;
|
||||
static TEXTURE_2D_SRV_UAV_RTV gridTerrainHeight;
|
||||
static TEXTURE_2D_SRV_UAV_RTV fontTextTemp;
|
||||
static TEXTURE_2D_SRV_UAV_RTV fontText;
|
||||
static TEXTURE_2D_SRV_UAV_RTV dt_g, dt_s, dt_t;
|
||||
static TEXTURE_2D_SRV_UAV_RTV tmpTex1;
|
||||
static TEXTURE_2D_SRV_UAV_RTV blurTex1;
|
||||
static TEXTURE_2D_SRV_UAV_RTV tmpTex8;
|
||||
static TEXTURE_2D_SRV_UAV_RTV blurTex8;
|
||||
static TEXTURE_2D_SRV_UAV_RTV tmpTex32;
|
||||
static TEXTURE_2D_SRV_UAV_RTV blurTex32;
|
||||
static TEXTURE_2D_SRV_UAV_RTV gTexture;
|
||||
static ID3D11SamplerState* samplerStates[3];
|
||||
static D3D11_MAPPED_SUBRESOURCE introMappedResource;
|
||||
static float distanceData[2 * FONT_WIDTH * FONT_HEIGHT];
|
||||
static float zero[32];
|
||||
static float ones[] = { 1, 1, 1, 1 };
|
||||
static float inf[] = { 0, 0, 0, D3D11_FLOAT32_MAX };
|
||||
static RenderMesh landscape;
|
||||
static RenderMesh landscapeKrallen;
|
||||
static RenderMesh obelisk0;
|
||||
static RenderMesh obelisk1;
|
||||
static RenderMesh obelisk2;
|
||||
static RenderMesh skeleton;
|
||||
static TEXTURE_2D_SRV_UAV_RTV greetingsTEXs[20];
|
||||
static TEXTURE_2D_SRV_UAV_RTV creditsTEXs[3];
|
||||
|
||||
#pragma data_seg(".meshInputLayoutDesc")
|
||||
extern D3D11_INPUT_ELEMENT_DESC meshInputLayoutDesc[3] =
|
||||
{
|
||||
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 28, D3D11_INPUT_PER_VERTEX_DATA, 0 }
|
||||
};
|
||||
|
||||
#pragma data_seg(".constantBufferSyncDesc")
|
||||
static D3D11_BUFFER_DESC constantBufferSyncDesc =
|
||||
{
|
||||
sizeof(SYNC_TYPE_NAME),
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_CONSTANT_BUFFER,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
struct ConstantBufferType
|
||||
{
|
||||
float time;
|
||||
float aspectRatio;
|
||||
float padding1;
|
||||
float padding2;
|
||||
};
|
||||
|
||||
struct ObjConstantBufferType
|
||||
{
|
||||
float posX;
|
||||
float posY;
|
||||
float posZ;
|
||||
float posW;
|
||||
float rotX;
|
||||
float rotY;
|
||||
float rotZ;
|
||||
float scale;
|
||||
};
|
||||
|
||||
#pragma bss_seg(".constantBuffer")
|
||||
static ConstantBufferType constantBuffer;
|
||||
|
||||
#pragma data_seg(".constantBufferDesc")
|
||||
static D3D11_BUFFER_DESC constantBufferDesc =
|
||||
{
|
||||
sizeof(ConstantBufferType) * 4,
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_CONSTANT_BUFFER,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
#pragma data_seg(".clampSamplerDesc")
|
||||
static D3D11_SAMPLER_DESC clampSamplerDesc =
|
||||
{
|
||||
D3D11_FILTER_MIN_MAG_MIP_LINEAR,
|
||||
D3D11_TEXTURE_ADDRESS_CLAMP,
|
||||
D3D11_TEXTURE_ADDRESS_CLAMP,
|
||||
D3D11_TEXTURE_ADDRESS_CLAMP,
|
||||
0.0f,
|
||||
1,
|
||||
D3D11_COMPARISON_NEVER,
|
||||
{ 0, 0, 0, 0 },
|
||||
0,
|
||||
D3D11_FLOAT32_MAX
|
||||
};
|
||||
|
||||
#pragma data_seg(".wrapSamplerDesc")
|
||||
static D3D11_SAMPLER_DESC wrapSamplerDesc =
|
||||
{
|
||||
D3D11_FILTER_MIN_MAG_MIP_LINEAR,
|
||||
D3D11_TEXTURE_ADDRESS_WRAP,
|
||||
D3D11_TEXTURE_ADDRESS_WRAP,
|
||||
D3D11_TEXTURE_ADDRESS_WRAP,
|
||||
0.0f,
|
||||
1,
|
||||
D3D11_COMPARISON_NEVER,
|
||||
{ 0, 0, 0, 0 },
|
||||
0,
|
||||
D3D11_FLOAT32_MAX
|
||||
};
|
||||
|
||||
#pragma data_seg(".mirrorSamplerDesc")
|
||||
static D3D11_SAMPLER_DESC mirrorSamplerDesc =
|
||||
{
|
||||
D3D11_FILTER_MIN_MAG_MIP_LINEAR,
|
||||
D3D11_TEXTURE_ADDRESS_MIRROR,
|
||||
D3D11_TEXTURE_ADDRESS_MIRROR,
|
||||
D3D11_TEXTURE_ADDRESS_MIRROR,
|
||||
0.0f,
|
||||
1,
|
||||
D3D11_COMPARISON_NEVER,
|
||||
{ 0, 0, 0, 0 },
|
||||
0,
|
||||
D3D11_FLOAT32_MAX
|
||||
};
|
||||
|
||||
#pragma data_seg(".fontTexDesc")
|
||||
static D3D11_TEXTURE2D_DESC fontTexDesc =
|
||||
{
|
||||
FONT_WIDTH, FONT_HEIGHT, 1, 1, DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
{ 1, 0 }, D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_SHADER_RESOURCE,
|
||||
0, 0
|
||||
};
|
||||
|
||||
#pragma data_seg(".greetings")
|
||||
static char* greetings[] =
|
||||
{
|
||||
" Andromeda ASD ",
|
||||
" Approximate ",
|
||||
" Brainstorm ",
|
||||
" UF&DD CNCD ",
|
||||
" Conspiracy ",
|
||||
" Ctrl+Alt+Test ",
|
||||
" Fairlight ",
|
||||
" Farbrausch ",
|
||||
" FRequency ",
|
||||
" ½-bit Cheese ",
|
||||
" Haujobb ",
|
||||
" Loonies MFX ",
|
||||
" Mercury TBC ",
|
||||
" Nuance Still ",
|
||||
" Panda Cube ",
|
||||
" Quite Rebels ",
|
||||
" RGBA SQNY ",
|
||||
" Scoopex TBL ",
|
||||
" Titan TRSi ",
|
||||
};
|
||||
|
||||
#pragma data_seg(".credits")
|
||||
static char* credits[] =
|
||||
{
|
||||
" xTr1m ",
|
||||
" hel ",
|
||||
" p0wl ",
|
||||
};
|
||||
|
||||
#pragma data_seg(".noiseTexDesc")
|
||||
static D3D11_TEXTURE3D_DESC noiseTexDesc =
|
||||
{
|
||||
512,
|
||||
64,
|
||||
512,
|
||||
1,
|
||||
DXGI_FORMAT_R32_FLOAT,
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS,
|
||||
0, 0
|
||||
};
|
||||
|
||||
#pragma data_seg(".standardTexDesc")
|
||||
static D3D11_TEXTURE2D_DESC standardTexDesc =
|
||||
{
|
||||
0, 0, 1, 1, DXGI_FORMAT_R16G16B16A16_FLOAT,
|
||||
{ 1, 0 }, D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS,
|
||||
0, D3D11_RESOURCE_MISC_GENERATE_MIPS
|
||||
};
|
||||
850
nordlicht2015-intro/src/intro/intro/init.h
Normal file
850
nordlicht2015-intro/src/intro/intro/init.h
Normal file
@@ -0,0 +1,850 @@
|
||||
#pragma once
|
||||
|
||||
#pragma code_seg(".createSRVUAVRTV")
|
||||
|
||||
const int TerrainMaterialId = 0;
|
||||
const int ObeliskSockelMaterialId = 1;
|
||||
const int ObeliskCrystalMaterialId = 2;
|
||||
const int Metal1MaterialId = 3;
|
||||
const int Metal2MaterialId = 4;
|
||||
const int CoolKralleMaterialId = 5;
|
||||
|
||||
void __stdcall createSRVUAVRTV(TEXTURE_2D_SRV_UAV_RTV* tex, int width, int height, const D3D11_SUBRESOURCE_DATA* data = 0)
|
||||
{
|
||||
standardTexDesc.Width = width;
|
||||
standardTexDesc.Height = height;
|
||||
device->CreateTexture2D(&standardTexDesc, data, &tex->TEX); // +14h
|
||||
device->CreateShaderResourceView(tex->TEX, NULL, &tex->SRV); // +1Ch
|
||||
device->CreateUnorderedAccessView(tex->TEX, NULL, &tex->UAV); // +20h
|
||||
device->CreateRenderTargetView(tex->TEX, NULL, &tex->RTV); // +24h
|
||||
}
|
||||
|
||||
void distanceTransformGPU(ID3D11ShaderResourceView* source, ID3D11UnorderedAccessView* target)
|
||||
{
|
||||
context->ClearUnorderedAccessViewUint(dt_g.UAV, (UINT*)zero);
|
||||
context->ClearUnorderedAccessViewUint(dt_s.UAV, (UINT*)zero);
|
||||
context->ClearUnorderedAccessViewUint(dt_t.UAV, (UINT*)zero);
|
||||
ID3D11UnorderedAccessView* uavs[] = { dt_g.UAV, dt_s.UAV, dt_t.UAV, target };
|
||||
context->CSSetShaderResources(0, 1, &source);
|
||||
context->CSSetUnorderedAccessViews(0, 4, uavs, NULL);
|
||||
context->CSSetShader(csDT1, NULL, NULL);
|
||||
context->Dispatch(FONT_WIDTH / 16, 1, 1);
|
||||
context->CSSetShader(csDT2, NULL, NULL);
|
||||
context->Dispatch(1, FONT_HEIGHT / 16, 1);
|
||||
context->CSSetUnorderedAccessViews(0, 4, (ID3D11UnorderedAccessView* const*)zero, NULL);
|
||||
context->CSSetShaderResources(0, 1, (ID3D11ShaderResourceView* const*)zero);
|
||||
}
|
||||
|
||||
Mesh* Obelisk(float sharpness = 0.5f, float twist = 0.0f, float symbolsSize = 1.0f, bool makeHole = false, bool makeRing = true)
|
||||
{
|
||||
auto mesh = Mesh::Cube(Vector3::zero, 1.0f, false);
|
||||
mesh->SetMaterialId(ObeliskSockelMaterialId);
|
||||
mesh->Scale(Vector3(1, 0.25f, 1));
|
||||
|
||||
Selection* selection = mesh->SelectFaces(Vector3::up);
|
||||
selection->Bevel(0.2f, 0.5f);
|
||||
selection->SetMaterialId(ObeliskCrystalMaterialId);
|
||||
selection->Bevel(0.2f, 2);
|
||||
|
||||
Selection* optionalWeldSelection = nullptr;
|
||||
if (twist == 0)
|
||||
{
|
||||
auto sides = selection->Bevel(2.0f, sharpness);
|
||||
if (makeHole)
|
||||
{
|
||||
optionalWeldSelection = sides->SelectFaces();
|
||||
sides = sides->SelectFaces(Vector3::right, 0.5f, true);
|
||||
sides->Bevel(0, 0.45f);
|
||||
sides->Subdivide(3);
|
||||
sides->Extrude(0.1f);
|
||||
sides->Project({ Vector3::right, Vector3::zero });
|
||||
sides->Delete();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
selection->AddSideIndexAsTagWhenExtruding = true;
|
||||
const int segments = 20;
|
||||
auto radPerSegment = twist / segments;
|
||||
for (int i = 0; i < segments; ++i)
|
||||
{
|
||||
selection->Rotate(Vector3::up, radPerSegment);
|
||||
selection->Bevel(2.0f / segments, 1.0f - (1.0f - sharpness) / segments);
|
||||
}
|
||||
selection->AddSideIndexAsTagWhenExtruding = false;
|
||||
|
||||
selection->Rotate(Vector3::up, radPerSegment);
|
||||
}
|
||||
|
||||
selection->Bevel(0.2f, 0);
|
||||
selection->Collapse();
|
||||
|
||||
//mesh->DetachAll();
|
||||
mesh->GroupFaces(0.2f);
|
||||
mesh->SetUVGenerator(new PlaneUVGenerator(0, PlaneUVGenerator::UVScaleMode::ScaleByValue, Vector3::one, Vector3::up));
|
||||
mesh->UVUnwrap();
|
||||
|
||||
/*if (optionalWeldSelection)
|
||||
optionalWeldSelection->WeldVertices();*/
|
||||
|
||||
if (twist != 0)
|
||||
{
|
||||
for (int i = 0; i < selection->SideCountOfLastExtrude; ++i)
|
||||
{
|
||||
auto tag = (char*)(i + Selection::ExtrudeResultSideIndexBase);
|
||||
auto side = mesh->SelectFaces(tag);
|
||||
side->RemoveTag(tag);
|
||||
side->WeldVertices();
|
||||
}
|
||||
}
|
||||
|
||||
List<int> mods;
|
||||
mods.Add(2);
|
||||
|
||||
if (makeRing)
|
||||
{
|
||||
auto deco = Mesh::Plane(Vector3::zero, 2.0f, PlaneDirection::Up);
|
||||
deco->SetMaterialId(Metal1MaterialId);
|
||||
deco->Subdivide(2);
|
||||
selection = deco->SelectFaces();
|
||||
selection->Bevel(0, 0.4f);
|
||||
selection->Delete();
|
||||
selection = deco->SelectFaces();
|
||||
selection->Clone()->FlipSides();
|
||||
auto sides = selection->Extrude(0.2f);
|
||||
|
||||
sides = sides->SelectFaces(mods, true);
|
||||
|
||||
sides->Tesselate();
|
||||
sides->DetachAll();
|
||||
sides->Bevel(0.1f, 0.5f);
|
||||
sides->Bevel(-0.1f, 0.8f);
|
||||
//sides->Bevel(2, 0);
|
||||
deco->DetachAll();
|
||||
deco->Move(Vector3(0, 0.5f, 0));
|
||||
|
||||
mesh->MoveToOwnMesh(deco->SelectFaces());
|
||||
}
|
||||
|
||||
if (symbolsSize != 0)
|
||||
{
|
||||
auto deco = Mesh::Plane({ 0, -0.6f, 0 }, symbolsSize, PlaneDirection::Up);
|
||||
deco->SetMaterialId(Metal2MaterialId);
|
||||
selection = deco->SelectFaces();
|
||||
selection->Bevel(0, 0.9f);
|
||||
|
||||
selection->Delete();
|
||||
selection = deco->SelectFaces();
|
||||
auto bottom = selection->Clone();
|
||||
deco->WeldVertices();
|
||||
bottom->FlipSides();
|
||||
auto sides = selection->Extrude(0.2f);
|
||||
sides = sides->SelectFaces(mods, true);
|
||||
selection->Scale(0.75f);
|
||||
bottom->Scale(0.8f);
|
||||
|
||||
sides->Tesselate();
|
||||
sides->Tesselate();
|
||||
sides->Tesselate();
|
||||
|
||||
mods.Clear();
|
||||
mods.Add(3);
|
||||
selection = sides->SelectFaces(mods, true);
|
||||
selection->Bevel(-0.01f, 0.5f);
|
||||
|
||||
mods.Clear();
|
||||
mods.Add(4);
|
||||
selection = sides->SelectFaces(mods, true)->SelectFacesExcept(selection);
|
||||
selection->Bevel(-0.01f, 0.5f);
|
||||
|
||||
deco->DetachAll();
|
||||
deco->Move(Vector3(0, 1.5f, 0));
|
||||
|
||||
mesh->MoveToOwnMesh(deco->SelectFaces());
|
||||
}
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
Mesh* RootPortal()
|
||||
{
|
||||
List<Vector3> pathElements;
|
||||
pathElements.Add(Vector3::zero);
|
||||
pathElements.Add(Vector3::up);
|
||||
pathElements.Add(Vector3::up + Vector3::up);
|
||||
pathElements.Add(Vector3::up + Vector3::up + Vector3::up + Vector3::right);
|
||||
pathElements.Add(Vector3::up + Vector3::up + Vector3::up + Vector3::right + Vector3::right);
|
||||
pathElements.Add(Vector3::up + Vector3::up + Vector3::up + Vector3::right + Vector3::right + Vector3::down);
|
||||
|
||||
List<float> scaleElements;
|
||||
scaleElements.Add(1);
|
||||
scaleElements.Add(0.5f);
|
||||
scaleElements.Add(0.5f);
|
||||
scaleElements.Add(0);
|
||||
|
||||
List<float> rotationElements;
|
||||
rotationElements.Add(0);
|
||||
rotationElements.Add(Math::Pi / 2.0f);
|
||||
rotationElements.Add(Math::Pi * 2);
|
||||
|
||||
Path path;
|
||||
path.SetPoints(pathElements);
|
||||
path.SetScale(scaleElements);
|
||||
path.SetRotation(rotationElements);
|
||||
|
||||
auto mesh = Mesh::Plane(Vector3::zero, 1.0f, PlaneDirection::Down);
|
||||
mesh->Subdivide(3);
|
||||
|
||||
auto selection = mesh->Clone();
|
||||
selection->Move(Vector3::right);
|
||||
selection->Scale(0.6f);
|
||||
selection = mesh->Clone();
|
||||
selection->Move(Vector3::forward);
|
||||
selection->Scale(1.3f);
|
||||
|
||||
mesh->SetCenter(Vector3::zero);
|
||||
|
||||
selection = mesh->Clone();
|
||||
selection->Loft(path, 20, true);
|
||||
|
||||
mesh->SetCenter(Vector3::zero);
|
||||
|
||||
auto selection0 = mesh->SelectFaces();
|
||||
selection = selection0->Clone();
|
||||
selection->Rotate(Vector3::up, Math::Pi);
|
||||
selection->Move(Vector3::right + Vector3::right);
|
||||
mesh->SetCenter(Vector3::zero);
|
||||
|
||||
List<int> mods;
|
||||
mods.Add(5);
|
||||
mods.Add(8);
|
||||
|
||||
auto spikePoints = mesh->SelectVertices(mods, true);
|
||||
spikePoints->ExtrudeVertices(0.1f, 0.25f);
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
void CreateArm(Selection* base, float scale, const Vector3& axis, float distort)
|
||||
{
|
||||
auto sides = base->Bevel(scale * 2, 0.8f);
|
||||
auto sideCount = sides->GetFaces().Count();
|
||||
|
||||
base->Subdivide();
|
||||
base->AddTag((char*)0);
|
||||
base->AddTag((char*)666);
|
||||
const int segments = 15;
|
||||
auto radPerSegment = 3.0f / segments;
|
||||
base->AddSideIndexAsTagWhenExtruding = true;
|
||||
|
||||
for (int i = 0; i < segments; ++i)
|
||||
{
|
||||
float factor = (i + 1.0f) / segments;
|
||||
|
||||
auto growth = (i + 1) % 4 == 0 ? 2 : 0;
|
||||
base->Bevel(base->GetNormal() * 10.0f / segments * scale, 1 - factor + growth);
|
||||
base->RotateAround(base->GetCenter(), axis, radPerSegment);
|
||||
|
||||
for (const auto& vertex : base->GetVertices())
|
||||
vertex->UV.z = factor;
|
||||
}
|
||||
|
||||
base->AddSideIndexAsTagWhenExtruding = false;
|
||||
base->Collapse();
|
||||
auto sideCountOfLastExtrude = base->SideCountOfLastExtrude;
|
||||
base = base->GetMesh()->SelectFaces((char*)0);
|
||||
int i = 0;
|
||||
for (const auto& vertex : base->GetVertices())
|
||||
{
|
||||
vertex->Position += Vector3((i % 5) / 5.0f, 0, (i % 9) / 9.0f) * 0.5f * scale * distort;
|
||||
++i;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= 10; ++i)
|
||||
base->SelectFaces(5 * i)->Collapse();
|
||||
|
||||
for (int i = 0; i < sideCountOfLastExtrude; ++i)
|
||||
{
|
||||
auto tag = (char*)(i + Selection::ExtrudeResultSideIndexBase);
|
||||
auto side = base->GetMesh()->SelectFaces(tag);
|
||||
side->RemoveTag(tag);
|
||||
side->Detach();
|
||||
}
|
||||
|
||||
base->GetMesh()->RemoveTag((char*)0);
|
||||
sides->WeldVertices(0, base);
|
||||
}
|
||||
|
||||
void CreateCave(Mesh* mesh)
|
||||
{
|
||||
Selection* base = mesh->SelectFaces();
|
||||
auto normal = base->GetNormal();
|
||||
normal.y = 0;
|
||||
normal.Normalize();
|
||||
base->Flatten(normal);
|
||||
base->Extrude(-0.5f);
|
||||
base->AddTag((char*)0);
|
||||
|
||||
base->Scale(Vector3(4, 1, 4));
|
||||
base->Extrude(-2);
|
||||
base->Scale(Vector3(4, 1, 4));
|
||||
base->Extrude(-4);
|
||||
base->Scale(Vector3(4, 1, 4));
|
||||
|
||||
base->AddTag((char*)1);
|
||||
|
||||
base->Extrude(-8);
|
||||
base->Extrude(-8);
|
||||
base->Extrude(-8);
|
||||
base->RemoveTag((char*)1);
|
||||
base->Bevel(-8, 0);
|
||||
base->Collapse();
|
||||
|
||||
base = mesh->SelectFaces((char*)0);
|
||||
base = base->SelectFaces(Vector3::up, 0.2f);
|
||||
base->Move(Vector3::down * 6);
|
||||
base = mesh->SelectFaces((char*)1);
|
||||
base = base->SelectFaces(Vector3::up, 0.2f);
|
||||
base->Flatten();
|
||||
base->Bevel(0, 0.5f);
|
||||
|
||||
List<int> mods;
|
||||
|
||||
mods.Add(3);
|
||||
Selection* selection = base->SelectVertices(mods, true);
|
||||
selection->Move(Vector3(0, 1, 0));
|
||||
|
||||
mods.Add(7);
|
||||
selection = base->SelectVertices(mods, true);
|
||||
selection->Move(Vector3(0, 0.5f, 0));
|
||||
|
||||
mods.Add(5);
|
||||
selection = base->SelectVertices(mods, true);
|
||||
selection->Move(Vector3(0, -0.5f, 0));
|
||||
base->Tesselate();
|
||||
|
||||
base->Tesselate();
|
||||
|
||||
auto count = base->GetFaces().Count();
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
auto f = base->SelectFaces(i);
|
||||
f->RotateAround(f->GetCenter(), Vector3::up, 0.2f * ((i % 2) == 0 ? 1 : -1));
|
||||
}
|
||||
base->Tesselate();
|
||||
base->Tesselate();
|
||||
|
||||
mods.Add(3);
|
||||
base = base->SelectFaces(mods, true);
|
||||
base->DetachAll();
|
||||
|
||||
count = base->GetFaces().Count();
|
||||
List<FaceSelection*> selections;
|
||||
for (int i = 0; i < count; ++i)
|
||||
selections.Add(base->SelectFaces(i));
|
||||
|
||||
auto center = mesh->GetCenter();
|
||||
for (auto root : selections)
|
||||
{
|
||||
auto dirToCenter = center - root->GetCenter();
|
||||
dirToCenter.y = 0;
|
||||
auto length = dirToCenter.GetLength();
|
||||
auto factor = 1.0f - Math::Clamp01(length / 20.0f);
|
||||
dirToCenter.Normalize();
|
||||
root->Bevel(Vector3::up * 0.1f, 0.5f);
|
||||
root->Bevel(Vector3::up * 0.5f - dirToCenter * 1 * factor, 0.5f);
|
||||
root->Bevel(Vector3::up * 0.5f - dirToCenter * 1.5f * factor, 0);
|
||||
root->Collapse();
|
||||
}
|
||||
}
|
||||
|
||||
Mesh** Landscape()
|
||||
{
|
||||
auto mesh = Mesh::Plane(Vector3::zero, 6.0f, PlaneDirection::Up);
|
||||
mesh->AddTag((char*)1);
|
||||
mesh->Tesselate();
|
||||
mesh->Tesselate();
|
||||
mesh->Tesselate();
|
||||
List<int> mods;
|
||||
mods.Add(3);
|
||||
Selection* selection = mesh->SelectVertices(mods, true);
|
||||
selection->Move(Vector3(0, 0.1f, 0));
|
||||
|
||||
mods.Add(7);
|
||||
selection = mesh->SelectVertices(mods, true);
|
||||
selection->Move(Vector3(0, 0.15f, 0));
|
||||
|
||||
mods.Add(5);
|
||||
selection = mesh->SelectVertices(mods, true);
|
||||
selection->Move(Vector3(0, 0.1f, 0));
|
||||
mesh->Tesselate();
|
||||
|
||||
selection = mesh->SelectVertices(Plane(Vector3::right, Vector3::left * 0.4f))->SelectVertices(Plane(Vector3::left, Vector3::right * 0.4f));
|
||||
selection->Move(Vector3::down * 0.2f);
|
||||
|
||||
mesh->Tesselate();
|
||||
|
||||
mods.Clear();
|
||||
mods.Add(7);
|
||||
selection = mesh->SelectFaces(mods, true);
|
||||
Selection* sides[2];
|
||||
sides[0] = selection->SelectFaces(Plane(Vector3::left, Vector3::left * 0.6f))->SelectFaces(Plane(Vector3::right, Vector3::left * 0.6f * 2));
|
||||
sides[1] = selection->SelectFaces(Plane(Vector3::right, Vector3::right * 0.6f))->SelectFaces(Plane(Vector3::left, Vector3::right * 0.6f * 2))->SelectFacesExcept(sides[0]);
|
||||
|
||||
List<FaceSelection*> sideSelections[2];
|
||||
for (int k = 0; k < 2; ++k)
|
||||
{
|
||||
sides[k]->RemoveTag((char*)1);
|
||||
auto count = sides[k]->GetFaces().Count();
|
||||
for (int i = 0; i < count; ++i)
|
||||
sideSelections[k].Add(sides[k]->SelectFaces(i));
|
||||
}
|
||||
|
||||
int c = 0;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
for (auto side : sideSelections[i])
|
||||
{
|
||||
side->Flatten();
|
||||
auto factor = (c % 8) / 8.0f * 0.1f;
|
||||
CreateArm(side, 0.05f + factor, i == 0 ? Vector3::back : Vector3::forward, 1);
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
auto ground = mesh->SelectFaces((char*)1);
|
||||
|
||||
selection = ground->SelectVertices(Plane(Vector3::right, Vector3::left * 0.2f))->SelectVertices(Plane(Vector3::left, Vector3::right * 0.2f));
|
||||
selection->Move(Vector3::down * 10); // set to 0.3f to remove canyon
|
||||
ground->Tesselate();
|
||||
|
||||
int i = 0;
|
||||
for (const auto& vertex : ground->GetVertices())
|
||||
{
|
||||
vertex->Position -= Vector3::up * ((i % 10) / 10.0f * 0.1f);
|
||||
++i;
|
||||
}
|
||||
|
||||
auto arms = mesh->SelectFaces((char*)666);
|
||||
auto armsMesh = arms->CloneToNewMesh();
|
||||
armsMesh->SetMaterialId(CoolKralleMaterialId);
|
||||
arms->Delete();
|
||||
|
||||
auto resultMeshs = new Mesh*[2];
|
||||
resultMeshs[0] = mesh;
|
||||
resultMeshs[1] = armsMesh;
|
||||
return resultMeshs;
|
||||
}
|
||||
|
||||
void StepPlace(Selection* element, const Vector3& pos, const Vector3& dir)
|
||||
{
|
||||
auto angle = Math::Atan2(dir.x, dir.z);
|
||||
element->Move(pos);
|
||||
element->Rotate(Vector3::up, angle);
|
||||
}
|
||||
|
||||
void CreateRib(Selection* base, Vector3 rotationAxis, float ribLength, float endRotation, int segments, float forwardStrength, float scale)
|
||||
{
|
||||
base->AddTag((char*)0);
|
||||
auto radPerSegment = endRotation / segments;
|
||||
for (int i = 0; i < segments; ++i)
|
||||
{
|
||||
base->Rotate(rotationAxis, radPerSegment);
|
||||
base->Bevel(ribLength / segments, Math::Clamp01(1.0f - scale / segments * i));
|
||||
base->Move(Vector3::forward * i / (float)segments * forwardStrength);
|
||||
}
|
||||
}
|
||||
|
||||
Mesh* Head()
|
||||
{
|
||||
auto mesh = Mesh::Cube(Vector3::zero, 1, true);
|
||||
|
||||
mesh->Scale({ 1, 1, 3 });
|
||||
|
||||
auto down = mesh->SelectFaces(Vector3::down);
|
||||
auto up = mesh->SelectFaces(Vector3::up);
|
||||
auto back = mesh->SelectFaces(Vector3::back);
|
||||
auto front = mesh->SelectFaces(Vector3::forward);
|
||||
auto sides = mesh->SelectFaces(Vector3::right, 0, true);
|
||||
|
||||
|
||||
back->Scale({ 2, 1.35f, 1 });
|
||||
back->Move({ 0, 1, 0 });
|
||||
|
||||
down->Bevel(-0.5f, 0.5f);
|
||||
down->Move({ 0, 0, 0.25f });
|
||||
down->Flatten(Vector3::down);
|
||||
|
||||
sides->Bevel(0, 0.25f);
|
||||
//sides->Move({ 0, -0.25f, 1 });
|
||||
sides->Bevel(-0.2f, 0.5f);
|
||||
|
||||
mesh->Subdivide();
|
||||
|
||||
auto nose1 = front->SelectFaces(0);
|
||||
auto nose2 = front->SelectFaces(1);
|
||||
|
||||
nose1->Bevel(0.5f, 0.5f);
|
||||
nose2->Bevel(0.5f, 0.5f);
|
||||
nose1->Flatten();
|
||||
nose2->Flatten();
|
||||
|
||||
nose1->Bevel(-0.75f, 1);
|
||||
nose2->Bevel(-0.75f, 1);
|
||||
|
||||
sides->Bevel(-0.5f, 0.5f);
|
||||
sides->Scale({ 1, 0.2f, 1 });
|
||||
sides->Move({ 0, -0.2f, 0 });
|
||||
up->Bevel(-0.35f, 0.75f);
|
||||
|
||||
back->Bevel(-0.1f, 0.25f);
|
||||
back->Subdivide();
|
||||
back->Bevel(-0.4f, 0.5f);
|
||||
mesh->Subdivide();
|
||||
|
||||
auto line = up->SelectFaces(Plane{ Vector3::right, Vector3{ 0.3f, 0, 0 } })->SelectFacesIncluding(up->SelectFaces(Plane{ Vector3::left, Vector3{ -0.3f, 0, 0 } }));
|
||||
//line->Flatten(Vector3::up);
|
||||
line->Bevel(0.2f, 0.25f);
|
||||
line->Scale({ 1, 1, 0.5f });
|
||||
|
||||
|
||||
// Jaw
|
||||
|
||||
{
|
||||
auto plane = Plane{ Vector3::down, Vector3::zero };
|
||||
auto upperJaw = mesh->SelectFaces(plane);
|
||||
auto jaw = upperJaw->SelectFaces(plane)->CloneToNewMesh();
|
||||
auto lower = jaw->SelectFaces();
|
||||
auto upper = jaw->Clone();
|
||||
lower->Extrude(Vector3::down);
|
||||
jaw->WeldVertices();
|
||||
upper->Mirror(plane);
|
||||
jaw->Scale({ 0.9f, 0.1f, 1 });
|
||||
jaw->Move({ 0, 0.4f, -0.2f });
|
||||
jaw->RotateAround(Vector3::zero, Vector3::right, 0.54f);
|
||||
|
||||
upper->DetachAll();
|
||||
upper->Bevel(0.1f, 0.1f);
|
||||
lower->DetachAll();
|
||||
lower->Bevel(0.1f, 0.1f);
|
||||
|
||||
upperJaw->DetachAll();
|
||||
upperJaw->Bevel(0.1f, 0.1f);
|
||||
|
||||
mesh->MoveToOwnMesh(jaw->SelectFaces());
|
||||
}
|
||||
mesh->WeldVertices();
|
||||
|
||||
mesh->Move({ 0, -2 });
|
||||
return mesh;
|
||||
}
|
||||
|
||||
Mesh* Skeleton()
|
||||
{
|
||||
auto mesh = Mesh::Cube(Vector3::zero, 1, true);
|
||||
auto forward = mesh->SelectFaces(Vector3::forward);
|
||||
auto back = mesh->SelectFaces(Vector3::back);
|
||||
auto right = mesh->SelectFaces(Vector3::right);
|
||||
auto left = mesh->SelectFaces(Vector3::left);
|
||||
auto up = mesh->SelectFaces(Vector3::up);
|
||||
up->AddTag((char*)1);
|
||||
auto down = mesh->SelectFaces(Vector3::down);
|
||||
auto leftAndright = left->SelectFacesIncluding(right);
|
||||
|
||||
mesh->Subdivide();
|
||||
|
||||
leftAndright->Bevel(0.5f, 0.25f);
|
||||
up->Extrude(0.5f);
|
||||
up->Scale({ 0.25f, 1, 1 });
|
||||
|
||||
forward->Move(Vector3::forward * 0.5f);
|
||||
back->Move(Vector3::back * 0.25f);
|
||||
back->Flatten();
|
||||
leftAndright->Extrude(0.5f);
|
||||
leftAndright->Move(Vector3::down * 0.5f);
|
||||
|
||||
auto result = new Mesh();
|
||||
|
||||
auto bone = result->MoveToOwnMesh(mesh->SelectFaces());
|
||||
|
||||
left->Flatten(Vector3::right);
|
||||
right->Flatten(Vector3::right);
|
||||
|
||||
auto bone2 = result->MoveToOwnMesh(mesh->SelectFaces());
|
||||
|
||||
auto boneBounds = bone->GetBounds();
|
||||
auto length = boneBounds.Max.z - boneBounds.Min.z - 0.35f;
|
||||
|
||||
Vector3 pos;
|
||||
Vector3 dir;
|
||||
|
||||
dir = Vector3::forward;
|
||||
|
||||
const int elements = 11;
|
||||
for (int i = 0; i < elements; ++i)
|
||||
{
|
||||
auto factor = (float)i / elements;
|
||||
if (i % 2 == 0 || i > 10)
|
||||
{
|
||||
auto clone = bone->Clone();
|
||||
auto upperThingy = clone->SelectFaces((char*)1);
|
||||
auto factor2 = 0.5f * factor;
|
||||
upperThingy->Move(Vector3::up * factor2 * 2);
|
||||
|
||||
|
||||
upperThingy->Scale({ 1, 1, 1 - factor2 });
|
||||
StepPlace(clone, pos, dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto clone = bone2->CloneToNewMesh();
|
||||
auto rightRib = clone->SelectFaces(Vector3::right);
|
||||
auto leftRib = clone->SelectFaces(Vector3::left);
|
||||
|
||||
auto ribAxis1 = Vector3::back + Vector3::up * 0.5f;
|
||||
auto ribAxis2 = Vector3::back + Vector3::up * 0.6f;
|
||||
ribAxis1.Normalize();
|
||||
ribAxis2.Normalize();
|
||||
|
||||
auto forwardFactor = 2 * factor;
|
||||
CreateRib(rightRib, ribAxis1, 10, Math::Pi * 0.98f, 10, -forwardFactor * 0.95f, 0.5f);
|
||||
CreateRib(leftRib, -ribAxis2, 10, Math::Pi, 10, -forwardFactor, 0.5f);
|
||||
|
||||
auto ribs = clone->SelectFaces((char*)0);
|
||||
ribs->Scale({ 1.5f, 1, 1 });
|
||||
|
||||
StepPlace(clone, pos, dir);
|
||||
|
||||
result->MoveToOwnMesh(clone->SelectFaces());
|
||||
}
|
||||
pos += dir * length;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 30; ++i)
|
||||
{
|
||||
auto factor = (float)i / 30;
|
||||
dir = { Math::Sin(factor), 0, Math::Cos(factor) };
|
||||
|
||||
auto clone = bone->Clone();
|
||||
if (i % 2 == 0)
|
||||
clone->Scale({ 1.5f, 1, 1 });
|
||||
auto upperThingy = clone->SelectFaces((char*)1);
|
||||
auto factor2 = 0.5f;
|
||||
upperThingy->Move(Vector3::up * factor2 * 2);
|
||||
|
||||
|
||||
upperThingy->Scale({ 1, 1, 1 - factor2 });
|
||||
clone->Scale(1 - factor);
|
||||
StepPlace(clone, pos, dir);
|
||||
pos += dir * length * (1 - factor) + Vector3::down * 0.2f;
|
||||
}
|
||||
|
||||
pos = Vector3::zero;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
auto factor = (float)i / 10;
|
||||
dir = { Math::Sin(factor), 0, Math::Cos(factor) };
|
||||
|
||||
auto clone = bone->Clone();
|
||||
if (i % 2 == 0)
|
||||
clone->Scale({ 1.5f, 1, 1 });
|
||||
auto upperThingy = clone->SelectFaces((char*)1);
|
||||
auto factor2 = 0.5f;
|
||||
upperThingy->Move(Vector3::up * factor2 * 2);
|
||||
|
||||
|
||||
upperThingy->Scale({ 1, 1, 1 - factor2 });
|
||||
clone->Scale(Math::Clamp01(1.5f - factor));
|
||||
StepPlace(clone, pos, dir);
|
||||
pos -= dir * length * Math::Clamp01(2 - factor) + Vector3::down * 0.2f;
|
||||
}
|
||||
|
||||
|
||||
bone->Delete();
|
||||
bone2->Delete();
|
||||
|
||||
auto headMesh = Head();
|
||||
headMesh->Scale(4);
|
||||
headMesh->Rotate(Vector3::up, Math::Pi);
|
||||
|
||||
StepPlace(headMesh, pos + dir * -4, dir);
|
||||
result->MoveToOwnMesh(headMesh->SelectFaces());
|
||||
result->Scale(0.1f);
|
||||
result->SetCenter(Vector3::zero);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void CreateText(TEXTURE_2D_SRV_UAV_RTV* target, char* text, size_t textLength)
|
||||
{
|
||||
auto hDC = ::GetDC(windowHandle);
|
||||
HDC hMemDC = CreateCompatibleDC(hDC);
|
||||
HBITMAP hBitmap = CreateCompatibleBitmap(hMemDC, FONT_WIDTH, FONT_HEIGHT);
|
||||
|
||||
auto hgiobj = SelectObject(hMemDC, hBitmap);
|
||||
auto gdiObj = SelectObject(hMemDC, font);
|
||||
auto result = TextOutA(hMemDC, 0, -FONT_HEIGHT / 2, text, textLength);
|
||||
|
||||
BITMAPFILEHEADER bmfHeader;
|
||||
BITMAPINFOHEADER bi;
|
||||
|
||||
bi.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bi.biWidth = FONT_WIDTH;
|
||||
bi.biHeight = FONT_HEIGHT;
|
||||
bi.biPlanes = 1;
|
||||
bi.biBitCount = 32;
|
||||
bi.biCompression = BI_RGB;
|
||||
bi.biSizeImage = 0;
|
||||
bi.biXPelsPerMeter = 0;
|
||||
bi.biYPelsPerMeter = 0;
|
||||
bi.biClrUsed = 0;
|
||||
bi.biClrImportant = 0;
|
||||
|
||||
DWORD dwBmpSize = FONT_WIDTH * 4 * FONT_HEIGHT;
|
||||
auto pBits = new char[dwBmpSize];
|
||||
memset(pBits, 255, dwBmpSize);
|
||||
auto ScanedLines = GetDIBits(hMemDC, hBitmap, 0, FONT_HEIGHT, pBits, (BITMAPINFO *)&bi, DIB_RGB_COLORS);
|
||||
|
||||
DeleteObject(hBitmap);
|
||||
DeleteDC(hMemDC);
|
||||
|
||||
D3D11_BOX box = { 0 };
|
||||
box.right = FONT_WIDTH;
|
||||
box.bottom = FONT_HEIGHT;
|
||||
box.back = 1;
|
||||
context->UpdateSubresource(fontTextTemp.TEX, 0, &box, pBits, FONT_WIDTH * 4, 0);
|
||||
delete[] pBits;
|
||||
distanceTransformGPU(fontTextTemp.SRV, target->UAV);
|
||||
}
|
||||
|
||||
#define USE_THREADS
|
||||
|
||||
#pragma code_seg(".IntroInit")
|
||||
INLINE void IntroInit()
|
||||
{
|
||||
Log("IntroInit");
|
||||
|
||||
device->CreateBuffer(&constantBufferDesc, NULL, &constantBuffers[0]);
|
||||
device->CreateBuffer(&constantBufferSyncDesc, NULL, &constantBuffers[1]);
|
||||
|
||||
context->CSSetConstantBuffers(0, 2, constantBuffers);
|
||||
context->VSSetConstantBuffers(0, 2, constantBuffers);
|
||||
context->GSSetConstantBuffers(0, 2, constantBuffers);
|
||||
context->PSSetConstantBuffers(0, 2, constantBuffers);
|
||||
|
||||
#ifdef USE_THREADS
|
||||
HANDLE threads[] =
|
||||
{
|
||||
::CreateThread(0, 0, [](void*)
|
||||
{
|
||||
auto m1 = Obelisk(0.5f, 0, 1.25f, false, true);
|
||||
auto m2 = Obelisk(0.5f, 0, 1.0f, true, true);
|
||||
auto m3 = Obelisk(0.5f, Math::Pi, 0.0f, false, true);
|
||||
m1->Rotate(Vector3::up, -Math::Pi / 4);
|
||||
m2->Rotate(Vector3::up, -Math::Pi / 4);
|
||||
m3->Rotate(Vector3::up, -Math::Pi / 4);
|
||||
m1->Move(Vector3(0, 0, 1) * 2.5);
|
||||
m2->Move(Vector3(0.707, 0, -0.707) * 2.5);
|
||||
m3->Move(Vector3(-0.707, 0, -0.707) * 2.5);
|
||||
obelisk0.Create(m1);
|
||||
obelisk1.Create(m2);
|
||||
obelisk2.Create(m3);
|
||||
return (DWORD)0;
|
||||
}, 0, 0, 0),
|
||||
::CreateThread(0, 0, [](void*)
|
||||
{
|
||||
auto landscapeMeshs = Landscape();
|
||||
landscape.Create(landscapeMeshs[0]);
|
||||
landscapeKrallen.Create(landscapeMeshs[1]);
|
||||
return (DWORD)0;
|
||||
}, 0, 0, 0),
|
||||
::CreateThread(0, 0, [](void*) { skeleton.Create(Skeleton()); return (DWORD)0; }, 0, 0, 0)
|
||||
};
|
||||
#else
|
||||
auto m1 = Obelisk(0.5f, 0, 1.25f, false, true);
|
||||
auto m2 = Obelisk(0.5f, 0, 1.0f, true, true);
|
||||
auto m3 = Obelisk(0.5f, Math::Pi, 0.0f, false, true);
|
||||
m1->Rotate(Vector3::up, -Math::Pi / 4);
|
||||
m2->Rotate(Vector3::up, -Math::Pi / 4);
|
||||
m3->Rotate(Vector3::up, -Math::Pi / 4);
|
||||
m1->Move(Vector3(0, 0, 1) * 2.5);
|
||||
m2->Move(Vector3(0.707, 0, -0.707) * 2.5);
|
||||
m3->Move(Vector3(-0.707, 0, -0.707) * 2.5);
|
||||
obelisk0.Create(m1);
|
||||
obelisk1.Create(m2);
|
||||
obelisk2.Create(m3);
|
||||
auto landscapeMeshs = Landscape();
|
||||
landscape.Create(landscapeMeshs[0]);
|
||||
landscapeKrallen.Create(landscapeMeshs[1]);
|
||||
skeleton.Create(Skeleton());
|
||||
#endif
|
||||
|
||||
font = CreateFont(FONT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Gabriola");
|
||||
device->CreateSamplerState(&clampSamplerDesc, &samplerStates[0]);
|
||||
device->CreateSamplerState(&wrapSamplerDesc, &samplerStates[1]);
|
||||
device->CreateSamplerState(&mirrorSamplerDesc, &samplerStates[2]);
|
||||
context->CSSetSamplers(0, 3, samplerStates);
|
||||
context->VSSetSamplers(0, 3, samplerStates);
|
||||
context->GSSetSamplers(0, 3, samplerStates);
|
||||
context->PSSetSamplers(0, 3, samplerStates);
|
||||
|
||||
device->CreateTexture2D(&fontTexDesc, NULL, &fontTextTemp.TEX);
|
||||
device->CreateShaderResourceView(fontTextTemp.TEX, NULL, &fontTextTemp.SRV);
|
||||
|
||||
standardTexDesc.Format = DXGI_FORMAT_R32_UINT;
|
||||
createSRVUAVRTV(&dt_g, FONT_WIDTH, FONT_HEIGHT);
|
||||
createSRVUAVRTV(&dt_s, FONT_WIDTH, FONT_HEIGHT);
|
||||
createSRVUAVRTV(&dt_t, FONT_WIDTH, FONT_HEIGHT);
|
||||
standardTexDesc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
|
||||
createSRVUAVRTV(&fontText, FONT_WIDTH, FONT_HEIGHT);
|
||||
|
||||
CreateText(&fontText, " BluFlame & Alcatraz ", 24);
|
||||
|
||||
int i = 0;
|
||||
for (auto greeting : greetings)
|
||||
{
|
||||
createSRVUAVRTV(&greetingsTEXs[i], FONT_WIDTH, FONT_HEIGHT);
|
||||
CreateText(&greetingsTEXs[i], greeting, 30);
|
||||
++i;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
for (auto credit : credits)
|
||||
{
|
||||
createSRVUAVRTV(&creditsTEXs[i], FONT_WIDTH / 2, FONT_HEIGHT);
|
||||
CreateText(&creditsTEXs[i], credit, 21);
|
||||
++i;
|
||||
}
|
||||
|
||||
createSRVUAVRTV(&stone, 1024, 1024);
|
||||
createSRVUAVRTV(&gridTerrainHeight, 1024, 1024);
|
||||
createSRVUAVRTV(&gTexture, SCREENWIDTH, SCREENHEIGHT);
|
||||
createSRVUAVRTV(&tmpTex1, SCREENWIDTH, SCREENHEIGHT);
|
||||
createSRVUAVRTV(&blurTex1, SCREENWIDTH, SCREENHEIGHT);
|
||||
createSRVUAVRTV(&tmpTex8, SCREENWIDTH / 8, SCREENHEIGHT / 8);
|
||||
createSRVUAVRTV(&blurTex8, SCREENWIDTH / 8, SCREENHEIGHT / 8);
|
||||
createSRVUAVRTV(&tmpTex32, SCREENWIDTH / 32, SCREENHEIGHT / 32);
|
||||
createSRVUAVRTV(&blurTex32, SCREENWIDTH / 32, SCREENHEIGHT / 32);
|
||||
createSRVUAVRTV(&gridTex, SCREENWIDTH, SCREENHEIGHT);
|
||||
createSRVUAVRTV(&tempTexture, SCREENWIDTH, SCREENHEIGHT);
|
||||
createSRVUAVRTV(&tempTexture2, SCREENWIDTH, SCREENHEIGHT);
|
||||
|
||||
device->CreateTexture3D(&noiseTexDesc, NULL, &noiseTex3d);
|
||||
device->CreateShaderResourceView(noiseTex3d, NULL, &noiseTex3dSRV);
|
||||
device->CreateUnorderedAccessView(noiseTex3d, NULL, &noiseTex3dUAV);
|
||||
|
||||
context->CSSetShader(cs_stone, NULL, 0);
|
||||
context->CSSetUnorderedAccessViews(0, 1, &stone.UAV, NULL);
|
||||
context->Dispatch(1024 / 16, 1024 / 16, 1);
|
||||
context->CSSetUnorderedAccessViews(0, 1, (ID3D11UnorderedAccessView* const*)zero, NULL);
|
||||
|
||||
context->CSSetShader(cs_Noise3d, NULL, 0);
|
||||
context->CSSetUnorderedAccessViews(0, 1, &noiseTex3dUAV, NULL);
|
||||
context->Dispatch(512 / 8, 64 / 8, 512 / 8);
|
||||
context->CSSetUnorderedAccessViews(0, 1, (ID3D11UnorderedAccessView* const*)zero, NULL);
|
||||
|
||||
#ifdef USE_THREADS
|
||||
WaitForMultipleObjects(ARRAYSIZE(threads), threads, TRUE, -1);
|
||||
#endif
|
||||
}
|
||||
7
nordlicht2015-intro/src/intro/intro/intro.h
Normal file
7
nordlicht2015-intro/src/intro/intro/intro.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "data.h"
|
||||
#include "init.h"
|
||||
#include "update.h"
|
||||
|
||||
// EOF
|
||||
419
nordlicht2015-intro/src/intro/intro/particlesystem.h
Normal file
419
nordlicht2015-intro/src/intro/intro/particlesystem.h
Normal file
@@ -0,0 +1,419 @@
|
||||
#pragma once
|
||||
|
||||
#include <DirectXMath.h>
|
||||
|
||||
namespace particlesystem
|
||||
{
|
||||
#include "../shaders/lib/ShaderConstants.h"
|
||||
|
||||
// GPUParticle structure is split into two sections for better cache efficiency - could even be SOA but would require creating more vertex buffers.
|
||||
struct GPUParticlePartA
|
||||
{
|
||||
DirectX::XMVECTOR m_params[3];
|
||||
};
|
||||
|
||||
struct GPUParticlePartB
|
||||
{
|
||||
DirectX::XMVECTOR m_params[3];
|
||||
};
|
||||
|
||||
// The tiling constant buffer. Contains all the tiling dimensions for the various stages of the culling and rendering processes.
|
||||
struct TilingConstantBuffer
|
||||
{
|
||||
unsigned int numTilesX;
|
||||
unsigned int numTilesY;
|
||||
unsigned int numCoarseCullingTilesX;
|
||||
unsigned int numCoarseCullingTilesY;
|
||||
|
||||
unsigned int numCullingTilesPerCoarseTileX;
|
||||
unsigned int numCullingTilesPerCoarseTileY;
|
||||
unsigned int pads[2];
|
||||
};
|
||||
|
||||
static TilingConstantBuffer m_tilingConstants =
|
||||
{
|
||||
// Set the coarse culling level
|
||||
align(SCREENWIDTH, TILE_RES_X) / TILE_RES_X,
|
||||
align(SCREENHEIGHT, TILE_RES_Y) / TILE_RES_Y,
|
||||
COARSE_CULLING_TILES_X,
|
||||
COARSE_CULLING_TILES_Y,
|
||||
align(m_tilingConstants.numTilesX, m_tilingConstants.numCoarseCullingTilesX) / m_tilingConstants.numCoarseCullingTilesX,
|
||||
align(m_tilingConstants.numTilesY, m_tilingConstants.numCoarseCullingTilesY) / m_tilingConstants.numCoarseCullingTilesY
|
||||
};
|
||||
|
||||
ID3D11Buffer* m_pParticleBufferA;
|
||||
ID3D11ShaderResourceView* m_pParticleBufferA_SRV;
|
||||
ID3D11UnorderedAccessView* m_pParticleBufferA_UAV;
|
||||
|
||||
ID3D11Buffer* m_pParticleBufferB;
|
||||
ID3D11UnorderedAccessView* m_pParticleBufferB_UAV;
|
||||
|
||||
ID3D11Buffer* m_pAliveIndexBuffer;
|
||||
ID3D11ShaderResourceView* m_pAliveIndexBufferSRV;
|
||||
ID3D11UnorderedAccessView* m_pAliveIndexBufferUAV;
|
||||
|
||||
ID3D11Buffer* m_pViewSpaceParticlePositions;
|
||||
ID3D11ShaderResourceView* m_pViewSpaceParticlePositionsSRV;
|
||||
ID3D11UnorderedAccessView* m_pViewSpaceParticlePositionsUAV;
|
||||
|
||||
ID3D11Buffer* m_pMaxRadiusBuffer;
|
||||
ID3D11ShaderResourceView* m_pMaxRadiusBufferSRV;
|
||||
ID3D11UnorderedAccessView* m_pMaxRadiusBufferUAV;
|
||||
|
||||
ID3D11Buffer* m_pStridedCoarseCullingBuffer;
|
||||
ID3D11ShaderResourceView* m_pStridedCoarseCullingBufferSRV;
|
||||
ID3D11UnorderedAccessView* m_pStridedCoarseCullingBufferUAV;
|
||||
|
||||
ID3D11Buffer* m_pStridedCoarseCullingBufferCounters;
|
||||
ID3D11ShaderResourceView* m_pStridedCoarseCullingBufferCountersSRV;
|
||||
ID3D11UnorderedAccessView* m_pStridedCoarseCullingBufferCountersUAV;
|
||||
|
||||
ID3D11Buffer* m_pRenderingBuffer;
|
||||
ID3D11ShaderResourceView* m_pRenderingBufferSRV;
|
||||
ID3D11UnorderedAccessView* m_pRenderingBufferUAV;
|
||||
|
||||
ID3D11BlendState* m_pCompositeBlendState;
|
||||
|
||||
ID3D11Buffer* m_pTiledIndexBuffer;
|
||||
ID3D11ShaderResourceView* m_pTiledIndexBufferSRV;
|
||||
ID3D11UnorderedAccessView* m_pTiledIndexBufferUAV;
|
||||
|
||||
bool m_ResetSystem;
|
||||
|
||||
ID3D11VertexShader* m_pQuadVS;
|
||||
ID3D11PixelShader* m_pQuadPS;
|
||||
|
||||
ID3D11ComputeShader* m_pCSSimulate;
|
||||
ID3D11ComputeShader* m_pCSResetParticles;
|
||||
ID3D11ComputeShader* m_pTiledRenderingCS;
|
||||
ID3D11ComputeShader* m_pCoarseCullingCS;
|
||||
ID3D11ComputeShader* m_pCullingCS;
|
||||
|
||||
void Init()
|
||||
{
|
||||
/* SHADERS
|
||||
m_pCSSimulate , L"cs_5_0", L"CS_Simulate", L"Shaders\\source\\ParticleSimulation.hlsl"
|
||||
m_pCSResetParticles , L"cs_5_0", L"CS_Reset", L"Shaders\\source\\ParticleSimulation.hlsl"
|
||||
m_pTiledRenderingCS , L"cs_5_0", L"FrontToBack", L"Shaders\\source\\TiledRendering.hlsl"
|
||||
m_pCullingCS , L"cs_5_0", L"Culling", L"Shaders\\source\\CullingCS.hlsl"
|
||||
m_pCoarseCullingCS , L"cs_5_0", L"CoarseCulling", L"Shaders\\source\\CoarseCullingCS.hlsl"
|
||||
*/
|
||||
|
||||
|
||||
// Allocate the tiled rendering buffer as RGBA16F
|
||||
D3D11_BUFFER_DESC BufferDesc;
|
||||
ZeroMemory(&BufferDesc, sizeof(BufferDesc));
|
||||
unsigned int uNumRenderingTiles = m_tilingConstants.numTilesX * m_tilingConstants.numTilesY;
|
||||
int numPixels = uNumRenderingTiles * TILE_RES_X * TILE_RES_Y;
|
||||
BufferDesc.ByteWidth = 8 * numPixels;
|
||||
BufferDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS;
|
||||
BufferDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
device->CreateBuffer(&BufferDesc, nullptr, &m_pRenderingBuffer);
|
||||
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srv;
|
||||
D3D11_UNORDERED_ACCESS_VIEW_DESC uav;
|
||||
|
||||
ZeroMemory(&srv, sizeof(uav));
|
||||
srv.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
|
||||
srv.Buffer.ElementOffset = 0;
|
||||
srv.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
srv.Buffer.ElementWidth = numPixels;
|
||||
device->CreateShaderResourceView(m_pRenderingBuffer, &srv, &m_pRenderingBufferSRV);
|
||||
|
||||
ZeroMemory(&uav, sizeof(uav));
|
||||
uav.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
|
||||
uav.Buffer.FirstElement = 0;
|
||||
uav.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
uav.Buffer.NumElements = numPixels;
|
||||
device->CreateUnorderedAccessView(m_pRenderingBuffer, &uav, &m_pRenderingBufferUAV);
|
||||
|
||||
ZeroMemory(&BufferDesc, sizeof(BufferDesc));
|
||||
int numElements = uNumRenderingTiles * PARTICLES_TILE_BUFFER_SIZE;
|
||||
BufferDesc.ByteWidth = 4 * numElements;
|
||||
BufferDesc.BindFlags = D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_SHADER_RESOURCE;
|
||||
BufferDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
device->CreateBuffer(&BufferDesc, nullptr, &m_pTiledIndexBuffer);
|
||||
|
||||
ZeroMemory(&uav, sizeof(uav));
|
||||
uav.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
|
||||
uav.Buffer.FirstElement = 0;
|
||||
uav.Format = DXGI_FORMAT_R32_UINT;
|
||||
uav.Buffer.NumElements = numElements;
|
||||
device->CreateUnorderedAccessView(m_pTiledIndexBuffer, &uav, &m_pTiledIndexBufferUAV);
|
||||
|
||||
ZeroMemory(&srv, sizeof(uav));
|
||||
srv.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
|
||||
srv.Buffer.ElementOffset = 0;
|
||||
srv.Format = DXGI_FORMAT_R32_UINT;
|
||||
srv.Buffer.ElementWidth = numElements;
|
||||
device->CreateShaderResourceView(m_pTiledIndexBuffer, &srv, &m_pTiledIndexBufferSRV);
|
||||
|
||||
// Create the global particle pool. Each particle is split into two parts for better cache coherency. The first half contains the data more
|
||||
// relevant to rendering while the second half is more related to simulation
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = sizeof(GPUParticlePartA) * MAX_PARTICLES;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
|
||||
desc.StructureByteStride = sizeof(GPUParticlePartA);
|
||||
|
||||
device->CreateBuffer(&desc, nullptr, &m_pParticleBufferA);
|
||||
|
||||
desc.ByteWidth = sizeof(GPUParticlePartB) * MAX_PARTICLES;
|
||||
desc.StructureByteStride = sizeof(GPUParticlePartB);
|
||||
|
||||
device->CreateBuffer(&desc, nullptr, &m_pParticleBufferB);
|
||||
|
||||
ZeroMemory(&srv, sizeof(uav));
|
||||
srv.Format = DXGI_FORMAT_UNKNOWN;
|
||||
srv.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
|
||||
srv.Buffer.ElementOffset = 0;
|
||||
srv.Buffer.ElementWidth = MAX_PARTICLES;
|
||||
|
||||
device->CreateShaderResourceView(m_pParticleBufferA, &srv, &m_pParticleBufferA_SRV);
|
||||
|
||||
ZeroMemory(&uav, sizeof(uav));
|
||||
uav.Format = DXGI_FORMAT_UNKNOWN;
|
||||
uav.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
|
||||
uav.Buffer.FirstElement = 0;
|
||||
uav.Buffer.NumElements = MAX_PARTICLES;
|
||||
uav.Buffer.Flags = 0;
|
||||
device->CreateUnorderedAccessView(m_pParticleBufferA, &uav, &m_pParticleBufferA_UAV);
|
||||
device->CreateUnorderedAccessView(m_pParticleBufferB, &uav, &m_pParticleBufferB_UAV);
|
||||
|
||||
// The view space positions of particles are cached during simulation so allocate a buffer for them
|
||||
desc.ByteWidth = 16 * MAX_PARTICLES;
|
||||
desc.StructureByteStride = 16;
|
||||
device->CreateBuffer(&desc, 0, &m_pViewSpaceParticlePositions);
|
||||
device->CreateShaderResourceView(m_pViewSpaceParticlePositions, &srv, &m_pViewSpaceParticlePositionsSRV);
|
||||
device->CreateUnorderedAccessView(m_pViewSpaceParticlePositions, &uav, &m_pViewSpaceParticlePositionsUAV);
|
||||
|
||||
// The maximum radii of each particle is cached during simulation to avoid recomputing multiple times later. This is only required
|
||||
// for streaked particles as they are not round so we cache the max radius of X and Y
|
||||
desc.ByteWidth = 4 * MAX_PARTICLES;
|
||||
desc.StructureByteStride = 4;
|
||||
device->CreateBuffer(&desc, 0, &m_pMaxRadiusBuffer);
|
||||
device->CreateShaderResourceView(m_pMaxRadiusBuffer, &srv, &m_pMaxRadiusBufferSRV);
|
||||
device->CreateUnorderedAccessView(m_pMaxRadiusBuffer, &uav, &m_pMaxRadiusBufferUAV);
|
||||
|
||||
// Create the coarse culling buffer. This is an index buffer that allocates the maximum number of particles for each coarse bin
|
||||
desc.StructureByteStride = 0;
|
||||
desc.MiscFlags = 0;
|
||||
desc.ByteWidth = sizeof(UINT) * MAX_PARTICLES * MAX_COARSE_CULLING_TILES;
|
||||
device->CreateBuffer(&desc, nullptr, &m_pStridedCoarseCullingBuffer);
|
||||
|
||||
uav.Format = DXGI_FORMAT_R32_UINT;
|
||||
uav.Buffer.Flags = 0;
|
||||
uav.Buffer.NumElements = MAX_PARTICLES * MAX_COARSE_CULLING_TILES;
|
||||
device->CreateUnorderedAccessView(m_pStridedCoarseCullingBuffer, &uav, &m_pStridedCoarseCullingBufferUAV);
|
||||
|
||||
srv.Format = DXGI_FORMAT_R32_UINT;
|
||||
srv.Buffer.NumElements = MAX_PARTICLES * MAX_COARSE_CULLING_TILES;
|
||||
device->CreateShaderResourceView(m_pStridedCoarseCullingBuffer, &srv, &m_pStridedCoarseCullingBufferSRV);
|
||||
|
||||
// In addition to the index buffer for the coarse culling, we also need to track how many particles are in each bin,
|
||||
// therefore we allocate one element per bin which is atomically incremented as each particle is added
|
||||
desc.ByteWidth = sizeof(UINT) * MAX_COARSE_CULLING_TILES;
|
||||
device->CreateBuffer(&desc, nullptr, &m_pStridedCoarseCullingBufferCounters);
|
||||
|
||||
uav.Buffer.NumElements = MAX_COARSE_CULLING_TILES;
|
||||
device->CreateUnorderedAccessView(m_pStridedCoarseCullingBufferCounters, &uav, &m_pStridedCoarseCullingBufferCountersUAV);
|
||||
|
||||
srv.Buffer.NumElements = MAX_COARSE_CULLING_TILES;
|
||||
device->CreateShaderResourceView(m_pStridedCoarseCullingBufferCounters, &srv, &m_pStridedCoarseCullingBufferCountersSRV);
|
||||
|
||||
// Create the particle billboard index buffer required for the rasterization VS-only path
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.ByteWidth = MAX_PARTICLES * 6 * sizeof(UINT);
|
||||
desc.Usage = D3D11_USAGE_IMMUTABLE;
|
||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
|
||||
// Create a blend state for compositing the particles onto the render target
|
||||
D3D11_BLEND_DESC blendDesc;
|
||||
ZeroMemory(&blendDesc, sizeof(D3D11_BLEND_DESC));
|
||||
blendDesc.AlphaToCoverageEnable = false;
|
||||
blendDesc.IndependentBlendEnable = false;
|
||||
blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||
blendDesc.RenderTarget[0].BlendEnable = true;
|
||||
blendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
||||
blendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
||||
blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
|
||||
blendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
|
||||
blendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
||||
blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||
device->CreateBlendState(&blendDesc, &m_pCompositeBlendState);
|
||||
|
||||
// Create the index buffer of alive particles that is to be sorted (at least in the rasterization path).
|
||||
// For the tiled rendering path this could be just a UINT index buffer as particles are not globally sorted
|
||||
desc.ByteWidth = sizeof(float) * MAX_PARTICLES;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
|
||||
desc.StructureByteStride = sizeof(float);
|
||||
|
||||
device->CreateBuffer(&desc, nullptr, &m_pAliveIndexBuffer);
|
||||
|
||||
srv.Format = DXGI_FORMAT_UNKNOWN;
|
||||
srv.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
|
||||
srv.Buffer.ElementOffset = 0;
|
||||
srv.Buffer.ElementWidth = MAX_PARTICLES;
|
||||
|
||||
device->CreateShaderResourceView(m_pAliveIndexBuffer, &srv, &m_pAliveIndexBufferSRV);
|
||||
|
||||
uav.Buffer.NumElements = MAX_PARTICLES;
|
||||
uav.Format = DXGI_FORMAT_UNKNOWN;
|
||||
device->CreateUnorderedAccessView(m_pAliveIndexBuffer, &uav, &m_pAliveIndexBufferUAV);
|
||||
}
|
||||
|
||||
void Render(float frameTime, int flags, ID3D11ShaderResourceView* depthSRV)
|
||||
{
|
||||
// If we are resetting the particle system, then initialize the dead list
|
||||
if (m_ResetSystem)
|
||||
{
|
||||
ID3D11UnorderedAccessView* uavs[] = { m_pParticleBufferA_UAV, m_pParticleBufferB_UAV };
|
||||
UINT initialCounts[] = { (UINT)-1, (UINT)-1 };
|
||||
|
||||
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, initialCounts);
|
||||
|
||||
context->CSSetShader(m_pCSResetParticles, nullptr, 0);
|
||||
context->Dispatch(align(MAX_PARTICLES, 256) / 256, 1, 1);
|
||||
|
||||
m_ResetSystem = false;
|
||||
}
|
||||
|
||||
Simulate(flags, depthSRV);
|
||||
CoarseCulling();
|
||||
CullParticlesIntoTiles(flags, depthSRV);
|
||||
FillRenderBuffer(flags, depthSRV);
|
||||
}
|
||||
|
||||
// Per-frame simulation step
|
||||
void Simulate(int flags, ID3D11ShaderResourceView* depthSRV)
|
||||
{
|
||||
// Set the UAVs and reset the alive index buffer's counter
|
||||
ID3D11UnorderedAccessView* uavs[] = { m_pParticleBufferA_UAV, m_pParticleBufferB_UAV, m_pAliveIndexBufferUAV, m_pViewSpaceParticlePositionsUAV, m_pMaxRadiusBufferUAV };
|
||||
|
||||
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, nullptr);
|
||||
|
||||
// Bind the depth buffer as a texture for doing collision detection and response
|
||||
ID3D11ShaderResourceView* srvs[] = { depthSRV };
|
||||
context->CSSetShaderResources(0, ARRAYSIZE(srvs), srvs);
|
||||
|
||||
// Dispatch enough thread groups to update all the particles
|
||||
context->CSSetShader(m_pCSSimulate, nullptr, 0);
|
||||
context->Dispatch(align(MAX_PARTICLES, 256) / 256, 1, 1);
|
||||
|
||||
ZeroMemory(srvs, sizeof(srvs));
|
||||
context->CSSetShaderResources(0, ARRAYSIZE(srvs), srvs);
|
||||
|
||||
ZeroMemory(uavs, sizeof(uavs));
|
||||
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, nullptr);
|
||||
}
|
||||
|
||||
|
||||
// Cull the particles into coarse bins to dramatically improve performance
|
||||
void CoarseCulling()
|
||||
{
|
||||
// Set the UAVs - first one is the index buffer that is divided into n bins. Second is the per-bin counters that keep track of the number of particles in each bin
|
||||
UINT initialCounts[] = { (UINT)-1, (UINT)-1 };
|
||||
ID3D11UnorderedAccessView* uavs[] = { m_pStridedCoarseCullingBufferUAV, m_pStridedCoarseCullingBufferCountersUAV };
|
||||
|
||||
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, initialCounts);
|
||||
|
||||
ID3D11ShaderResourceView* srvs[] = { m_pViewSpaceParticlePositionsSRV, m_pMaxRadiusBufferSRV, m_pAliveIndexBufferSRV };
|
||||
context->CSSetShaderResources(0, ARRAYSIZE(srvs), srvs);
|
||||
|
||||
context->CSSetShader(m_pCoarseCullingCS, nullptr, 0);
|
||||
context->Dispatch(align(MAX_PARTICLES, COARSE_CULLING_THREADS) / COARSE_CULLING_THREADS, 1, 1); // Could use DispatchIndirect based on number of alive particles
|
||||
|
||||
ZeroMemory(uavs, sizeof(uavs));
|
||||
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, nullptr);
|
||||
|
||||
ZeroMemory(srvs, sizeof(srvs));
|
||||
context->CSSetShaderResources(0, ARRAYSIZE(srvs), srvs);
|
||||
}
|
||||
|
||||
|
||||
// Perform fine-grained culling. The culling tile size matches the tile size that we will be rendering with
|
||||
void CullParticlesIntoTiles(int flags, ID3D11ShaderResourceView* depthSRV)
|
||||
{
|
||||
// Set the UAV we are going to write to
|
||||
UINT initialCounts[] = { (UINT)-1 };
|
||||
ID3D11UnorderedAccessView* uavs[] = { m_pTiledIndexBufferUAV };
|
||||
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, initialCounts);
|
||||
|
||||
// Set the CS inputs
|
||||
ID3D11ShaderResourceView* srvs[] = { m_pViewSpaceParticlePositionsSRV, m_pMaxRadiusBufferSRV, m_pAliveIndexBufferSRV, depthSRV, m_pStridedCoarseCullingBufferSRV, m_pStridedCoarseCullingBufferCountersSRV };
|
||||
context->CSSetShaderResources(0, ARRAYSIZE(srvs), srvs);
|
||||
|
||||
// Pick the right shader based on the system options
|
||||
|
||||
context->CSSetShader(m_pCullingCS, nullptr, 0);
|
||||
|
||||
// Dispatch a thread group per tile
|
||||
context->Dispatch(m_tilingConstants.numTilesX, m_tilingConstants.numTilesY, 1);
|
||||
|
||||
ZeroMemory(uavs, sizeof(uavs));
|
||||
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, nullptr);
|
||||
|
||||
ZeroMemory(srvs, sizeof(srvs));
|
||||
context->CSSetShaderResources(0, ARRAYSIZE(srvs), srvs);
|
||||
}
|
||||
|
||||
// Do the tiled rendering using a compute shader
|
||||
void FillRenderBuffer(int flags, ID3D11ShaderResourceView* depthSRV)
|
||||
{
|
||||
// Set the UAV that we will write the shaded particle pixels to
|
||||
UINT initialCounts[] = { (UINT)-1 };
|
||||
ID3D11UnorderedAccessView* uavs[] = { m_pRenderingBufferUAV };
|
||||
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, initialCounts);
|
||||
|
||||
// Set the shader inputs. Note that the coarse culling buffer isn't required for tiled rendering, but we pass it through for the debug visualization
|
||||
ID3D11ShaderResourceView* srvs[] = { m_pParticleBufferA_SRV, m_pViewSpaceParticlePositionsSRV, depthSRV, m_pTiledIndexBufferSRV, m_pStridedCoarseCullingBufferCountersSRV };
|
||||
context->CSSetShaderResources(0, ARRAYSIZE(srvs), srvs);
|
||||
|
||||
context->CSSetShader(m_pTiledRenderingCS, nullptr, 0);
|
||||
|
||||
// Dispatch a thread group per tile
|
||||
context->Dispatch(m_tilingConstants.numTilesX, m_tilingConstants.numTilesY, 1);
|
||||
context->CSSetShader(nullptr, nullptr, 0);
|
||||
|
||||
ZeroMemory(uavs, sizeof(uavs));
|
||||
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(uavs), uavs, nullptr);
|
||||
|
||||
ZeroMemory(srvs, sizeof(srvs));
|
||||
context->CSSetShaderResources(0, ARRAYSIZE(srvs), srvs);
|
||||
}
|
||||
|
||||
// Function to write the UAV back on to the scene render target
|
||||
void RenderQuad()
|
||||
{
|
||||
// Set the blend state to do compositing
|
||||
context->OMSetBlendState(m_pCompositeBlendState, nullptr, 0xffffffff);
|
||||
|
||||
// Set the quad shader
|
||||
context->VSSetShader(m_pQuadVS, nullptr, 0);
|
||||
context->PSSetShader(m_pQuadPS, nullptr, 0);
|
||||
|
||||
// No vertex buffer or index buffer required. Just use vertexId to generate triangles
|
||||
context->IASetIndexBuffer(nullptr, DXGI_FORMAT_UNKNOWN, 0);
|
||||
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
|
||||
// Bind the tiled UAV to the pixel shader
|
||||
ID3D11ShaderResourceView* srvs[] = { m_pRenderingBufferSRV };
|
||||
context->PSSetShaderResources(0, ARRAYSIZE(srvs), srvs);
|
||||
|
||||
// Draw one large triangle
|
||||
context->Draw(3, 0);
|
||||
|
||||
ZeroMemory(srvs, sizeof(srvs));
|
||||
context->PSSetShaderResources(0, ARRAYSIZE(srvs), srvs);
|
||||
|
||||
// Restore the default blend state
|
||||
context->OMSetBlendState(nullptr, nullptr, 0xffffffff);
|
||||
}
|
||||
};
|
||||
149
nordlicht2015-intro/src/intro/intro/sortlib.h
Normal file
149
nordlicht2015-intro/src/intro/intro/sortlib.h
Normal file
@@ -0,0 +1,149 @@
|
||||
#pragma once
|
||||
|
||||
namespace sortlib
|
||||
{
|
||||
typedef struct SortConstants
|
||||
{
|
||||
int x, y, z, w;
|
||||
} int4;
|
||||
|
||||
#pragma bss_seg(".sortbss")
|
||||
static ID3D11Buffer* cbDispatchInfo; // constant buffer containing dispatch specific information
|
||||
static ID3D11Buffer* indirectSortArgsBuffer;
|
||||
static ID3D11UnorderedAccessView* indirectSortArgsBufferUAV;
|
||||
|
||||
#pragma data_seg(".sortlib_cbDesc")
|
||||
static D3D11_BUFFER_DESC cbDesc =
|
||||
{
|
||||
sizeof(int4),
|
||||
D3D11_USAGE_DYNAMIC,
|
||||
D3D11_BIND_CONSTANT_BUFFER,
|
||||
D3D11_CPU_ACCESS_WRITE,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
#pragma data_seg(".sortlib_desc")
|
||||
static D3D11_BUFFER_DESC desc =
|
||||
{
|
||||
4 * sizeof(UINT),
|
||||
D3D11_USAGE_DEFAULT,
|
||||
D3D11_BIND_UNORDERED_ACCESS,
|
||||
0,
|
||||
D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS,
|
||||
0
|
||||
};
|
||||
|
||||
#pragma data_seg(".sortlib_uavDesc")
|
||||
static D3D11_UNORDERED_ACCESS_VIEW_DESC sortlib_uavDesc =
|
||||
{
|
||||
DXGI_FORMAT_R32_UINT,
|
||||
D3D11_UAV_DIMENSION_BUFFER,
|
||||
{
|
||||
0,
|
||||
4,
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
#pragma code_seg(".sortlib_init")
|
||||
void init()
|
||||
{
|
||||
device->CreateBuffer(&cbDesc, nullptr, &cbDispatchInfo);
|
||||
device->CreateBuffer(&desc, nullptr, &indirectSortArgsBuffer);
|
||||
device->CreateUnorderedAccessView(indirectSortArgsBuffer, &sortlib_uavDesc, &indirectSortArgsBufferUAV);
|
||||
}
|
||||
|
||||
#pragma code_seg(".sortlib_run")
|
||||
void run(unsigned int maxSize, ID3D11UnorderedAccessView* sortBufferUAV, ID3D11Buffer* itemCountBuffer)
|
||||
{
|
||||
ID3D11Buffer* cbs[] = { itemCountBuffer, cbDispatchInfo };
|
||||
context->CSSetConstantBuffers(0, 2, cbs);
|
||||
|
||||
// Write the indirect args to a UAV
|
||||
context->CSSetUnorderedAccessViews(0, 1, &indirectSortArgsBufferUAV, nullptr);
|
||||
context->CSSetShader(cs_InitDispatchArgs, nullptr, 0);
|
||||
context->Dispatch(1, 1, 1);
|
||||
|
||||
context->CSSetUnorderedAccessViews(0, 1, &sortBufferUAV, nullptr);
|
||||
|
||||
bool bDone = sortInitial(maxSize);
|
||||
int presorted = 512;
|
||||
while (!bDone)
|
||||
{
|
||||
bDone = sortIncremental(presorted, maxSize);
|
||||
presorted *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma code_seg(".sortlib_sortInitial")
|
||||
bool sortInitial(unsigned int maxSize)
|
||||
{
|
||||
bool bDone = true;
|
||||
|
||||
unsigned int numThreadGroups = ((maxSize - 1) >> 9) + 1;
|
||||
|
||||
if (numThreadGroups>1) bDone = false;
|
||||
|
||||
// sort all buffers of size 512 (and presort bigger ones)
|
||||
context->CSSetShader(cs_BitonicSortLDS, nullptr, 0);
|
||||
context->DispatchIndirect(indirectSortArgsBuffer, 0);
|
||||
|
||||
return bDone;
|
||||
}
|
||||
|
||||
#pragma code_seg(".sortlib_sortIncremental")
|
||||
bool sortIncremental(unsigned int presorted, unsigned int maxSize)
|
||||
{
|
||||
bool bDone = true;
|
||||
context->CSSetShader(cs_BitonicSortStep, nullptr, 0);
|
||||
|
||||
// prepare thread group description data
|
||||
unsigned int numThreadGroups = 0;
|
||||
if (maxSize > presorted)
|
||||
{
|
||||
if (maxSize > presorted * 2)
|
||||
{
|
||||
bDone = false;
|
||||
}
|
||||
|
||||
unsigned int pow2 = presorted;
|
||||
|
||||
while (pow2 < maxSize)
|
||||
{
|
||||
pow2 *= 2;
|
||||
}
|
||||
|
||||
numThreadGroups = pow2 >> 9;
|
||||
}
|
||||
|
||||
unsigned int nMergeSize = presorted * 2;
|
||||
for (unsigned int nMergeSubSize = nMergeSize >> 1; nMergeSubSize>256; nMergeSubSize = nMergeSubSize >> 1)
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE MappedResource;
|
||||
|
||||
context->Map(cbDispatchInfo, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource);
|
||||
SortConstants* sc = (SortConstants*)MappedResource.pData;
|
||||
sc->x = nMergeSubSize;
|
||||
if (nMergeSubSize == nMergeSize >> 1)
|
||||
{
|
||||
sc->y = (2 * nMergeSubSize - 1);
|
||||
sc->z = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sc->y = nMergeSubSize;
|
||||
sc->z = 1;
|
||||
}
|
||||
sc->w = 0;
|
||||
context->Unmap(cbDispatchInfo, 0);
|
||||
|
||||
context->Dispatch(numThreadGroups, 1, 1);
|
||||
}
|
||||
|
||||
context->CSSetShader(cs_BitonicInnerSort, nullptr, 0);
|
||||
context->Dispatch(numThreadGroups, 1, 1);
|
||||
|
||||
return bDone;
|
||||
}
|
||||
}
|
||||
301
nordlicht2015-intro/src/intro/intro/update.h
Normal file
301
nordlicht2015-intro/src/intro/intro/update.h
Normal file
@@ -0,0 +1,301 @@
|
||||
#pragma once
|
||||
|
||||
void Glow(ID3D11ShaderResourceView* from, ID3D11UnorderedAccessView* to)
|
||||
{
|
||||
|
||||
// BlurV (1/1)
|
||||
context->CSSetUnorderedAccessViews(0, 1, &tmpTex1.UAV, NULL);
|
||||
context->CSSetShaderResources(0, 1, &from);
|
||||
context->CSSetShader(csBlurV, NULL, 0);
|
||||
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
|
||||
|
||||
// BlurH (1/1) -> blurTex1
|
||||
context->CSSetUnorderedAccessViews(0, 1, &blurTex1.UAV, NULL);
|
||||
context->CSSetShaderResources(0, 1, &tmpTex1.SRV);
|
||||
context->CSSetShader(csBlurH, NULL, 0);
|
||||
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
|
||||
|
||||
context->GenerateMips(blurTex1.SRV);
|
||||
|
||||
// BlurV (1/8)
|
||||
context->CSSetUnorderedAccessViews(0, 1, &tmpTex8.UAV, NULL);
|
||||
context->CSSetShaderResources(0, 1, &blurTex1.SRV);
|
||||
context->CSSetShader(csBlurV, NULL, 0);
|
||||
context->Dispatch(SCREENWIDTH / 128 + 1, SCREENHEIGHT / 128 + 1, 1);
|
||||
|
||||
// BlurH (1/8) -> blurTex8 -> merge / ghosts
|
||||
context->CSSetUnorderedAccessViews(0, 1, &blurTex8.UAV, NULL);
|
||||
context->CSSetShaderResources(0, 1, &tmpTex8.SRV);
|
||||
context->CSSetShader(csBlurH, NULL, 0);
|
||||
context->Dispatch(SCREENWIDTH / 128 + 1, SCREENHEIGHT / 128 + 1, 1);
|
||||
|
||||
context->GenerateMips(blurTex8.SRV);
|
||||
|
||||
// BlurV (1/32)
|
||||
context->CSSetUnorderedAccessViews(0, 1, &tmpTex32.UAV, NULL);
|
||||
context->CSSetShaderResources(0, 1, &blurTex8.SRV);
|
||||
context->CSSetShader(csBlurV, NULL, 0);
|
||||
context->Dispatch(SCREENWIDTH / 512 + 1, SCREENHEIGHT / 512 + 1, 1);
|
||||
|
||||
// BlurH (1/32) -> blurTex32 -> merge / lensDirt / smallDirt / ghosts
|
||||
context->CSSetUnorderedAccessViews(0, 1, &blurTex32.UAV, NULL);
|
||||
context->CSSetShaderResources(0, 1, &tmpTex32.SRV);
|
||||
context->CSSetShader(csBlurV, NULL, 0);
|
||||
context->Dispatch(SCREENWIDTH / 512 + 1, SCREENHEIGHT / 512 + 1, 1);
|
||||
|
||||
// Merge
|
||||
ID3D11ShaderResourceView* mergeSRV[] = { from, blurTex1.SRV, blurTex8.SRV, blurTex32.SRV };
|
||||
context->CSSetUnorderedAccessViews(0, 1, &to, NULL);
|
||||
context->CSSetShaderResources(0, 4, mergeSRV);
|
||||
context->CSSetShader(csMerge, NULL, 0);
|
||||
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
|
||||
|
||||
context->CSSetUnorderedAccessViews(0, 1, (ID3D11UnorderedAccessView* const*)zero, NULL);
|
||||
context->CSSetShaderResources(0, 4, (ID3D11ShaderResourceView* const*)zero);
|
||||
}
|
||||
|
||||
void GridVulcan(ID3D11RenderTargetView* to)
|
||||
{
|
||||
context->CSSetShader(cs_gridline, NULL, 0);
|
||||
context->CSSetUnorderedAccessViews(0, 1, &gridTerrainHeight.UAV, NULL);
|
||||
context->Dispatch(1024, 1024, 1);
|
||||
context->CSSetUnorderedAccessViews(0, 1, (ID3D11UnorderedAccessView* const*)zero, NULL);
|
||||
context->CSSetShader(NULL, NULL, 0);
|
||||
|
||||
context->ClearRenderTargetView(to, (const FLOAT*)zero);
|
||||
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
|
||||
context->GSSetShaderResources(0, 1, &gridTerrainHeight.SRV);
|
||||
context->VSSetShader(vs_gridline, NULL, 0);
|
||||
context->GSSetShader(gs_gridline, NULL, 0);
|
||||
context->PSSetShader(ps_gridline, NULL, 0);
|
||||
context->PSSetShaderResources(0, 1, &fontText.SRV);
|
||||
for (int i = 1; i <= 3; ++i)
|
||||
context->PSSetShaderResources(i, 1, &creditsTEXs[i - 1].SRV);
|
||||
|
||||
context->OMSetRenderTargets(1, &to, depthStencilView);
|
||||
context->RSSetViewports(1, &viewPort);
|
||||
context->RSSetState(rsSolidCullNone);
|
||||
context->Draw(1024 * 1024 * 2, 0);
|
||||
|
||||
context->PSSetShaderResources(0, 4, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->GSSetShaderResources(0, 1, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->OMSetRenderTargets(0, NULL, NULL);
|
||||
}
|
||||
|
||||
void DrawIntroText(ID3D11ShaderResourceView* from, ID3D11UnorderedAccessView* to, ID3D11ShaderResourceView* font)
|
||||
{
|
||||
context->CSSetShader(cs_Sample, NULL, 0);
|
||||
context->CSSetUnorderedAccessViews(0, 1, &to, NULL);
|
||||
context->CSSetShaderResources(0, 1, &font);
|
||||
context->CSSetShaderResources(1, 1, &from);
|
||||
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
|
||||
context->CSSetShaderResources(0, 2, (ID3D11ShaderResourceView* const*)zero);
|
||||
}
|
||||
|
||||
void DrawMesh(ID3D11RenderTargetView* to, RenderMesh& mesh)
|
||||
{
|
||||
ID3D11RenderTargetView* rtvs[] = { to, gTexture.RTV };
|
||||
context->PSSetShader(ps_mesh, NULL, 0);
|
||||
context->OMSetRenderTargets(2, rtvs, depthStencilView);
|
||||
context->RSSetViewports(1, &viewPort);
|
||||
context->RSSetState(rsSolidCullBack);
|
||||
context->PSSetShaderResources(0, 1, &stone.SRV);
|
||||
mesh.Render();
|
||||
context->PSSetShaderResources(0, 2, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->OMSetRenderTargets(0, NULL, NULL);
|
||||
}
|
||||
|
||||
void DrawParticleFlock(ID3D11RenderTargetView* to)
|
||||
{
|
||||
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
|
||||
context->OMSetBlendState(alphaBlendState, NULL, -1);
|
||||
//context->OMSetDepthStencilState(noDepthWriteStencilState, 0);
|
||||
context->OMSetRenderTargets(1, &to, depthStencilView);
|
||||
context->RSSetViewports(1, &viewPort);
|
||||
context->RSSetState(rsSolidCullBack);
|
||||
context->VSSetShaderResources(0, 1, &stone.SRV);
|
||||
context->PSSetShaderResources(0, 1, &stone.SRV);
|
||||
context->VSSetShader(vs_ParticlesFlock, NULL, 0);
|
||||
context->GSSetShader(gs_Particles, NULL, 0);
|
||||
context->PSSetShader(ps_Particles, NULL, 0);
|
||||
context->Draw(1024, 0);
|
||||
context->VSSetShaderResources(0, 2, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->PSSetShaderResources(0, 2, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->VSSetShader(NULL, NULL, 0);
|
||||
context->GSSetShader(NULL, NULL, 0);
|
||||
context->PSSetShader(NULL, NULL, 0);
|
||||
context->OMSetRenderTargets(0, NULL, NULL);
|
||||
//context->OMSetDepthStencilState(depthStencilState, 0);
|
||||
context->OMSetBlendState(NULL, NULL, -1);
|
||||
}
|
||||
|
||||
void DrawTerrain(ID3D11RenderTargetView* to)
|
||||
{
|
||||
ID3D11RenderTargetView* rtvs[] = { to, gTexture.RTV };
|
||||
context->PSSetShader(ps_mesh, NULL, 0);
|
||||
context->OMSetRenderTargets(2, rtvs, depthStencilView);
|
||||
context->RSSetViewports(1, &viewPort);
|
||||
context->RSSetState(rsSolidCullBack);
|
||||
context->GSSetShaderResources(0, 1, &stone.SRV);
|
||||
context->PSSetShaderResources(0, 1, &stone.SRV);
|
||||
|
||||
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
|
||||
context->VSSetShader(vs_terrain, NULL, 0);
|
||||
context->GSSetShader(gs_terrain, NULL, 0);
|
||||
context->Draw(1024 * 1024, 0);
|
||||
context->VSSetShader(NULL, NULL, 0);
|
||||
context->GSSetShader(NULL, NULL, 0);
|
||||
|
||||
context->GSSetShaderResources(0, 1, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->PSSetShaderResources(0, 2, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->OMSetRenderTargets(0, NULL, NULL);
|
||||
}
|
||||
|
||||
void DrawSun(ID3D11RenderTargetView* to)
|
||||
{
|
||||
context->OMSetRenderTargets(1, &to, depthStencilView);
|
||||
context->RSSetViewports(1, &viewPort);
|
||||
context->RSSetState(rsSolidCullNone);
|
||||
|
||||
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
|
||||
context->VSSetShader(vs_Sun, NULL, 0);
|
||||
context->PSSetShader(ps_Sun, NULL, 0);
|
||||
context->Draw(4, 0);
|
||||
context->VSSetShader(NULL, NULL, 0);
|
||||
context->PSSetShader(NULL, NULL, 0);
|
||||
|
||||
context->OMSetRenderTargets(0, NULL, NULL);
|
||||
}
|
||||
|
||||
void Raymarching(ID3D11RenderTargetView* to)
|
||||
{
|
||||
ID3D11RenderTargetView* rtvs[] = { to, gTexture.RTV };
|
||||
context->RSSetViewports(1, &viewPort);
|
||||
context->RSSetState(rsSolidCullBack);
|
||||
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
|
||||
context->VSSetShader(vs_Raymarching, NULL, 0);
|
||||
context->PSSetShader(ps_Raymarching, NULL, 0);
|
||||
context->PSSetShaderResources(0, 1, &stone.SRV);
|
||||
for (int i = 0; i < 20; ++i)
|
||||
context->PSSetShaderResources(i + 1, 1, &greetingsTEXs[i].SRV);
|
||||
context->OMSetRenderTargets(2, rtvs, depthStencilView);
|
||||
context->Draw(4, 0);
|
||||
context->PSSetShaderResources(0, 21, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->OMSetRenderTargets(0, NULL, NULL);
|
||||
}
|
||||
|
||||
void Copy(ID3D11ShaderResourceView* from, ID3D11UnorderedAccessView* to)
|
||||
{
|
||||
context->CSSetShader(cs_Copy, NULL, 0);
|
||||
context->CSSetUnorderedAccessViews(0, 1, &to, NULL);
|
||||
context->CSSetShaderResources(0, 1, &from);
|
||||
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
|
||||
context->CSSetShaderResources(0, 1, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->CSSetUnorderedAccessViews(0, 1, (ID3D11UnorderedAccessView* const*)zero, NULL);
|
||||
}
|
||||
|
||||
void Postprocess(ID3D11ShaderResourceView* from, ID3D11UnorderedAccessView* to)
|
||||
{
|
||||
context->CSSetShader(cs_Postprocess, NULL, 0);
|
||||
context->CSSetUnorderedAccessViews(0, 1, &to, NULL);
|
||||
context->CSSetShaderResources(0, 1, &from);
|
||||
context->CSSetShaderResources(1, 1, &depthStencilSRV);
|
||||
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
|
||||
context->CSSetShaderResources(0, 2, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->CSSetUnorderedAccessViews(0, 1, (ID3D11UnorderedAccessView* const*)zero, NULL);
|
||||
}
|
||||
|
||||
void SSAO(ID3D11ShaderResourceView* from, ID3D11UnorderedAccessView* to)
|
||||
{
|
||||
context->CSSetShader(cs_Ssao, NULL, 0);
|
||||
context->CSSetUnorderedAccessViews(0, 1, &to, NULL);
|
||||
context->CSSetShaderResources(0, 1, &from);
|
||||
context->CSSetShaderResources(1, 1, &gTexture.SRV);
|
||||
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
|
||||
context->CSSetShaderResources(0, 2, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->CSSetUnorderedAccessViews(0, 1, (ID3D11UnorderedAccessView* const*)zero, NULL);
|
||||
}
|
||||
|
||||
void VolumetricFog(ID3D11ShaderResourceView* from, ID3D11UnorderedAccessView* to)
|
||||
{
|
||||
context->CSSetShader(cs_VolumetricFog, NULL, 0);
|
||||
context->CSSetUnorderedAccessViews(0, 1, &to, NULL);
|
||||
context->CSSetShaderResources(0, 1, &noiseTex3dSRV);
|
||||
context->CSSetShaderResources(1, 1, &depthStencilSRV);
|
||||
context->CSSetShaderResources(2, 1, &from);
|
||||
context->Dispatch(SCREENWIDTH / 16, SCREENHEIGHT / 16, 1);
|
||||
context->CSSetShaderResources(0, 3, (ID3D11ShaderResourceView* const*)zero);
|
||||
context->CSSetUnorderedAccessViews(0, 1, (ID3D11UnorderedAccessView* const*)zero, NULL);
|
||||
}
|
||||
|
||||
#pragma code_seg(".IntroUpdate")
|
||||
INLINE void IntroUpdate(float _introPosition)
|
||||
{
|
||||
constantBuffer.time = _introPosition;
|
||||
constantBuffer.aspectRatio = aspectRatio;
|
||||
context->UpdateSubresource(constantBuffers[0], 0, NULL, &constantBuffer, sizeof(ConstantBufferType), sizeof(ConstantBufferType));
|
||||
context->UpdateSubresource(constantBuffers[1], 0, NULL, &SYNC_VAR_NAME, sizeof(SYNC_TYPE_NAME), sizeof(SYNC_TYPE_NAME));
|
||||
context->OMSetDepthStencilState(depthStencilState, 0);
|
||||
|
||||
context->CSSetConstantBuffers(0, 2, constantBuffers);
|
||||
context->VSSetConstantBuffers(0, 2, constantBuffers);
|
||||
context->GSSetConstantBuffers(0, 2, constantBuffers);
|
||||
context->PSSetConstantBuffers(0, 2, constantBuffers);
|
||||
|
||||
context->ClearRenderTargetView(backBufferRTV, (const FLOAT*)zero);
|
||||
context->ClearRenderTargetView(tempTexture.RTV, (const FLOAT*)zero);
|
||||
context->ClearRenderTargetView(tempTexture2.RTV, (const FLOAT*)zero);
|
||||
context->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
|
||||
context->ClearUnorderedAccessViewFloat(gTexture.UAV, inf);
|
||||
|
||||
if (s_ST.scene < 1)
|
||||
{
|
||||
GridVulcan(tempTexture2.RTV);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawTerrain(tempTexture2.RTV);
|
||||
|
||||
if (s_ST.scene < 2)
|
||||
{
|
||||
DrawMesh(tempTexture2.RTV, landscape);
|
||||
DrawMesh(tempTexture2.RTV, landscapeKrallen);
|
||||
}
|
||||
else if (s_ST.scene < 3)
|
||||
{
|
||||
DrawMesh(tempTexture2.RTV, obelisk0);
|
||||
DrawMesh(tempTexture2.RTV, obelisk1);
|
||||
DrawMesh(tempTexture2.RTV, obelisk2);
|
||||
Raymarching(tempTexture2.RTV);
|
||||
}
|
||||
else if (s_ST.scene < 4)
|
||||
{
|
||||
DrawMesh(tempTexture2.RTV, skeleton);
|
||||
DrawParticleFlock(tempTexture2.RTV);
|
||||
}
|
||||
else if (s_ST.scene < 5)
|
||||
{
|
||||
Raymarching(tempTexture2.RTV);
|
||||
}
|
||||
|
||||
SSAO(tempTexture2.SRV, tempTexture.UAV);
|
||||
VolumetricFog(tempTexture.SRV, tempTexture2.UAV);
|
||||
}
|
||||
|
||||
Postprocess(tempTexture2.SRV, tempTexture.UAV);
|
||||
|
||||
if (s_ST.scene < 1)
|
||||
{
|
||||
DrawIntroText(tempTexture.SRV, tempTexture2.UAV, fontText.SRV);
|
||||
Glow(tempTexture2.SRV, backBufferUAV);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawSun(tempTexture.RTV);
|
||||
Glow(tempTexture.SRV, backBufferUAV);
|
||||
}
|
||||
|
||||
//Copy(tempTexture.SRV, backBufferUAV);
|
||||
|
||||
swapChain->Present(0, 0);
|
||||
}
|
||||
77
nordlicht2015-intro/src/intro/main.cpp
Normal file
77
nordlicht2015-intro/src/intro/main.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "framework/framework.h"
|
||||
#include "../mesh/Core/Mesh.h"
|
||||
#include "../mesh/Core/Face.h"
|
||||
#include "../mesh/Core/Vertex.h"
|
||||
#include "../mesh/Selection/FaceSelection.h"
|
||||
#include "../mesh/Selection/VertexSelection.h"
|
||||
#include "../mesh/UVGenerators/PlaneUVGenerator.h"
|
||||
#include "intro/RenderMesh.h"
|
||||
#include "intro/intro.h"
|
||||
#include <new>
|
||||
|
||||
void* _cdecl operator new (size_t size)
|
||||
{
|
||||
return ::GlobalAlloc(GPTR, size);
|
||||
}
|
||||
|
||||
void _cdecl operator delete (void *p)
|
||||
{
|
||||
//::GlobalFree(p);
|
||||
}
|
||||
|
||||
void* _cdecl operator new[](size_t size)
|
||||
{
|
||||
return ::GlobalAlloc(GPTR, size);
|
||||
}
|
||||
|
||||
void _cdecl operator delete[](void *p)
|
||||
{
|
||||
//::GlobalFree(p);
|
||||
}
|
||||
|
||||
void* _cdecl memset(void* dest, int val, size_t _size)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov eax, val
|
||||
mov edi, dest
|
||||
mov ecx, _size
|
||||
rep stosb
|
||||
}
|
||||
}
|
||||
|
||||
void* _cdecl memcpy(void* dest, const void* source, size_t _size)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov esi, source
|
||||
mov edi, dest
|
||||
mov ecx, _size
|
||||
rep movsb
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
int _cdecl main(int argc, char* argv[])
|
||||
#else
|
||||
int CALLBACK WinMain(
|
||||
_In_ HINSTANCE hInstance,
|
||||
_In_ HINSTANCE hPrevInstance,
|
||||
_In_ LPSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
#endif
|
||||
{
|
||||
FrameworkInit();
|
||||
|
||||
do
|
||||
{
|
||||
MSG msg;
|
||||
::PeekMessage(&msg, windowHandle, 0, 0, 0);
|
||||
FrameworkUpdate();
|
||||
} while (FrameworkContinueExecuting());
|
||||
|
||||
FrameworkDispose();
|
||||
ExitProcess(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
116
nordlicht2015-intro/src/intro/shaders/intro.hlsl
Normal file
116
nordlicht2015-intro/src/intro/shaders/intro.hlsl
Normal file
@@ -0,0 +1,116 @@
|
||||
RWTexture3D<float> o3d0 : register(u0);
|
||||
RWTexture2D<float4> o2d0 : register(u0);
|
||||
RWTexture2D<float4> o2d1 : register(u1);
|
||||
Texture3D t3d0 : register(t0);
|
||||
Texture2D t2d0 : register(t0);
|
||||
Texture2D t2d1 : register(t1);
|
||||
Texture2D t2d2 : register(t2);
|
||||
Texture2D t2d3 : register(t3);
|
||||
Texture2D t2d4 : register(t4);
|
||||
Texture2D t2d5 : register(t5);
|
||||
Texture2D t2d6 : register(t6);
|
||||
Texture2D t2d7 : register(t7);
|
||||
Texture2D t2d8 : register(t8);
|
||||
Texture2D t2d9 : register(t9);
|
||||
Texture2D t2d10 : register(t10);
|
||||
Texture2D t2d11 : register(t11);
|
||||
Texture2D t2d12 : register(t12);
|
||||
Texture2D t2d13 : register(t13);
|
||||
Texture2D t2d14 : register(t14);
|
||||
Texture2D t2d15 : register(t15);
|
||||
Texture2D t2d16 : register(t16);
|
||||
Texture2D t2d17 : register(t17);
|
||||
Texture2D t2d18 : register(t18);
|
||||
Texture2D t2d19 : register(t19);
|
||||
Texture2D t2d20 : register(t20);
|
||||
SamplerState samplerClamp : register(s0);
|
||||
SamplerState samplerWrap : register(s1);
|
||||
SamplerState samplerMirror : register(s2);
|
||||
|
||||
#define pi 3.141592
|
||||
|
||||
[syncstruct]
|
||||
struct ST
|
||||
{
|
||||
float4 cameraPosition;
|
||||
float4 cameraCenter;
|
||||
float4 cameraUp;
|
||||
float4 lightDir;
|
||||
float fade;
|
||||
float fontFade;
|
||||
float scene;
|
||||
float fogAmount;
|
||||
float4 gridBorderColor;
|
||||
float4 gridFaceColor;
|
||||
float4 glowParams;
|
||||
float gridLineTime;
|
||||
float contrast;
|
||||
float2 _padding;
|
||||
};
|
||||
|
||||
//[
|
||||
cbuffer _cb0 : register(b0)
|
||||
{
|
||||
//]
|
||||
float time;
|
||||
float aspectRatio;
|
||||
//[
|
||||
}
|
||||
|
||||
cbuffer _cb1 : register(b1)
|
||||
{
|
||||
//]
|
||||
ST _s;
|
||||
//[
|
||||
}
|
||||
|
||||
float3 getFontColor(float2 uv)
|
||||
{
|
||||
float font = t2d0.SampleLevel(samplerClamp, uv, 0).x;
|
||||
float3 color = 1 - smoothstep(0, 5, abs(((font + time * 50) % 10.0) - 5));
|
||||
color *= smoothstep(-100, 0, -font);
|
||||
float3 floorColor = float3(0.0, 0.6, 0.8);
|
||||
color = lerp(floorColor, color * floorColor, saturate(font));
|
||||
color *= smoothstep(0, 0.05, uv.x);
|
||||
color *= smoothstep(-1, -0.95, -uv.x);
|
||||
color *= smoothstep(0, 0.05, uv.y);
|
||||
color *= smoothstep(-1, -0.95, -uv.y);
|
||||
return color;
|
||||
}
|
||||
|
||||
[numthreads(16,16,1)]
|
||||
[entrypoint(cs)]
|
||||
void cs_Sample(int3 id: SV_DispatchThreadID)
|
||||
{
|
||||
float2 s;
|
||||
o2d0.GetDimensions(s.x, s.y);
|
||||
float2 uv = (id.xy + 0.5) / s;
|
||||
float offset = 1 - 1.5 * _s.fontFade;
|
||||
uv.x -= offset;
|
||||
uv.x *= s.y / s.x;
|
||||
uv.y = 1 - uv.y;
|
||||
float3 existing = t2d1.Load(int3(id.xy, 0)).xyz;
|
||||
float fade = 1-abs(_s.fontFade - 1);
|
||||
o2d0[id.xy] = float4(
|
||||
max(existing, fade * getFontColor(uv)),
|
||||
1);
|
||||
}
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
[entrypoint(cs)]
|
||||
void cs_Copy(int3 id: SV_DispatchThreadID)
|
||||
{
|
||||
o2d0[id.xy] = t2d0.Load(int3(id.xy, 0));
|
||||
}
|
||||
|
||||
#include "lib/shared.hlsl"
|
||||
#include "lib/blur.hlsl"
|
||||
#include "lib/distance-transform.hlsl"
|
||||
#include "lib/grid-lines.hlsl"
|
||||
#include "lib/mesh.hlsl"
|
||||
#include "lib/textures.hlsl"
|
||||
#include "lib/postprocess.hlsl"
|
||||
#include "lib/raymarching.hlsl"
|
||||
#include "lib/ssao.hlsl"
|
||||
#include "lib/particles.hlsl"
|
||||
#include "lib/volumetric-fog.hlsl"
|
||||
51
nordlicht2015-intro/src/intro/shaders/lib/blur.hlsl
Normal file
51
nordlicht2015-intro/src/intro/shaders/lib/blur.hlsl
Normal file
@@ -0,0 +1,51 @@
|
||||
void bBlur(int3 id, float2 direction)
|
||||
{
|
||||
float2 resolution;
|
||||
o2d0.GetDimensions(resolution.x, resolution.y);
|
||||
|
||||
float2 sourceResolution;
|
||||
t2d0.GetDimensions(sourceResolution.x, sourceResolution.y);
|
||||
|
||||
float mipLevel = log2(sourceResolution.x / resolution.x);
|
||||
|
||||
float2 tc = (id.xy + 0.5) / resolution;
|
||||
float2 d = direction / resolution;
|
||||
|
||||
float4 a = 0;
|
||||
for (float i = -50; i <= 50; ++i)
|
||||
{
|
||||
float weight = exp(-i*i / 1000);
|
||||
float4 b = t2d0.SampleLevel(samplerClamp, i * d + tc, mipLevel);
|
||||
a += b * weight;
|
||||
}
|
||||
|
||||
o2d0[id.xy] = a / sqrt(1000 * pi);
|
||||
}
|
||||
|
||||
[entrypoint(cs)]
|
||||
[numthreads(16, 16, 1)] void csBlurH(int3 id:SV_DispatchThreadID)
|
||||
{
|
||||
bBlur(id, float2(1, 0));
|
||||
}
|
||||
|
||||
[entrypoint(cs)]
|
||||
[numthreads(16, 16, 1)] void csBlurV(int3 id:SV_DispatchThreadID)
|
||||
{
|
||||
bBlur(id, float2(0, 1));
|
||||
}
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
[entrypoint(cs)]
|
||||
void csMerge(int3 id:SV_DispatchThreadID)
|
||||
{
|
||||
float2 resolution;
|
||||
o2d0.GetDimensions(resolution.x, resolution.y);
|
||||
|
||||
float2 tc = (id.xy + 0.5) / resolution;
|
||||
|
||||
o2d0[id.xy] = float4(
|
||||
t2d0.SampleLevel(samplerClamp, tc, 0).xyz * _s.glowParams.x +
|
||||
t2d1.SampleLevel(samplerClamp, tc, 0).xyz * _s.glowParams.y +
|
||||
t2d2.SampleLevel(samplerClamp, tc, 0).xyz * _s.glowParams.z +
|
||||
t2d3.SampleLevel(samplerClamp, tc, 0).xyz * _s.glowParams.w, 1);
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
RWTexture2D<uint> g : register(u0);
|
||||
RWTexture2D<uint> s : register(u1);
|
||||
RWTexture2D<uint> t : register(u2);
|
||||
RWTexture2D<float> dt : register(u3);
|
||||
|
||||
[numthreads(16, 1, 1)]
|
||||
[entrypoint(cs)]
|
||||
void csDT1(int3 id : SV_DispatchThreadID) // parallelize X
|
||||
{
|
||||
int2 s;
|
||||
g.GetDimensions(s.x, s.y);
|
||||
|
||||
uint infinity = s.x + s.y;
|
||||
int2 uv = int2(id.x, 0);
|
||||
int2 p1 = int2(0, 1);
|
||||
|
||||
g[uv] = step(0.5, t2d0[uv].x) * infinity;
|
||||
|
||||
// Scan 1
|
||||
for (uv.y = 1; uv.y < s.y; uv.y++)
|
||||
{
|
||||
g[uv] = step(0.5, t2d0[uv].x) * (1 + g[uv - p1]);
|
||||
}
|
||||
|
||||
// Scan 2
|
||||
for (uv.y = s.y - 2; uv.y >= 0; uv.y--)
|
||||
{
|
||||
uint t = g[uv + p1];
|
||||
if (t < g[uv])
|
||||
g[uv] = 1 + t;
|
||||
}
|
||||
}
|
||||
|
||||
uint EDT_f(uint x, uint i, uint g_i)
|
||||
{
|
||||
return (x - i)*(x - i) + g_i*g_i;
|
||||
}
|
||||
|
||||
uint EDT_Sep(uint i, uint u, uint g_i, uint g_u)
|
||||
{
|
||||
return (u*u - i*i + g_u*g_u - g_i*g_i) / (2 * (u - i));
|
||||
}
|
||||
|
||||
[numthreads(1, 16, 1)]
|
||||
[entrypoint(cs)]
|
||||
void csDT2(int3 id : SV_DispatchThreadID) // parallelize Y
|
||||
{
|
||||
int2 dim;
|
||||
g.GetDimensions(dim.x, dim.y);
|
||||
|
||||
int2 uv = int2(0, id.y);
|
||||
int2 q = int2(0, id.y);
|
||||
int2 w = int2(0, id.y);
|
||||
|
||||
s[uv] = 0;
|
||||
t[uv] = 0;
|
||||
|
||||
// Scan 3
|
||||
for (uv.x = 1; uv.x < dim.x; uv.x++)
|
||||
{
|
||||
while (q.x >= 0 &&
|
||||
EDT_f(t[q], s[q], g[uint2(s[q], uv.y)]) >
|
||||
EDT_f(t[q], uv.x, g[uv]))
|
||||
{
|
||||
q.x--;
|
||||
}
|
||||
|
||||
if (q.x < 0)
|
||||
{
|
||||
q.x = 0;
|
||||
s[uint2(0, uv.y)] = uv.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
w.x = 1 + EDT_Sep(s[q], uv.x, g[uint2(s[q], uv.y)], g[uv]);
|
||||
if (w.x < dim.x)
|
||||
{
|
||||
q.x++;
|
||||
s[q] = uv.x;
|
||||
t[q] = w.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Scan 4
|
||||
for (; uv.x >= 0; uv.x--)
|
||||
{
|
||||
uint d = EDT_f(uv.x, s[q], g[uint2(s[q], uv.y)]);
|
||||
dt[uv] = sqrt(d);
|
||||
if (uv.x == int(t[q]))
|
||||
q.x--;
|
||||
}
|
||||
}
|
||||
150
nordlicht2015-intro/src/intro/shaders/lib/grid-lines.hlsl
Normal file
150
nordlicht2015-intro/src/intro/shaders/lib/grid-lines.hlsl
Normal file
@@ -0,0 +1,150 @@
|
||||
|
||||
struct VOut
|
||||
{
|
||||
float3 pos : POSITION0;
|
||||
int type : TYPE;
|
||||
float4 offset : TEXCOORD0;
|
||||
};
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
[entrypoint(cs)]
|
||||
void cs_gridline(int3 id : SV_DispatchThreadID)
|
||||
{
|
||||
float2 uv = id.xy - 512;
|
||||
float x = length(uv) - (_s.gridLineTime - 2 ) * 8 * pi+ 1;
|
||||
o2d0[id.xy] = float4(5 * sin(x)/x, 0, 0, 0);
|
||||
}
|
||||
|
||||
[entrypoint(vs)]
|
||||
void vs_gridline(uint id : SV_VertexID, out VOut o)
|
||||
{
|
||||
int type = id / (1024 * 1024);
|
||||
id %= (1024 * 1024);
|
||||
int z = id / 1024;
|
||||
int x = id % 1024;
|
||||
o.pos = float3(x, z, 512);
|
||||
o.type = type;
|
||||
uint seed = id;
|
||||
o.offset = float4(hash(seed++), hash(seed++), hash(seed++), hash(seed++));
|
||||
}
|
||||
|
||||
struct GOut
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float4 offset : TEXCOORD0;
|
||||
float2 uv : TEXCOORD1;
|
||||
};
|
||||
|
||||
float4 transform(float3 v, float3 o, out float2 uv)
|
||||
{
|
||||
uv = o.xy;
|
||||
float3 r = float3(v.xy + o.xy, 0).xzy;
|
||||
float2 tc = r.xz / (2 * v.z);
|
||||
r.y = t2d0.SampleLevel(samplerClamp, tc, 0).x + o.z;
|
||||
r.xz -= v.z;
|
||||
return ftransform(r);
|
||||
}
|
||||
|
||||
[maxvertexcount(10)]
|
||||
[entrypoint(gs)]
|
||||
void gs_gridline(point VOut ia[1], inout TriangleStream<GOut> os)
|
||||
{
|
||||
VOut i = ia[0];
|
||||
GOut o;
|
||||
o.offset = i.offset;
|
||||
float lw = 0.1;
|
||||
float lh = -0.2;
|
||||
float4 cellColor = 0;
|
||||
float4 floorColor = float4(_s.gridBorderColor.xyz, 1);
|
||||
if (i.type == 0 && time >= 16)
|
||||
{
|
||||
o.color = float4(_s.gridFaceColor.xyz, 1);
|
||||
|
||||
o.pos = transform(i.pos, float3(lw, lw, 0), o.uv);
|
||||
os.Append(o);
|
||||
o.pos = transform(i.pos, float3(1 - lw, lw, 0), o.uv);
|
||||
os.Append(o);
|
||||
o.pos = transform(i.pos, float3(lw, 1 - lw, 0), o.uv);
|
||||
os.Append(o);
|
||||
o.pos = transform(i.pos, float3(1 - lw, 1 - lw, 0), o.uv);
|
||||
os.Append(o);
|
||||
os.RestartStrip();
|
||||
}
|
||||
else if (i.type == 1)
|
||||
{
|
||||
o.color = cellColor;
|
||||
o.pos = transform(i.pos, float3(0.0, 0.0, lh), o.uv);
|
||||
os.Append(o);
|
||||
|
||||
o.color = floorColor;
|
||||
o.pos = transform(i.pos, float3(lw, lw, 0), o.uv);
|
||||
os.Append(o);
|
||||
|
||||
o.color = cellColor;
|
||||
o.pos = transform(i.pos, float3(0.0, 1.0, lh), o.uv);
|
||||
os.Append(o);
|
||||
|
||||
o.color = floorColor;
|
||||
o.pos = transform(i.pos, float3(lw, 1 - lw, 0), o.uv);
|
||||
os.Append(o);
|
||||
|
||||
o.color = cellColor;
|
||||
o.pos = transform(i.pos, float3(1.0, 1.0, lh), o.uv);
|
||||
os.Append(o);
|
||||
|
||||
o.color = floorColor;
|
||||
o.pos = transform(i.pos, float3(1 - lw, 1 - lw, 0), o.uv);
|
||||
os.Append(o);
|
||||
|
||||
o.color = cellColor;
|
||||
o.pos = transform(i.pos, float3(1.0, 0.0, lh), o.uv);
|
||||
os.Append(o);
|
||||
|
||||
o.color = floorColor;
|
||||
o.pos = transform(i.pos, float3(1 - lw, lw, 0), o.uv);
|
||||
os.Append(o);
|
||||
|
||||
o.color = cellColor;
|
||||
o.pos = transform(i.pos, float3(0.0, 0.0, lh), o.uv);
|
||||
os.Append(o);
|
||||
|
||||
o.color = floorColor;
|
||||
o.pos = transform(i.pos, float3(lw, lw, 0), o.uv);
|
||||
os.Append(o);
|
||||
|
||||
os.RestartStrip();
|
||||
}
|
||||
}
|
||||
|
||||
float4 gridFont(float2 uv, Texture2D tex)
|
||||
{
|
||||
uv.y = -0.5 + 2 * uv.y;
|
||||
float font = 1 - tex.SampleLevel(samplerClamp, uv, 0).x;
|
||||
float color = smoothstep(-100, 0, -font);
|
||||
color = lerp(0, color, saturate(font));
|
||||
color *= smoothstep(0, 0.05, uv.x);
|
||||
color *= smoothstep(-1, -0.95, -uv.x);
|
||||
color *= smoothstep(0, 0.05, uv.y);
|
||||
color *= smoothstep(-1, -0.95, -uv.y);
|
||||
return float4(0, 0, 0, color);
|
||||
}
|
||||
|
||||
[entrypoint(ps)]
|
||||
float4 ps_gridline(GOut i) : SV_Target0
|
||||
{
|
||||
float2 uv = i.uv;
|
||||
if (uv.x<0.1||uv.y<0.1||uv.x>0.9||uv.y>0.9)
|
||||
return i.color;
|
||||
|
||||
float4 fontColor = float4(0, 0, 0, 0);
|
||||
int texId = floor(i.offset.x * 3);
|
||||
if (texId == 0)
|
||||
fontColor = gridFont(uv, t2d1);
|
||||
else if (texId == 1)
|
||||
fontColor = gridFont(uv, t2d2);
|
||||
else if (texId == 2)
|
||||
fontColor = gridFont(uv, t2d3);
|
||||
|
||||
return lerp(i.color, float4(fontColor.xyz, 1), fontColor.w);
|
||||
}
|
||||
182
nordlicht2015-intro/src/intro/shaders/lib/mesh.hlsl
Normal file
182
nordlicht2015-intro/src/intro/shaders/lib/mesh.hlsl
Normal file
@@ -0,0 +1,182 @@
|
||||
struct MeshVIn
|
||||
{
|
||||
float3 pos: POSITION0;
|
||||
float4 uv: TEXCOORD0;
|
||||
float3 normal: NORMAL0;
|
||||
};
|
||||
|
||||
struct MeshPIn
|
||||
{
|
||||
float4 pos: SV_POSITION;
|
||||
float4 uv: TEXCOORD0;
|
||||
float3 normal: NORMAL0;
|
||||
float3 lightNormal: NORMAL1;
|
||||
float3 world: TEXCOORD2;
|
||||
};
|
||||
|
||||
[entrypoint(vs_il, 3)]
|
||||
void mesh(in MeshVIn i, out MeshPIn o)
|
||||
{
|
||||
o.pos = ftransform(i.pos);
|
||||
o.uv = i.uv;
|
||||
o.normal = i.normal;
|
||||
o.lightNormal = i.normal;
|
||||
o.world = i.pos;
|
||||
}
|
||||
|
||||
float3 textureX(float2 uv)
|
||||
{
|
||||
float l = t2d0.SampleLevel(samplerMirror, uv * 2, 0).z;
|
||||
l += 0.5 * t2d0.SampleLevel(samplerMirror, uv * 2, 0).w;
|
||||
return lerp(
|
||||
float3(0.4, 0.3, 0.2),
|
||||
float3(0, -0.1, -0.2),
|
||||
0.2 + 0.8 * l);
|
||||
}
|
||||
|
||||
float3 textureY(float2 uv)
|
||||
{
|
||||
float l = t2d0.SampleLevel(samplerMirror, uv * 0.2, 0).z;
|
||||
l += 0.5 * t2d0.SampleLevel(samplerMirror, uv, 0).w;
|
||||
return lerp(
|
||||
float3(0.1, 0.2, 0.1) * (-0.1 + 0.7 * t2d0.SampleLevel(samplerMirror, uv, 0).y),
|
||||
float3(1, 1, 0.5) * (0.3 + 0.7 * t2d0.SampleLevel(samplerMirror, uv * 4, 0).y),
|
||||
l);
|
||||
}
|
||||
|
||||
float3 textureZ(float2 uv)
|
||||
{
|
||||
float l = t2d0.SampleLevel(samplerMirror, uv, 0).x;
|
||||
l += t2d0.SampleLevel(samplerMirror, uv * 2, 0).w;
|
||||
return lerp(
|
||||
float3(0.3, 0.3, 0.3),
|
||||
float3(-0.1, 0, 0.0),
|
||||
l);
|
||||
}
|
||||
|
||||
float3 texturize(float3 w, float3 n)
|
||||
{
|
||||
return
|
||||
textureX(w.yz) * pow(abs(n.x), 2) +
|
||||
textureY(w.xz) * pow(abs(n.y), 2) +
|
||||
textureZ(w.xy) * pow(abs(n.z), 2);
|
||||
}
|
||||
|
||||
float3 envmap(float3 n)
|
||||
{
|
||||
return
|
||||
t2d0.SampleLevel(samplerMirror, n.yz, 0).w * n.x +
|
||||
t2d0.SampleLevel(samplerMirror, n.xz, 0).w * n.y +
|
||||
t2d0.SampleLevel(samplerMirror, n.xy, 0).w * n.z;
|
||||
}
|
||||
|
||||
float3 enlighten(float3 n, float shininess, float3 rd)
|
||||
{
|
||||
float3 sunDir = normalize(- _s.lightDir.xyz);
|
||||
float3 indDir = normalize(sunDir * float3(-1.0, 0.0, -1.0));
|
||||
|
||||
float sun = saturate(dot(n, sunDir));
|
||||
float sky = saturate(0.5 + 0.5 * n.y);
|
||||
float ind = abs(dot(n, sunDir));
|
||||
float3 ref = reflect(rd, n);
|
||||
float spc = 8 * pow(saturate(dot(ref, sunDir)), 64) * shininess;
|
||||
|
||||
float3 light =
|
||||
spc * float3(2.64,1.87,0.99) +
|
||||
sun * float3(2.64,1.87,0.99) +//*pow(vec3(sha),vec3(1.0,1.2,1.5));
|
||||
sky * float3(0.16,0.20,0.28) +//*occ;
|
||||
ind * float3(0.40,0.28,0.20);//*occ;
|
||||
|
||||
return light;
|
||||
}
|
||||
|
||||
[entrypoint(ps)]
|
||||
void ps_mesh(in MeshPIn i, out float4 o0 : SV_Target0, out float4 o1 : SV_Target1)
|
||||
{
|
||||
float3 n = normalize(i.lightNormal);
|
||||
float3 tex = texturize(i.world * 2, n);
|
||||
|
||||
float3 matColor = 0;
|
||||
float shininess = step(0.5, i.uv.w) * saturate(3 * i.uv.z);
|
||||
if (distance(i.uv.w, 2) < 0.1) // kristall
|
||||
{
|
||||
float map = 2 * t2d0.SampleLevel(samplerMirror, i.uv.xy, 0).y;
|
||||
matColor = lerp(float3(0.8, 0.2, 0.2), float3(0.5, 0, 0), map);
|
||||
shininess = 1.0;
|
||||
}
|
||||
else if (distance(i.uv.w, 3) < 0.1) // metall 1
|
||||
{
|
||||
matColor = float3(0.2, 0.2, 0.3);
|
||||
shininess = 1.0;
|
||||
}
|
||||
else if (distance(i.uv.w, 4) < 0.1) // metall 2
|
||||
{
|
||||
matColor = float3(0.2, 0.3, 0.2);
|
||||
shininess = 1.0;
|
||||
}
|
||||
else if (distance(i.uv.w, 5) < 0.1) // kralle
|
||||
{
|
||||
matColor = lerp(tex, 0.5 * float3(-0.2, -0.1, 0.2), i.uv.z);
|
||||
float ring = 1.0 - smoothstep(0.0, 0.03, abs((((time + i.world.z + i.world.x) % 1) - i.uv.z - 0.05)));
|
||||
ring *= i.uv.z * 0.5;
|
||||
matColor += ring * float3(0.5, 0.8, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
matColor = tex;
|
||||
}
|
||||
|
||||
float3 rd = i.world - _s.cameraPosition.xyz;
|
||||
float z = length(rd);
|
||||
o0 = float4(enlighten(n, shininess, normalize(rd)) * matColor, 1);
|
||||
o1 = float4(normalize(i.normal), z);
|
||||
}
|
||||
|
||||
float3 getWorldTerrain(int2 id, out float2 uv)
|
||||
{
|
||||
float3 npos = float3(id.x - 512, 0, id.y - 512) / 512;
|
||||
uv = npos.xz * 0.5 + 0.5;
|
||||
float3 world = npos * 128;
|
||||
world.y = t2d0.SampleLevel(samplerMirror, uv, 0).w * 4 - 2 ;
|
||||
return world;
|
||||
}
|
||||
|
||||
struct TerrainVOut
|
||||
{
|
||||
int2 id : POSITION;
|
||||
};
|
||||
|
||||
[entrypoint(vs)]
|
||||
void vs_terrain(uint id: SV_VertexID, out TerrainVOut o)
|
||||
{
|
||||
int z = id / 1024;
|
||||
int x = id % 1024;
|
||||
o.id = int2(x, z);
|
||||
}
|
||||
|
||||
MeshPIn getVertex(int x, int z)
|
||||
{
|
||||
float2 uv;
|
||||
float3 world = getWorldTerrain(int2(x, z), uv);
|
||||
MeshPIn o;
|
||||
o.pos = ftransform(world);
|
||||
o.uv = float4(uv, 0, 0);
|
||||
float nx = getWorldTerrain(int2(x + 1, z), uv).y - getWorldTerrain(int2(x - 1, z), uv).y;
|
||||
float nz = getWorldTerrain(int2(x, z + 1), uv).y - getWorldTerrain(int2(x, z - 1), uv).y;
|
||||
o.normal = normalize(float3(nx, 0.01, nz));
|
||||
o.lightNormal = normalize(float3(nx, 1, nz));
|
||||
o.world = world;
|
||||
return o;
|
||||
}
|
||||
|
||||
[maxvertexcount(4)]
|
||||
[entrypoint(gs)]
|
||||
void gs_terrain(point TerrainVOut ia[1], inout TriangleStream<MeshPIn> os)
|
||||
{
|
||||
int2 id = ia[0].id;
|
||||
os.Append(getVertex(id.x + 1, id.y));
|
||||
os.Append(getVertex(id.x, id.y));
|
||||
os.Append(getVertex(id.x + 1, id.y + 1));
|
||||
os.Append(getVertex(id.x, id.y + 1));
|
||||
os.RestartStrip();
|
||||
}
|
||||
65
nordlicht2015-intro/src/intro/shaders/lib/particles.hlsl
Normal file
65
nordlicht2015-intro/src/intro/shaders/lib/particles.hlsl
Normal file
@@ -0,0 +1,65 @@
|
||||
struct ParticlePIn
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct ParticleGIn
|
||||
{
|
||||
float3 pos : POSITION;
|
||||
float size : SIZE;
|
||||
};
|
||||
|
||||
[entrypoint(vs)]
|
||||
void vs_ParticlesFlock(uint id : SV_VertexID, out ParticleGIn o)
|
||||
{
|
||||
int seed = id;
|
||||
float2 uvX = float2(time * 0.01, id / 1024.0);
|
||||
float2 uvY = float2(id / 1024.0, time * 0.01);
|
||||
float2 uvZ = float2(1 - time * 0.01, 1 - id / 1024.0);
|
||||
o.pos = float3(hash(seed++), hash(seed++), hash(seed++)) * 2 - 1;
|
||||
float3 velocity = (float3(
|
||||
t2d0.SampleLevel(samplerMirror, uvX, 0).w,
|
||||
t2d0.SampleLevel(samplerMirror, uvY, 0).w,
|
||||
t2d0.SampleLevel(samplerMirror, uvZ, 0).w) * 2 - 1) * 3;
|
||||
o.pos += velocity * float3(2, 1, 2);
|
||||
o.size = 0.02;
|
||||
}
|
||||
|
||||
float4 ptransform(float3 world, float3 offset, out float2 uv)
|
||||
{
|
||||
uv = offset.xy * 0.5 + 0.5;
|
||||
offset.xy *= offset.z;
|
||||
float3 rd = normalize(world - _s.cameraPosition.xyz);
|
||||
float3 right = normalize(cross(rd, _s.cameraUp.xyz));
|
||||
return ftransform(world + offset.x * right + offset.y * _s.cameraUp.xyz);
|
||||
}
|
||||
|
||||
[maxvertexcount(4)]
|
||||
[entrypoint(gs)]
|
||||
void gs_Particles(point ParticleGIn ia[1], inout TriangleStream<ParticlePIn> os)
|
||||
{
|
||||
ParticleGIn i = ia[0];
|
||||
ParticlePIn o;
|
||||
|
||||
o.pos = ptransform(i.pos, float3(-1, -1, i.size), o.uv);
|
||||
os.Append(o);
|
||||
o.pos = ptransform(i.pos, float3(1, -1, i.size), o.uv);
|
||||
os.Append(o);
|
||||
o.pos = ptransform(i.pos, float3(-1, 1, i.size), o.uv);
|
||||
os.Append(o);
|
||||
o.pos = ptransform(i.pos, float3(1, 1, i.size), o.uv);
|
||||
os.Append(o);
|
||||
os.RestartStrip();
|
||||
}
|
||||
|
||||
[entrypoint(ps)]
|
||||
float4 ps_Particles(ParticlePIn i) : SV_Target0
|
||||
{
|
||||
float2 uv = i.uv * 2 - 1;
|
||||
float alpha = saturate(1.1-length(uv));
|
||||
if (alpha < 0.5)
|
||||
discard;
|
||||
|
||||
return float4(0, 0, 0, alpha);
|
||||
}
|
||||
60
nordlicht2015-intro/src/intro/shaders/lib/postprocess.hlsl
Normal file
60
nordlicht2015-intro/src/intro/shaders/lib/postprocess.hlsl
Normal file
@@ -0,0 +1,60 @@
|
||||
struct SunPIn
|
||||
{
|
||||
float4 pos : SV_Position;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
[entrypoint(vs)]
|
||||
void vs_Sun(uint id: SV_VertexID, out SunPIn o)
|
||||
{
|
||||
float3 lDir = normalize(-_s.lightDir.xyz);
|
||||
lDir.y *= -1;
|
||||
float3 lightPos = _s.cameraPosition.xyz + 50 * lDir;
|
||||
float4 sLightPos = ftransform(lightPos);
|
||||
|
||||
float y = id / 2;
|
||||
float x = 1 - id % 2;
|
||||
float2 offset = float2(x * 2 - 1, y * 2 - 1);
|
||||
o.uv = offset;
|
||||
offset.x /= aspectRatio;
|
||||
sLightPos.xy += offset * 5;
|
||||
o.pos = sLightPos;
|
||||
}
|
||||
|
||||
[entrypoint(ps)]
|
||||
float4 ps_Sun(SunPIn i) : SV_Target0
|
||||
{
|
||||
if (length(i.uv) > 1)
|
||||
discard;
|
||||
|
||||
return lerp(lerp(0, float4(5, 4, 1, 1.0), min(1, _s.fade * 2)), 1, max(0, (_s.fade - 0.5) * 2));
|
||||
}
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
[entrypoint(cs)]
|
||||
void cs_Postprocess(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
float2 s;
|
||||
o2d0.GetDimensions(s.x, s.y);
|
||||
float2 uv = (id.xy + 0.5) / s;
|
||||
float3 ro, rd;
|
||||
camera(uv, ro, rd);
|
||||
|
||||
float depth = t2d1.SampleLevel(samplerClamp, uv, 0).x;
|
||||
float fog = _s.fogAmount * pow(max(0, smoothstep(0.9, 1.0, depth)), 64.0);
|
||||
float3 fogColor = lerp(
|
||||
float3(0.7, 0.6, 0.5),
|
||||
float3(1.0, 0.75, 0.4), pow(saturate(dot(rd, normalize(-_s.lightDir.xyz))), 8));
|
||||
|
||||
float3 existingColor = saturate(t2d0.SampleLevel(samplerClamp, uv, 0).xyz);
|
||||
float3 color = lerp(existingColor, fogColor, fog);
|
||||
color = max(existingColor, color);
|
||||
color = pow(max(0, color), 1.0 / 2.2);
|
||||
|
||||
float vignette = 1.2 - 0.5*smoothstep(0, 1, pow(length(uv - 0.5), 0.8));
|
||||
float grain = 0.8 + 0.2 * hash(noise2(id.xy) + time * 10000);
|
||||
color = lerp(lerp(0, color, min(1, _s.fade * 2)), 1, max(0, (_s.fade - 0.5) * 2));
|
||||
color *= saturate(time*16);
|
||||
color = (color - 0.5) * _s.contrast + 0.5;
|
||||
o2d0[id.xy] = float4(color * vignette * grain, 1);
|
||||
}
|
||||
208
nordlicht2015-intro/src/intro/shaders/lib/raymarching.hlsl
Normal file
208
nordlicht2015-intro/src/intro/shaders/lib/raymarching.hlsl
Normal file
@@ -0,0 +1,208 @@
|
||||
#include "sdf.hlsl"
|
||||
|
||||
static float3 q, p, n;
|
||||
static float h, i, j, k;
|
||||
static float dOut, d0, d1, d2, d3;
|
||||
|
||||
float fGimbalLock(float3 p)
|
||||
{
|
||||
p.y -= 5;
|
||||
float3 q1 = p;
|
||||
r(q1.xy, pi/2);
|
||||
r(q1.yz, time * 0.5);
|
||||
float3 q2 = q1;
|
||||
fOpRepeat(q1, 16, 0);
|
||||
float dd1 = fBox(q1 + float3(1, 0.0, 0.0), float3(0.05, 0.05, 0.15)) - 0.05;
|
||||
|
||||
r(q2.yz, time * 2);
|
||||
float3 q3 = q2;
|
||||
fOpRepeat(q2, 16, time * 2);
|
||||
d2 = fBox(q2 + float3(0.8, 0.0, 0.0), float3(0.05, 0.05, 0.12)) - 0.05;
|
||||
|
||||
r(q3.xy, time * 3);
|
||||
fOpRepeat(q3, 16, time * 2);
|
||||
d3 = fBox(q3 + float3(0.6, 0.0, 0.0), float3(0.05, 0.05, 0.09)) - 0.05;
|
||||
|
||||
return dOut = min(dd1, min(d2, d3));
|
||||
}
|
||||
|
||||
float fText(float3 p, Texture2D tex)
|
||||
{
|
||||
float fText = 0;
|
||||
p.y *= 2;
|
||||
if (p.x >= 1.01 || p.x <= -1.01 || p.y >= 1.01 || p.y <= -1.01)
|
||||
{
|
||||
float2 dd = abs(p.xy) - 1;
|
||||
fText = max(dd.x, dd.y);
|
||||
}
|
||||
else
|
||||
fText = tex.SampleLevel(samplerClamp, p.xy*0.5 + 0.5, 0).x * 0.0008;
|
||||
float2 d = float2(fText, abs(p.z) - 0.1);
|
||||
return length(max(d, 0)) + min(max(d.x, d.y), 0) * 0.75;
|
||||
}
|
||||
|
||||
float fGrabstein(float3 p, float2 b)
|
||||
{
|
||||
float2 d = float2(length(p.xy)-b.x, abs(p.z)-b.y);
|
||||
return length(max(d, 0)) + min(max(d.x, d.y), 0);
|
||||
}
|
||||
|
||||
float fTextGrabstein(float3 p, Texture2D tex)
|
||||
{
|
||||
float bv = fBox(p, float3(1, 2, 0.2));
|
||||
if (bv > 1)
|
||||
return bv;
|
||||
|
||||
float dist = fGrabstein(p, float2(1, 0.15));
|
||||
p.y += 1.5;
|
||||
dist = min(dist, fBox(p, float3(1, 1.5, 0.15))) - 0.05;
|
||||
p.z += 0.15;
|
||||
p.y -= 1.5;
|
||||
float text = fText(p, tex);
|
||||
d1 = min(d1, text);
|
||||
dist = min(dist, text);
|
||||
return dist;
|
||||
}
|
||||
|
||||
void plot(float3 p, inout float dist, Texture2D tex, float3 offset, float rot)
|
||||
{
|
||||
float3 q = p;
|
||||
q -= offset;
|
||||
r(q.xz, rot);
|
||||
dist = min(dist, fTextGrabstein(q, tex));
|
||||
}
|
||||
|
||||
float fFriedhof(float3 p)
|
||||
{
|
||||
d1 = INFINITY;
|
||||
p.y -= 1;
|
||||
float dist = INFINITY;
|
||||
plot(p, dist, t2d1, float3(-2, 0.2, -2), -0.5);
|
||||
plot(p, dist, t2d2, float3(0, 0, 0), 0.2);
|
||||
plot(p, dist, t2d3, float3(2, 0, -2), 0.8);
|
||||
plot(p, dist, t2d4, float3(-2, 0.5, -4), -0.3);
|
||||
plot(p, dist, t2d5, float3(-3, 1, -6), -0.8);
|
||||
plot(p, dist, t2d6, float3(1, 0, -6), 0.5);
|
||||
plot(p, dist, t2d7, float3(4, 0.5, -8), 1.0);
|
||||
plot(p, dist, t2d8, float3(1, 0.0, -8), 1.0);
|
||||
plot(p, dist, t2d9, float3(0.5, 0.5, -12.5), 2.5);
|
||||
plot(p, dist, t2d10, float3(2, 0.0, -10), 0.0);
|
||||
plot(p, dist, t2d11, float3(4, 0.0, -9), -0.5);
|
||||
plot(p, dist, t2d12, float3(6, 0.5, -8), 0);
|
||||
plot(p, dist, t2d13, float3(2, 0.5, -13), -1.5);
|
||||
plot(p, dist, t2d14, float3(3, 0.5, -14.5), -2.5);
|
||||
plot(p, dist, t2d15, float3(6, 0.5, -12), -1);
|
||||
plot(p, dist, t2d16, float3(6, 1.0, -16), -3);
|
||||
plot(p, dist, t2d17, float3(7.5, 1.0, -18), -3);
|
||||
plot(p, dist, t2d18, float3(11, 1.5, -16), 2);
|
||||
plot(p, dist, t2d19, float3(10, 1.0, -19), 3);
|
||||
return dOut = dist;
|
||||
}
|
||||
|
||||
float f(float3 p)
|
||||
{
|
||||
float dist = 0;
|
||||
if (_s.scene < 3)
|
||||
{
|
||||
dist = fGimbalLock(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
dist = fFriedhof(p);
|
||||
}
|
||||
return dist;
|
||||
}
|
||||
|
||||
struct rmPS
|
||||
{
|
||||
float4 o: SV_Position;
|
||||
float2 uv: TEXCOORD0;
|
||||
};
|
||||
|
||||
[entrypoint(vs)]
|
||||
void vs_Raymarching(uint id : SV_VertexID, out rmPS o)
|
||||
{
|
||||
float y = id / 2;
|
||||
float x = 1 - id % 2;
|
||||
o.o = float4(x * 2 - 1, y * 2 - 1, 0, 1);
|
||||
o.uv = float2(x, y);
|
||||
}
|
||||
|
||||
[entrypoint(ps)]
|
||||
void ps_Raymarching(rmPS input, out float4 o0 : SV_Target0, out float4 o1 : SV_Target1, out float depth : SV_Depth)
|
||||
{
|
||||
camera(input.uv, p, q);
|
||||
float t_min = 0.0001;
|
||||
|
||||
float pixelRadius = 0.00003636;
|
||||
float t_max = t_min + 150;
|
||||
float omega = 1.3;
|
||||
float t = t_min;
|
||||
float previousRadius = 0;
|
||||
float stepLength = 0;
|
||||
float4 d = 0;
|
||||
float functionSign = f(p) < 0 ? -1 : +1;
|
||||
float2 intersection = { 0, INFINITY };
|
||||
|
||||
for (float i = 0; i < 56; ++i)
|
||||
{
|
||||
float signedRadius = functionSign * f(q*t + p);
|
||||
float radius = abs(signedRadius);
|
||||
|
||||
bool sorFail = omega > 1 && radius + previousRadius < stepLength;
|
||||
if (sorFail)
|
||||
{
|
||||
stepLength = stepLength - omega * stepLength;
|
||||
omega = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
stepLength = signedRadius * omega;
|
||||
}
|
||||
|
||||
previousRadius = radius;
|
||||
float screenSpaceError = radius / t;
|
||||
if (!sorFail && screenSpaceError < intersection.y)
|
||||
intersection = float2(t, screenSpaceError);
|
||||
if (!sorFail && screenSpaceError < pixelRadius || t > t_max)
|
||||
break;
|
||||
|
||||
t += stepLength;
|
||||
}
|
||||
|
||||
if (t > t_max || intersection.y > pixelRadius)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
float3 hit = q*t + p;
|
||||
|
||||
float4 pos = ftransform(hit);
|
||||
pos /= pos.w;
|
||||
|
||||
if (pos.z > 0.999)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
depth = pos.z;
|
||||
|
||||
float2 e = float2(0.001, 0);
|
||||
float3 n = normalize(float3(
|
||||
f(hit + e.xyy).x - f(hit - e.xyy).x,
|
||||
f(hit + e.yxy).x - f(hit - e.yxy).x,
|
||||
f(hit + e.yyx).x - f(hit - e.yyx).x));
|
||||
|
||||
float3 color =
|
||||
t2d0.SampleLevel(samplerMirror, hit.yz, 0).w * abs(n.x) +
|
||||
t2d0.SampleLevel(samplerMirror, hit.xz, 0).w * abs(n.y) +
|
||||
t2d0.SampleLevel(samplerMirror, hit.xy, 0).w * abs(n.z);
|
||||
|
||||
if (dOut != d1)
|
||||
color = 0.25 + 0.25 * color;
|
||||
|
||||
float4 c = float4(color * enlighten(n, 1, q), 1);
|
||||
float z = distance(hit, _s.cameraPosition.xyz);
|
||||
o0 = c;
|
||||
o1 = float4(n, z);
|
||||
}
|
||||
413
nordlicht2015-intro/src/intro/shaders/lib/sdf.hlsl
Normal file
413
nordlicht2015-intro/src/intro/shaders/lib/sdf.hlsl
Normal file
@@ -0,0 +1,413 @@
|
||||
static const float3 fAklemanVectors_[19] = {
|
||||
{1.000, 0.000, 0.000},
|
||||
{0.000, 1.000, 0.000},
|
||||
{0.000, 0.000, 1.000},
|
||||
|
||||
{0.577, 0.577, 0.577},
|
||||
{-0.577, 0.577, 0.577},
|
||||
{0.577, -0.577, 0.577},
|
||||
{0.577, 0.577, -0.577},
|
||||
|
||||
{0.000, 0.357, 0.934},
|
||||
{0.000, -0.357, 0.934},
|
||||
{0.934, 0.000, 0.357},
|
||||
{-0.934, 0.000, 0.357},
|
||||
{0.357, 0.934, 0.000},
|
||||
{-0.357, 0.934, 0.000},
|
||||
|
||||
{0.000, 0.851, 0.526},
|
||||
{0.000, -0.851, 0.526},
|
||||
{0.526, 0.000, 0.851},
|
||||
{-0.526, 0.000, 0.851},
|
||||
{0.851, 0.526, 0.000},
|
||||
{-0.851, 0.526, 0.000}
|
||||
};
|
||||
|
||||
|
||||
static const float3 fAklemanVectors[19] = {
|
||||
normalize(float3(1, 0, 0)),
|
||||
normalize(float3(0, 1, 0)),
|
||||
normalize(float3(0, 0, 1)),
|
||||
|
||||
normalize(float3(1, 1, 1 )),
|
||||
normalize(float3(-1, 1, 1)),
|
||||
normalize(float3(1, -1, 1)),
|
||||
normalize(float3(1, 1, -1)),
|
||||
|
||||
normalize(float3(0, 1, PHI+1)),
|
||||
normalize(float3(0, -1, PHI+1)),
|
||||
normalize(float3(PHI+1, 0, 1)),
|
||||
normalize(float3(-PHI-1, 0, 1)),
|
||||
normalize(float3(1, PHI+1, 0)),
|
||||
normalize(float3(-1, PHI+1, 0)),
|
||||
|
||||
normalize(float3(0, PHI, 1)),
|
||||
normalize(float3(0, -PHI, 1)),
|
||||
normalize(float3(1, 0, PHI)),
|
||||
normalize(float3(-1, 0, PHI)),
|
||||
normalize(float3(PHI, 1, 0)),
|
||||
normalize(float3(-PHI, 1, 0))
|
||||
};
|
||||
|
||||
float3 fOpBend(float3 p) {
|
||||
if (p.y > 0) {
|
||||
p.xy = float2(length(p.xy), atan2(p.y, p.x));
|
||||
} else if (p.x < 0) {
|
||||
p.xy *= -1;
|
||||
p.y += 2 * asin(1);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
float3 fOpBend(float3 p, float k, float s0) {
|
||||
if (abs(k) < 0.01)
|
||||
return p;
|
||||
float sk = sign(k);
|
||||
float r = 1/k;
|
||||
float2 d = sk * float2(p.x - s0, r - p.y);
|
||||
float a = atan2(d.x, d.y);
|
||||
return float3(a*r + s0, -length(d)*sk + r, p.z);
|
||||
}
|
||||
|
||||
float3 fOpBend(float3 p, float angle, float s0, float sBegin, float sEnd) {
|
||||
float k = angle / (sEnd - sBegin);
|
||||
if (abs(k) < 0.0001)
|
||||
return p;
|
||||
float sk = sign(k);
|
||||
float ak = abs(k);
|
||||
float r = 1/k;
|
||||
float2 d = sk * float2(p.x - s0, r - p.y);
|
||||
float a = atan2(d.x, d.y);
|
||||
float2 boundary = (float2(sBegin, sEnd) - s0) * k;
|
||||
float b = clamp(a, min(boundary.x, boundary.y), max(boundary.x, boundary.y));
|
||||
float s = b*r + s0;
|
||||
if (abs(a - b) > 0) {
|
||||
float2 c = float2(cos(b), sin(b));
|
||||
return float3(-sk * (c * d.x * float2(-1,1) + c.yx * d.y) + float2(s, r), p.z);
|
||||
}
|
||||
return float3(s, -length(d)*sk + r, p.z);
|
||||
}
|
||||
|
||||
#define fOpR45(p) p = 0.7071 * p + 0.7071 * float2(p.y, -p.x)
|
||||
|
||||
//repeat around y axis n times
|
||||
void fOpRepeat(inout float3 p, float n, float offset = 0) {
|
||||
float w = 2.0*pi / n;
|
||||
float a = atan2(p.z, p.x);
|
||||
float r = length(p.xz);
|
||||
a = mod(offset + a + pi*.5, w) + pi - pi / n;
|
||||
p.xz = r * float2(cos(a), sin(a));
|
||||
}
|
||||
|
||||
float fOpIntersectD(float d1, float d2, float r) {
|
||||
return (-d1 < r) && (-d2 < r) ? (d1 + r + d2) * sqrt(0.5) : max(d1,d2);
|
||||
}
|
||||
|
||||
float fOpDivideD(float d1, float d2, float r) {
|
||||
return fOpIntersectD(d1, -d2, r);
|
||||
}
|
||||
|
||||
float fOpCombineD(float d1, float d2, float r) {
|
||||
return (d1 < r) && (d2 < r) ? (d1 - r + d2) * sqrt(0.5) : min(d1,d2);
|
||||
}
|
||||
|
||||
float3 fOpVoxelize(float3 p, float s) {
|
||||
return floor(p/s + 0.5) * s;
|
||||
}
|
||||
|
||||
float fTooth(float3 p) {
|
||||
// x^4 + y^4 + z^4 - x^2 + y^2 + z^2
|
||||
float d = dot(pow(p, 4), 1) - dot(pow(p, 2), 1);
|
||||
|
||||
// d/dx = 4x^3 - 2x
|
||||
// d/dy = 4y^3 - 2y
|
||||
// d/dy = 4z^3 - 2z
|
||||
float3 g = 4*p*p*p - 2*p;
|
||||
return d / length(g);
|
||||
}
|
||||
|
||||
float fTeardrop(float3 p) {
|
||||
float d = p.y*p.y*p.y*p.y + p.y*p.y*p.y + p.x*p.x + p.z*p.z;
|
||||
float3 g = float3(2*p.x, -4*p.y*p.y*p.y - 3*p.y*p.y, 2*p.z);
|
||||
return d / length(g);
|
||||
}
|
||||
|
||||
float fKusnerSchmitt(float3 p) {
|
||||
float d = (p.x*p.x + 3) * (p.y*p.y + 3) * (p.z*p.z + 3) - 32 * (p.x*p.y*p.z + 1);
|
||||
|
||||
// d/dx = 2 x (y^2+3) (z^2+3) - 32yz
|
||||
// d/dy = 2 y (x^2+3) (z^2+3) - 32xz
|
||||
// d/dy = 2 z (x^2+3) (y^2+3) - 32xy
|
||||
float3 g = 2 * p.xyz * (p.yxx * p.yxx + 3) * (p.zzy * p.zzy + 3) - 32 * p.yxx * p.zzy;
|
||||
return d / length(g);
|
||||
}
|
||||
|
||||
float fSteinerRoman(float3 p) {
|
||||
//x^2 + y^2 + z^2 - 1)^2 - ((z - 1)^2 - 2*x^2)*((z + 1)^2 - 2*y^2)
|
||||
float d = (p.x*p.x + p.y*p.y + p.z*p.z - 1) * (p.x*p.x + p.y*p.y + p.z*p.z - 1) -
|
||||
((p.z - 1) * (p.z - 1) - 2*p.x*p.x) * ((p.z + 1) * (p.z + 1) - 2*p.y*p.y);
|
||||
|
||||
float3 g = 4 * float3(p.x, p.y, 1) *
|
||||
float3(
|
||||
p.x*p.x - p.y*p.y + 2*p.z*(p.z + 1),
|
||||
-p.x*p.x + p.y*p.y + 2*p.z*(p.z - 1),
|
||||
p.x*p.x*(2*p.z + 1) + p.y*p.y*(2*p.z - 1)
|
||||
);
|
||||
|
||||
return d / length(g);
|
||||
}
|
||||
|
||||
float fTetrahedralSymmetry(float3 p) {
|
||||
float d = (p.x*p.x + p.y*p.y + p.z*p.z) * (p.x*p.x + p.y*p.y + p.z*p.z) +
|
||||
8*p.x*p.y*p.z - 10*(p.x*p.x + p.y*p.y + p.z*p.z) + 25;
|
||||
float3 g = 4 * float3(
|
||||
p.x*p.x*p.x + p.x*(p.y*p.y + p.z*p.z - 5) + 2*p.y*p.z,
|
||||
p.y*(p.x*p.x + p.z*p.z - 5) + 2*p.x*p.z + p.y*p.y*p.y,
|
||||
p.x*p.x*p.z + 2*p.x*p.y + p.z*(p.y*p.y + p.z*p.z - 5)
|
||||
);
|
||||
return d / max(16, length(g));
|
||||
}
|
||||
|
||||
float fHyperbolicOctahedron(float3 p) {
|
||||
float3 p23 = pow(p*p, 1.0/3.0);
|
||||
float d = p23.x + p23.y + p23.z - 1;
|
||||
float3 g = 2*p / (3*p23*p23);
|
||||
return d / max(3, length(g));
|
||||
}
|
||||
|
||||
float fMcMullenK3(float3 p) {
|
||||
float d = (p.x*p.x + 1) * (p.y*p.y + 1) * (p.z*p.z + 1) +
|
||||
8*p.x*p.y*p.z - 2;
|
||||
float3 g = 2*p*(p.yxx*p.yxx + 1)*(p.zzy*p.zzy + 1) +
|
||||
8*p.yxx*p.zzy;
|
||||
return d / max(1, length(g));
|
||||
}
|
||||
|
||||
float fAkleman(float3 p, float r, float e, int begin, int end) {
|
||||
float d = 0;
|
||||
[unroll] for (int i = begin; i <= end; ++i)
|
||||
d += pow(abs(dot(p, fAklemanVectors[i])), e);
|
||||
return pow(d, 1/e) - r;
|
||||
}
|
||||
|
||||
float fAkleman(float3 p, float r, int begin, int end) {
|
||||
float d = 0;
|
||||
[unroll] for (int i = begin; i <= end; ++i)
|
||||
d = max(d, abs(dot(p, fAklemanVectors[i])));
|
||||
return d - r;
|
||||
}
|
||||
|
||||
float fPowAkleman(float3 p, float e, int begin, int end) {
|
||||
float d = 0;
|
||||
[unroll] for (int i = begin; i <= end; ++i)
|
||||
d += pow(abs(dot(p, fAklemanVectors[i])), e);
|
||||
return d;
|
||||
}
|
||||
|
||||
float fPyramid(float3 p, float r, float e) {
|
||||
float d = 0;
|
||||
[unroll] for (int i = 3; i <= 6; ++i)
|
||||
d += pow(abs(dot(p, fAklemanVectors[i])), e);
|
||||
d += pow(max(0, -dot(p - float3(0,0.95,0), float3(0,1,0))), e);
|
||||
return pow(d, 1/e) - r;
|
||||
}
|
||||
|
||||
float fCrystal(float3 p, float r, float e) {
|
||||
float d = 0;
|
||||
[unroll] for (int i = 0; i < 6; ++i) {
|
||||
float w0 = (PI/3 * i), w1 = w0 + PI/6;
|
||||
d += pow(max(0, -dot(p, normalize(float3(cos(w0), 0.75, sin(w0))))), e);
|
||||
d += pow(max(0, +dot(p, normalize(float3(cos(w1), 1.5, sin(w1))))), e);
|
||||
}
|
||||
d += pow(max(0, dot(p + float3(0, 0.5, 0), float3(0,1,0))), e);
|
||||
return pow(d, 1/e) - r;
|
||||
}
|
||||
|
||||
float fCrystal(float3 p, float r) {
|
||||
float d = 0;
|
||||
[unroll] for (int i = 0; i < 6; ++i) {
|
||||
float w0 = (PI/3 * i), w1 = w0 + PI/6;
|
||||
d = max(d, -dot(p, normalize(float3(cos(w0), 0.75, sin(w0)))));
|
||||
d = max(d, dot(p, normalize(float3(cos(w1), 1.5, sin(w1)))));
|
||||
}
|
||||
d = max(d, dot(p + float3(0, 0.5, 0), float3(0,1,0)));
|
||||
return d - r;
|
||||
}
|
||||
|
||||
float fDodecahedron(float3 p, float r, float e) {
|
||||
return fAkleman(p, r, e, 13, 18);
|
||||
}
|
||||
|
||||
float fOctahedron(float3 p, float r, float e) {
|
||||
return fAkleman(p, r, e, 3, 6);
|
||||
}
|
||||
|
||||
float fIcosahedron(float3 p, float r, float e) {
|
||||
return fAkleman(p, r, e, 3, 12);
|
||||
}
|
||||
|
||||
float fTruncatedOctahedron(float3 p, float r, float e) {
|
||||
return fAkleman(p, r, e, 0, 6);
|
||||
}
|
||||
|
||||
float fTruncatedIcosahedron(float3 p, float r, float e) {
|
||||
return fAkleman(p, r, e, 3, 18);
|
||||
}
|
||||
|
||||
float fOctahedron(float3 p, float r) {
|
||||
return fAkleman(p, r, 3, 6);
|
||||
}
|
||||
|
||||
float fDodecahedron(float3 p, float r) {
|
||||
return fAkleman(p, r, 13, 18);
|
||||
}
|
||||
|
||||
float fIcosahedron(float3 p, float r) {
|
||||
return fAkleman(p, r, 3, 12);
|
||||
}
|
||||
|
||||
float fTruncatedOctahedron(float3 p, float r) {
|
||||
return fAkleman(p, r, 0, 6);
|
||||
}
|
||||
|
||||
float fTruncatedIcosahedron(float3 p, float r) {
|
||||
return fAkleman(p, r, 3, 18);
|
||||
}
|
||||
|
||||
float fBox(float3 p, float3 b){
|
||||
float3 d = abs(p) - b;
|
||||
return length(max(d, 0)) + min(max(max(d.x, d.y), d.z), 0);
|
||||
}
|
||||
|
||||
float fBoxNonEuclidean(float3 p, float3 b) {
|
||||
float3 d = abs(p) - b;
|
||||
return max(max(d.x, d.y), d.z);
|
||||
}
|
||||
|
||||
float fCylinder(float3 p, float r) {
|
||||
return length(p.xz) - r;
|
||||
}
|
||||
|
||||
float fLineSegment(float3 p, float3 a, float3 b) {
|
||||
float3 ab = b - a;
|
||||
float t = saturate(dot(p - a, ab) / dot(ab, ab));
|
||||
return length((ab*t + a) - p);
|
||||
}
|
||||
|
||||
float fTorus(float3 p, float rInner, float rOuter) {
|
||||
return length(float2(length(p.xz) - rInner, p.y)) - rOuter;
|
||||
}
|
||||
|
||||
float fCircle(float3 p, float r) {
|
||||
float l = length(p.xz) - r;
|
||||
return length(float2(p.y, l));
|
||||
}
|
||||
|
||||
float fDisc(float3 p, float r) {
|
||||
float l = length(p.xz) - r;
|
||||
return l < 0 ? abs(p.y) : length(float2(p.y, l));
|
||||
}
|
||||
|
||||
float fCone(float3 p, float2 d) {
|
||||
return dot(d, float2(length(p.xz), p.y));
|
||||
}
|
||||
|
||||
float fHexagon(float3 p, float2 h) {
|
||||
float3 q = abs(p);
|
||||
return max(q.y - h.y, max(q.z*0.866025 + q.x*0.5, q.x) - h.x);
|
||||
}
|
||||
|
||||
float fHelix(float3 p, float f, float r) {
|
||||
float s = 0.5 * f / PI;
|
||||
float x = PI * s;
|
||||
float a = atan2(p.z, p.y) * s;
|
||||
float b = mod(p.x, 2*x);
|
||||
a = abs(a-b);
|
||||
a = a > x ? 2*x - a : a;
|
||||
return length(float2(length(p.yz) - r, a));
|
||||
}
|
||||
|
||||
float fDiscNonEuclidean(float3 p, float r) {
|
||||
return max(length(p.xz) - r, abs(p.y));
|
||||
}
|
||||
|
||||
float fSphere(float3 p, float r) {
|
||||
return length(p) - r;
|
||||
}
|
||||
|
||||
float fStar(float3 p, float r) {
|
||||
float3 n0 = normalize(float3(-PHI, PHI-1, 1));
|
||||
float3 n1 = normalize(float3(1, -PHI, PHI+1));
|
||||
|
||||
p = abs(p);
|
||||
p -= 2 * max(0, dot(p, n0)) * n0;
|
||||
p -= 2 * max(0, dot(p, n1)) * n1;
|
||||
p = abs(p);
|
||||
p -= 2 * max(0, dot(p, n0)) * n0;
|
||||
p -= 2 * max(0, dot(p, n1)) * n1;
|
||||
|
||||
return p.y - r;
|
||||
}
|
||||
|
||||
float fHG(float3 p, float depthFactor = 0.5) {
|
||||
float hgUnit = 1.0 / 8.0;
|
||||
float depth = hgUnit * depthFactor;
|
||||
float d = INFINITY;
|
||||
d = min(d, fBox(p - float3(0, 0, 0), float3(hgUnit * 4, hgUnit, depth)));
|
||||
d = min(d, fBox(p - float3(0, -hgUnit * 2.5, 0), float3(hgUnit, hgUnit * 3.5, depth)));
|
||||
p.x = abs(p.x);
|
||||
d = min(d, fBox(p - float3(hgUnit * 7.5, 0, 0), float3(hgUnit * 0.5, hgUnit * 8, depth)));
|
||||
d = min(d, fBox(p - float3(hgUnit * 3, hgUnit * 2.5, 0), float3(hgUnit, hgUnit * 3.5, depth)));
|
||||
p.y = abs(p.y);
|
||||
d = min(d, fBox(p - float3(0, hgUnit * 7.5, 0), float3(hgUnit * 8, hgUnit * 0.5, depth)));
|
||||
d = min(d, fBox(p - float3(0, hgUnit * 3, 0), float3(hgUnit * 4, hgUnit, depth)));
|
||||
return d;
|
||||
}
|
||||
|
||||
float fGlass(float3 p) {
|
||||
float l = length(p.xz);
|
||||
float3 q = float3(l, p.y, 0);
|
||||
q = fOpBend(q.yxz, PI/3, -0.25, -0.25, 0.0).yxz;
|
||||
q = fOpBend(q.yxz, -PI/2, 0.0, 0.0, 1.5).yxz;
|
||||
q = fOpBend(q.yxz, -PI/2, -0.75, -0.75, -1.5).yxz;
|
||||
return fBox(q, float3(0.05-abs(q.y)*0.02, 1.5, 0.1)) * 0.8;
|
||||
}
|
||||
|
||||
float fGummibaer(float3 p) {
|
||||
if (length(p) > 1.41)
|
||||
return length(p) - 1.4;
|
||||
|
||||
const float4 data[] = {
|
||||
// Koerper
|
||||
float4(1.0, 0.0, 0.0, 2.5),
|
||||
float4(-1.0, 0.0, 0.0, 2.5),
|
||||
float4(1.0, 2.0, 0.0, 2.5),
|
||||
float4(-1.0, 2.0, 0.0, 2.5),
|
||||
float4(1.0, 4.0, 0.0, 1.0),
|
||||
float4(-1.0, 4.0, 0.0, 1.0),
|
||||
|
||||
// Arme / Beine
|
||||
float4(1.5, -0.0, 1.5, 1.2),
|
||||
float4(-1.5, -0.0, 1.5, 1.2),
|
||||
float4(1.55, 2.0, 1.5, 0.0),
|
||||
float4(-1.5, 2.0, 1.5, 0.0),
|
||||
|
||||
// Ohren
|
||||
float4(1.3, 4.8, -0.2, 0.3),
|
||||
float4(-1.3, 4.8, -0.2, 0.3),
|
||||
|
||||
// Gesicht
|
||||
float4(-0.0, 4.0, 1.0, 0.0)
|
||||
};
|
||||
|
||||
float globalScale = 0.1;
|
||||
p /= globalScale;
|
||||
|
||||
p.y += 4.8 / 2;
|
||||
|
||||
float b = 0;
|
||||
for (int i = 0; i < 13; ++i)
|
||||
b += 0.5 - atan(length(p - 3 * data[i].xyz) - data[i].w) / PI;
|
||||
|
||||
return ((tan((-clamp(b, 0.0001, 0.78) - 0.5) * PI) + 1)) * globalScale;
|
||||
}
|
||||
182
nordlicht2015-intro/src/intro/shaders/lib/shared.hlsl
Normal file
182
nordlicht2015-intro/src/intro/shaders/lib/shared.hlsl
Normal file
@@ -0,0 +1,182 @@
|
||||
#define pi 3.141592
|
||||
#define PI 3.141592
|
||||
#define PHI (sqrt(5)*0.5 + 0.5)
|
||||
#define INFINITY 1000.0
|
||||
|
||||
float mod(float x, float y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
float2 mod(float2 x, float2 y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
float3 mod(float3 x, float3 y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
float2 mod(float2 x, float y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
float3 mod(float3 x, float y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
|
||||
float hash(float n)
|
||||
{
|
||||
return frac(sin(n)*43758.5453123);
|
||||
}
|
||||
|
||||
float noise2(float2 x)
|
||||
{
|
||||
float2 p = floor(x);
|
||||
float2 f = frac(x);
|
||||
f = f*f*(3 - 2 * f);
|
||||
|
||||
float n = p.x + p.y * 157;
|
||||
return lerp(lerp(hash(n), hash(n + 1), f.x), lerp(hash(n + 157), hash(n + 158), f.x), f.y);
|
||||
}
|
||||
|
||||
float noise3(float3 x)
|
||||
{
|
||||
float3 p = floor(x);
|
||||
float3 f = frac(x);
|
||||
f = f*f*(3 - 2 * f);
|
||||
|
||||
float n = p.x + p.y * 157 + 113 * p.z;
|
||||
return lerp(
|
||||
lerp(lerp(hash(n), hash(n + 1), f.x), lerp(hash(n + 157), hash(n + 158), f.x), f.y),
|
||||
lerp(lerp(hash(n + 113), hash(n + 114), f.x), lerp(hash(n + 270), hash(n + 271), f.x), f.y), f.z);
|
||||
}
|
||||
|
||||
float smoothnoise(float2 uv, float scale)
|
||||
{
|
||||
float2x2 r = { 1.1, 0.9, -0.9, 1.1 };
|
||||
float n = 0;
|
||||
for (int i = 1; i < 8; ++i)
|
||||
{
|
||||
n += noise2(uv * scale) / pow(2, i);
|
||||
uv = mul(uv, r);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
float smoothnoise3(float3 uv, float scale)
|
||||
{
|
||||
float n = 0;
|
||||
for (int i = 1; i < 8; ++i)
|
||||
{
|
||||
n += noise3(uv * scale) / pow(2, i);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
void r(inout float2 v, float y)
|
||||
{
|
||||
v = cos(y)*v + sin(y)*float2(-v.y, v.x);
|
||||
}
|
||||
|
||||
float4 smin(float4 a, float4 b)
|
||||
{
|
||||
if (a.x < b.x)
|
||||
return a;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
float4 smax(float4 a, float4 b)
|
||||
{
|
||||
if (a.x > b.x)
|
||||
return a;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
float4 sinv(float4 a)
|
||||
{
|
||||
return float4(-a.x, a.y, a.z, a.w);
|
||||
}
|
||||
|
||||
float sdSphere(float3 p, float s)
|
||||
{
|
||||
return length(p) - s;
|
||||
}
|
||||
|
||||
float sdBox(float3 p, float3 b, float r)
|
||||
{
|
||||
float3 d = abs(p) - b;
|
||||
return min(max(d.x, max(d.y, d.z)), 0) +
|
||||
length(max(d, 0)) - r;
|
||||
}
|
||||
|
||||
float sdCylinder(float3 p, float3 c)
|
||||
{
|
||||
return length(p.xz - c.xy) - c.z;
|
||||
}
|
||||
|
||||
float smoothmax(float a, float b, float k)
|
||||
{
|
||||
return log(exp(k*a) + exp(k*b)) / k;
|
||||
}
|
||||
|
||||
float smoothmin(float a, float b, float k)
|
||||
{
|
||||
return -log(exp(-k*a) + exp(-k*b)) / k;
|
||||
}
|
||||
|
||||
float4 debugGradient(float3 n)
|
||||
{
|
||||
float f = length(n);
|
||||
return float4(lerp(float3(0, 1, 0), float3(1, 0, 0), abs(f - 1)), 1);
|
||||
}
|
||||
|
||||
float3 hsv2rgb(float h, float s, float v) {
|
||||
return lerp(1, saturate(abs(frac(h + float3(3, 2, 1) / 3) * 6 - 3) - 1), s)*v;
|
||||
}
|
||||
|
||||
float4x4 lookTo()
|
||||
{
|
||||
float3 zaxis = normalize(_s.cameraCenter.xyz - _s.cameraPosition.xyz);
|
||||
float3 xaxis = normalize(cross(normalize(_s.cameraUp.xyz), zaxis));
|
||||
float3 yaxis = normalize(cross(zaxis, xaxis));
|
||||
|
||||
float4x4 result = {
|
||||
xaxis, -dot(xaxis, _s.cameraPosition.xyz),
|
||||
yaxis, -dot(yaxis, _s.cameraPosition.xyz),
|
||||
zaxis, -dot(zaxis, _s.cameraPosition.xyz),
|
||||
0, 0, 0, 1
|
||||
};
|
||||
|
||||
return transpose(result);
|
||||
}
|
||||
|
||||
float4 ftransform(float3 v)
|
||||
{
|
||||
float h = 1 / tan(pi / 6);
|
||||
float w = h / aspectRatio;
|
||||
float4 result = mul(mul(float4(v, 1), lookTo()),
|
||||
float4x4(
|
||||
w, 0, 0, 0,
|
||||
0, h, 0, 0,
|
||||
0, 0, 1, 1,
|
||||
0, 0, -0.1, 0
|
||||
));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void camera(float2 tc, out float3 ro, out float3 rd)
|
||||
{
|
||||
float3 viewDirection = normalize(_s.cameraCenter.xyz - _s.cameraPosition.xyz);
|
||||
float3 viewUp = normalize(_s.cameraUp.xyz);
|
||||
ro = _s.cameraPosition.xyz;
|
||||
rd = mul(
|
||||
transpose(float3x3(cross(viewUp, viewDirection), viewUp, viewDirection)),
|
||||
normalize(float3((tc * 2 - 1) * float2(aspectRatio, 1), 1 / tan(pi / 6))));
|
||||
}
|
||||
67
nordlicht2015-intro/src/intro/shaders/lib/ssao.hlsl
Normal file
67
nordlicht2015-intro/src/intro/shaders/lib/ssao.hlsl
Normal file
@@ -0,0 +1,67 @@
|
||||
static float random_size;
|
||||
static float g_sample_rad = 0.1;
|
||||
static float g_intensity = 4.0;
|
||||
static float g_scale = 2.0;
|
||||
static float g_bias = 0.5;
|
||||
|
||||
float3 getPosition(in float2 uv)
|
||||
{
|
||||
float3 ro, rd;
|
||||
camera(uv, ro, rd);
|
||||
return ro + rd * t2d1.SampleLevel(samplerClamp, uv, 0).w;
|
||||
}
|
||||
|
||||
float3 getNormal(in float2 uv)
|
||||
{
|
||||
return t2d1.SampleLevel(samplerClamp, uv, 0).xyz;
|
||||
}
|
||||
|
||||
float2 getRandom(in float2 uv)
|
||||
{
|
||||
return float2(smoothnoise(uv, 8), smoothnoise(uv.yx * 1.3, 7.6));
|
||||
}
|
||||
|
||||
float doAmbientOcclusion(in float2 tcoord, in float2 uv, in float3 p, in float3 cnorm)
|
||||
{
|
||||
float3 diff = getPosition(tcoord + uv) - p;
|
||||
const float3 v = normalize(diff);
|
||||
const float d = length(diff)*g_scale;
|
||||
return max(0.0, dot(cnorm, v) - g_bias)*(1.0 / (1.0 + d))*g_intensity;
|
||||
}
|
||||
|
||||
[numthreads(16,16,1)]
|
||||
[entrypoint(cs)]
|
||||
void cs_Ssao(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
float2 s;
|
||||
o2d0.GetDimensions(s.x, s.y);
|
||||
float2 uv0 = (id.xy + 0.5) / s;
|
||||
float2 uv1 = float2(uv0.x, 1 - uv0.y);
|
||||
float3 p = getPosition(uv0);
|
||||
float3 n = getNormal(uv0);
|
||||
float2 rand = getRandom(uv0);
|
||||
|
||||
const float2 vec[4] = {float2(1,0),float2(-1,0), float2(0,1),float2(0,-1)};
|
||||
float ao = 0.0f;
|
||||
float rad = g_sample_rad / p.z;
|
||||
|
||||
//**SSAO Calculation**//
|
||||
int iterations = 4;
|
||||
for (int j = 0; j < iterations; ++j)
|
||||
{
|
||||
float2 coord1 = reflect(vec[j],rand)*rad;
|
||||
float2 coord2 = float2(coord1.x*0.707 - coord1.y*0.707, coord1.x*0.707 + coord1.y*0.707);
|
||||
|
||||
ao += doAmbientOcclusion(uv0, coord1*0.25, p, n);
|
||||
ao += doAmbientOcclusion(uv0, coord2*0.5, p, n);
|
||||
ao += doAmbientOcclusion(uv0, coord1*0.75, p, n);
|
||||
ao += doAmbientOcclusion(uv0, coord2, p, n);
|
||||
}
|
||||
ao /= (float)iterations*4.0;
|
||||
//**END**//
|
||||
|
||||
float4 color = t2d0.SampleLevel(samplerClamp, uv0, 0);
|
||||
color.xyz *= 1 - ao;
|
||||
o2d0[id.xy] = color;
|
||||
//o2d0[id.xy] = float4(n*0.5+0.5, 1);
|
||||
}
|
||||
37
nordlicht2015-intro/src/intro/shaders/lib/textures.hlsl
Normal file
37
nordlicht2015-intro/src/intro/shaders/lib/textures.hlsl
Normal file
@@ -0,0 +1,37 @@
|
||||
[numthreads(16, 16, 1)]
|
||||
[entrypoint(cs)]
|
||||
void cs_stone(uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
float2 s;
|
||||
o2d0.GetDimensions(s.x, s.y);
|
||||
float2 uv = (id.xy / s);
|
||||
|
||||
int numPoints = 80;
|
||||
float min1 = 1, min2 = 1; float seed = 10;
|
||||
for (int i = 0; i < numPoints; ++i)
|
||||
{
|
||||
float2 pointPos = float2(noise2(float2(0, seed++)), noise2(float2(1, seed++)));
|
||||
//pointPos += float2(sin(Z.z + noise2(float2(0, seed++))), cos(Z.z + noise2(float2(1, seed++))))*0.1;
|
||||
float2 d = abs(uv - pointPos);
|
||||
float2 s = step(0.5, d);
|
||||
d = s + d*(-s * 2 + 1);
|
||||
float dist = length(d);
|
||||
if (dist < min2)
|
||||
{
|
||||
if (dist < min1)
|
||||
{
|
||||
min2 = min1;
|
||||
min1 = dist;
|
||||
}
|
||||
else
|
||||
{
|
||||
min2 = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
min1 *= 4;
|
||||
min2 *= 4;
|
||||
float l = min2 - min1;
|
||||
o2d0[id.xy] = float4(min1, min2, l, smoothnoise(uv, 64));
|
||||
}
|
||||
104
nordlicht2015-intro/src/intro/shaders/lib/volumetric-fog.hlsl
Normal file
104
nordlicht2015-intro/src/intro/shaders/lib/volumetric-fog.hlsl
Normal file
@@ -0,0 +1,104 @@
|
||||
struct INTER
|
||||
{
|
||||
bool hit;
|
||||
float dist;
|
||||
};
|
||||
|
||||
INTER rayPlaneIntersect(float3 o, float3 d, float h)
|
||||
{
|
||||
INTER result;
|
||||
result.hit = false;
|
||||
float3 pn = float3(0, 1, 0);
|
||||
float vd = dot(pn, d);
|
||||
if (vd == 0)
|
||||
return result;
|
||||
float v0 = -dot(pn, o) + h;
|
||||
float t = v0 / vd;
|
||||
if (t < 0)
|
||||
return result;
|
||||
|
||||
result.hit = true;
|
||||
result.dist = t;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool discOcclude(float3 o, float3 d, float3 c)
|
||||
{
|
||||
float3 sd = c - o;
|
||||
float b = dot(d, sd);
|
||||
float disc = b*b + 1 - dot(sd, sd);
|
||||
return disc > 0.01;
|
||||
}
|
||||
|
||||
float fogLookup(float density, float3 p, float3 o)
|
||||
{
|
||||
p.xz /= 8;
|
||||
return density * (t3d0.SampleLevel(samplerWrap, p / 4 + o, 0).r) * smoothstep(0.4, 0.8, t3d0.SampleLevel(samplerWrap, p / 16 + o * 2, 0).r);
|
||||
}
|
||||
|
||||
[numthreads(8,8,8)]
|
||||
[entrypoint(cs)]
|
||||
void cs_Noise3d(uint3 id: SV_DispatchThreadID)
|
||||
{
|
||||
o3d0[id] = smoothnoise3(id, 64);
|
||||
}
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
[entrypoint(cs)]
|
||||
void cs_VolumetricFog(uint3 id: SV_DispatchThreadID)
|
||||
{
|
||||
float2 s;
|
||||
o2d0.GetDimensions(s.x, s.y);
|
||||
float2 uv = (id.xy + 0.5) / s;
|
||||
float3 o, d;
|
||||
camera(float2(uv.x, 1-uv.y), o, d);
|
||||
|
||||
//between -1 and -4
|
||||
float upperPlane = 5;
|
||||
float lowerPlane = -5;
|
||||
INTER i = rayPlaneIntersect(o, d, upperPlane);
|
||||
INTER i2 = rayPlaneIntersect(o, d, lowerPlane);
|
||||
|
||||
float t0, t1;
|
||||
if (lowerPlane < o.y && o.y < upperPlane)
|
||||
{
|
||||
t0 = 0;
|
||||
t1 = i.hit ? i.dist : i2.dist;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(i.hit || i2.hit))
|
||||
return;
|
||||
|
||||
if (o.y >= upperPlane)
|
||||
{
|
||||
t0 = i.dist;
|
||||
t1 = i2.dist;
|
||||
}
|
||||
else
|
||||
{
|
||||
t0 = i2.dist;
|
||||
t1 = i.dist;
|
||||
}
|
||||
}
|
||||
|
||||
float depth = t2d1.SampleLevel(samplerClamp, uv, 0).w;
|
||||
|
||||
if (t1 > depth)
|
||||
t1 = depth;
|
||||
|
||||
float fog = 0;
|
||||
for (int j = 0; j < 48; ++j)
|
||||
{
|
||||
float3 smp = o + lerp(t0, t1, j / 48.0) * d;
|
||||
float density = 1 - saturate((smp.y - lowerPlane) / (upperPlane - lowerPlane));
|
||||
fog += fogLookup(density, smp, float3(time * 0.005, 0, 0));
|
||||
}
|
||||
|
||||
fog /= 28;
|
||||
float3 color = float3(0.9, 0.8, 0.6);
|
||||
float4 existing = saturate(t2d2.SampleLevel(samplerClamp, uv, 0));
|
||||
float4 result = float4(lerp(existing.xyz, color, fog), 1);
|
||||
result.xyz = max(result.xyz, existing.xyz);
|
||||
o2d0[id.xy] = result;
|
||||
}
|
||||
BIN
nordlicht2015-intro/src/intro/sync__padding.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync__padding.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraCenter_w.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraCenter_w.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraCenter_x.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraCenter_x.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraCenter_y.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraCenter_y.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraCenter_z.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraCenter_z.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraPosition_w.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraPosition_w.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraPosition_x.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraPosition_x.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraPosition_y.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraPosition_y.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraPosition_z.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraPosition_z.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraUp_w.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraUp_w.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraUp_x.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraUp_x.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraUp_y.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraUp_y.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_cameraUp_z.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_cameraUp_z.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_fade.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_fade.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_fontFade.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_fontFade.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_lightDir_w.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_lightDir_w.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_lightDir_x.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_lightDir_x.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_lightDir_y.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_lightDir_y.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_lightDir_z.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_lightDir_z.track
Normal file
Binary file not shown.
BIN
nordlicht2015-intro/src/intro/sync_scene.track
Normal file
BIN
nordlicht2015-intro/src/intro/sync_scene.track
Normal file
Binary file not shown.
57
nordlicht2015-intro/src/mesh/Core/BaseElement.cpp
Normal file
57
nordlicht2015-intro/src/mesh/Core/BaseElement.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "BaseElement.h"
|
||||
#include "Vertex.h"
|
||||
|
||||
|
||||
BaseElement::BaseElement(Mesh* mesh)
|
||||
: mesh{ mesh }
|
||||
{
|
||||
}
|
||||
|
||||
Vector3 BaseElement::GetNormal() const
|
||||
{
|
||||
const auto& vertices = GetVertices();
|
||||
Vector3 normal;
|
||||
if (vertices.Count() != 0)
|
||||
{
|
||||
for (const auto& vertex : vertices)
|
||||
normal += vertex->GetNormal();
|
||||
normal.Normalize();
|
||||
}
|
||||
return normal;
|
||||
}
|
||||
|
||||
|
||||
Bounds BaseElement::GetBounds() const
|
||||
{
|
||||
auto vertices = GetVertices();
|
||||
if (vertices.Count() == 0)
|
||||
return Bounds{ 0, 0 };
|
||||
|
||||
auto min = vertices[0]->Position;
|
||||
auto max = min;
|
||||
for (const auto& vertex : vertices)
|
||||
{
|
||||
min = Vector3::Min(vertex->Position, min);
|
||||
max = Vector3::Max(vertex->Position, max);
|
||||
}
|
||||
|
||||
Bounds result = { min, max };
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Vector3 BaseElement::GetCenter() const
|
||||
{
|
||||
auto bounds = GetBounds();
|
||||
auto center = (bounds.Min + bounds.Max) * 0.5f;
|
||||
return center;
|
||||
}
|
||||
|
||||
|
||||
void BaseElement::SetCenter(const Vector3& center)
|
||||
{
|
||||
auto oldCenter = GetCenter();
|
||||
|
||||
for (const auto& vertex : GetVertices())
|
||||
vertex->Position += center - oldCenter;
|
||||
}
|
||||
35
nordlicht2015-intro/src/mesh/Core/BaseElement.h
Normal file
35
nordlicht2015-intro/src/mesh/Core/BaseElement.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "../List.h"
|
||||
#include "../Math/Vector3.h"
|
||||
#include "../Math/Bounds.h"
|
||||
|
||||
class Mesh;
|
||||
class Vertex;
|
||||
class Face;
|
||||
class Edge;
|
||||
|
||||
typedef List<Vertex*> VertexList;
|
||||
typedef List<Face*> FaceList;
|
||||
typedef List<Edge*> EdgeList;
|
||||
|
||||
class BaseElement
|
||||
{
|
||||
public:
|
||||
BaseElement(Mesh* mesh);
|
||||
|
||||
virtual Vector3 GetNormal() const;
|
||||
Bounds GetBounds() const;
|
||||
virtual Vector3 GetCenter() const;
|
||||
virtual void SetCenter(const Vector3& center);
|
||||
|
||||
Mesh* GetMesh() const { return mesh; }
|
||||
|
||||
virtual VertexList GetVertices() const = 0;
|
||||
virtual FaceList GetFaces() const = 0;
|
||||
virtual EdgeList GetEdges() const = 0;
|
||||
|
||||
protected:
|
||||
Mesh* mesh;
|
||||
};
|
||||
|
||||
96
nordlicht2015-intro/src/mesh/Core/Edge.cpp
Normal file
96
nordlicht2015-intro/src/mesh/Core/Edge.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
#include "Edge.h"
|
||||
#include "Face.h"
|
||||
#include "Vertex.h"
|
||||
|
||||
|
||||
Edge::Edge()
|
||||
: BaseElement{ nullptr }
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Edge::Edge(Vertex* a, Vertex* b)
|
||||
: BaseElement{ nullptr }
|
||||
{
|
||||
vertices.Add(a);
|
||||
vertices.Add(b);
|
||||
|
||||
if (a > b)
|
||||
hash = ((long long)a << 32) | (long long)b;
|
||||
else
|
||||
hash = ((long long)b << 32) | (long long)a;
|
||||
}
|
||||
|
||||
|
||||
Edge::~Edge()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Vertex* Edge::GetOtherVertex(Vertex* vertex) const
|
||||
{
|
||||
return vertices[0] == vertex ? vertices[1] : vertices[0];
|
||||
}
|
||||
|
||||
|
||||
bool Edge::operator== (const Edge& other) const
|
||||
{
|
||||
return other.hash == hash;
|
||||
return (vertices[0] == other.vertices[0] && vertices[1] == other.vertices[1]) ||
|
||||
(vertices[1] == other.vertices[0] && vertices[0] == other.vertices[1]);
|
||||
}
|
||||
|
||||
|
||||
long long Edge::GetHash() const
|
||||
{
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
VertexList Edge::GetVertices() const
|
||||
{
|
||||
return vertices;
|
||||
}
|
||||
|
||||
|
||||
FaceList Edge::GetFaces() const
|
||||
{
|
||||
return faces;
|
||||
}
|
||||
|
||||
|
||||
EdgeList Edge::GetEdges() const
|
||||
{
|
||||
auto result = Linq::SelectUniqueMany<Edge*>(faces, [](Face* face){ return face->GetEdges(); });
|
||||
result.Remove(const_cast<Edge*>(this));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Vector3 Edge::GetDirection() const
|
||||
{
|
||||
auto direction = vertices[1]->Position - vertices[0]->Position;
|
||||
direction.Normalize();
|
||||
return direction;
|
||||
}
|
||||
|
||||
|
||||
float Edge::GetLength() const
|
||||
{
|
||||
auto length = vertices[0]->Position - vertices[1]->Position;
|
||||
return length.GetLength();
|
||||
}
|
||||
|
||||
|
||||
Edge* Edge::CreateOrderedEdge(Face* face) const
|
||||
{
|
||||
auto edges = face->GetEdges();
|
||||
auto index = edges.IndexOf(const_cast<Edge*>(this));
|
||||
auto faceVertices = face->GetVertices();
|
||||
|
||||
auto next = (index + 1) % faceVertices.Count();
|
||||
|
||||
auto newEdge = new Edge(faceVertices[index], faceVertices[next]);
|
||||
newEdge->faces = faces;
|
||||
return newEdge;
|
||||
}
|
||||
50
nordlicht2015-intro/src/mesh/Core/Edge.h
Normal file
50
nordlicht2015-intro/src/mesh/Core/Edge.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "../Linq.h"
|
||||
#include "BaseElement.h"
|
||||
|
||||
class Edge : public BaseElement
|
||||
{
|
||||
friend class Mesh;
|
||||
public:
|
||||
Edge();
|
||||
Edge(Vertex* a, Vertex* b);
|
||||
~Edge();
|
||||
|
||||
Vertex* GetOtherVertex(Vertex* vertex) const;
|
||||
|
||||
VertexList GetVertices() const;
|
||||
FaceList GetFaces() const;
|
||||
EdgeList GetEdges() const;
|
||||
|
||||
Vector3 GetDirection() const;
|
||||
float GetLength() const;
|
||||
|
||||
Edge* CreateOrderedEdge(Face* face) const;
|
||||
|
||||
bool operator== (const Edge& other) const;
|
||||
long long GetHash() const;
|
||||
|
||||
private:
|
||||
VertexList vertices;
|
||||
FaceList faces;
|
||||
long long hash;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct equality<Edge * const &>
|
||||
{
|
||||
static bool Equals(Edge * const & a, Edge * const & b)
|
||||
{
|
||||
return *a == *b;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hashing<Edge * const &>
|
||||
{
|
||||
static long long Generate(Edge * const & a)
|
||||
{
|
||||
return a->GetHash();
|
||||
}
|
||||
};
|
||||
240
nordlicht2015-intro/src/mesh/Core/Face.cpp
Normal file
240
nordlicht2015-intro/src/mesh/Core/Face.cpp
Normal file
@@ -0,0 +1,240 @@
|
||||
#include "Mesh.h"
|
||||
#include "Face.h"
|
||||
#include "Vertex.h"
|
||||
#include "../Linq.h"
|
||||
|
||||
|
||||
Face::Face()
|
||||
: BaseElement{nullptr}
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Face::Face(Vertex* a, Vertex* b, Vertex* c, Vertex* d)
|
||||
: BaseElement{ nullptr }
|
||||
, materialId{ 0 }
|
||||
, uvGenerator{ nullptr }
|
||||
{
|
||||
vertices.Add(a);
|
||||
vertices.Add(b);
|
||||
vertices.Add(c);
|
||||
if (d != nullptr)
|
||||
vertices.Add(d);
|
||||
}
|
||||
|
||||
|
||||
Face::Face(const VertexList& otherVertices)
|
||||
: BaseElement{ nullptr }
|
||||
, materialId{ 0 }
|
||||
, uvGenerator{ nullptr }
|
||||
{
|
||||
vertices = otherVertices;
|
||||
}
|
||||
|
||||
|
||||
Face::~Face()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Vector3 Face::GetNormal() const
|
||||
{
|
||||
Vector3 normal;
|
||||
|
||||
auto cnt = vertices.Count();
|
||||
for (int i = 0; i < cnt; i++)
|
||||
normal += Vector3::Cross(vertices[i]->Position, vertices[(i + 1) % cnt]->Position); // cross product
|
||||
|
||||
normal.Normalize();
|
||||
return normal;
|
||||
}
|
||||
|
||||
|
||||
bool Face::IsTriangle() const
|
||||
{
|
||||
return vertices.Count() == 3;
|
||||
}
|
||||
|
||||
|
||||
List<Triangle> Face::GetTriangles(bool autoFlip) const
|
||||
{
|
||||
List<Triangle> result(2);
|
||||
if (vertices.Count() == 3)
|
||||
{
|
||||
result.Add({ vertices[0], vertices[1], vertices[2] });
|
||||
}
|
||||
else
|
||||
{
|
||||
if (autoFlip &&
|
||||
(vertices[0]->Position - vertices[2]->Position).GetLengthSq() >=
|
||||
(vertices[1]->Position - vertices[3]->Position).GetLengthSq())
|
||||
{
|
||||
result.Add({ vertices[1], vertices[2], vertices[3] });
|
||||
result.Add({ vertices[3], vertices[0], vertices[1] });
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add({ vertices[0], vertices[1], vertices[2] });
|
||||
result.Add({ vertices[2], vertices[3], vertices[0] });
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
List<int> Face::GetIndices() const
|
||||
{
|
||||
List<int> result;
|
||||
|
||||
auto triangles = GetTriangles(true);
|
||||
for (const auto& triangle : triangles)
|
||||
for (const auto& vertex : triangle.GetVertices())
|
||||
result.Add(vertex->GetIndex());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void Face::FlipNormal()
|
||||
{
|
||||
vertices = Linq::Reverse(vertices);
|
||||
}
|
||||
|
||||
|
||||
void Face::FlipNormal(const Vector3& dir)
|
||||
{
|
||||
if (Vector3::Dot(GetNormal(), dir) < 0)
|
||||
FlipNormal();
|
||||
}
|
||||
|
||||
|
||||
void Face::Triangulate()
|
||||
{
|
||||
if (IsTriangle() && !IsDegenerated())
|
||||
return;
|
||||
|
||||
auto triangles = GetTriangles(true);
|
||||
for (const auto& triangle : triangles)
|
||||
{
|
||||
if (triangle.IsDegenerated())
|
||||
continue;
|
||||
auto newFace = new Face(triangle.GetVertices());
|
||||
newFace->CopyProperties(this);
|
||||
mesh->AddFace(newFace);
|
||||
}
|
||||
mesh->RemoveFace(this);
|
||||
}
|
||||
|
||||
|
||||
bool Face::IsDegenerated() const
|
||||
{
|
||||
auto triangles = GetTriangles(true);
|
||||
for (const auto& triangle : triangles)
|
||||
if (!triangle.IsDegenerated())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Face::RegainIntegrity()
|
||||
{
|
||||
if (!IsTriangle())
|
||||
{
|
||||
auto triangles = GetTriangles(true);
|
||||
for (const auto& triangle : triangles)
|
||||
if (triangle.IsDegenerated())
|
||||
{
|
||||
vertices = Linq::Distinct(vertices);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Face::CopyProperties(Face* other)
|
||||
{
|
||||
tags = other->tags;
|
||||
materialId = other->materialId;
|
||||
}
|
||||
|
||||
|
||||
VertexList Face::GetVertices() const
|
||||
{
|
||||
return vertices;
|
||||
}
|
||||
|
||||
|
||||
FaceList Face::GetFaces() const
|
||||
{
|
||||
auto result = Linq::SelectUniqueMany<Face*>(edges, [](Edge* edge){ return edge->GetFaces(); });
|
||||
result.Remove(const_cast<Face*>(this));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
EdgeList Face::GetEdges() const
|
||||
{
|
||||
return edges;
|
||||
}
|
||||
|
||||
|
||||
bool Face::HasTag(char* tag) const
|
||||
{
|
||||
return tags.IndexOf(tag) != -1;
|
||||
}
|
||||
|
||||
|
||||
bool Face::HasTagsAny(const List<char*>& tagsToCheck) const
|
||||
{
|
||||
return Linq::Intersect(tags, tagsToCheck).Count() > 0;
|
||||
}
|
||||
|
||||
|
||||
bool Face::HasTagsAll(const List<char*>& tagsToCheck) const
|
||||
{
|
||||
return Linq::Intersect(tags, tagsToCheck).Count() == tags.Count();
|
||||
}
|
||||
|
||||
|
||||
void Face::AddTag(char* tag)
|
||||
{
|
||||
if (HasTag(tag))
|
||||
return;
|
||||
tags.Add(tag);
|
||||
}
|
||||
|
||||
|
||||
void Face::RemoveTag(char* tag)
|
||||
{
|
||||
if (!HasTag(tag))
|
||||
return;
|
||||
tags.Remove(tag);
|
||||
}
|
||||
|
||||
|
||||
List<char*> Face::GetTags() const
|
||||
{
|
||||
return tags;
|
||||
}
|
||||
|
||||
|
||||
void Face::SetMaterialId(int materialId)
|
||||
{
|
||||
this->materialId = materialId;
|
||||
}
|
||||
|
||||
int Face::GetMaterialId() const
|
||||
{
|
||||
return materialId;
|
||||
}
|
||||
|
||||
|
||||
void Face::SetUVGenerator(UVGeneratorBase* generator)
|
||||
{
|
||||
uvGenerator = generator;
|
||||
}
|
||||
|
||||
UVGeneratorBase* Face::GetUVGenerator() const
|
||||
{
|
||||
return uvGenerator;
|
||||
}
|
||||
58
nordlicht2015-intro/src/mesh/Core/Face.h
Normal file
58
nordlicht2015-intro/src/mesh/Core/Face.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
#include "../List.h"
|
||||
#include "BaseElement.h"
|
||||
#include "Triangle.h"
|
||||
|
||||
class Vertex;
|
||||
class UVGeneratorBase;
|
||||
|
||||
class Face : public BaseElement
|
||||
{
|
||||
friend class Mesh;
|
||||
friend class Selection;
|
||||
friend class FaceSelection;
|
||||
public:
|
||||
Face();
|
||||
Face(Vertex* a, Vertex* b, Vertex* c, Vertex* d = nullptr);
|
||||
Face(const VertexList& vertices);
|
||||
~Face();
|
||||
|
||||
Vector3 GetNormal() const override;
|
||||
|
||||
bool IsTriangle() const;
|
||||
void FlipNormal();
|
||||
void FlipNormal(const Vector3& dir);
|
||||
void Triangulate();
|
||||
|
||||
bool IsDegenerated() const;
|
||||
void RegainIntegrity();
|
||||
|
||||
VertexList GetVertices() const;
|
||||
FaceList GetFaces() const;
|
||||
EdgeList GetEdges() const;
|
||||
|
||||
bool HasTag(char* tag) const;
|
||||
bool HasTagsAny(const List<char*>& tagsToCheck) const;
|
||||
bool HasTagsAll(const List<char*>& tagsToCheck) const;
|
||||
void AddTag(char* tag);
|
||||
void RemoveTag(char* tag);
|
||||
List<char*> GetTags() const;
|
||||
|
||||
void SetMaterialId(int materialId);
|
||||
int GetMaterialId() const;
|
||||
void SetUVGenerator(UVGeneratorBase* generator);
|
||||
UVGeneratorBase* GetUVGenerator() const;
|
||||
|
||||
List<int> GetIndices() const;
|
||||
|
||||
private:
|
||||
List<Triangle> GetTriangles(bool autoFlip) const;
|
||||
|
||||
void CopyProperties(Face* other);
|
||||
List<char*> tags;
|
||||
|
||||
UVGeneratorBase* uvGenerator;
|
||||
VertexList vertices;
|
||||
EdgeList edges;
|
||||
int materialId;
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user