Minor update - celshading rework started
This commit is contained in:
parent
0d5e26266b
commit
151ea9b191
14
.idea/.idea.KhaoticEngineReborn/.idea/discord.xml
generated
Normal file
14
.idea/.idea.KhaoticEngineReborn/.idea/discord.xml
generated
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DiscordProjectSettings">
|
||||||
|
<option name="show" value="PROJECT_FILES" />
|
||||||
|
<option name="description" value="" />
|
||||||
|
<option name="applicationTheme" value="default" />
|
||||||
|
<option name="iconsTheme" value="default" />
|
||||||
|
<option name="button1Title" value="" />
|
||||||
|
<option name="button1Url" value="" />
|
||||||
|
<option name="button2Title" value="" />
|
||||||
|
<option name="button2Url" value="" />
|
||||||
|
<option name="customApplicationId" value="" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/.idea.KhaoticEngineReborn/.idea/encodings.xml
generated
Normal file
8
.idea/.idea.KhaoticEngineReborn/.idea/encodings.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" charset="windows-1252" />
|
||||||
|
<file url="file://$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" charset="windows-1252" />
|
||||||
|
<file url="PROJECT" charset="windows-1252" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -3,7 +3,9 @@
|
|||||||
<component name="MaterialThemeProjectNewConfig">
|
<component name="MaterialThemeProjectNewConfig">
|
||||||
<option name="metadata">
|
<option name="metadata">
|
||||||
<MTProjectMetadataState>
|
<MTProjectMetadataState>
|
||||||
<option name="userId" value="-6a4cade4:194a9b80ce0:-7ffa" />
|
<option name="migrated" value="true" />
|
||||||
|
<option name="pristineConfig" value="false" />
|
||||||
|
<option name="userId" value="4025287c:194ad69ad19:-7ff7" />
|
||||||
</MTProjectMetadataState>
|
</MTProjectMetadataState>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="RiderProjectSettingsUpdater">
|
<component name="RiderProjectSettingsUpdater">
|
||||||
<option name="singleClickDiffPreview" value="1" />
|
<option name="vcsConfiguration" value="2" />
|
||||||
<option name="vcsConfiguration" value="3" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
100
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
100
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@ -1,10 +1,77 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="RunManager" selected="C/C++ Project.enginecustom">
|
<component name="AutoImportSettings">
|
||||||
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
|
</component>
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/discord.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/encodings.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/material_theme_project_new.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/material_theme_project_new.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/assets/Texture/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/assets/Texture/imgui.ini" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/imgui.ini" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/shader-error.txt" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/shader-error.txt" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/hlsl/celshading.ps" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/hlsl/celshading.ps" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/hlsl/celshading.vs" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/hlsl/celshading.vs" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/CelShadingShader.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/CelShadingShader.h" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/shadermanagerclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/shadermanagerclass.h" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/applicationclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/applicationclass.h" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/shadermanagerclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/shadermanagerclass.cpp" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" afterDir="false" />
|
||||||
|
</list>
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="HighlightingSettingsPerFile">
|
||||||
|
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectColorInfo">{
|
||||||
|
"associatedIndex": 6
|
||||||
|
}</component>
|
||||||
|
<component name="ProjectId" id="2sGIWDeT5ixyzDQ0he4A3RFpG9W" />
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
|
"keyToString": {
|
||||||
|
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
|
"C++ Project.enginecustom.executor": "Run",
|
||||||
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
|
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
|
"git-widget-placeholder": "main",
|
||||||
|
"node.js.detected.package.eslint": "true",
|
||||||
|
"node.js.detected.package.tslint": "true",
|
||||||
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
|
"nodejs_package_manager_path": "npm",
|
||||||
|
"settings.editor.selected.configurable": "preferences.fileTypes",
|
||||||
|
"vue.rearranger.settings.migration": "true"
|
||||||
|
},
|
||||||
|
"keyToStringList": {
|
||||||
|
"rider.external.source.directories": [
|
||||||
|
"C:\\Users\\arivas\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\DecompilerCache",
|
||||||
|
"C:\\Users\\arivas\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache",
|
||||||
|
"C:\\Users\\arivas\\AppData\\Local\\Symbols\\src"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}]]></component>
|
||||||
|
<component name="RunManager" selected="C++ Project.enginecustom">
|
||||||
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
|
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
|
||||||
<configuration_1 setup="1">
|
<configuration_1>
|
||||||
<option name="CONFIGURATION" value="Debug" />
|
<option name="CONFIGURATION" value="Debug" />
|
||||||
<option name="PLATFORM" value="x64" />
|
<option name="PLATFORM" value="x64" />
|
||||||
|
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
|
||||||
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
|
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
|
||||||
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
|
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
|
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
|
||||||
@ -12,19 +79,18 @@
|
|||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
|
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
|
||||||
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
|
|
||||||
</configuration_1>
|
</configuration_1>
|
||||||
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
|
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
|
||||||
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
|
|
||||||
<option name="AUTO_SELECT_PRIORITY" value="0" />
|
<option name="AUTO_SELECT_PRIORITY" value="0" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Build" />
|
<option name="Build" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="enginecustom" type="CppProject" factoryName="C++ Project">
|
<configuration name="enginecustom" type="CppProject" factoryName="C++ Project">
|
||||||
<configuration_1 setup="1">
|
<configuration_1>
|
||||||
<option name="CONFIGURATION" value="Debug" />
|
<option name="CONFIGURATION" value="Debug" />
|
||||||
<option name="PLATFORM" value="x64" />
|
<option name="PLATFORM" value="x64" />
|
||||||
|
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
||||||
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
|
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
|
||||||
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
|
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
|
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
|
||||||
@ -32,14 +98,34 @@
|
|||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
|
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
|
||||||
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
|
||||||
</configuration_1>
|
</configuration_1>
|
||||||
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
||||||
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
|
||||||
<option name="AUTO_SELECT_PRIORITY" value="0" />
|
<option name="AUTO_SELECT_PRIORITY" value="0" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Build" />
|
<option name="Build" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="" />
|
||||||
|
<created>1738075515913</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1738075515913</updated>
|
||||||
|
<workItem from="1738075517746" duration="553000" />
|
||||||
|
<workItem from="1738076088229" duration="80000" />
|
||||||
|
<workItem from="1738076192788" duration="19000" />
|
||||||
|
<workItem from="1738076222547" duration="6131000" />
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
<option name="version" value="3" />
|
||||||
|
</component>
|
||||||
|
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
|
||||||
|
<component name="VcsManagerConfiguration">
|
||||||
|
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
@ -1,28 +1,89 @@
|
|||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
Pos=60,60
|
Pos=60,60
|
||||||
Size=400,400
|
Size=400,400
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Khaotic Engine]
|
[Window][Khaotic Engine]
|
||||||
Pos=1142,43
|
Pos=1180,27
|
||||||
Size=392,273
|
Size=396,826
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000005,0
|
||||||
|
|
||||||
[Window][Objects]
|
[Window][Objects]
|
||||||
Pos=598,29
|
Pos=8,27
|
||||||
Size=457,294
|
Size=290,826
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000A,0
|
||||||
|
|
||||||
[Window][Terrain]
|
[Window][Terrain]
|
||||||
Pos=58,62
|
Pos=8,27
|
||||||
Size=342,82
|
Size=290,487
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000009,0
|
||||||
|
|
||||||
[Window][Light]
|
[Window][Light]
|
||||||
Pos=1548,17
|
Pos=8,27
|
||||||
Size=358,535
|
Size=290,487
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000009,1
|
||||||
|
|
||||||
[Window][Shader Manager]
|
[Window][Shader Manager]
|
||||||
Pos=471,90
|
Pos=8,27
|
||||||
Size=180,79
|
Size=330,487
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000001,2
|
||||||
|
|
||||||
[Window][Engine Settings]
|
[Window][Engine Settings]
|
||||||
Pos=106,212
|
Pos=1516,27
|
||||||
Size=407,81
|
Size=396,974
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000005,1
|
||||||
|
|
||||||
|
[Window][DockSpace Demo]
|
||||||
|
Size=1584,861
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Render Window]
|
||||||
|
Pos=300,27
|
||||||
|
Size=878,826
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000002,0
|
||||||
|
|
||||||
|
[Window][DockSpace]
|
||||||
|
Pos=0,0
|
||||||
|
Size=1584,861
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Add Object]
|
||||||
|
Pos=1188,0
|
||||||
|
Size=396,430
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Log]
|
||||||
|
Pos=8,518
|
||||||
|
Size=1568,335
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000C,0
|
||||||
|
|
||||||
|
[Window][Log Window]
|
||||||
|
Pos=8,775
|
||||||
|
Size=1904,226
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000E,0
|
||||||
|
|
||||||
|
[Docking][Data]
|
||||||
|
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
||||||
|
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
||||||
|
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
||||||
|
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=Y
|
||||||
|
DockNode ID=0x0000000D Parent=0xCCBD8CF7 SizeRef=1568,598 Split=Y
|
||||||
|
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 Split=X
|
||||||
|
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=290,826 Split=Y Selected=0x393905AB
|
||||||
|
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=395,413 Selected=0x393905AB
|
||||||
|
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=395,411 Selected=0x031DC75C
|
||||||
|
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=1276,826 Split=X
|
||||||
|
DockNode ID=0x00000002 Parent=0x00000008 SizeRef=878,826 CentralNode=1 Selected=0x9204953B
|
||||||
|
DockNode ID=0x00000005 Parent=0x00000008 SizeRef=396,826 Selected=0x9F035453
|
||||||
|
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1568,335 Selected=0x139FDA3F
|
||||||
|
DockNode ID=0x0000000E Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9
|
||||||
|
|
||||||
|
@ -10,20 +10,20 @@ Collapsed=0
|
|||||||
DockId=0x00000005,0
|
DockId=0x00000005,0
|
||||||
|
|
||||||
[Window][Objects]
|
[Window][Objects]
|
||||||
Pos=8,442
|
Pos=8,27
|
||||||
Size=290,411
|
Size=290,826
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000A,0
|
DockId=0x0000000A,0
|
||||||
|
|
||||||
[Window][Terrain]
|
[Window][Terrain]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=290,826
|
Size=290,487
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,0
|
DockId=0x00000009,0
|
||||||
|
|
||||||
[Window][Light]
|
[Window][Light]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=290,826
|
Size=290,487
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,1
|
DockId=0x00000009,1
|
||||||
|
|
||||||
@ -34,8 +34,8 @@ Collapsed=0
|
|||||||
DockId=0x00000001,2
|
DockId=0x00000001,2
|
||||||
|
|
||||||
[Window][Engine Settings]
|
[Window][Engine Settings]
|
||||||
Pos=1180,27
|
Pos=1516,27
|
||||||
Size=396,826
|
Size=396,974
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,1
|
DockId=0x00000005,1
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ Size=1584,861
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Render Window]
|
[Window][Render Window]
|
||||||
Pos=8,27
|
Pos=300,27
|
||||||
Size=1170,826
|
Size=878,826
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,0
|
DockId=0x00000002,0
|
||||||
|
|
||||||
@ -66,8 +66,8 @@ Collapsed=0
|
|||||||
DockId=0x0000000C,0
|
DockId=0x0000000C,0
|
||||||
|
|
||||||
[Window][Log Window]
|
[Window][Log Window]
|
||||||
Pos=8,627
|
Pos=8,775
|
||||||
Size=1568,226
|
Size=1904,226
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x0000000E,0
|
DockId=0x0000000E,0
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1,34 +1,78 @@
|
|||||||
cbuffer LightBuffer
|
/////////////
|
||||||
|
// GLOBALS //
|
||||||
|
/////////////
|
||||||
|
Texture2D shaderTexture : register(t0);
|
||||||
|
SamplerState SampleType : register(s0);
|
||||||
|
cbuffer SunLightBuffer
|
||||||
{
|
{
|
||||||
|
float4 ambientColor;
|
||||||
float4 diffuseColor;
|
float4 diffuseColor;
|
||||||
float3 lightDirection;
|
float3 lightDirection;
|
||||||
float padding; // Padding to ensure the structure is a multiple of 16 bytes.
|
float intensity;
|
||||||
float3 lightPosition; // Add light position
|
|
||||||
float padding2; // Padding to ensure the structure is a multiple of 16 bytes.
|
|
||||||
float constantAttenuation;
|
|
||||||
float linearAttenuation;
|
|
||||||
float quadraticAttenuation;
|
|
||||||
float padding3; // Padding to ensure the structure is a multiple of 16 bytes.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Texture2D shaderTexture;
|
cbuffer SunLightColorBuffer
|
||||||
SamplerState SampleType;
|
{
|
||||||
|
float4 sunColor;
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////
|
||||||
|
// TYPEDEFS //
|
||||||
|
//////////////
|
||||||
struct PixelInputType
|
struct PixelInputType
|
||||||
{
|
{
|
||||||
float4 position : SV_POSITION;
|
float4 position : SV_POSITION;
|
||||||
float3 normal : NORMAL;
|
|
||||||
float2 tex : TEXCOORD0;
|
float2 tex : TEXCOORD0;
|
||||||
float3 worldPos : TEXCOORD1; // Add world position
|
float3 normal : NORMAL;
|
||||||
};
|
};
|
||||||
|
|
||||||
float4 CelShadingPixelShader(PixelInputType input) : SV_TARGET
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Pixel Shader
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
float4 SunLightPixelShader(PixelInputType input) : SV_TARGET
|
||||||
{
|
{
|
||||||
// Normalize the normal
|
float4 textureColor;
|
||||||
float3 normal = normalize(input.normal);
|
float4 color;
|
||||||
|
float lightIntensity;
|
||||||
|
float4 colorArray;
|
||||||
|
float4 colorSum;
|
||||||
|
|
||||||
// Convert the normal to a color
|
// Sample the pixel color from the texture using the sampler at this texture coordinate location.
|
||||||
float4 color = float4((normal + 1.0f) * 0.5f, 1.0f);
|
textureColor = shaderTexture.Sample(SampleType, input.tex);
|
||||||
|
|
||||||
|
// Calculate the different amounts of light on this pixel based on the direction of the light.
|
||||||
|
lightIntensity = saturate(dot(input.normal, -lightDirection));
|
||||||
|
|
||||||
|
if(lightIntensity > 0.95f)
|
||||||
|
{
|
||||||
|
lightIntensity = 1.0f;
|
||||||
|
}
|
||||||
|
else if(lightIntensity > 0.5f)
|
||||||
|
{
|
||||||
|
lightIntensity = 0.75f;
|
||||||
|
}
|
||||||
|
else if(lightIntensity > 0.25f)
|
||||||
|
{
|
||||||
|
lightIntensity = 0.5f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lightIntensity = 0.25f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine the diffuse color amount of the light.
|
||||||
|
colorArray = (diffuseColor * lightIntensity) * intensity;
|
||||||
|
|
||||||
|
// Initialize the sum of colors.
|
||||||
|
colorSum = float4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
// Add the light color.
|
||||||
|
colorSum.r += colorArray.r;
|
||||||
|
colorSum.g += colorArray.g;
|
||||||
|
colorSum.b += colorArray.b;
|
||||||
|
|
||||||
|
// Multiply the texture pixel by the light color to get the final result.
|
||||||
|
color = saturate(colorSum) * textureColor;
|
||||||
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
/////////////
|
||||||
|
// GLOBALS //
|
||||||
|
/////////////
|
||||||
cbuffer MatrixBuffer
|
cbuffer MatrixBuffer
|
||||||
{
|
{
|
||||||
matrix worldMatrix;
|
matrix worldMatrix;
|
||||||
@ -5,22 +8,42 @@ cbuffer MatrixBuffer
|
|||||||
matrix projectionMatrix;
|
matrix projectionMatrix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cbuffer CameraBuffer
|
||||||
|
{
|
||||||
|
float3 cameraPosition;
|
||||||
|
float padding;
|
||||||
|
};
|
||||||
|
|
||||||
|
cbuffer SunLightBuffer
|
||||||
|
{
|
||||||
|
float4 ambientColor; // Color of the ambient light.
|
||||||
|
float4 diffuseColor; // Color of the diffuse light.
|
||||||
|
float3 lightDirection; // Direction of the light.
|
||||||
|
float intensity; // Intensity of the light.
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//////////////
|
||||||
|
// TYPEDEFS //
|
||||||
|
//////////////
|
||||||
struct VertexInputType
|
struct VertexInputType
|
||||||
{
|
{
|
||||||
float4 position : POSITION;
|
float4 position : POSITION;
|
||||||
float3 normal : NORMAL;
|
|
||||||
float2 tex : TEXCOORD0;
|
float2 tex : TEXCOORD0;
|
||||||
|
float3 normal : NORMAL;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PixelInputType
|
struct PixelInputType
|
||||||
{
|
{
|
||||||
float4 position : SV_POSITION;
|
float4 position : SV_POSITION;
|
||||||
float3 normal : NORMAL;
|
|
||||||
float2 tex : TEXCOORD0;
|
float2 tex : TEXCOORD0;
|
||||||
float3 worldPos : TEXCOORD1; // Add world position
|
float3 normal : NORMAL;
|
||||||
};
|
};
|
||||||
|
|
||||||
PixelInputType CelShadingVertexShader(VertexInputType input)
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Vertex Shader
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
PixelInputType SunLightVertexShader(VertexInputType input)
|
||||||
{
|
{
|
||||||
PixelInputType output;
|
PixelInputType output;
|
||||||
|
|
||||||
@ -28,18 +51,18 @@ PixelInputType CelShadingVertexShader(VertexInputType input)
|
|||||||
input.position.w = 1.0f;
|
input.position.w = 1.0f;
|
||||||
|
|
||||||
// Calculate the position of the vertex against the world, view, and projection matrices.
|
// Calculate the position of the vertex against the world, view, and projection matrices.
|
||||||
float4 worldPosition = mul(input.position, worldMatrix);
|
output.position = mul(input.position, worldMatrix);
|
||||||
output.position = mul(worldPosition, viewMatrix);
|
output.position = mul(output.position, viewMatrix);
|
||||||
output.position = mul(output.position, projectionMatrix);
|
output.position = mul(output.position, projectionMatrix);
|
||||||
|
|
||||||
// Pass the normal to the pixel shader
|
|
||||||
output.normal = mul((float3x3)worldMatrix, input.normal);
|
|
||||||
|
|
||||||
// Pass the world position to the pixel shader
|
|
||||||
output.worldPos = worldPosition.xyz;
|
|
||||||
|
|
||||||
// Store the texture coordinates for the pixel shader.
|
// Store the texture coordinates for the pixel shader.
|
||||||
output.tex = input.tex;
|
output.tex = input.tex;
|
||||||
|
|
||||||
|
// Calculate the normal vector against the world matrix only.
|
||||||
|
output.normal = mul(input.normal, (float3x3) worldMatrix);
|
||||||
|
|
||||||
|
// Normalize the normal vector.
|
||||||
|
output.normal = normalize(output.normal);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
#ifndef _CELSHADINGSHADER_H_
|
#pragma once
|
||||||
#define _CELSHADINGSHADER_H_
|
|
||||||
|
|
||||||
//////////////
|
|
||||||
// INCLUDES //
|
|
||||||
//////////////
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
#include <d3dcompiler.h>
|
#include <d3dcompiler.h>
|
||||||
@ -12,57 +8,57 @@
|
|||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
class CelshadeClass
|
||||||
// Class name: CelShadingShader
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
class CelShadingShader
|
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
struct MatrixBufferType
|
private :
|
||||||
|
struct MatrixBufferType
|
||||||
{
|
{
|
||||||
XMMATRIX world;
|
XMMATRIX world;
|
||||||
XMMATRIX view;
|
XMMATRIX view;
|
||||||
XMMATRIX projection;
|
XMMATRIX projection;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LightBufferType
|
struct CameraBufferType
|
||||||
{
|
{
|
||||||
XMFLOAT4 diffuseColor;
|
XMFLOAT3 cameraPosition;
|
||||||
XMFLOAT3 lightDirection;
|
float padding;
|
||||||
float padding; // Padding to ensure the structure is a multiple of 16 bytes.
|
|
||||||
XMFLOAT3 lightPosition; // Add light position
|
|
||||||
float padding2; // Padding to ensure the structure is a multiple of 16 bytes.
|
|
||||||
float constantAttenuation;
|
|
||||||
float linearAttenuation;
|
|
||||||
float quadraticAttenuation;
|
|
||||||
float padding3; // Padding to ensure the structure is a multiple of 16 bytes.
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SunLightBufferType
|
||||||
|
{
|
||||||
|
XMFLOAT4 diffuseColor;
|
||||||
|
XMFLOAT4 ambientColor;
|
||||||
|
XMFLOAT3 sunDirection;
|
||||||
|
float intensity;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
public:
|
public :
|
||||||
CelShadingShader();
|
CelshadeClass();
|
||||||
CelShadingShader(const CelShadingShader&);
|
CelshadeClass(const CelshadeClass&);
|
||||||
~CelShadingShader();
|
~CelshadeClass();
|
||||||
|
|
||||||
bool Initialize(ID3D11Device*, HWND);
|
bool Initialize(ID3D11Device*, HWND);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
bool Render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3);
|
bool Render(ID3D11DeviceContext* deviceContex, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection,float intensity);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
|
bool InitializeShader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
|
||||||
void ShutdownShader();
|
void ShutdownShader();
|
||||||
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
|
void OutputShaderErrorMessage(ID3D10Blob*, HWND, WCHAR*);
|
||||||
|
|
||||||
bool SetShaderParameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3);
|
bool SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity);
|
||||||
void RenderShader(ID3D11DeviceContext*, int);
|
void RenderShader(ID3D11DeviceContext*, int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ID3D11VertexShader* m_vertexShader;
|
ID3D11VertexShader* m_vertexShader;
|
||||||
ID3D11PixelShader* m_pixelShader;
|
ID3D11PixelShader* m_pixelShader;
|
||||||
ID3D11InputLayout* m_layout;
|
ID3D11InputLayout* m_layout;
|
||||||
ID3D11Buffer* m_matrixBuffer;
|
|
||||||
ID3D11SamplerState* m_sampleState;
|
ID3D11SamplerState* m_sampleState;
|
||||||
ID3D11Buffer* m_lightBuffer;
|
ID3D11Buffer* m_matrixBuffer;
|
||||||
};
|
ID3D11Buffer* m_cameraBuffer;
|
||||||
|
ID3D11Buffer* m_sunlightBuffer;
|
||||||
#endif
|
ID3D11Buffer* m_sunlightColorBuffer;
|
||||||
|
ID3D11Buffer* m_sunlightPositionBuffer;
|
||||||
|
};
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef _SHADERMANAGERCLASS_H_
|
#ifndef _SHADERMANAGERCLASS_H_
|
||||||
#define _SHADERMANAGERCLASS_H_
|
#define _SHADERMANAGERCLASS_H_
|
||||||
|
|
||||||
// Inclure les en-têtes nécessaires
|
// Inclure les en-têtes nécessaires
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
#include <DirectXMath.h>
|
#include <DirectXMath.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -42,7 +42,7 @@ public:
|
|||||||
bool RenderlightMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
|
bool RenderlightMapShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*);
|
||||||
bool RenderRefractionShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
|
bool RenderRefractionShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
|
||||||
bool RenderWaterShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
|
bool RenderWaterShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
|
||||||
bool RenderCelShadingShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4, XMFLOAT3);
|
bool RenderCelShadingShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
||||||
bool RenderSunlightShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
bool RenderSunlightShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
||||||
private:
|
private:
|
||||||
TextureShaderClass* m_TextureShader;
|
TextureShaderClass* m_TextureShader;
|
||||||
@ -56,7 +56,7 @@ private:
|
|||||||
LightMapShaderClass* m_LightMapShader;
|
LightMapShaderClass* m_LightMapShader;
|
||||||
RefractionShaderClass* m_RefractionShader;
|
RefractionShaderClass* m_RefractionShader;
|
||||||
WaterShaderClass* m_WaterShader;
|
WaterShaderClass* m_WaterShader;
|
||||||
CelShadingShader* m_CelShadingShader;
|
CelshadeClass* m_CelShadingShader;
|
||||||
SunlightShaderClass* m_SunlightShader;
|
SunlightShaderClass* m_SunlightShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
#include <comdef.h> // Pour _com_error
|
#include <comdef.h> // Pour _com_error
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <DirectXMath.h>
|
||||||
|
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
@ -136,7 +139,6 @@ public:
|
|||||||
bool GetCanFixedUpdate() const { return CanFixedUpdate; };
|
bool GetCanFixedUpdate() const { return CanFixedUpdate; };
|
||||||
void SetCanFixedUpdate(bool canFixedUpdate) { CanFixedUpdate = canFixedUpdate; };
|
void SetCanFixedUpdate(bool canFixedUpdate) { CanFixedUpdate = canFixedUpdate; };
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool Render(float, float, float, float, float);
|
bool Render(float, float, float, float, float);
|
||||||
bool RenderPhysics(bool keyLeft, bool keyRight, bool keyUp, bool keyDown, float deltaTime);
|
bool RenderPhysics(bool keyLeft, bool keyRight, bool keyUp, bool keyDown, float deltaTime);
|
||||||
|
@ -33,7 +33,6 @@ public:
|
|||||||
void WidgetObjectWindow(ApplicationClass* app);
|
void WidgetObjectWindow(ApplicationClass* app);
|
||||||
void WidgetTerrainWindow(ApplicationClass* app);
|
void WidgetTerrainWindow(ApplicationClass* app);
|
||||||
void WidgetLightWindow(ApplicationClass* app);
|
void WidgetLightWindow(ApplicationClass* app);
|
||||||
void WidgetShaderWindow(ApplicationClass* app);
|
|
||||||
void WidgetEngineSettingsWindow(ApplicationClass* app);
|
void WidgetEngineSettingsWindow(ApplicationClass* app);
|
||||||
void WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize);
|
void WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize);
|
||||||
void WidgetLogWindow(ApplicationClass* app);
|
void WidgetLogWindow(ApplicationClass* app);
|
||||||
|
@ -1,38 +1,47 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Filename: lightshaderclass.cpp
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#include "CelShadingShader.h"
|
#include "CelShadingShader.h"
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
CelShadingShader::CelShadingShader()
|
|
||||||
|
CelshadeClass::CelshadeClass()
|
||||||
{
|
{
|
||||||
m_vertexShader = 0;
|
m_vertexShader = 0;
|
||||||
m_pixelShader = 0;
|
m_pixelShader = 0;
|
||||||
m_layout = 0;
|
m_layout = 0;
|
||||||
m_matrixBuffer = 0;
|
|
||||||
m_sampleState = 0;
|
m_sampleState = 0;
|
||||||
m_lightBuffer = 0;
|
m_matrixBuffer = 0;
|
||||||
|
m_cameraBuffer = 0;
|
||||||
|
m_sunlightBuffer = 0;
|
||||||
|
m_sunlightColorBuffer = 0;
|
||||||
|
m_sunlightPositionBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CelShadingShader::CelShadingShader(const CelShadingShader& other)
|
|
||||||
|
CelshadeClass::CelshadeClass(const CelshadeClass& other)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CelShadingShader::~CelShadingShader()
|
|
||||||
|
CelshadeClass::~CelshadeClass()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CelShadingShader::Initialize(ID3D11Device* device, HWND hwnd)
|
|
||||||
{
|
|
||||||
Logger::Get().Log("Initializing CelShadingShader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
|
||||||
|
|
||||||
bool result;
|
bool CelshadeClass::Initialize(ID3D11Device* device, HWND hwnd)
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
wchar_t vsFilename[128];
|
wchar_t vsFilename[128];
|
||||||
wchar_t psFilename[128];
|
wchar_t psFilename[128];
|
||||||
int error;
|
int error;
|
||||||
|
bool result;
|
||||||
|
|
||||||
// Set the filename of the vertex shader.
|
// Set the filename of the vertex shader.
|
||||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/celshading.vs");
|
error = wcscpy_s(vsFilename, 128, L"src/hlsl/celshading.vs");
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Failed to set the filename of the vertex shader", __FILE__, __LINE__);
|
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,38 +49,42 @@ bool CelShadingShader::Initialize(ID3D11Device* device, HWND hwnd)
|
|||||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/celshading.ps");
|
error = wcscpy_s(psFilename, 128, L"src/hlsl/celshading.ps");
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Failed to set the filename of the pixel shader", __FILE__, __LINE__);
|
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the vertex and pixel shaders.
|
// Initialize the vertex and pixel shaders.
|
||||||
result = InitializeShader(device, hwnd, vsFilename, psFilename);
|
result = InitializeShader(device, hwnd, vsFilename, psFilename);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Failed to initialize the vertex and pixel shaders", __FILE__, __LINE__);
|
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::Get().Log("Successfully initialized CelShadingShader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
Logger::Get().Log("SunLightShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CelShadingShader::Shutdown()
|
|
||||||
|
void CelshadeClass::Shutdown()
|
||||||
{
|
{
|
||||||
// Shutdown the vertex and pixel shaders as well as the related objects.
|
// Shutdown the vertex and pixel shaders as well as the related objects.
|
||||||
ShutdownShader();
|
ShutdownShader();
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CelShadingShader::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
bool CelshadeClass::Render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||||
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 lightPosition)
|
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
|
|
||||||
// Set the shader parameters that it will use for rendering.
|
// Set the shader parameters that it will use for rendering.
|
||||||
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, diffuseColor, lightPosition);
|
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("CelShading Error", __FILE__, __LINE__, Logger::LogLevel::Error);
|
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,89 +94,92 @@ bool CelShadingShader::Render(ID3D11DeviceContext* deviceContext, int indexCount
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CelShadingShader::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
|
||||||
|
bool CelshadeClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||||
{
|
{
|
||||||
|
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
ID3D10Blob* errorMessage = nullptr;
|
ID3D10Blob* errorMessage;
|
||||||
ID3D10Blob* vertexShaderBuffer = nullptr;
|
ID3D10Blob* vertexShaderBuffer;
|
||||||
ID3D10Blob* pixelShaderBuffer = nullptr;
|
ID3D10Blob* pixelShaderBuffer;
|
||||||
D3D11_INPUT_ELEMENT_DESC polygonLayout[3];
|
D3D11_INPUT_ELEMENT_DESC polygonLayout[3];
|
||||||
unsigned int numElements;
|
unsigned int numElements;
|
||||||
D3D11_BUFFER_DESC matrixBufferDesc;
|
|
||||||
D3D11_SAMPLER_DESC samplerDesc;
|
D3D11_SAMPLER_DESC samplerDesc;
|
||||||
D3D11_BUFFER_DESC lightBufferDesc;
|
D3D11_BUFFER_DESC matrixBufferDesc;
|
||||||
|
D3D11_BUFFER_DESC sunlightBufferDesc;
|
||||||
|
|
||||||
|
// Initialize the pointers this function will use to null.
|
||||||
|
errorMessage = 0;
|
||||||
|
vertexShaderBuffer = 0;
|
||||||
|
pixelShaderBuffer = 0;
|
||||||
|
|
||||||
// Compile the vertex shader code.
|
// Compile the vertex shader code.
|
||||||
result = D3DCompileFromFile(vsFilename, nullptr, nullptr, "CelShadingVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &vertexShaderBuffer, &errorMessage);
|
result = D3DCompileFromFile(vsFilename, NULL, NULL, "SunLightVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &vertexShaderBuffer, &errorMessage);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
// If the shader failed to compile it should have written something to the error message.
|
|
||||||
if (errorMessage)
|
if (errorMessage)
|
||||||
{
|
{
|
||||||
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
|
OutputShaderErrorMessage(errorMessage, hwnd, vsFilename);
|
||||||
}
|
}
|
||||||
// If there was nothing in the error message then it simply could not find the shader file itself.
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox(hwnd, vsFilename, L"Missing Shader File", MB_OK);
|
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile the pixel shader code.
|
// Compile the pixel shader code.
|
||||||
result = D3DCompileFromFile(psFilename, nullptr, nullptr, "CelShadingPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &pixelShaderBuffer, &errorMessage);
|
result = D3DCompileFromFile(psFilename, NULL, NULL, "SunLightPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &pixelShaderBuffer, &errorMessage);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
// If the shader failed to compile it should have written something to the error message.
|
|
||||||
if (errorMessage)
|
if (errorMessage)
|
||||||
{
|
{
|
||||||
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
|
OutputShaderErrorMessage(errorMessage, hwnd, psFilename);
|
||||||
}
|
}
|
||||||
// If there was nothing in the error message then it simply could not find the file itself.
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MessageBox(hwnd, psFilename, L"Missing Shader File", MB_OK);
|
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the vertex shader from the buffer.
|
// Create the vertex shader from the buffer.
|
||||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), nullptr, &m_vertexShader);
|
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
|
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the pixel shader from the buffer.
|
// Create the pixel shader from the buffer.
|
||||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), nullptr, &m_pixelShader);
|
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
|
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the vertex input layout description.
|
// Create the vertex input layout description.
|
||||||
// This setup needs to match the VertexType structure in the ModelClass and in the shader.
|
|
||||||
polygonLayout[0].SemanticName = "POSITION";
|
polygonLayout[0].SemanticName = "POSITION";
|
||||||
polygonLayout[0].SemanticIndex = 0;
|
polygonLayout[0].SemanticIndex = 0;
|
||||||
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||||
polygonLayout[0].InputSlot = 0;
|
polygonLayout[0].InputSlot = 0;
|
||||||
polygonLayout[0].AlignedByteOffset = 0;
|
polygonLayout[0].AlignedByteOffset = 0;
|
||||||
polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||||
polygonLayout[0].InstanceDataStepRate = 0;
|
polygonLayout[0].InstanceDataStepRate = 0;
|
||||||
|
|
||||||
polygonLayout[1].SemanticName = "NORMAL";
|
polygonLayout[1].SemanticName = "TEXCOORD";
|
||||||
polygonLayout[1].SemanticIndex = 0;
|
polygonLayout[1].SemanticIndex = 0;
|
||||||
polygonLayout[1].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
polygonLayout[1].Format = DXGI_FORMAT_R32G32_FLOAT;
|
||||||
polygonLayout[1].InputSlot = 0;
|
polygonLayout[1].InputSlot = 0;
|
||||||
polygonLayout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
|
polygonLayout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
|
||||||
polygonLayout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
polygonLayout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||||
polygonLayout[1].InstanceDataStepRate = 0;
|
polygonLayout[1].InstanceDataStepRate = 0;
|
||||||
|
|
||||||
polygonLayout[2].SemanticName = "TEXCOORD";
|
polygonLayout[2].SemanticName = "NORMAL";
|
||||||
polygonLayout[2].SemanticIndex = 0;
|
polygonLayout[2].SemanticIndex = 0;
|
||||||
polygonLayout[2].Format = DXGI_FORMAT_R32G32_FLOAT;
|
polygonLayout[2].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||||
polygonLayout[2].InputSlot = 0;
|
polygonLayout[2].InputSlot = 0;
|
||||||
polygonLayout[2].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
|
polygonLayout[2].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
|
||||||
polygonLayout[2].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
polygonLayout[2].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||||
@ -176,30 +192,16 @@ bool CelShadingShader::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
|
|||||||
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &m_layout);
|
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &m_layout);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
|
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||||
vertexShaderBuffer->Release();
|
vertexShaderBuffer->Release();
|
||||||
vertexShaderBuffer = nullptr;
|
vertexShaderBuffer = 0;
|
||||||
|
|
||||||
pixelShaderBuffer->Release();
|
pixelShaderBuffer->Release();
|
||||||
pixelShaderBuffer = nullptr;
|
pixelShaderBuffer = 0;
|
||||||
|
|
||||||
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
|
|
||||||
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
|
||||||
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
|
|
||||||
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
|
||||||
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
|
||||||
matrixBufferDesc.MiscFlags = 0;
|
|
||||||
matrixBufferDesc.StructureByteStride = 0;
|
|
||||||
|
|
||||||
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
|
|
||||||
result = device->CreateBuffer(&matrixBufferDesc, nullptr, &m_matrixBuffer);
|
|
||||||
if (FAILED(result))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a texture sampler state description.
|
// Create a texture sampler state description.
|
||||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||||
@ -220,78 +222,128 @@ bool CelShadingShader::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR*
|
|||||||
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
|
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
|
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the description of the light dynamic constant buffer that is in the pixel shader.
|
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
|
||||||
lightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
lightBufferDesc.ByteWidth = sizeof(LightBufferType);
|
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
|
||||||
lightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||||
lightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
lightBufferDesc.MiscFlags = 0;
|
matrixBufferDesc.MiscFlags = 0;
|
||||||
lightBufferDesc.StructureByteStride = 0;
|
matrixBufferDesc.StructureByteStride = 0;
|
||||||
|
|
||||||
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
|
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
|
||||||
result = device->CreateBuffer(&lightBufferDesc, nullptr, &m_lightBuffer);
|
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
|
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
|
||||||
|
sunlightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
|
sunlightBufferDesc.ByteWidth = sizeof(SunLightBufferType);
|
||||||
|
sunlightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||||
|
sunlightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
|
sunlightBufferDesc.MiscFlags = 0;
|
||||||
|
sunlightBufferDesc.StructureByteStride = 0;
|
||||||
|
|
||||||
|
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
|
||||||
|
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &m_sunlightBuffer);
|
||||||
|
if (FAILED(result))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Failed to create sunlight buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CelShadingShader::ShutdownShader()
|
|
||||||
|
|
||||||
|
void CelshadeClass::ShutdownShader()
|
||||||
{
|
{
|
||||||
// Release the light constant buffer.
|
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||||
if (m_lightBuffer)
|
|
||||||
|
// Release the light constant buffers.
|
||||||
|
if (m_sunlightColorBuffer)
|
||||||
{
|
{
|
||||||
m_lightBuffer->Release();
|
m_sunlightColorBuffer->Release();
|
||||||
m_lightBuffer = nullptr;
|
m_sunlightColorBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the sampler state.
|
if (m_sunlightPositionBuffer)
|
||||||
if (m_sampleState)
|
|
||||||
{
|
{
|
||||||
m_sampleState->Release();
|
m_sunlightPositionBuffer->Release();
|
||||||
m_sampleState = nullptr;
|
m_sunlightPositionBuffer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release the light constant buffer.
|
||||||
|
if (m_sunlightBuffer)
|
||||||
|
{
|
||||||
|
m_sunlightBuffer->Release();
|
||||||
|
m_sunlightBuffer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release the camera constant buffer.
|
||||||
|
if (m_cameraBuffer)
|
||||||
|
{
|
||||||
|
m_cameraBuffer->Release();
|
||||||
|
m_cameraBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the matrix constant buffer.
|
// Release the matrix constant buffer.
|
||||||
if (m_matrixBuffer)
|
if (m_matrixBuffer)
|
||||||
{
|
{
|
||||||
m_matrixBuffer->Release();
|
m_matrixBuffer->Release();
|
||||||
m_matrixBuffer = nullptr;
|
m_matrixBuffer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release the sampler state.
|
||||||
|
if (m_sampleState)
|
||||||
|
{
|
||||||
|
m_sampleState->Release();
|
||||||
|
m_sampleState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the layout.
|
// Release the layout.
|
||||||
if (m_layout)
|
if (m_layout)
|
||||||
{
|
{
|
||||||
m_layout->Release();
|
m_layout->Release();
|
||||||
m_layout = nullptr;
|
m_layout = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the pixel shader.
|
// Release the pixel shader.
|
||||||
if (m_pixelShader)
|
if (m_pixelShader)
|
||||||
{
|
{
|
||||||
m_pixelShader->Release();
|
m_pixelShader->Release();
|
||||||
m_pixelShader = nullptr;
|
m_pixelShader = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the vertex shader.
|
// Release the vertex shader.
|
||||||
if (m_vertexShader)
|
if (m_vertexShader)
|
||||||
{
|
{
|
||||||
m_vertexShader->Release();
|
m_vertexShader->Release();
|
||||||
m_vertexShader = nullptr;
|
m_vertexShader = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger::Get().Log("SunLightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CelShadingShader::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
|
|
||||||
|
void CelshadeClass::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
|
||||||
{
|
{
|
||||||
char* compileErrors;
|
char* compileErrors;
|
||||||
unsigned long bufferSize, i;
|
unsigned __int64 bufferSize, i;
|
||||||
std::ofstream fout;
|
ofstream fout;
|
||||||
|
|
||||||
|
|
||||||
// Get a pointer to the error message text buffer.
|
// Get a pointer to the error message text buffer.
|
||||||
compileErrors = (char*)(errorMessage->GetBufferPointer());
|
compileErrors = (char*)(errorMessage->GetBufferPointer());
|
||||||
@ -313,20 +365,32 @@ void CelShadingShader::OutputShaderErrorMessage(ID3D10Blob* errorMessage, HWND h
|
|||||||
|
|
||||||
// Release the error message.
|
// Release the error message.
|
||||||
errorMessage->Release();
|
errorMessage->Release();
|
||||||
errorMessage = nullptr;
|
errorMessage = 0;
|
||||||
|
|
||||||
// Pop a message up on the screen to notify the user to check the text file for compile errors.
|
// Pop a message up on the screen to notify the user to check the text file for compile errors.
|
||||||
MessageBox(hwnd, L"Error compiling shader. Check shader-error.txt for message.", shaderFilename, MB_OK);
|
MessageBox(hwnd, L"Error compiling shader. Check shader-error.txt for message.", shaderFilename, MB_OK);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CelShadingShader::SetShaderParameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
bool CelshadeClass::SetShaderParameters(
|
||||||
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 lightPosition)
|
ID3D11DeviceContext* deviceContext,
|
||||||
|
XMMATRIX worldMatrix,
|
||||||
|
XMMATRIX viewMatrix,
|
||||||
|
XMMATRIX projectionMatrix,
|
||||||
|
ID3D11ShaderResourceView* texture,
|
||||||
|
XMFLOAT4 ambientColor,
|
||||||
|
XMFLOAT4 diffuseColor,
|
||||||
|
XMFLOAT3 lightDirection,
|
||||||
|
float sunIntensity
|
||||||
|
)
|
||||||
{
|
{
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||||
MatrixBufferType* dataPtr;
|
MatrixBufferType* dataPtr;
|
||||||
LightBufferType* dataPtr2;
|
CameraBufferType* dataPtr2;
|
||||||
|
SunLightBufferType* dataPtr3;
|
||||||
unsigned int bufferNumber;
|
unsigned int bufferNumber;
|
||||||
|
|
||||||
// Transpose the matrices to prepare them for the shader.
|
// Transpose the matrices to prepare them for the shader.
|
||||||
@ -358,32 +422,30 @@ bool CelShadingShader::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
|
|||||||
// Finally set the constant buffer in the vertex shader with the updated values.
|
// Finally set the constant buffer in the vertex shader with the updated values.
|
||||||
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
|
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &m_matrixBuffer);
|
||||||
|
|
||||||
// Lock the light constant buffer so it can be written to.
|
// Lock the sunlight constant buffer so it can be written to.
|
||||||
result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
result = deviceContext->Map(m_sunlightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||||
if (FAILED(result))
|
if (FAILED(result))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a pointer to the data in the constant buffer.
|
// Get a pointer to the data in the constant buffer.
|
||||||
dataPtr2 = (LightBufferType*)mappedResource.pData;
|
dataPtr3 = (SunLightBufferType*)mappedResource.pData;
|
||||||
|
|
||||||
// Copy the lighting variables into the constant buffer.
|
// Copy the lighting variables into the constant buffer.
|
||||||
dataPtr2->diffuseColor = diffuseColor;
|
dataPtr3->ambientColor = ambientColor;
|
||||||
dataPtr2->lightDirection = lightDirection;
|
dataPtr3->diffuseColor = diffuseColor;
|
||||||
dataPtr2->lightPosition = lightPosition;
|
dataPtr3->sunDirection = lightDirection;
|
||||||
dataPtr2->constantAttenuation = 0.5f; // Set your attenuation values here
|
dataPtr3->intensity = sunIntensity;
|
||||||
dataPtr2->linearAttenuation = 0.1f;
|
|
||||||
dataPtr2->quadraticAttenuation = 0.01f;
|
|
||||||
|
|
||||||
// Unlock the constant buffer.
|
// Unlock the constant buffer.
|
||||||
deviceContext->Unmap(m_lightBuffer, 0);
|
deviceContext->Unmap(m_sunlightBuffer, 0);
|
||||||
|
|
||||||
// Set the position of the light constant buffer in the pixel shader.
|
// Set the position of the sunlight constant buffer in the pixel shader.
|
||||||
bufferNumber = 0;
|
bufferNumber = 0;
|
||||||
|
|
||||||
// Finally set the light constant buffer in the pixel shader with the updated values.
|
// Finally set the sunlight constant buffer in the pixel shader with the updated values.
|
||||||
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);
|
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_sunlightBuffer);
|
||||||
|
|
||||||
// Set shader texture resource in the pixel shader.
|
// Set shader texture resource in the pixel shader.
|
||||||
deviceContext->PSSetShaderResources(0, 1, &texture);
|
deviceContext->PSSetShaderResources(0, 1, &texture);
|
||||||
@ -391,20 +453,20 @@ bool CelShadingShader::SetShaderParameters(ID3D11DeviceContext* deviceContext, X
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CelshadeClass::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||||
|
|
||||||
void CelShadingShader::RenderShader(ID3D11DeviceContext* deviceContext, int indexCount)
|
|
||||||
{
|
{
|
||||||
// Set the vertex input layout.
|
// Set the vertex input layout.
|
||||||
deviceContext->IASetInputLayout(m_layout);
|
deviceContext->IASetInputLayout(m_layout);
|
||||||
|
|
||||||
// Set the vertex and pixel shaders that will be used to render this triangle.
|
// Set the vertex and pixel shaders that will be used to render this triangle.
|
||||||
deviceContext->VSSetShader(m_vertexShader, nullptr, 0);
|
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
|
||||||
deviceContext->PSSetShader(m_pixelShader, nullptr, 0);
|
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
|
||||||
|
|
||||||
// Set the sampler state in the pixel shader.
|
// Set the sampler state in the pixel shader.
|
||||||
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
|
deviceContext->PSSetSamplers(0, 1, &m_sampleState);
|
||||||
|
|
||||||
// Render the triangle.
|
// Render the triangle.
|
||||||
deviceContext->DrawIndexed(indexCount, 0, 0);
|
deviceContext->DrawIndexed(indexCount, 0, 0);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ bool ShaderManagerClass::Initialize(ID3D11Device* device, HWND hwnd)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_CelShadingShader = new CelShadingShader;
|
m_CelShadingShader = new CelshadeClass;
|
||||||
result = m_CelShadingShader->Initialize(device, hwnd);
|
result = m_CelShadingShader->Initialize(device, hwnd);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
@ -422,11 +422,11 @@ bool ShaderManagerClass::RenderWaterShader(ID3D11DeviceContext* deviceContext, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ShaderManagerClass::RenderCelShadingShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
bool ShaderManagerClass::RenderCelShadingShader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||||
ID3D11ShaderResourceView* texture, XMFLOAT3 lightDirection, XMFLOAT4 diffuseColor, XMFLOAT3 lightPosition)
|
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
result = m_CelShadingShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, lightDirection, diffuseColor, lightPosition);
|
result = m_CelShadingShader->Render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1899,8 +1899,18 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
|||||||
switch (object->GetActiveShader())
|
switch (object->GetActiveShader())
|
||||||
{
|
{
|
||||||
case Object::CEL_SHADING:
|
case Object::CEL_SHADING:
|
||||||
result = m_ShaderManager->RenderCelShadingShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, view, projection, object->GetTexture(0),
|
result = m_ShaderManager->RenderCelShadingShader(
|
||||||
m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(), TrueLightPosition);
|
m_Direct3D->GetDeviceContext(),
|
||||||
|
object->GetIndexCount(),
|
||||||
|
worldMatrix,
|
||||||
|
view,
|
||||||
|
projection,
|
||||||
|
object->GetTexture(0),
|
||||||
|
m_SunLight->GetDiffuseColor(),
|
||||||
|
m_SunLight->GetAmbientColor(),
|
||||||
|
m_SunLight->GetDirection(),
|
||||||
|
m_SunLight->GetIntensity()
|
||||||
|
);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Could not render the model using the cel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
Logger::Get().Log("Could not render the model using the cel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
@ -1909,7 +1919,17 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Object::NORMAL_MAPPING:
|
case Object::NORMAL_MAPPING:
|
||||||
result = m_ShaderManager->RenderNormalMapShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, view, projection, object->GetTexture(0), object->GetTexture(1), m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor());
|
result = m_ShaderManager->RenderNormalMapShader(
|
||||||
|
m_Direct3D->GetDeviceContext(),
|
||||||
|
object->GetIndexCount(),
|
||||||
|
worldMatrix,
|
||||||
|
view,
|
||||||
|
projection,
|
||||||
|
object->GetTexture(0),
|
||||||
|
object->GetTexture(1),
|
||||||
|
m_Lights[0]->GetDirection(),
|
||||||
|
m_Lights[0]->GetDiffuseColor()
|
||||||
|
);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Could not render the model using the normal map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
Logger::Get().Log("Could not render the model using the normal map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
@ -1945,8 +1965,17 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Object::SUNLIGHT:
|
case Object::SUNLIGHT:
|
||||||
result = m_ShaderManager->RenderSunlightShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, view, projection,
|
result = m_ShaderManager->RenderSunlightShader(
|
||||||
object->GetTexture(0), m_SunLight->GetDiffuseColor(), m_SunLight->GetAmbientColor(), m_SunLight->GetDirection(), m_SunLight->GetIntensity());
|
m_Direct3D->GetDeviceContext(),
|
||||||
|
object->GetIndexCount(),
|
||||||
|
worldMatrix,
|
||||||
|
view,
|
||||||
|
projection,
|
||||||
|
object->GetTexture(0),
|
||||||
|
m_SunLight->GetDiffuseColor(),
|
||||||
|
m_SunLight->GetAmbientColor(),
|
||||||
|
m_SunLight->GetDirection(),
|
||||||
|
m_SunLight->GetIntensity());
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Could not render the object model using the sunlight shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
Logger::Get().Log("Could not render the object model using the sunlight shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
@ -134,17 +134,6 @@ void imguiManager::WidgetAddObject(ApplicationClass* app)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void imguiManager::WidgetShaderWindow(ApplicationClass* app)
|
|
||||||
{
|
|
||||||
ImGui::Begin("Shader Manager");
|
|
||||||
|
|
||||||
// Checkbox for toggling cel shading globally in the application class by calling the SetCelShading function in the application class when the checkbox state changes
|
|
||||||
ImGui::Checkbox("Enable Cel Shading", &m_EnableCelShading);
|
|
||||||
app->SetCelShading(m_EnableCelShading);
|
|
||||||
|
|
||||||
ImGui::End();
|
|
||||||
}
|
|
||||||
|
|
||||||
void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
||||||
{
|
{
|
||||||
ImGui::Begin("Objects", &showObjectWindow);
|
ImGui::Begin("Objects", &showObjectWindow);
|
||||||
@ -417,11 +406,6 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
|
|||||||
WidgetLightWindow(app);
|
WidgetLightWindow(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showShaderWindow)
|
|
||||||
{
|
|
||||||
WidgetShaderWindow(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showEngineSettingsWindow)
|
if (showEngineSettingsWindow)
|
||||||
{
|
{
|
||||||
WidgetEngineSettingsWindow(app);
|
WidgetEngineSettingsWindow(app);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user