Revert "Minor - Start Shadow Map - V10.5.0"
This reverts commit d6b7626446e965d3cf4567f5cd787511c9bbe4f3.
This commit is contained in:
parent
d6b7626446
commit
dbd27d1fe7
163
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
163
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@ -5,24 +5,97 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/enginecustom/src/hlsl/depth.ps" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/enginecustom/src/hlsl/depth.vs" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/depth_shader_class.h" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/shadow_map.h" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/depth_shader_class.cpp" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/enginecustom/src/src/system/shadow_map.cpp" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/fps_limiter.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/encodings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/encodings.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/DemoScene_V10.1.2.ker" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/DemoScene_V10.1.2.ker" 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/enginecustom.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" 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/sunlight.ps" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/hlsl/sunlight.ps" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/hlsl/sunlight.vs" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/hlsl/sunlight.vs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/shader_manager_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/shader_manager_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/sunlight_shader_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/sunlight_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/shader_manager_class.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/shader_manager_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/sunlight_shader_class.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/sunlight_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/include/imgui.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/include/imgui.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/CelShadingShader.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/celshade_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/Colorshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/color_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/Multitextureshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/multi_texture_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/SkyboxShaderClass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/skybox_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/alphamapshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/alpha_map_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/fontshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/font_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/lightmapshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/light_map_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/lightshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/light_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/lightshaderwaterclass.h" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/normalmapshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/normal_map_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/reflectionshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/reflection_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/refractionshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/refraction_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/shadermanagerclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/shader_manager_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/specmapshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/spec_map_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/sunlightshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/sunlight_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/textureshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/texture_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/translateshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/translate_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/transparentshaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/transparent_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/watershaderclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/water_shader_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/Cameraclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/camera_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/Logger.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/Logger.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/Positionclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/position_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/Skybox.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/Skybox.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/Spriteclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/sprite_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/Timerclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/timer_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/applicationclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/bitmapclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/bitmap_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/d3dclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/d_3d_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/displayplaneclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/display_plane_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/fontclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/font_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/fpsclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/fps_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/frustum.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/frustum.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/inc/system/inputclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/input_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/lightclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/light_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/model_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/physics.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/physics.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/rendertextureclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/render_texture_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/systemclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/system_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/textclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/text_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/textureclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/texture_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/celshade_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/Colorshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/color_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/Multitextureshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/multi_texture_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/SkyboxShaderClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/skybox_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/alphamapshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/alpha_map_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/fontshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/font_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/lightmapshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/light_map_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/lightshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/light_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/normalmapshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/normal_map_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/reflectionshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/reflection_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/refractionshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/refraction_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/shadermanagerclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/shader_manager_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/specmapshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/spec_map_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/sunlightshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/sunlight_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/textureshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/texture_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/translateshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/translate_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/transparentshaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/transparent_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/watershaderclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/water_shader_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Cameraclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/camera_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/Main.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Positionclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/position_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Skybox.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/Skybox.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Spriteclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/sprite_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Systemclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/system_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Timerclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/timer_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/bitmapclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/bitmap_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/d3dclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/d_3d_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/displayplaneclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/display_plane_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/fontclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/font_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/fpsclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/fps_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/frustum.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/frustum.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" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/inputclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/input_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/lightclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/light_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/model_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/physics.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/physics.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/rendertextureclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/render_texture_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/textclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/text_class.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/textureclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/texture_class.cpp" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -108,10 +181,64 @@
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="cidr-memory-view://10" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/d3d11.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/include/Inc/VertexTypes.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
||||
</component>
|
||||
<component name="KubernetesApiPersistence">{}</component>
|
||||
@ -126,9 +253,6 @@
|
||||
"associatedIndex": 6
|
||||
}</component>
|
||||
<component name="ProjectId" id="2sGIWDeT5ixyzDQ0he4A3RFpG9W" />
|
||||
<component name="ProjectLevelVcsManager">
|
||||
<ConfirmationsSetting value="2" id="Add" />
|
||||
</component>
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
@ -282,7 +406,6 @@
|
||||
<workItem from="1747258663152" duration="835000" />
|
||||
<workItem from="1747826758888" duration="3587000" />
|
||||
<workItem from="1747830379222" duration="7954000" />
|
||||
<workItem from="1747917137074" duration="10453000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
||||
<option name="closed" value="true" />
|
||||
|
@ -33,82 +33,6 @@
|
||||
<ClCompile Include="src\src\shader\alpha_map_shader_class.cpp" />
|
||||
<ClCompile Include="src\src\shader\celshade_class.cpp" />
|
||||
<ClCompile Include="src\src\shader\color_shader_class.cpp" />
|
||||
<ClCompile Include="src\src\shader\depth_shader_class.cpp">
|
||||
<RuntimeLibrary>MultiThreadedDebugDll</RuntimeLibrary>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SupportJustMyCode>true</SupportJustMyCode>
|
||||
<AssemblerOutput>NoListing</AssemblerOutput>
|
||||
<AssemblerListingLocation>x64\Debug\</AssemblerListingLocation>
|
||||
<UndefineAllPreprocessorDefinitions>false</UndefineAllPreprocessorDefinitions>
|
||||
<BrowseInformation>false</BrowseInformation>
|
||||
<BrowseInformationFile>x64\Debug\</BrowseInformationFile>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<DiagnosticsFormat>Column</DiagnosticsFormat>
|
||||
<DisableLanguageExtensions>false</DisableLanguageExtensions>
|
||||
<ErrorReporting>Prompt</ErrorReporting>
|
||||
<ExpandAttributedSource>false</ExpandAttributedSource>
|
||||
<ExceptionHandling>Sync</ExceptionHandling>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
<EnableFuzzer>false</EnableFuzzer>
|
||||
<EnableFiberSafeOptimizations>false</EnableFiberSafeOptimizations>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<EnableVectorLength>NotSet</EnableVectorLength>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<GenerateModuleDependencies>false</GenerateModuleDependencies>
|
||||
<GenerateSourceDependencies>false</GenerateSourceDependencies>
|
||||
<GenerateXMLDocumentationFiles>false</GenerateXMLDocumentationFiles>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<IntrinsicFunctions>false</IntrinsicFunctions>
|
||||
<IgnoreStandardIncludePath>false</IgnoreStandardIncludePath>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<LanguageStandard_C>Default</LanguageStandard_C>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<ModuleDependenciesFile>x64\Debug\</ModuleDependenciesFile>
|
||||
<ModuleOutputFile>x64\Debug\</ModuleOutputFile>
|
||||
<OmitDefaultLibName>false</OmitDefaultLibName>
|
||||
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<ObjectFileName>x64\Debug\</ObjectFileName>
|
||||
<CallingConvention>Cdecl</CallingConvention>
|
||||
<ProgramDataBaseFileName>x64\Debug\vc143.pdb</ProgramDataBaseFileName>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>x64\Debug\KhaoticCore.pch</PrecompiledHeaderOutputFile>
|
||||
<PreprocessToFile>false</PreprocessToFile>
|
||||
<PreprocessKeepComments>false</PreprocessKeepComments>
|
||||
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
|
||||
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||
<ScanSourceForModuleDependencies>false</ScanSourceForModuleDependencies>
|
||||
<ShowIncludes>false</ShowIncludes>
|
||||
<SourceDependenciesFile>x64\Debug\</SourceDependenciesFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<SmallerTypeCheck>false</SmallerTypeCheck>
|
||||
<SpectreMitigation>false</SpectreMitigation>
|
||||
<StructMemberAlignment>Default</StructMemberAlignment>
|
||||
<TrackerLogDirectory>x64\Debug\KhaoticCore.tlog\</TrackerLogDirectory>
|
||||
<TranslateIncludes>false</TranslateIncludes>
|
||||
<MinimalRebuildFromTracking>true</MinimalRebuildFromTracking>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<UseFullPaths>true</UseFullPaths>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<XMLDocumentationFileName>x64\Debug\</XMLDocumentationFileName>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<IntelJCCErratum>false</IntelJCCErratum>
|
||||
<BuildStlModules>false</BuildStlModules>
|
||||
<TreatAngleIncludeAsExternal>false</TreatAngleIncludeAsExternal>
|
||||
<ExternalWarningLevel>InheritWarningLevel</ExternalWarningLevel>
|
||||
<TreatExternalTemplatesAsInternal>true</TreatExternalTemplatesAsInternal>
|
||||
<DisableAnalyzeExternal>false</DisableAnalyzeExternal>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_UNICODE;UNICODE;</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>F:\Github_Repo\khaotic-engine-Reborn\enginecustom\include\backends;F:\Github_Repo\khaotic-engine-Reborn\enginecustom\include\Inc;F:\Github_Repo\khaotic-engine-Reborn\enginecustom\include;F:\Github_Repo\khaotic-engine-Reborn\enginecustom\src\inc\shader;F:\Github_Repo\khaotic-engine-Reborn\enginecustom\src\inc\system;F:\Github_Repo\khaotic-engine-Reborn\enginecustom\include\Vulkan\Include;</AdditionalIncludeDirectories>
|
||||
<LinkCompiled>true</LinkCompiled>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\src\shader\font_shader_class.cpp" />
|
||||
<ClCompile Include="src\src\shader\light_map_shader_class.cpp" />
|
||||
<ClCompile Include="src\src\shader\light_shader_class.cpp" />
|
||||
@ -143,7 +67,6 @@
|
||||
<ClCompile Include="src\src\system\physics.cpp" />
|
||||
<ClCompile Include="src\src\system\position_class.cpp" />
|
||||
<ClCompile Include="src\src\system\render_texture_class.cpp" />
|
||||
<ClCompile Include="src\src\system\shadow_map.cpp" />
|
||||
<ClCompile Include="src\src\system\Skybox.cpp" />
|
||||
<ClCompile Include="src\src\system\sprite_class.cpp" />
|
||||
<ClCompile Include="src\src\system\system_class.cpp" />
|
||||
@ -169,7 +92,6 @@
|
||||
<ClInclude Include="src\inc\shader\alpha_map_shader_class.h" />
|
||||
<ClInclude Include="src\inc\shader\celshade_class.h" />
|
||||
<ClInclude Include="src\inc\shader\color_shader_class.h" />
|
||||
<ClInclude Include="src\inc\shader\depth_shader_class.h" />
|
||||
<ClInclude Include="src\inc\shader\font_shader_class.h" />
|
||||
<ClInclude Include="src\inc\shader\light_map_shader_class.h" />
|
||||
<ClInclude Include="src\inc\shader\light_shader_class.h" />
|
||||
@ -206,7 +128,6 @@
|
||||
<ClInclude Include="src\inc\system\position_class.h" />
|
||||
<ClInclude Include="src\inc\system\render_texture_class.h" />
|
||||
<ClInclude Include="src\inc\system\sceneManager.h" />
|
||||
<ClInclude Include="src\inc\system\shadow_map.h" />
|
||||
<ClInclude Include="src\inc\system\Skybox.h" />
|
||||
<ClInclude Include="src\inc\system\sprite_class.h" />
|
||||
<ClInclude Include="src\inc\system\system_class.h" />
|
||||
@ -246,16 +167,6 @@
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\src\hlsl</DestinationFolders>
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\src\hlsl</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="src\hlsl\depth.ps">
|
||||
<DestinationFolders>F:\Github_Repo\khaotic-engine-Reborn\x64\Debug\\src\hlsl</DestinationFolders>
|
||||
<DestinationFileName>%(Filename)%(Extension)</DestinationFileName>
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="src\hlsl\depth.vs">
|
||||
<DestinationFolders>F:\Github_Repo\khaotic-engine-Reborn\x64\Debug\\src\hlsl</DestinationFolders>
|
||||
<DestinationFileName>%(Filename)%(Extension)</DestinationFileName>
|
||||
<FileType>Document</FileType>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="src\hlsl\font.ps">
|
||||
<FileType>Document</FileType>
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\src\hlsl</DestinationFolders>
|
||||
|
@ -16,8 +16,8 @@ Collapsed=0
|
||||
DockId=0x00000011,0
|
||||
|
||||
[Window][Terrain]
|
||||
Pos=0,19
|
||||
Size=280,842
|
||||
Pos=283,19
|
||||
Size=280,615
|
||||
Collapsed=0
|
||||
DockId=0x00000007,0
|
||||
|
||||
|
Binary file not shown.
@ -1,10 +0,0 @@
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
};
|
||||
|
||||
float4 DepthPixelShader(PS_INPUT input) : SV_TARGET
|
||||
{
|
||||
// Pas de couleur, juste la profondeur
|
||||
return float4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
cbuffer MatrixBuffer : register(b0)
|
||||
{
|
||||
matrix world;
|
||||
matrix view;
|
||||
matrix projection;
|
||||
};
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 position : POSITION;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
};
|
||||
|
||||
VS_OUTPUT DepthVertexShader(VS_INPUT input)
|
||||
{
|
||||
VS_OUTPUT output;
|
||||
float4 worldPosition = mul(float4(input.position, 1.0f), world);
|
||||
float4 viewPosition = mul(worldPosition, view);
|
||||
output.position = mul(viewPosition, projection);
|
||||
return output;
|
||||
}
|
@ -3,9 +3,6 @@
|
||||
/////////////
|
||||
Texture2D shaderTexture : register(t0);
|
||||
SamplerState SampleType : register(s0);
|
||||
Texture2D shadowMap : register(t1);
|
||||
SamplerState shadowSampleType : register(s1);
|
||||
|
||||
cbuffer SunLightBuffer
|
||||
{
|
||||
float4 ambientColor;
|
||||
@ -27,7 +24,6 @@ struct PixelInputType
|
||||
float4 position : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
float3 normal : NORMAL;
|
||||
float4 lightPosition : TEXCOORD1;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -35,47 +31,23 @@ struct PixelInputType
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
float4 SunLightPixelShader(PixelInputType input) : SV_TARGET
|
||||
{
|
||||
|
||||
// temp return to check if the shader is working
|
||||
return float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
float4 textureColor;
|
||||
float4 color;
|
||||
float lightIntensity;
|
||||
float4 colorArray;
|
||||
float4 colorSum;
|
||||
float bias = 0.001f;
|
||||
float shadowFactor = 1.0f;
|
||||
|
||||
// Sample the pixel color from the texture using the sampler at this coordinate
|
||||
// Sample the pixel color from the texture using the sampler at this texture coordinate location.
|
||||
textureColor = shaderTexture.Sample(SampleType, input.tex);
|
||||
|
||||
// Calculate shadow factor
|
||||
// Projection division to normalize coordinates
|
||||
float2 projectTexCoord;
|
||||
projectTexCoord.x = input.lightPosition.x / input.lightPosition.w / 2.0f + 0.5f;
|
||||
projectTexCoord.y = -input.lightPosition.y / input.lightPosition.w / 2.0f + 0.5f;
|
||||
|
||||
if((saturate(projectTexCoord.x) == projectTexCoord.x) && (saturate(projectTexCoord.y) == projectTexCoord.y))
|
||||
{
|
||||
float depthValue = input.lightPosition.z / input.lightPosition.w;
|
||||
float shadowDepth = shadowMap.Sample(shadowSampleType, projectTexCoord).r;
|
||||
|
||||
if(depthValue - bias > shadowDepth)
|
||||
{
|
||||
// Pixel est dans l'ombre
|
||||
shadowFactor = 0.3f; // Ombre non totale pour un effet plus réaliste
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the different amounts of light on this pixel based on the direction of the light.
|
||||
lightIntensity = saturate(dot(input.normal, -lightDirection));
|
||||
|
||||
// Determine the diffuse color amount of the light.
|
||||
colorArray = (diffuseColor * lightIntensity) * intensity * shadowFactor;
|
||||
|
||||
colorArray = (diffuseColor * lightIntensity) * intensity;
|
||||
|
||||
// Initialize the sum of colors.
|
||||
colorSum = ambientColor; // Conserver l'éclairage ambiant même dans l'ombre
|
||||
colorSum = float4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
// Add the light color.
|
||||
colorSum.r += colorArray.r;
|
||||
@ -86,4 +58,4 @@ float4 SunLightPixelShader(PixelInputType input) : SV_TARGET
|
||||
color = saturate(colorSum) * textureColor;
|
||||
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
@ -22,12 +22,6 @@ cbuffer SunLightBuffer
|
||||
float intensity;
|
||||
};
|
||||
|
||||
cbuffer LightViewMatrixBuffer : register(b2)
|
||||
{
|
||||
matrix lightViewMatrix;
|
||||
matrix lightProjectionMatrix;
|
||||
};
|
||||
|
||||
//////////////
|
||||
// TYPEDEFS //
|
||||
//////////////
|
||||
@ -43,7 +37,6 @@ struct PixelInputType
|
||||
float4 position : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
float3 normal : NORMAL;
|
||||
float4 lightPosition : TEXCOORD1;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -52,30 +45,23 @@ struct PixelInputType
|
||||
PixelInputType SunLightVertexShader(VertexInputType input)
|
||||
{
|
||||
PixelInputType output;
|
||||
float4 worldPosition; // Déclaration de la variable manquante
|
||||
|
||||
// Change the position vector to be 4 units for proper matrix calculations.
|
||||
input.position.w = 1.0f;
|
||||
|
||||
// Calculate the position of the vertex against the world matrix
|
||||
worldPosition = mul(input.position, worldMatrix);
|
||||
|
||||
// Calculate position in light view space.
|
||||
output.lightPosition = mul(worldPosition, lightViewMatrix);
|
||||
output.lightPosition = mul(output.lightPosition, lightProjectionMatrix);
|
||||
|
||||
// Standard position calculation
|
||||
output.position = mul(worldPosition, viewMatrix);
|
||||
// Calculate the position of the vertex against the world, view, and projection matrices.
|
||||
output.position = mul(input.position, worldMatrix);
|
||||
output.position = mul(output.position, viewMatrix);
|
||||
output.position = mul(output.position, projectionMatrix);
|
||||
|
||||
// Store the texture coordinates for the pixel shader.
|
||||
output.tex = input.tex;
|
||||
|
||||
// Calculate the normal vector against the world matrix only.
|
||||
output.normal = mul(input.normal, (float3x3)worldMatrix);
|
||||
output.normal = mul(input.normal, (float3x3) worldMatrix);
|
||||
|
||||
// Normalize the normal vector.
|
||||
output.normal = normalize(output.normal);
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <DirectXMath.h>
|
||||
using namespace DirectX;
|
||||
|
||||
class depth_shader_class
|
||||
{
|
||||
public:
|
||||
depth_shader_class();
|
||||
~depth_shader_class();
|
||||
|
||||
bool initialize(ID3D11Device* device, HWND hwnd);
|
||||
void shutdown();
|
||||
bool render(ID3D11DeviceContext* deviceContext, int indexCount,
|
||||
XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix);
|
||||
|
||||
private:
|
||||
struct MatrixBufferType
|
||||
{
|
||||
XMMATRIX world;
|
||||
XMMATRIX view;
|
||||
XMMATRIX projection;
|
||||
};
|
||||
|
||||
bool initialize_shader(ID3D11Device* device, HWND hwnd, const WCHAR* vsFilename, const WCHAR* psFilename);
|
||||
void shutdown_shader();
|
||||
void output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, const WCHAR* shaderFilename);
|
||||
bool set_shader_parameters(ID3D11DeviceContext* deviceContext,
|
||||
XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix);
|
||||
void render_shader(ID3D11DeviceContext* deviceContext, int indexCount);
|
||||
|
||||
ID3D11VertexShader* vertex_shader_;
|
||||
ID3D11PixelShader* pixel_shader_;
|
||||
ID3D11InputLayout* layout_;
|
||||
ID3D11Buffer* matrix_buffer_;
|
||||
};
|
@ -19,7 +19,6 @@
|
||||
#include "celshade_class.h"
|
||||
#include "skybox_shader_class.h"
|
||||
#include "sunlight_shader_class.h"
|
||||
#include "depth_shader_class.h"
|
||||
|
||||
using namespace DirectX;
|
||||
|
||||
@ -45,10 +44,8 @@ public:
|
||||
bool render_refraction_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT3, XMFLOAT4[], XMFLOAT4[], XMFLOAT4[], XMFLOAT4);
|
||||
bool render_water_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, ID3D11ShaderResourceView*, float, float);
|
||||
bool render_cel_shading_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
||||
bool render_sunlight_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float, ID3D11ShaderResourceView
|
||||
* shadowMap, XMMATRIX lightViewMatrix, XMMATRIX lightProjectionMatrix);
|
||||
bool render_sunlight_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
||||
bool render_skybox_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
||||
bool render_depth_shader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX);
|
||||
|
||||
private:
|
||||
texture_shader_class* texture_shader_;
|
||||
@ -65,7 +62,6 @@ private:
|
||||
celshade_class* cel_shading_shader_;
|
||||
sunlight_shader_class* sunlight_shader_;
|
||||
skybox_shader_class* skybox_shader_;
|
||||
depth_shader_class* depth_shader_;
|
||||
};
|
||||
|
||||
#endif
|
@ -38,12 +38,6 @@ private :
|
||||
XMFLOAT4 sun_color;
|
||||
};
|
||||
|
||||
struct light_view_matrix_buffer_type
|
||||
{
|
||||
XMMATRIX light_view;
|
||||
XMMATRIX light_projection;
|
||||
};
|
||||
|
||||
public :
|
||||
sunlight_shader_class();
|
||||
sunlight_shader_class(const sunlight_shader_class&);
|
||||
@ -51,29 +45,14 @@ public :
|
||||
|
||||
bool initialize(ID3D11Device*, HWND);
|
||||
void shutdown();
|
||||
bool render(
|
||||
ID3D11DeviceContext* device_context,
|
||||
int index_count,
|
||||
XMMATRIX world_matrix,
|
||||
XMMATRIX view_matrix,
|
||||
XMMATRIX projection_matrix,
|
||||
ID3D11ShaderResourceView* texture,
|
||||
XMFLOAT4 diffuse_color,
|
||||
XMFLOAT4 ambient_color,
|
||||
XMFLOAT3 sun_direction,
|
||||
float sun_intensity,
|
||||
ID3D11ShaderResourceView* shadow_map,
|
||||
XMMATRIX light_view_matrix,
|
||||
XMMATRIX light_projection_matrix
|
||||
);
|
||||
bool render(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3,float);
|
||||
|
||||
private:
|
||||
bool initialize_shader(ID3D11Device*, HWND, WCHAR*, WCHAR*);
|
||||
void shutdown_shader();
|
||||
void output_shader_error_message(ID3D10Blob*, HWND, WCHAR*);
|
||||
|
||||
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float, ID3D11ShaderResourceView
|
||||
* shadowMap, XMMATRIX lightViewMatrix, XMMATRIX lightProjectionMatrix);
|
||||
bool set_shader_parameters(ID3D11DeviceContext*, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
||||
void render_shader(ID3D11DeviceContext*, int);
|
||||
|
||||
private:
|
||||
@ -86,7 +65,4 @@ private:
|
||||
ID3D11Buffer* sunlight_buffer_;
|
||||
ID3D11Buffer* sunlight_color_buffer_;
|
||||
ID3D11Buffer* sunlight_position_buffer_;
|
||||
ID3D11Buffer* light_view_matrix_buffer_;
|
||||
ID3D11ShaderResourceView* shadow_map_texture_;
|
||||
ID3D11SamplerState* shadow_sampler_state_;
|
||||
};
|
@ -43,8 +43,6 @@
|
||||
#include <DirectXMath.h>
|
||||
#include <mutex>
|
||||
|
||||
#include "shadow_map.h"
|
||||
|
||||
|
||||
/////////////
|
||||
// GLOBALS //
|
||||
@ -187,17 +185,8 @@ private:
|
||||
bool render_scene_to_texture(float);
|
||||
bool render_refraction_to_texture();
|
||||
bool render_reflection_to_texture();
|
||||
bool render_pass(
|
||||
const std::vector<std::reference_wrapper<std::vector<object*>>>& RenderQueues,
|
||||
XMFLOAT4* diffuse,
|
||||
XMFLOAT4* position,
|
||||
XMFLOAT4* ambient,
|
||||
XMMATRIX view,
|
||||
XMMATRIX projection
|
||||
);
|
||||
bool create_shadow_map(
|
||||
const std::vector<std::reference_wrapper<std::vector<object*>>>& RenderQueues
|
||||
);
|
||||
bool render_pass(const std::vector<std::reference_wrapper<std::vector<object*>>>& RenderQueues, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection);
|
||||
|
||||
void update_skybox_position();
|
||||
|
||||
public :
|
||||
@ -331,18 +320,6 @@ private :
|
||||
// ------------------------------------------------- //
|
||||
|
||||
input inputs_;
|
||||
|
||||
// ------------------------------------------------- //
|
||||
// -------------------- Shadows -------------------- //
|
||||
// ------------------------------------------------- //
|
||||
|
||||
shadow_map* shadow_map_;
|
||||
camera_class* light_camera_;
|
||||
XMFLOAT4 light_position_buffer_;
|
||||
XMFLOAT3 light_rotation_buffer_;
|
||||
XMMATRIX light_view_matrix_;
|
||||
XMMATRIX light_projection_matrix_;
|
||||
ID3D11ShaderResourceView* shadow_srv_;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,33 +0,0 @@
|
||||
#pragma once
|
||||
#include <d3d11.h>
|
||||
|
||||
class shadow_map
|
||||
{
|
||||
public:
|
||||
|
||||
shadow_map();
|
||||
shadow_map(const shadow_map&) = delete;
|
||||
shadow_map& operator=(const shadow_map&) = delete;
|
||||
~shadow_map();
|
||||
|
||||
bool initialize(
|
||||
ID3D11Device* device,
|
||||
int shadow_map_width,
|
||||
int shadow_map_height
|
||||
);
|
||||
|
||||
void set_render_target(ID3D11DeviceContext* context);
|
||||
void clear_render_target(ID3D11DeviceContext* context, float depth);
|
||||
|
||||
ID3D11ShaderResourceView* get_shader_resource_view() const;
|
||||
|
||||
void shutdown();
|
||||
|
||||
private:
|
||||
ID3D11Texture2D* depth_texture_;
|
||||
ID3D11DepthStencilView* depth_stencil_view_;
|
||||
ID3D11ShaderResourceView* shader_resource_view_;
|
||||
D3D11_VIEWPORT viewport_;
|
||||
|
||||
|
||||
};
|
@ -1,224 +0,0 @@
|
||||
#include "depth_shader_class.h"
|
||||
|
||||
#include <d3dcompiler.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
depth_shader_class::depth_shader_class()
|
||||
{
|
||||
vertex_shader_ = nullptr;
|
||||
pixel_shader_ = nullptr;
|
||||
layout_ = nullptr;
|
||||
matrix_buffer_ = nullptr;
|
||||
}
|
||||
|
||||
depth_shader_class::~depth_shader_class()
|
||||
{
|
||||
shutdown();
|
||||
}
|
||||
|
||||
bool depth_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
|
||||
Logger::Get().Log("Initializing depth shader class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
// Charger et compiler les shaders (remplacez les chemins par les vôtres)
|
||||
bool result = initialize_shader(device, hwnd, L"src/hlsl/depth.vs", L"src/hlsl/depth.ps");
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to initialize depth shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Initialized depth shader class", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void depth_shader_class::shutdown()
|
||||
{
|
||||
shutdown_shader();
|
||||
}
|
||||
|
||||
bool depth_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix)
|
||||
{
|
||||
if (!set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix))
|
||||
return false;
|
||||
|
||||
render_shader(deviceContext, indexCount);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool depth_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, const WCHAR* vsFilename, const WCHAR* psFilename)
|
||||
{
|
||||
HRESULT result;
|
||||
ID3DBlob* vertexShaderBuffer = nullptr;
|
||||
ID3DBlob* pixelShaderBuffer = nullptr;
|
||||
ID3DBlob* errorMessage = nullptr;
|
||||
|
||||
// Compiler le vertex shader
|
||||
result = D3DCompileFromFile(vsFilename, nullptr, nullptr, "DepthVertexShader", "vs_5_0", 0, 0, &vertexShaderBuffer, &errorMessage);
|
||||
if (FAILED(result))
|
||||
{
|
||||
if (errorMessage)
|
||||
{
|
||||
output_shader_error_message(errorMessage, hwnd, vsFilename);
|
||||
errorMessage->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Fichier de vertex shader introuvable: " + std::to_string(reinterpret_cast<uintptr_t>(vsFilename)), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Compiler le pixel shader
|
||||
errorMessage = nullptr;
|
||||
result = D3DCompileFromFile(psFilename, nullptr, nullptr, "DepthPixelShader", "ps_5_0", 0, 0, &pixelShaderBuffer, &errorMessage);
|
||||
if (FAILED(result))
|
||||
{
|
||||
if (errorMessage)
|
||||
{
|
||||
output_shader_error_message(errorMessage, hwnd, psFilename);
|
||||
errorMessage->Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Fichier de pixel shader introuvable: " + std::to_string(reinterpret_cast<uintptr_t>(psFilename)), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
}
|
||||
|
||||
if (vertexShaderBuffer)
|
||||
{
|
||||
vertexShaderBuffer->Release();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Créer les shaders
|
||||
device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), nullptr, &vertex_shader_);
|
||||
device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), nullptr, &pixel_shader_);
|
||||
|
||||
// Définir la description du layout d'entrée
|
||||
D3D11_INPUT_ELEMENT_DESC polygonLayout[1];
|
||||
polygonLayout[0].SemanticName = "POSITION";
|
||||
polygonLayout[0].SemanticIndex = 0;
|
||||
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||
polygonLayout[0].InputSlot = 0;
|
||||
polygonLayout[0].AlignedByteOffset = 0;
|
||||
polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||
polygonLayout[0].InstanceDataStepRate = 0;
|
||||
|
||||
// Créer le layout
|
||||
device->CreateInputLayout(polygonLayout, 1, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
|
||||
// Libérer les buffers
|
||||
vertexShaderBuffer->Release();
|
||||
pixelShaderBuffer->Release();
|
||||
|
||||
// Créer le buffer de matrices
|
||||
D3D11_BUFFER_DESC matrixBufferDesc = {};
|
||||
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
matrixBufferDesc.ByteWidth = sizeof(MatrixBufferType);
|
||||
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
device->CreateBuffer(&matrixBufferDesc, nullptr, &matrix_buffer_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool depth_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix)
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
MatrixBufferType* dataPtr;
|
||||
|
||||
// Transposer les matrices pour le shader
|
||||
worldMatrix = XMMatrixTranspose(worldMatrix);
|
||||
viewMatrix = XMMatrixTranspose(viewMatrix);
|
||||
projectionMatrix = XMMatrixTranspose(projectionMatrix);
|
||||
|
||||
// Mapper le buffer
|
||||
HRESULT result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
return false;
|
||||
|
||||
dataPtr = (MatrixBufferType*)mappedResource.pData;
|
||||
dataPtr->world = worldMatrix;
|
||||
dataPtr->view = viewMatrix;
|
||||
dataPtr->projection = projectionMatrix;
|
||||
|
||||
deviceContext->Unmap(matrix_buffer_, 0);
|
||||
|
||||
// Définir le buffer de constantes pour le vertex shader
|
||||
deviceContext->VSSetConstantBuffers(0, 1, &matrix_buffer_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void depth_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||
{
|
||||
// Définir le layout d'entrée
|
||||
deviceContext->IASetInputLayout(layout_);
|
||||
|
||||
// Définir les shaders
|
||||
deviceContext->VSSetShader(vertex_shader_, nullptr, 0);
|
||||
deviceContext->PSSetShader(pixel_shader_, nullptr, 0);
|
||||
|
||||
// Dessiner
|
||||
deviceContext->DrawIndexed(indexCount, 0, 0);
|
||||
}
|
||||
|
||||
void depth_shader_class::shutdown_shader()
|
||||
{
|
||||
// Libérer le buffer de matrice
|
||||
if (matrix_buffer_)
|
||||
{
|
||||
matrix_buffer_->Release();
|
||||
matrix_buffer_ = nullptr;
|
||||
}
|
||||
|
||||
// Libérer le layout
|
||||
if (layout_)
|
||||
{
|
||||
layout_->Release();
|
||||
layout_ = nullptr;
|
||||
}
|
||||
|
||||
// Libérer le pixel shader
|
||||
if (pixel_shader_)
|
||||
{
|
||||
pixel_shader_->Release();
|
||||
pixel_shader_ = nullptr;
|
||||
}
|
||||
|
||||
// Libérer le vertex shader
|
||||
if (vertex_shader_)
|
||||
{
|
||||
vertex_shader_->Release();
|
||||
vertex_shader_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void depth_shader_class::output_shader_error_message(ID3DBlob* errorMessage, HWND hwnd, const WCHAR* shaderFilename)
|
||||
{
|
||||
// Obtenir un pointeur vers le message d'erreur
|
||||
char* compileErrors = (char*)(errorMessage->GetBufferPointer());
|
||||
|
||||
// Obtenir la taille du message
|
||||
SIZE_T bufferSize = errorMessage->GetBufferSize();
|
||||
|
||||
// Allouer de la mémoire pour le message d'erreur formaté
|
||||
char* message = new char[bufferSize + 100];
|
||||
|
||||
// Définir le message d'erreur formaté
|
||||
sprintf_s(message, bufferSize + 100, "Erreur de compilation du shader %ls :\n%s",
|
||||
shaderFilename, compileErrors);
|
||||
|
||||
// Afficher le message d'erreur dans la console
|
||||
Logger::Get().Log(message, __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
|
||||
// Afficher une boîte de dialogue avec l'erreur
|
||||
MessageBoxA(hwnd, message, "Erreur de Shader", MB_OK);
|
||||
|
||||
// Libérer la mémoire
|
||||
delete[] message;
|
||||
}
|
@ -149,14 +149,6 @@ bool shader_manager_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
return false;
|
||||
}
|
||||
|
||||
depth_shader_ = new depth_shader_class;
|
||||
result = depth_shader_->initialize(device, hwnd);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Error initializing depth_shader_class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
Logger::Get().Log("shader_manager_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
return true;
|
||||
@ -276,13 +268,6 @@ void shader_manager_class::shutdown()
|
||||
skybox_shader_ = 0;
|
||||
}
|
||||
|
||||
if (depth_shader_)
|
||||
{
|
||||
skybox_shader_->Shutdown();
|
||||
delete depth_shader_;
|
||||
depth_shader_ = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("shader_manager_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
}
|
||||
|
||||
@ -465,39 +450,12 @@ bool shader_manager_class::render_cel_shading_shader(ID3D11DeviceContext* device
|
||||
return true;
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_sunlight_shader(
|
||||
ID3D11DeviceContext* deviceContext,
|
||||
int indexCount,
|
||||
XMMATRIX worldMatrix,
|
||||
XMMATRIX viewMatrix,
|
||||
XMMATRIX projectionMatrix,
|
||||
ID3D11ShaderResourceView* texture,
|
||||
XMFLOAT4 diffuseColor,
|
||||
XMFLOAT4 ambientColor,
|
||||
XMFLOAT3 sunDirection,
|
||||
float sunIntensity,
|
||||
ID3D11ShaderResourceView* shadowMap,
|
||||
XMMATRIX lightViewMatrix,
|
||||
XMMATRIX lightProjectionMatrix
|
||||
)
|
||||
bool shader_manager_class::render_sunlight_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = sunlight_shader_->render(
|
||||
deviceContext,
|
||||
indexCount,
|
||||
worldMatrix,
|
||||
viewMatrix,
|
||||
projectionMatrix,
|
||||
texture,
|
||||
diffuseColor,
|
||||
ambientColor,
|
||||
sunDirection,
|
||||
sunIntensity,
|
||||
shadowMap,
|
||||
lightViewMatrix,
|
||||
lightProjectionMatrix
|
||||
);
|
||||
result = sunlight_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
@ -519,16 +477,3 @@ bool shader_manager_class::render_skybox_shader(ID3D11DeviceContext* deviceConte
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool shader_manager_class::render_depth_shader(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix)
|
||||
{
|
||||
bool result;
|
||||
|
||||
result = depth_shader_->render(deviceContext, indexCount, worldMatrix, viewMatrix, projectionMatrix);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -1,552 +1,462 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Filename: lightshaderclass.cpp
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include "sunlight_shader_class.h"
|
||||
|
||||
|
||||
sunlight_shader_class::sunlight_shader_class()
|
||||
{
|
||||
vertex_shader_ = nullptr;
|
||||
pixel_shader_ = nullptr;
|
||||
layout_ = nullptr;
|
||||
sample_state_ = nullptr;
|
||||
matrix_buffer_ = nullptr;
|
||||
camera_buffer_ = nullptr;
|
||||
sunlight_buffer_ = nullptr;
|
||||
sunlight_color_buffer_ = nullptr;
|
||||
sunlight_position_buffer_ = nullptr;
|
||||
light_view_matrix_buffer_ = nullptr;
|
||||
shadow_map_texture_ = nullptr;
|
||||
shadow_sampler_state_ = nullptr;
|
||||
vertex_shader_ = 0;
|
||||
pixel_shader_ = 0;
|
||||
layout_ = 0;
|
||||
sample_state_ = 0;
|
||||
matrix_buffer_ = 0;
|
||||
camera_buffer_ = 0;
|
||||
sunlight_buffer_ = 0;
|
||||
sunlight_color_buffer_ = 0;
|
||||
sunlight_position_buffer_ = 0;
|
||||
}
|
||||
|
||||
sunlight_shader_class::sunlight_shader_class(const sunlight_shader_class&)
|
||||
|
||||
sunlight_shader_class::sunlight_shader_class(const sunlight_shader_class& other)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
sunlight_shader_class::~sunlight_shader_class()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool sunlight_shader_class::initialize(ID3D11Device* device, HWND hwnd)
|
||||
{
|
||||
bool result;
|
||||
WCHAR vs_filename[128];
|
||||
WCHAR ps_filename[128];
|
||||
Logger::Get().Log("Initializing LightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
// Définir les fichiers des shaders vertex et pixel
|
||||
wcscpy_s(vs_filename, 128, L"./src/hlsl/sunlight.vs");
|
||||
wcscpy_s(ps_filename, 128, L"./src/hlsl/sunlight.ps");
|
||||
wchar_t vsFilename[128];
|
||||
wchar_t psFilename[128];
|
||||
int error;
|
||||
bool result;
|
||||
|
||||
// Initialiser les shaders
|
||||
result = initialize_shader(device, hwnd, vs_filename, ps_filename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Échec d'initialisation des shaders sunlight", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Set the filename of the vertex shader.
|
||||
error = wcscpy_s(vsFilename, 128, L"src/hlsl/sunlight.vs");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
// Set the filename of the pixel shader.
|
||||
error = wcscpy_s(psFilename, 128, L"src/hlsl/sunlight.ps");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to copy string", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// initialize the vertex and pixel shaders.
|
||||
result = initialize_shader(device, hwnd, vsFilename, psFilename);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to initialize shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
Logger::Get().Log("SunLightShaderClass initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void sunlight_shader_class::shutdown()
|
||||
{
|
||||
shutdown_shader();
|
||||
return;
|
||||
// shutdown the vertex and pixel shaders as well as the related objects.
|
||||
shutdown_shader();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool sunlight_shader_class::render(ID3D11DeviceContext* device_context, int index_count, XMMATRIX world_matrix, XMMATRIX view_matrix, XMMATRIX projection_matrix, ID3D11ShaderResourceView* texture, XMFLOAT4 diffuse_color, XMFLOAT4 ambient_color, XMFLOAT3 sun_direction, float sun_intensity, ID3D11ShaderResourceView* shadow_map, XMMATRIX light_view_matrix, XMMATRIX light_projection_matrix)
|
||||
bool sunlight_shader_class::render(ID3D11DeviceContext* deviceContext, int indexCount, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix,
|
||||
ID3D11ShaderResourceView* texture, XMFLOAT4 diffuseColor, XMFLOAT4 ambientColor, XMFLOAT3 sunDirection, float sunIntensity)
|
||||
{
|
||||
bool result;
|
||||
bool result;
|
||||
|
||||
// Définir les paramètres du shader
|
||||
result = set_shader_parameters(device_context, world_matrix, view_matrix, projection_matrix, texture, diffuse_color, ambient_color, sun_direction, sun_intensity, shadow_map, light_view_matrix, light_projection_matrix);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Échec de définition des paramètres du shader sunlight", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Rendre le shader
|
||||
render_shader(device_context, index_count);
|
||||
// Set the shader parameters that it will use for rendering.
|
||||
result = set_shader_parameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture, diffuseColor, ambientColor, sunDirection, sunIntensity);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to set shader parameters", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
// Now render the prepared buffers with the shader.
|
||||
render_shader(deviceContext, indexCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vs_filename, WCHAR* ps_filename)
|
||||
|
||||
bool sunlight_shader_class::initialize_shader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
|
||||
{
|
||||
HRESULT result;
|
||||
ID3D10Blob* error_message = nullptr;
|
||||
ID3D10Blob* vertex_shader_buffer = nullptr;
|
||||
ID3D10Blob* pixel_shader_buffer = nullptr;
|
||||
D3D11_INPUT_ELEMENT_DESC polygon_layout[3];
|
||||
unsigned int num_elements;
|
||||
D3D11_BUFFER_DESC matrix_buffer_desc;
|
||||
D3D11_BUFFER_DESC camera_buffer_desc;
|
||||
D3D11_BUFFER_DESC light_buffer_desc;
|
||||
D3D11_BUFFER_DESC light_color_buffer_desc;
|
||||
D3D11_BUFFER_DESC light_view_matrix_buffer_desc;
|
||||
D3D11_SAMPLER_DESC sampler_desc;
|
||||
D3D11_SAMPLER_DESC shadow_sampler_desc;
|
||||
Logger::Get().Log("Initializing shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
// Compiler le vertex shader
|
||||
result = D3DCompileFromFile(vs_filename, NULL, NULL, "SunLightVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &vertex_shader_buffer, &error_message);
|
||||
if (FAILED(result))
|
||||
{
|
||||
if (error_message)
|
||||
{
|
||||
output_shader_error_message(error_message, hwnd, vs_filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(hwnd, vs_filename, L"Fichier shader manquant", MB_OK);
|
||||
}
|
||||
HRESULT result;
|
||||
ID3D10Blob* errorMessage;
|
||||
ID3D10Blob* vertexShaderBuffer;
|
||||
ID3D10Blob* pixelShaderBuffer;
|
||||
D3D11_INPUT_ELEMENT_DESC polygonLayout[3];
|
||||
unsigned int numElements;
|
||||
D3D11_SAMPLER_DESC samplerDesc;
|
||||
D3D11_BUFFER_DESC matrixBufferDesc;
|
||||
D3D11_BUFFER_DESC sunlightBufferDesc;
|
||||
|
||||
return false;
|
||||
}
|
||||
// initialize the pointers this function will use to null.
|
||||
errorMessage = 0;
|
||||
vertexShaderBuffer = 0;
|
||||
pixelShaderBuffer = 0;
|
||||
|
||||
// Compiler le pixel shader
|
||||
result = D3DCompileFromFile(ps_filename, NULL, NULL, "SunLightPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &pixel_shader_buffer, &error_message);
|
||||
if (FAILED(result))
|
||||
{
|
||||
if (error_message)
|
||||
{
|
||||
output_shader_error_message(error_message, hwnd, ps_filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(hwnd, ps_filename, L"Fichier shader manquant", MB_OK);
|
||||
}
|
||||
// Compile the vertex shader code.
|
||||
result = D3DCompileFromFile(vsFilename, NULL, NULL, "SunLightVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &vertexShaderBuffer, &errorMessage);
|
||||
if (FAILED(result))
|
||||
{
|
||||
if (errorMessage)
|
||||
{
|
||||
output_shader_error_message(errorMessage, hwnd, vsFilename);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// Compile the pixel shader code.
|
||||
result = D3DCompileFromFile(psFilename, NULL, NULL, "SunLightPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, &pixelShaderBuffer, &errorMessage);
|
||||
if (FAILED(result))
|
||||
{
|
||||
if (errorMessage)
|
||||
{
|
||||
output_shader_error_message(errorMessage, hwnd, psFilename);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to compile shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Créer le vertex shader à partir du buffer
|
||||
result = device->CreateVertexShader(vertex_shader_buffer->GetBufferPointer(), vertex_shader_buffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec de création du vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Create the vertex shader from the buffer.
|
||||
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertex_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Créer le pixel shader à partir du buffer
|
||||
result = device->CreatePixelShader(pixel_shader_buffer->GetBufferPointer(), pixel_shader_buffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec de création du pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Create the pixel shader from the buffer.
|
||||
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &pixel_shader_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Créer le layout d'entrée du vertex shader
|
||||
polygon_layout[0].SemanticName = "POSITION";
|
||||
polygon_layout[0].SemanticIndex = 0;
|
||||
polygon_layout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||
polygon_layout[0].InputSlot = 0;
|
||||
polygon_layout[0].AlignedByteOffset = 0;
|
||||
polygon_layout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||
polygon_layout[0].InstanceDataStepRate = 0;
|
||||
// Create the vertex input layout description.
|
||||
polygonLayout[0].SemanticName = "POSITION";
|
||||
polygonLayout[0].SemanticIndex = 0;
|
||||
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||
polygonLayout[0].InputSlot = 0;
|
||||
polygonLayout[0].AlignedByteOffset = 0;
|
||||
polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||
polygonLayout[0].InstanceDataStepRate = 0;
|
||||
|
||||
polygon_layout[1].SemanticName = "TEXCOORD";
|
||||
polygon_layout[1].SemanticIndex = 0;
|
||||
polygon_layout[1].Format = DXGI_FORMAT_R32G32_FLOAT;
|
||||
polygon_layout[1].InputSlot = 0;
|
||||
polygon_layout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
|
||||
polygon_layout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||
polygon_layout[1].InstanceDataStepRate = 0;
|
||||
polygonLayout[1].SemanticName = "TEXCOORD";
|
||||
polygonLayout[1].SemanticIndex = 0;
|
||||
polygonLayout[1].Format = DXGI_FORMAT_R32G32_FLOAT;
|
||||
polygonLayout[1].InputSlot = 0;
|
||||
polygonLayout[1].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
|
||||
polygonLayout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||
polygonLayout[1].InstanceDataStepRate = 0;
|
||||
|
||||
polygon_layout[2].SemanticName = "NORMAL";
|
||||
polygon_layout[2].SemanticIndex = 0;
|
||||
polygon_layout[2].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||
polygon_layout[2].InputSlot = 0;
|
||||
polygon_layout[2].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
|
||||
polygon_layout[2].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||
polygon_layout[2].InstanceDataStepRate = 0;
|
||||
polygonLayout[2].SemanticName = "NORMAL";
|
||||
polygonLayout[2].SemanticIndex = 0;
|
||||
polygonLayout[2].Format = DXGI_FORMAT_R32G32B32_FLOAT;
|
||||
polygonLayout[2].InputSlot = 0;
|
||||
polygonLayout[2].AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
|
||||
polygonLayout[2].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||
polygonLayout[2].InstanceDataStepRate = 0;
|
||||
|
||||
// Obtenir le nombre d'éléments dans le layout
|
||||
num_elements = sizeof(polygon_layout) / sizeof(polygon_layout[0]);
|
||||
// Get a count of the elements in the layout.
|
||||
numElements = sizeof(polygonLayout) / sizeof(polygonLayout[0]);
|
||||
|
||||
// Créer le layout d'entrée du vertex
|
||||
result = device->CreateInputLayout(polygon_layout, num_elements, vertex_shader_buffer->GetBufferPointer(), vertex_shader_buffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec de création du layout d'entrée", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Create the vertex input layout.
|
||||
result = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &layout_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Libérer les buffers des shaders
|
||||
vertex_shader_buffer->Release();
|
||||
vertex_shader_buffer = nullptr;
|
||||
// Release the vertex shader buffer and pixel shader buffer since they are no longer needed.
|
||||
vertexShaderBuffer->Release();
|
||||
vertexShaderBuffer = 0;
|
||||
|
||||
pixel_shader_buffer->Release();
|
||||
pixel_shader_buffer = nullptr;
|
||||
pixelShaderBuffer->Release();
|
||||
pixelShaderBuffer = 0;
|
||||
|
||||
// Configurer les descripteurs des buffers constants
|
||||
// Descripteur du buffer de matrices
|
||||
matrix_buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
matrix_buffer_desc.ByteWidth = sizeof(matrix_buffer_type);
|
||||
matrix_buffer_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
matrix_buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
matrix_buffer_desc.MiscFlags = 0;
|
||||
matrix_buffer_desc.StructureByteStride = 0;
|
||||
// Create a texture sampler state description.
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 1;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
|
||||
// Créer le buffer constant de matrices
|
||||
result = device->CreateBuffer(&matrix_buffer_desc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec de création du buffer constant de matrices", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Create the texture sampler state.
|
||||
result = device->CreateSamplerState(&samplerDesc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Descripteur du buffer de caméra
|
||||
camera_buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
camera_buffer_desc.ByteWidth = sizeof(camera_buffer_type);
|
||||
camera_buffer_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
camera_buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
camera_buffer_desc.MiscFlags = 0;
|
||||
camera_buffer_desc.StructureByteStride = 0;
|
||||
// Setup the description of the dynamic matrix constant buffer that is in the vertex shader.
|
||||
matrixBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
matrixBufferDesc.ByteWidth = sizeof(matrix_buffer_type);
|
||||
matrixBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
matrixBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
matrixBufferDesc.MiscFlags = 0;
|
||||
matrixBufferDesc.StructureByteStride = 0;
|
||||
|
||||
// Créer le buffer constant de caméra
|
||||
result = device->CreateBuffer(&camera_buffer_desc, NULL, &camera_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec de création du buffer constant de caméra", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Create the constant buffer pointer so we can access the vertex shader constant buffer from within this class.
|
||||
result = device->CreateBuffer(&matrixBufferDesc, NULL, &matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create matrix buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Descripteur du buffer de lumière du soleil
|
||||
light_buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
light_buffer_desc.ByteWidth = sizeof(sun_light_buffer_type);
|
||||
light_buffer_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
light_buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
light_buffer_desc.MiscFlags = 0;
|
||||
light_buffer_desc.StructureByteStride = 0;
|
||||
// Setup the description of the dynamic sunlight constant buffer that is in the pixel shader.
|
||||
sunlightBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
sunlightBufferDesc.ByteWidth = sizeof(sun_light_buffer_type);
|
||||
sunlightBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
sunlightBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
sunlightBufferDesc.MiscFlags = 0;
|
||||
sunlightBufferDesc.StructureByteStride = 0;
|
||||
|
||||
// Créer le buffer constant de lumière du soleil
|
||||
result = device->CreateBuffer(&light_buffer_desc, NULL, &sunlight_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec de création du buffer constant de lumière du soleil", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Create the constant buffer pointer so we can access the pixel shader constant buffer from within this class.
|
||||
result = device->CreateBuffer(&sunlightBufferDesc, NULL, &sunlight_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create sunlight buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Descripteur du buffer de couleur de lumière du soleil
|
||||
light_color_buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
light_color_buffer_desc.ByteWidth = sizeof(sun_light_color_buffer_type);
|
||||
light_color_buffer_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
light_color_buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
light_color_buffer_desc.MiscFlags = 0;
|
||||
light_color_buffer_desc.StructureByteStride = 0;
|
||||
Logger::Get().Log("Shader initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
// Créer le buffer constant de couleur de lumière du soleil
|
||||
result = device->CreateBuffer(&light_color_buffer_desc, NULL, &sunlight_color_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec de création du buffer constant de couleur de lumière du soleil", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Descripteur du buffer de matrices de vue de lumière
|
||||
light_view_matrix_buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
light_view_matrix_buffer_desc.ByteWidth = sizeof(light_view_matrix_buffer_type);
|
||||
light_view_matrix_buffer_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
light_view_matrix_buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
light_view_matrix_buffer_desc.MiscFlags = 0;
|
||||
light_view_matrix_buffer_desc.StructureByteStride = 0;
|
||||
|
||||
// Créer le buffer constant de matrices de vue de lumière
|
||||
result = device->CreateBuffer(&light_view_matrix_buffer_desc, NULL, &light_view_matrix_buffer_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec de création du buffer constant de matrices de vue de lumière", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Créer un sampler state pour la texture
|
||||
sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
sampler_desc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sampler_desc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sampler_desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
sampler_desc.MipLODBias = 0.0f;
|
||||
sampler_desc.MaxAnisotropy = 1;
|
||||
sampler_desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
||||
sampler_desc.BorderColor[0] = 0;
|
||||
sampler_desc.BorderColor[1] = 0;
|
||||
sampler_desc.BorderColor[2] = 0;
|
||||
sampler_desc.BorderColor[3] = 0;
|
||||
sampler_desc.MinLOD = 0;
|
||||
sampler_desc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
|
||||
// Créer le sampler state
|
||||
result = device->CreateSamplerState(&sampler_desc, &sample_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec de création du sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Créer un sampler state pour la shadow map
|
||||
shadow_sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
shadow_sampler_desc.AddressU = D3D11_TEXTURE_ADDRESS_BORDER;
|
||||
shadow_sampler_desc.AddressV = D3D11_TEXTURE_ADDRESS_BORDER;
|
||||
shadow_sampler_desc.AddressW = D3D11_TEXTURE_ADDRESS_BORDER;
|
||||
shadow_sampler_desc.MipLODBias = 0.0f;
|
||||
shadow_sampler_desc.MaxAnisotropy = 1;
|
||||
shadow_sampler_desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
||||
shadow_sampler_desc.BorderColor[0] = 1.0f;
|
||||
shadow_sampler_desc.BorderColor[1] = 1.0f;
|
||||
shadow_sampler_desc.BorderColor[2] = 1.0f;
|
||||
shadow_sampler_desc.BorderColor[3] = 1.0f;
|
||||
shadow_sampler_desc.MinLOD = 0;
|
||||
shadow_sampler_desc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
|
||||
// Créer le sampler state pour la shadow map
|
||||
result = device->CreateSamplerState(&shadow_sampler_desc, &shadow_sampler_state_);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec de création du sampler state pour la shadow map", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void sunlight_shader_class::shutdown_shader()
|
||||
{
|
||||
// Libérer tous les objets
|
||||
if (shadow_sampler_state_)
|
||||
{
|
||||
shadow_sampler_state_->Release();
|
||||
shadow_sampler_state_ = nullptr;
|
||||
}
|
||||
Logger::Get().Log("Shutting down SunLightShaderClass", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
|
||||
if (light_view_matrix_buffer_)
|
||||
{
|
||||
light_view_matrix_buffer_->Release();
|
||||
light_view_matrix_buffer_ = nullptr;
|
||||
}
|
||||
// Release the light constant buffers.
|
||||
if (sunlight_color_buffer_)
|
||||
{
|
||||
sunlight_color_buffer_->Release();
|
||||
sunlight_color_buffer_ = 0;
|
||||
}
|
||||
|
||||
if (sunlight_color_buffer_)
|
||||
{
|
||||
sunlight_color_buffer_->Release();
|
||||
sunlight_color_buffer_ = nullptr;
|
||||
}
|
||||
if (sunlight_position_buffer_)
|
||||
{
|
||||
sunlight_position_buffer_->Release();
|
||||
sunlight_position_buffer_ = 0;
|
||||
}
|
||||
|
||||
if (sunlight_buffer_)
|
||||
{
|
||||
sunlight_buffer_->Release();
|
||||
sunlight_buffer_ = nullptr;
|
||||
}
|
||||
// Release the light constant buffer.
|
||||
if (sunlight_buffer_)
|
||||
{
|
||||
sunlight_buffer_->Release();
|
||||
sunlight_buffer_ = 0;
|
||||
}
|
||||
|
||||
if (camera_buffer_)
|
||||
{
|
||||
camera_buffer_->Release();
|
||||
camera_buffer_ = nullptr;
|
||||
}
|
||||
// Release the camera constant buffer.
|
||||
if (camera_buffer_)
|
||||
{
|
||||
camera_buffer_->Release();
|
||||
camera_buffer_ = 0;
|
||||
}
|
||||
|
||||
if (matrix_buffer_)
|
||||
{
|
||||
matrix_buffer_->Release();
|
||||
matrix_buffer_ = nullptr;
|
||||
}
|
||||
// Release the matrix constant buffer.
|
||||
if (matrix_buffer_)
|
||||
{
|
||||
matrix_buffer_->Release();
|
||||
matrix_buffer_ = 0;
|
||||
}
|
||||
|
||||
if (sample_state_)
|
||||
{
|
||||
sample_state_->Release();
|
||||
sample_state_ = nullptr;
|
||||
}
|
||||
// Release the sampler state.
|
||||
if (sample_state_)
|
||||
{
|
||||
sample_state_->Release();
|
||||
sample_state_ = 0;
|
||||
}
|
||||
|
||||
if (layout_)
|
||||
{
|
||||
layout_->Release();
|
||||
layout_ = nullptr;
|
||||
}
|
||||
// Release the layout.
|
||||
if (layout_)
|
||||
{
|
||||
layout_->Release();
|
||||
layout_ = 0;
|
||||
}
|
||||
|
||||
if (pixel_shader_)
|
||||
{
|
||||
pixel_shader_->Release();
|
||||
pixel_shader_ = nullptr;
|
||||
}
|
||||
// Release the pixel shader.
|
||||
if (pixel_shader_)
|
||||
{
|
||||
pixel_shader_->Release();
|
||||
pixel_shader_ = 0;
|
||||
}
|
||||
|
||||
if (vertex_shader_)
|
||||
{
|
||||
vertex_shader_->Release();
|
||||
vertex_shader_ = nullptr;
|
||||
}
|
||||
// Release the vertex shader.
|
||||
if (vertex_shader_)
|
||||
{
|
||||
vertex_shader_->Release();
|
||||
vertex_shader_ = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
Logger::Get().Log("SunLightShaderClass shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void sunlight_shader_class::output_shader_error_message(ID3D10Blob* error_message, HWND hwnd, WCHAR* shader_filename)
|
||||
|
||||
void sunlight_shader_class::output_shader_error_message(ID3D10Blob* errorMessage, HWND hwnd, WCHAR* shaderFilename)
|
||||
{
|
||||
char* compile_errors;
|
||||
unsigned long long buffer_size;
|
||||
ofstream fout;
|
||||
char* compileErrors;
|
||||
unsigned __int64 bufferSize, i;
|
||||
ofstream fout;
|
||||
|
||||
// Obtenir un pointeur vers le texte d'erreur dans le buffer d'erreur
|
||||
compile_errors = (char*)(error_message->GetBufferPointer());
|
||||
|
||||
// Obtenir la taille du message
|
||||
buffer_size = error_message->GetBufferSize();
|
||||
// Get a pointer to the error message text buffer.
|
||||
compileErrors = (char*)(errorMessage->GetBufferPointer());
|
||||
|
||||
// Ouvrir un fichier pour écrire les messages d'erreur
|
||||
fout.open("shader-error.txt");
|
||||
// Get the length of the message.
|
||||
bufferSize = errorMessage->GetBufferSize();
|
||||
|
||||
// Écrire le message d'erreur
|
||||
for (unsigned long long i = 0; i < buffer_size; i++)
|
||||
{
|
||||
fout << compile_errors[i];
|
||||
}
|
||||
// Open a file to write the error message to.
|
||||
fout.open("shader-error.txt");
|
||||
|
||||
// Fermer le fichier
|
||||
fout.close();
|
||||
// Write out the error message.
|
||||
for (i = 0; i < bufferSize; i++)
|
||||
{
|
||||
fout << compileErrors[i];
|
||||
}
|
||||
|
||||
// Libérer le buffer d'erreur
|
||||
error_message->Release();
|
||||
error_message = nullptr;
|
||||
// Close the file.
|
||||
fout.close();
|
||||
|
||||
// Afficher un message d'erreur
|
||||
MessageBox(hwnd, L"Erreur de compilation du shader. Voir shader-error.txt pour plus de détails.", shader_filename, MB_OK);
|
||||
// Release the error message.
|
||||
errorMessage->Release();
|
||||
errorMessage = 0;
|
||||
|
||||
return;
|
||||
// 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);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool sunlight_shader_class::set_shader_parameters(ID3D11DeviceContext* device_context, XMMATRIX world_matrix, XMMATRIX view_matrix, XMMATRIX projection_matrix, ID3D11ShaderResourceView* texture, XMFLOAT4 diffuse_color, XMFLOAT4 ambient_color, XMFLOAT3 sun_direction, float sun_intensity, ID3D11ShaderResourceView* shadow_map, XMMATRIX light_view_matrix, XMMATRIX light_projection_matrix)
|
||||
|
||||
bool sunlight_shader_class::set_shader_parameters(ID3D11DeviceContext* deviceContext, XMMATRIX worldMatrix, XMMATRIX viewMatrix, XMMATRIX projectionMatrix, ID3D11ShaderResourceView* texture, XMFLOAT4 ambientColor, XMFLOAT4 diffuseColor, XMFLOAT3 lightDirection, float sunIntensity)
|
||||
{
|
||||
HRESULT result;
|
||||
D3D11_MAPPED_SUBRESOURCE mapped_resource;
|
||||
matrix_buffer_type* data_ptr;
|
||||
camera_buffer_type* camera_data_ptr;
|
||||
sun_light_buffer_type* light_data_ptr;
|
||||
sun_light_color_buffer_type* light_color_data_ptr;
|
||||
light_view_matrix_buffer_type* light_view_data_ptr;
|
||||
HRESULT result;
|
||||
D3D11_MAPPED_SUBRESOURCE mappedResource;
|
||||
matrix_buffer_type* dataPtr;
|
||||
camera_buffer_type* dataPtr2;
|
||||
sun_light_buffer_type* dataPtr3;
|
||||
unsigned int bufferNumber;
|
||||
|
||||
// Transposer les matrices pour qu'elles soient prêtes pour le shader
|
||||
world_matrix = XMMatrixTranspose(world_matrix);
|
||||
view_matrix = XMMatrixTranspose(view_matrix);
|
||||
projection_matrix = XMMatrixTranspose(projection_matrix);
|
||||
light_view_matrix = XMMatrixTranspose(light_view_matrix);
|
||||
light_projection_matrix = XMMatrixTranspose(light_projection_matrix);
|
||||
// Transpose the matrices to prepare them for the shader.
|
||||
worldMatrix = XMMatrixTranspose(worldMatrix);
|
||||
viewMatrix = XMMatrixTranspose(viewMatrix);
|
||||
projectionMatrix = XMMatrixTranspose(projectionMatrix);
|
||||
|
||||
// Verrouiller le buffer constant pour l'écriture
|
||||
result = device_context->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec du verrouillage du buffer constant de matrices", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Lock the constant buffer so it can be written to.
|
||||
result = deviceContext->Map(matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Obtenir un pointeur vers les données
|
||||
data_ptr = (matrix_buffer_type*)mapped_resource.pData;
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
dataPtr = (matrix_buffer_type*)mappedResource.pData;
|
||||
|
||||
// Copier les matrices dans le buffer constant
|
||||
data_ptr->world = world_matrix;
|
||||
data_ptr->view = view_matrix;
|
||||
data_ptr->projection = projection_matrix;
|
||||
// Copy the matrices into the constant buffer.
|
||||
dataPtr->world = worldMatrix;
|
||||
dataPtr->view = viewMatrix;
|
||||
dataPtr->projection = projectionMatrix;
|
||||
|
||||
// Déverrouiller le buffer constant
|
||||
device_context->Unmap(matrix_buffer_, 0);
|
||||
// Unlock the constant buffer.
|
||||
deviceContext->Unmap(matrix_buffer_, 0);
|
||||
|
||||
// Définir la position du buffer constant dans le vertex shader
|
||||
unsigned int buffer_number = 0;
|
||||
// Set the position of the constant buffer in the vertex shader.
|
||||
bufferNumber = 0;
|
||||
|
||||
// Définir le buffer constant du vertex shader
|
||||
device_context->VSSetConstantBuffers(buffer_number, 1, &matrix_buffer_);
|
||||
// Finally set the constant buffer in the vertex shader with the updated values.
|
||||
deviceContext->VSSetConstantBuffers(bufferNumber, 1, &matrix_buffer_);
|
||||
|
||||
// Verrouiller le buffer constant de caméra
|
||||
result = device_context->Map(camera_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec du verrouillage du buffer constant de caméra", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Lock the sunlight constant buffer so it can be written to.
|
||||
result = deviceContext->Map(sunlight_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Obtenir un pointeur vers les données
|
||||
camera_data_ptr = (camera_buffer_type*)mapped_resource.pData;
|
||||
// Get a pointer to the data in the constant buffer.
|
||||
dataPtr3 = (sun_light_buffer_type*)mappedResource.pData;
|
||||
|
||||
// TODO: Ajouter la position de la caméra ici si nécessaire
|
||||
camera_data_ptr->camera_position = XMFLOAT3(0.0f, 0.0f, 0.0f);
|
||||
camera_data_ptr->padding = 0.0f;
|
||||
// Copy the lighting variables into the constant buffer.
|
||||
dataPtr3->ambient_color = ambientColor;
|
||||
dataPtr3->diffuse_color = diffuseColor;
|
||||
dataPtr3->sun_direction = lightDirection;
|
||||
dataPtr3->intensity = sunIntensity;
|
||||
|
||||
// Déverrouiller le buffer constant
|
||||
device_context->Unmap(camera_buffer_, 0);
|
||||
// Unlock the constant buffer.
|
||||
deviceContext->Unmap(sunlight_buffer_, 0);
|
||||
|
||||
// Définir la position du buffer constant dans le vertex shader
|
||||
buffer_number = 1;
|
||||
// Set the position of the sunlight constant buffer in the pixel shader.
|
||||
bufferNumber = 0;
|
||||
|
||||
// Définir le buffer constant du vertex shader
|
||||
device_context->VSSetConstantBuffers(buffer_number, 1, &camera_buffer_);
|
||||
// Finally set the sunlight constant buffer in the pixel shader with the updated values.
|
||||
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &sunlight_buffer_);
|
||||
|
||||
// Verrouiller le buffer constant de lumière
|
||||
result = device_context->Map(sunlight_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec du verrouillage du buffer constant de lumière", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Set shader texture resource in the pixel shader.
|
||||
deviceContext->PSSetShaderResources(0, 1, &texture);
|
||||
|
||||
// Obtenir un pointeur vers les données
|
||||
light_data_ptr = (sun_light_buffer_type*)mapped_resource.pData;
|
||||
|
||||
// Copier les paramètres de lumière dans le buffer constant
|
||||
light_data_ptr->ambient_color = ambient_color;
|
||||
light_data_ptr->diffuse_color = diffuse_color;
|
||||
light_data_ptr->sun_direction = sun_direction;
|
||||
light_data_ptr->intensity = sun_intensity;
|
||||
|
||||
// Déverrouiller le buffer constant
|
||||
device_context->Unmap(sunlight_buffer_, 0);
|
||||
|
||||
// Définir la position du buffer constant dans le pixel shader
|
||||
buffer_number = 0;
|
||||
|
||||
// Définir le buffer constant du pixel shader
|
||||
device_context->PSSetConstantBuffers(buffer_number, 1, &sunlight_buffer_);
|
||||
device_context->VSSetConstantBuffers(buffer_number, 1, &sunlight_buffer_);
|
||||
|
||||
// Verrouiller le buffer constant de matrices de vue de lumière
|
||||
result = device_context->Map(light_view_matrix_buffer_, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Échec du verrouillage du buffer constant de matrices de vue de lumière", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Obtenir un pointeur vers les données
|
||||
light_view_data_ptr = (light_view_matrix_buffer_type*)mapped_resource.pData;
|
||||
|
||||
// Copier les matrices de vue de lumière dans le buffer constant
|
||||
light_view_data_ptr->light_view = light_view_matrix;
|
||||
light_view_data_ptr->light_projection = light_projection_matrix;
|
||||
|
||||
// Déverrouiller le buffer constant
|
||||
device_context->Unmap(light_view_matrix_buffer_, 0);
|
||||
|
||||
// Définir la position du buffer constant dans le vertex shader
|
||||
buffer_number = 2;
|
||||
|
||||
// Définir le buffer constant du vertex shader
|
||||
device_context->VSSetConstantBuffers(buffer_number, 1, &light_view_matrix_buffer_);
|
||||
|
||||
// Définir la ressource de texture du shader
|
||||
device_context->PSSetShaderResources(0, 1, &texture);
|
||||
|
||||
// Définir la ressource de shadow map du shader
|
||||
device_context->PSSetShaderResources(1, 1, &shadow_map);
|
||||
|
||||
// Définir les sampler states dans le pixel shader
|
||||
device_context->PSSetSamplers(0, 1, &sample_state_);
|
||||
device_context->PSSetSamplers(1, 1, &shadow_sampler_state_);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void sunlight_shader_class::render_shader(ID3D11DeviceContext* device_context, int index_count)
|
||||
void sunlight_shader_class::render_shader(ID3D11DeviceContext* deviceContext, int indexCount)
|
||||
{
|
||||
// Définir le layout du vertex input
|
||||
device_context->IASetInputLayout(layout_);
|
||||
// Set the vertex input layout.
|
||||
deviceContext->IASetInputLayout(layout_);
|
||||
|
||||
// Définir les shaders vertex et pixel
|
||||
device_context->VSSetShader(vertex_shader_, NULL, 0);
|
||||
device_context->PSSetShader(pixel_shader_, NULL, 0);
|
||||
// Set the vertex and pixel shaders that will be used to render this triangle.
|
||||
deviceContext->VSSetShader(vertex_shader_, NULL, 0);
|
||||
deviceContext->PSSetShader(pixel_shader_, NULL, 0);
|
||||
|
||||
// Rendre la géométrie
|
||||
device_context->DrawIndexed(index_count, 0, 0);
|
||||
// Set the sampler state in the pixel shader.
|
||||
deviceContext->PSSetSamplers(0, 1, &sample_state_);
|
||||
|
||||
return;
|
||||
}
|
||||
// render the triangle.
|
||||
deviceContext->DrawIndexed(indexCount, 0, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -126,14 +126,6 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
camera_->set_rotation(0.0f, 0.0f, 0.0f);
|
||||
camera_->render();
|
||||
camera_->get_view_matrix(base_view_matrix_);
|
||||
|
||||
// create the ligth camera
|
||||
light_camera_ = new camera_class;
|
||||
if (!light_camera_)
|
||||
{
|
||||
Logger::Get().Log("Could not create the light camera object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create and initialize the font shader object.
|
||||
font_shader_ = new font_shader_class;
|
||||
@ -473,13 +465,6 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
return false;
|
||||
}
|
||||
|
||||
shadow_map_ = new shadow_map();
|
||||
if (!shadow_map_->initialize(direct_3d_->get_device(), screenWidth, screenHeight))
|
||||
{
|
||||
Logger::Get().Log("Could not create the shadow map object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
physics_ = new physics;
|
||||
|
||||
physics_thread_ = std::thread(&application_class::physics_thread_function, this);
|
||||
@ -508,12 +493,6 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
void application_class::shutdown()
|
||||
{
|
||||
Logger::Get().Log("Shutting down application class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
|
||||
if (shadow_map_) {
|
||||
shadow_map_->shutdown();
|
||||
delete shadow_map_;
|
||||
shadow_map_ = nullptr;
|
||||
}
|
||||
|
||||
// Release the shader manager object.
|
||||
if (shader_manager_)
|
||||
@ -1039,11 +1018,11 @@ bool application_class::render(float rotation, float x, float y, float z, float
|
||||
// Redimensionner la texture de rendu si nécessaire
|
||||
if (DEBUG_MODE)
|
||||
{
|
||||
// if ((float)scene_texture_->GetTextureWidth() != window_size_.x || (float)scene_texture_->GetTextureHeight() != window_size_.y)
|
||||
// {
|
||||
// scene_texture_->Shutdown();
|
||||
// scene_texture_->Initialize(direct_3d_->get_device(), (int)window_size_.x, (int)window_size_.y, screen_depth, screen_near, 1);
|
||||
// }
|
||||
if ((float)scene_texture_->GetTextureWidth() != window_size_.x || (float)scene_texture_->GetTextureHeight() != window_size_.y)
|
||||
{
|
||||
scene_texture_->Shutdown();
|
||||
scene_texture_->Initialize(direct_3d_->get_device(), (int)window_size_.x, (int)window_size_.y, screen_depth, screen_near, 1);
|
||||
}
|
||||
|
||||
direct_3d_->set_back_buffer_render_target();
|
||||
direct_3d_->reset_viewport();
|
||||
@ -1074,51 +1053,9 @@ bool application_class::render(float rotation, float x, float y, float z, float
|
||||
|
||||
direct_3d_->turn_z_buffer_on(); // Enable the Z buffer after rendering the skybox.
|
||||
|
||||
|
||||
// --------------------------------------------------------- //
|
||||
// ------------------ shadow map creation ------------------ //
|
||||
// --------------------------------------------------------- //
|
||||
|
||||
shadow_map_->set_render_target(direct_3d_->get_device_context());
|
||||
shadow_map_->clear_render_target(direct_3d_->get_device_context(), 1.0f);
|
||||
|
||||
// Configuration de la caméra de lumière
|
||||
light_position_buffer_ = sun_light_->GetPosition();
|
||||
light_rotation_buffer_ = sun_light_->GetDirection();
|
||||
|
||||
// Positionnez la caméra de lumière à une position appropriée pour votre scène
|
||||
float lightDistance = 100.0f;
|
||||
light_camera_->set_position(-light_rotation_buffer_.x * lightDistance, -light_rotation_buffer_.y * lightDistance, -light_rotation_buffer_.z * lightDistance);
|
||||
light_camera_->set_rotation(light_rotation_buffer_.x, light_rotation_buffer_.y, light_rotation_buffer_.z);
|
||||
light_camera_->render();
|
||||
|
||||
// Récupération explicite de la matrice de vue
|
||||
light_camera_->get_view_matrix(light_view_matrix_);
|
||||
|
||||
// Création d'une matrice de projection orthographique avec des valeurs adaptées
|
||||
float lightViewWidth = 200.0f; // Agrandir la zone couverte par l'ombre
|
||||
float lightViewHeight = 200.0f;
|
||||
float lightNearPlane = 1.0f;
|
||||
float lightFarPlane = 300.0f; // Augmenter la profondeur
|
||||
light_projection_matrix_ = XMMatrixOrthographicLH(lightViewWidth, lightViewHeight, lightNearPlane, lightFarPlane);
|
||||
|
||||
|
||||
// Rendu de la scene sans texture juste geometrie.
|
||||
if (!create_shadow_map(render_queues_))
|
||||
{
|
||||
Logger::Get().Log("Error creating shadow map", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
}
|
||||
|
||||
shadow_srv_ = shadow_map_->get_shader_resource_view();
|
||||
|
||||
// reset the render target back to the original back buffer and not the render to texture anymore. And reset the viewport back to the original.
|
||||
direct_3d_->set_back_buffer_render_target();
|
||||
direct_3d_->reset_viewport();
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
// ------------ render the object in the queue ------------ //
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
result = render_pass(render_queues_, diffuseColor, lightPosition, ambientColor, viewMatrix, projectionMatrix);
|
||||
if (!result)
|
||||
{
|
||||
@ -1934,11 +1871,8 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
|
||||
sun_light_->GetDiffuseColor(),
|
||||
sun_light_->GetAmbientColor(),
|
||||
sun_light_->GetDirection(),
|
||||
sun_light_->GetIntensity(),
|
||||
shadow_srv_,
|
||||
light_view_matrix_,
|
||||
light_projection_matrix_
|
||||
);
|
||||
sun_light_->GetIntensity()
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the object model using the sunlight shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
@ -1980,76 +1914,6 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
|
||||
return true;
|
||||
}
|
||||
|
||||
bool application_class::create_shadow_map(const std::vector<std::reference_wrapper<std::vector<object*>>>& RenderQueues)
|
||||
{
|
||||
for (auto& RenderQueue : RenderQueues)
|
||||
{
|
||||
|
||||
if (&RenderQueue.get() == &skybox_)
|
||||
{
|
||||
continue; // Skip rendering the skybox_ for shadow mapping
|
||||
}
|
||||
|
||||
for (auto& object : RenderQueue.get())
|
||||
{
|
||||
|
||||
// Vérification des ressources critiques
|
||||
if (shadow_map_ == nullptr) {
|
||||
Logger::Get().Log("shadow_map_ est nul!", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (light_camera_ == nullptr) {
|
||||
Logger::Get().Log("light_camera_ est nul!", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool hasNaN = false;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
XMVECTOR row = light_view_matrix_.r[i];
|
||||
if (XMComparisonAnyTrue(XMVector4IsNaN(row))) {
|
||||
hasNaN = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasNaN) {
|
||||
Logger::Get().Log("light_view_matrix_ contient des valeurs invalides!", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (object == nullptr)
|
||||
{
|
||||
Logger::Get().Log("object is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!object->IsVisible())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
object->Render(direct_3d_->get_device_context());
|
||||
|
||||
bool result = shader_manager_->render_depth_shader(
|
||||
direct_3d_->get_device_context(),
|
||||
object->GetIndexCount(),
|
||||
object->GetTranslateMatrix(),
|
||||
light_view_matrix_,
|
||||
light_projection_matrix_
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the object model using the shadow map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void application_class::construct_frustum()
|
||||
{
|
||||
XMMATRIX projectionMatrix = direct_3d_->get_projection_matrix();
|
||||
|
@ -1,105 +0,0 @@
|
||||
#include "shadow_map.h"
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
shadow_map::shadow_map() :
|
||||
depth_texture_(nullptr),
|
||||
depth_stencil_view_(nullptr),
|
||||
shader_resource_view_(nullptr)
|
||||
{
|
||||
ZeroMemory(&viewport_, sizeof(viewport_));
|
||||
}
|
||||
|
||||
shadow_map::~shadow_map()
|
||||
{
|
||||
shutdown();
|
||||
}
|
||||
|
||||
bool shadow_map::initialize(ID3D11Device* device, int shadow_map_width, int shadow_map_height)
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC text_desc = {};
|
||||
text_desc.Width = shadow_map_width;
|
||||
text_desc.Height = shadow_map_height;
|
||||
text_desc.MipLevels = 1;
|
||||
text_desc.ArraySize = 1;
|
||||
text_desc.Format = DXGI_FORMAT_R32_TYPELESS;
|
||||
text_desc.SampleDesc.Count = 1;
|
||||
text_desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
text_desc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
|
||||
|
||||
if (FAILED(device->CreateTexture2D(&text_desc, nullptr, &depth_texture_)))
|
||||
{
|
||||
Logger::Get().Log("Failed to create depth texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC dsv_Desc = {};
|
||||
dsv_Desc.Format = DXGI_FORMAT_D32_FLOAT;
|
||||
dsv_Desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
dsv_Desc.Texture2D.MipSlice = 0;
|
||||
|
||||
if (FAILED(device->CreateDepthStencilView(depth_texture_, &dsv_Desc, &depth_stencil_view_)))
|
||||
{
|
||||
Logger::Get().Log("Failed to create depth texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc = {};
|
||||
srv_desc.Format = DXGI_FORMAT_R32_FLOAT;
|
||||
srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
srv_desc.Texture2D.MostDetailedMip = 0;
|
||||
srv_desc.Texture2D.MipLevels = 1;
|
||||
|
||||
if (FAILED(device->CreateShaderResourceView(depth_texture_, &srv_desc, &shader_resource_view_)))
|
||||
{
|
||||
Logger::Get().Log("Failed to create shader resource view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
viewport_.Width = static_cast<FLOAT>(shadow_map_width);
|
||||
viewport_.Height = static_cast<FLOAT>(shadow_map_height);
|
||||
viewport_.MinDepth = 0.0f;
|
||||
viewport_.MaxDepth = 1.0f;
|
||||
viewport_.TopLeftX = 0.0f;
|
||||
viewport_.TopLeftY = 0.0f;
|
||||
|
||||
Logger::Get().Log("Shadow map initialized", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
void shadow_map::set_render_target(ID3D11DeviceContext* context)
|
||||
{
|
||||
context->OMSetRenderTargets(0, nullptr, depth_stencil_view_);
|
||||
context->RSSetViewports(1, &viewport_);
|
||||
}
|
||||
|
||||
void shadow_map::clear_render_target(ID3D11DeviceContext* context, float depth)
|
||||
{
|
||||
context->ClearDepthStencilView(depth_stencil_view_, D3D11_CLEAR_DEPTH, depth, 0);
|
||||
}
|
||||
|
||||
ID3D11ShaderResourceView* shadow_map::get_shader_resource_view() const
|
||||
{
|
||||
return shader_resource_view_;
|
||||
}
|
||||
|
||||
void shadow_map::shutdown()
|
||||
{
|
||||
|
||||
if (shader_resource_view_) {
|
||||
shader_resource_view_->Release();
|
||||
shader_resource_view_ = nullptr;
|
||||
}
|
||||
if (depth_stencil_view_) {
|
||||
depth_stencil_view_->Release();
|
||||
depth_stencil_view_ = nullptr;
|
||||
}
|
||||
if (depth_texture_) {
|
||||
depth_texture_->Release();
|
||||
depth_texture_ = nullptr;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Shadow map shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user