faut tout pt encore
This commit is contained in:
parent
c5de18a9b3
commit
58cafd7682
@ -1505,6 +1505,7 @@ void ApplicationClass::AddKobject(WCHAR* filepath)
|
|||||||
// Liste des fichiers de texture
|
// Liste des fichiers de texture
|
||||||
std::vector<std::wstring> kobjTexture = {
|
std::vector<std::wstring> kobjTexture = {
|
||||||
L"assets/Texture/Bricks2K.png",
|
L"assets/Texture/Bricks2K.png",
|
||||||
|
L"assets/Texture/BricksNRM2K.png",
|
||||||
L"assets/Texture/EmptyTexture.png"
|
L"assets/Texture/EmptyTexture.png"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
28
enginecustom/assets/Texture/imgui.ini
Normal file
28
enginecustom/assets/Texture/imgui.ini
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
[Window][Debug##Default]
|
||||||
|
Pos=60,60
|
||||||
|
Size=400,400
|
||||||
|
|
||||||
|
[Window][Khaotic Engine]
|
||||||
|
Pos=1142,43
|
||||||
|
Size=392,273
|
||||||
|
|
||||||
|
[Window][Objects]
|
||||||
|
Pos=598,29
|
||||||
|
Size=457,294
|
||||||
|
|
||||||
|
[Window][Terrain]
|
||||||
|
Pos=58,62
|
||||||
|
Size=342,82
|
||||||
|
|
||||||
|
[Window][Light]
|
||||||
|
Pos=1548,17
|
||||||
|
Size=358,535
|
||||||
|
|
||||||
|
[Window][Shader Manager]
|
||||||
|
Pos=471,90
|
||||||
|
Size=180,79
|
||||||
|
|
||||||
|
[Window][Engine Settings]
|
||||||
|
Pos=106,212
|
||||||
|
Size=407,81
|
||||||
|
|
@ -24,64 +24,11 @@ struct PixelInputType
|
|||||||
|
|
||||||
float4 CelShadingPixelShader(PixelInputType input) : SV_TARGET
|
float4 CelShadingPixelShader(PixelInputType input) : SV_TARGET
|
||||||
{
|
{
|
||||||
float4 textureColor;
|
// Normalize the normal
|
||||||
float lightIntensity;
|
|
||||||
float4 finalColor;
|
|
||||||
|
|
||||||
// Sample the pixel color from the texture.
|
|
||||||
textureColor = shaderTexture.Sample(SampleType, input.tex);
|
|
||||||
|
|
||||||
float3 normal = normalize(input.normal);
|
float3 normal = normalize(input.normal);
|
||||||
|
|
||||||
// Calculate the light vector from the light position to the world position
|
// Convert the normal to a color
|
||||||
float3 lightVector = normalize(lightPosition - input.worldPos);
|
float4 color = float4((normal + 1.0f) * 0.5f, 1.0f);
|
||||||
|
|
||||||
// Calculate the light intensity based on the light direction.
|
return color;
|
||||||
float directionalLightIntensity = saturate(dot(normal, normalize(lightDirection)));
|
|
||||||
|
|
||||||
// Calculate the light intensity based on the light position.
|
|
||||||
float positionalLightIntensity = saturate(dot(normal, lightVector));
|
|
||||||
|
|
||||||
// Combine the directional and positional light intensities.
|
|
||||||
lightIntensity = max(directionalLightIntensity, positionalLightIntensity);
|
|
||||||
|
|
||||||
// Calculate the distance from the light to the fragment.
|
|
||||||
float distance = length(lightPosition - input.worldPos);
|
|
||||||
|
|
||||||
// Apply an attenuation factor based on the distance.
|
|
||||||
float attenuation = 1.0f / (constantAttenuation + linearAttenuation * distance + quadraticAttenuation * distance * distance);
|
|
||||||
|
|
||||||
// Combine the light intensity with the attenuation factor.
|
|
||||||
lightIntensity *= attenuation;
|
|
||||||
|
|
||||||
// Apply a step function to create the cel shading effect.
|
|
||||||
if (lightIntensity > 0.75f)
|
|
||||||
{
|
|
||||||
lightIntensity = 1.0f; // Brightest level
|
|
||||||
}
|
|
||||||
else if (lightIntensity > 0.5f)
|
|
||||||
{
|
|
||||||
lightIntensity = 0.7f; // Mid-bright level
|
|
||||||
}
|
|
||||||
else if (lightIntensity > 0.25f)
|
|
||||||
{
|
|
||||||
lightIntensity = 0.4f; // Mid-dark level
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lightIntensity = 0.1f; // Darkest level
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simple shadow calculation: if the fragment is behind the light source, it is in shadow.
|
|
||||||
float3 toLight = normalize(lightPosition - input.worldPos);
|
|
||||||
float shadow = saturate(dot(normal, toLight));
|
|
||||||
if (shadow < 0.1f)
|
|
||||||
{
|
|
||||||
lightIntensity *= 0.5f; // Darken the fragment if it is in shadow
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate the final color by combining the texture color with the light intensity and diffuse color.
|
|
||||||
finalColor = textureColor * diffuseColor * lightIntensity;
|
|
||||||
|
|
||||||
return finalColor;
|
|
||||||
}
|
}
|
||||||
|
@ -42,4 +42,4 @@ PixelInputType CelShadingVertexShader(VertexInputType input)
|
|||||||
output.tex = input.tex;
|
output.tex = input.tex;
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ Pos=1142,43
|
|||||||
Size=392,273
|
Size=392,273
|
||||||
|
|
||||||
[Window][Objects]
|
[Window][Objects]
|
||||||
Pos=934,36
|
Pos=598,29
|
||||||
Size=457,294
|
Size=457,294
|
||||||
|
|
||||||
[Window][Terrain]
|
[Window][Terrain]
|
||||||
|
@ -93,7 +93,7 @@ void imguiManager::WidgetAddObject(ApplicationClass* app)
|
|||||||
ofn.lpstrFile = szFile;
|
ofn.lpstrFile = szFile;
|
||||||
ofn.lpstrFile[0] = '\0';
|
ofn.lpstrFile[0] = '\0';
|
||||||
ofn.nMaxFile = sizeof(szFile);
|
ofn.nMaxFile = sizeof(szFile);
|
||||||
ofn.lpstrFilter = L"TXT\0*.txt\0KOBJ\0*.kobj\0*OBJ\0*.obj";
|
ofn.lpstrFilter = L"OBJ\0*.obj\0KOBJ\0*.kobj\0TXT\0*.txt";
|
||||||
ofn.nFilterIndex = 1;
|
ofn.nFilterIndex = 1;
|
||||||
ofn.lpstrFileTitle = NULL;
|
ofn.lpstrFileTitle = NULL;
|
||||||
ofn.nMaxFileTitle = 0;
|
ofn.nMaxFileTitle = 0;
|
||||||
@ -169,36 +169,15 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
|||||||
"Refraction"
|
"Refraction"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
for (int count = 0; count < 1; count++)
|
|
||||||
{
|
|
||||||
std::string textureLabel = "Texture##" + std::to_string(index);
|
|
||||||
ID3D11ShaderResourceView* texture = object->GetTexture(count);
|
|
||||||
if (texture != nullptr)
|
|
||||||
{
|
|
||||||
// Set the cursor position
|
|
||||||
ImGui::SetCursorPosX(count * (64 + 20) + 10); // 64 is the width of the image, 10 is the spacing
|
|
||||||
|
|
||||||
// Display the texture name
|
|
||||||
std::string textureName = textureCategories[count];
|
|
||||||
ImGui::Text(textureName.c_str());
|
|
||||||
|
|
||||||
if(count < 5)
|
|
||||||
{
|
|
||||||
ImGui::SameLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display all images
|
// Display all images
|
||||||
for (int count = 0; count < 1; count++)
|
for (int count = 0; count < textureCategories.size(); count++)
|
||||||
{
|
{
|
||||||
std::string textureLabel = "Texture##" + std::to_string(index);
|
std::string textureLabel = "Texture##" + std::to_string(index) + "##" + std::to_string(count);
|
||||||
ID3D11ShaderResourceView* texture = object->GetTexture(count);
|
ID3D11ShaderResourceView* texture = object->GetTexture(count);
|
||||||
if (texture != nullptr)
|
if (texture != nullptr)
|
||||||
{
|
{
|
||||||
// Set the cursor position
|
ImGui::Text(textureCategories[count].c_str());
|
||||||
ImGui::SetCursorPosX(count * (64 + 20) + 10); // 64 is the width of the image, 10 is the spacing
|
ImGui::SameLine();
|
||||||
|
|
||||||
if (ImGui::ImageButton((ImTextureID)texture, ImVec2(64, 64)))
|
if (ImGui::ImageButton((ImTextureID)texture, ImVec2(64, 64)))
|
||||||
{
|
{
|
||||||
@ -221,7 +200,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
|||||||
if (GetOpenFileName(&ofn))
|
if (GetOpenFileName(&ofn))
|
||||||
{
|
{
|
||||||
// Load the selected texture
|
// Load the selected texture
|
||||||
object->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, index);
|
object->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,8 +211,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
|||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is not the last texture, put the next button on the same line
|
if (count < textureCategories.size() - 1)
|
||||||
if (count < 5)
|
|
||||||
{
|
{
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
}
|
}
|
||||||
@ -310,6 +288,7 @@ void imguiManager::WidgetTerrainWindow(ApplicationClass* app)
|
|||||||
app->DeleteTerrain();
|
app->DeleteTerrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,6 +442,10 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
|
|||||||
// Finally set the light constant buffer in the pixel shader with the updated values.
|
// Finally set the light constant buffer in the pixel shader with the updated values.
|
||||||
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);
|
deviceContext->PSSetConstantBuffers(bufferNumber, 1, &m_lightBuffer);
|
||||||
|
|
||||||
|
// Set shader texture resources in the pixel shader.
|
||||||
|
deviceContext->PSSetShaderResources(0, 1, &texture1);
|
||||||
|
deviceContext->PSSetShaderResources(1, 1, &texture2);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user