Minor - Depth shader - V10.6.0

This commit is contained in:
2025-05-28 13:24:53 +02:00
parent f20adee22f
commit 1af71960c3
3 changed files with 28 additions and 58 deletions

View File

@@ -18,11 +18,7 @@ struct PixelInputType
////////////////////////////////////////////////////////////////////////////////
float4 DepthPixelShader(PixelInputType input) : SV_TARGET
{
float4 textureColor;
// Sample the pixel color from the texture using the sampler at this texture coordinate location.
textureColor = shaderTexture.Sample(SampleType, input.tex);
return textureColor;
float depth = input.position.z / input.position.w;
depth = 1.0f - depth;
return float4(depth, depth, depth, 1.0f);
}

View File

@@ -839,8 +839,11 @@ bool application_class::frame(input_class* Input)
camera_->set_rotation(rotationX, rotationY, 0.0f);
} else {
// Update the sun camera position and rotation based on the light position.
sun_camera_->set_position(sun_light_->GetPosition().x, sun_light_->GetPosition().y, sun_light_->GetPosition().z);
sun_camera_->set_rotation(pitch, yaw, roll);
// sun_camera_->set_position(sun_light_->GetPosition().x, sun_light_->GetPosition().y, sun_light_->GetPosition().z);
// sun_camera_->set_rotation(pitch, yaw, roll);
sun_camera_->set_position(positionX, positionY, positionZ);
sun_camera_->set_rotation(rotationX, rotationY, 0.0f);
}
active_camera_->render();
@@ -1110,46 +1113,12 @@ bool application_class::render(float rotation, float x, float y, float z, float
// ------------ render the object in the queue ------------ //
// -------------------------------------------------------- //
if (active_camera_ == sun_camera_)
result = render_pass(render_queues_, diffuseColor, lightPosition, ambientColor, viewMatrix, projectionMatrix);
if (!result)
{
for (auto& render : render_queues_)
{
bool isSkybox = (&render.get() == &skybox_);
if (isSkybox)
{
direct_3d_->turn_z_buffer_off();
}
for (auto& item : render.get())
{
item->Render(direct_3d_->get_device_context());
// render the item using depth shader
result = shader_manager_->render_depth_shader(
direct_3d_->get_device_context(),
item->GetIndexCount(),
worldMatrix,
viewMatrix,
projectionMatrix,
item->GetTexture(TextureType::Diffuse,0)
);
}
if (isSkybox)
{
direct_3d_->turn_z_buffer_on();
}
}
}
else
{
result = render_pass(render_queues_, diffuseColor, lightPosition, ambientColor, viewMatrix, projectionMatrix);
if (!result)
{
Logger::Get().Log("Could not render the model using any shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
Logger::Get().Log("Could not render the model using any shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -1761,7 +1730,7 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
int renderCount = 0;
//construct_frustum();
//construct_frustum();
for (const auto& RenderQueue : RenderQueues)
{
@@ -1804,6 +1773,18 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
object->Render(direct_3d_->get_device_context());
if (active_camera_ == sun_camera_)
{
result = shader_manager_->render_depth_shader(
direct_3d_->get_device_context(),
object->GetIndexCount(),
worldMatrix,
view,
projection,
object->GetTexture(TextureType::Diffuse,0)
);
}
// Utiliser l'enum ShaderType pour d<>terminer quel shader utiliser
switch (object->GetActiveShader())
{