patch update - fix sunlight shader

Prend en compte les paramètres direction et intensité
This commit is contained in:
CatChow0 2025-01-23 22:45:59 +01:00
parent d8851cc679
commit 425224a96c
4 changed files with 29 additions and 34 deletions

View File

@ -79,7 +79,7 @@ DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=Y
DockNode ID=0x0000000D Parent=0xCCBD8CF7 SizeRef=1568,598 Split=Y
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 Split=X
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=290,826 Split=Y Selected=0x393905AB
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=395,413 Selected=0x321620B2
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=395,413 Selected=0x393905AB
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=395,411 Selected=0x031DC75C
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=1276,826 Split=X
DockNode ID=0x00000002 Parent=0x00000008 SizeRef=878,826 CentralNode=1 Selected=0x9204953B

View File

@ -252,31 +252,36 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
app->DeleteKobject(index);
}
// Shader selection
std::string shaderLabel = "Shader##" + std::to_string(index);
ImGui::Separator();
// Radio buttons for shader options
Object::ShaderType activeShader = object->GetActiveShader();
if (ImGui::RadioButton("Enable Lighting", activeShader == Object::LIGHTING))
// Liste des options
const char* shaderOptions[] = { "Enable Global Lighting", "Enable Lighting", "Enable Cel Shading", "Enable Normal Mapping", "Enable Specular Mapping" };
Object::ShaderType shaderTypes[] = { Object::SUNLIGHT,Object::LIGHTING, Object::CEL_SHADING, Object::NORMAL_MAPPING, Object::SPECULAR_MAPPING };
// Variable pour stocker l'option sélectionnée
static int currentShader = 0; // Index de l'option actuellement sélectionnée
// Création du menu déroulant
if (ImGui::BeginCombo("Shader Options", shaderOptions[currentShader]))
{
object->SetActiveShader(Object::LIGHTING);
}
if (ImGui::RadioButton("Enable Cel Shading", activeShader == Object::CEL_SHADING))
{
object->SetActiveShader(Object::CEL_SHADING);
}
if (ImGui::RadioButton("Enable Normal Mapping", activeShader == Object::NORMAL_MAPPING))
{
object->SetActiveShader(Object::NORMAL_MAPPING);
for (int i = 0; i < IM_ARRAYSIZE(shaderOptions); i++)
{
// Crée une option sélectionnable pour chaque shader
bool isSelected = (currentShader == i);
if (ImGui::Selectable(shaderOptions[i], isSelected))
{
// Met à jour l'option sélectionnée
currentShader = i;
object->SetActiveShader(shaderTypes[i]);
}
// Si l'option sélectionnée est active, nous mettons en surbrillance
if (isSelected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
if (ImGui::RadioButton("Enable Specular Mapping", activeShader == Object::SPECULAR_MAPPING))
{
object->SetActiveShader(Object::SPECULAR_MAPPING);
}
ImGui::Separator();

View File

@ -24,8 +24,6 @@ struct PixelInputType
float4 position : SV_POSITION;
float2 tex : TEXCOORD0;
float3 normal : NORMAL;
float3 lightDir : TEXCOORD1;
float intensity : TEXCOORD2;
};
////////////////////////////////////////////////////////////////////////////////
@ -34,7 +32,6 @@ struct PixelInputType
float4 SunLightPixelShader(PixelInputType input) : SV_TARGET
{
float4 textureColor;
float3 lightDir;
float4 color;
float lightIntensity;
float4 colorArray;
@ -44,10 +41,10 @@ float4 SunLightPixelShader(PixelInputType input) : SV_TARGET
textureColor = shaderTexture.Sample(SampleType, input.tex);
// Calculate the different amounts of light on this pixel based on the direction of the light.
lightIntensity = saturate(dot(input.normal, input.lightDir)) * input.intensity;
lightIntensity = saturate(dot(input.normal, -lightDirection));
// Determine the diffuse color amount of the light.
colorArray = diffuseColor * lightIntensity;
colorArray = (diffuseColor * lightIntensity) * intensity;
// Initialize the sum of colors.
colorSum = float4(0.0f, 0.0f, 0.0f, 1.0f);

View File

@ -37,8 +37,6 @@ struct PixelInputType
float4 position : SV_POSITION;
float2 tex : TEXCOORD0;
float3 normal : NORMAL;
float3 lightDir : TEXCOORD1;
float intensity : TEXCOORD2;
};
////////////////////////////////////////////////////////////////////////////////
@ -65,10 +63,5 @@ PixelInputType SunLightVertexShader(VertexInputType input)
// Normalize the normal vector.
output.normal = normalize(output.normal);
// Use the light direction directly.
output.lightDir = normalize(lightDirection);
output.intensity = intensity;
return output;
}