mirror of
https://github.com/4sval/FModel.git
synced 2026-04-03 07:36:11 -05:00
blinded by the lights
This commit is contained in:
parent
0295d47eba
commit
926cbec7eb
|
|
@ -59,35 +59,41 @@ void main()
|
|||
{
|
||||
FragColor = fColor;
|
||||
}
|
||||
else if (material.hasDiffuseColor)
|
||||
{
|
||||
FragColor = material.diffuseColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
vec3 n_normal_map = getNormalFromMap();
|
||||
vec3 n_light_direction = normalize(light.position - fPos);
|
||||
vec3 result = light.ambient * vec3(texture(material.diffuseMap, fTexCoords));
|
||||
|
||||
// diffuse
|
||||
float diff = max(dot(n_normal_map, n_light_direction), 0.0f);
|
||||
vec4 diffuse_map = texture(material.diffuseMap, fTexCoords);
|
||||
result += light.diffuse * diff * diffuse_map.rgb;
|
||||
|
||||
// specular
|
||||
if (material.useSpecularMap)
|
||||
if (material.hasDiffuseColor)
|
||||
{
|
||||
vec3 n_view_direction = normalize(viewPos - fPos);
|
||||
vec3 reflect_direction = reflect(-n_light_direction, n_normal_map);
|
||||
float metallic = pow(max(dot(n_view_direction, reflect_direction), 0.0f), material.metallic_value);
|
||||
vec3 specular_map = vec3(texture(material.specularMap, fTexCoords));
|
||||
result += light.specular * metallic * specular_map.b * material.roughness_value * specular_map.g * specular_map.r;
|
||||
vec4 result = vec4(light.ambient, 1.0) * material.diffuseColor;
|
||||
result += vec4(light.diffuse, 1.0) * diff * material.diffuseColor;
|
||||
FragColor = result;
|
||||
}
|
||||
else
|
||||
{
|
||||
vec3 result = light.ambient * vec3(texture(material.diffuseMap, fTexCoords));
|
||||
|
||||
// emission
|
||||
vec3 emission_map = vec3(texture(material.emissionMap, fTexCoords));
|
||||
result += material.emissionColor.rgb * emission_map;
|
||||
// diffuse
|
||||
vec4 diffuse_map = texture(material.diffuseMap, fTexCoords);
|
||||
result += light.diffuse * diff * diffuse_map.rgb;
|
||||
|
||||
FragColor = vec4(result, 1.0);
|
||||
// specular
|
||||
if (material.useSpecularMap)
|
||||
{
|
||||
vec3 n_view_direction = normalize(viewPos - fPos);
|
||||
vec3 reflect_direction = reflect(-n_light_direction, n_normal_map);
|
||||
float metallic = pow(max(dot(n_view_direction, reflect_direction), 0.0f), material.metallic_value);
|
||||
vec3 specular_map = vec3(texture(material.specularMap, fTexCoords));
|
||||
result += light.specular * metallic * specular_map.b * material.roughness_value * specular_map.g * specular_map.r;
|
||||
}
|
||||
|
||||
// emission
|
||||
vec3 emission_map = vec3(texture(material.emissionMap, fTexCoords));
|
||||
result += material.emissionColor.rgb * emission_map;
|
||||
|
||||
FragColor = vec4(result, 1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ public class Model : IDisposable
|
|||
|
||||
private BufferObject<uint> _ebo;
|
||||
private BufferObject<float> _vbo;
|
||||
private BufferObject<float>[] _morphVbo;
|
||||
private BufferObject<Matrix4x4> _matrixVbo;
|
||||
private VertexArrayObject<float, uint> _vao;
|
||||
|
||||
|
|
@ -54,8 +53,6 @@ public class Model : IDisposable
|
|||
Transforms = new List<Transform>();
|
||||
Show = true;
|
||||
IsSavable = owner is not UWorld;
|
||||
|
||||
_morphVbo = Array.Empty<BufferObject<float>>();
|
||||
}
|
||||
|
||||
public Model(UObject owner, string name, string type, CBaseMeshLod lod, CMeshVertex[] vertices, FPackageIndex[] morphTargets = null, List<CSkelMeshBone> skeleton = null, Transform transform = null)
|
||||
|
|
@ -71,7 +68,6 @@ public class Model : IDisposable
|
|||
HasMorphTargets = morphTargets != null;
|
||||
if (HasMorphTargets)
|
||||
{
|
||||
_morphVbo = new BufferObject<float>[4 * morphTargets.Length]; // PositionDelta + SourceIdx
|
||||
var morph = morphTargets[0].Load<UMorphTarget>().MorphLODModels[0];
|
||||
foreach (var delta in morph.Vertices)
|
||||
{
|
||||
|
|
@ -229,10 +225,6 @@ public class Model : IDisposable
|
|||
_ebo.Dispose();
|
||||
_vbo.Dispose();
|
||||
_matrixVbo.Dispose();
|
||||
for (int i = 0; i < _morphVbo.Length; i++)
|
||||
{
|
||||
_morphVbo[i].Dispose();
|
||||
}
|
||||
_vao.Dispose();
|
||||
for (int section = 0; section < Sections.Length; section++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -313,10 +313,12 @@ public class SnimGui : IDisposable
|
|||
ImGui.EndTabItem();
|
||||
}
|
||||
|
||||
ImGui.BeginDisabled(!model.HasMorphTargets);
|
||||
if (ImGui.BeginTabItem("Shape Keys"))
|
||||
{
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
ImGui.EndDisabled();
|
||||
}
|
||||
|
||||
ImGui.End();
|
||||
|
|
@ -342,7 +344,7 @@ public class SnimGui : IDisposable
|
|||
ImGui.SetNextItemWidth(300);
|
||||
ImGui.ColorEdit4(section.TexturesLabels[0], ref section.DiffuseColor, ImGuiColorEditFlags.AlphaPreview | ImGuiColorEditFlags.AlphaBar);
|
||||
}
|
||||
else
|
||||
// else
|
||||
{
|
||||
for (var i = 0; i < section.Textures.Length; i++)
|
||||
{
|
||||
|
|
@ -388,23 +390,6 @@ public class SnimGui : IDisposable
|
|||
}
|
||||
ImGui.EndGroup();
|
||||
|
||||
// ImGui.Text($"Faces: {FacesCount} ({Math.Round(FacesCount / indices * 100f, 2)}%%)");
|
||||
// ImGui.Text($"First Face: {FirstFaceIndex}");
|
||||
// ImGui.Separator();
|
||||
// if (_hasDiffuseColor)
|
||||
// {
|
||||
// ImGui.ColorEdit4("Diffuse Color", ref _diffuseColor, ImGuiColorEditFlags.NoInputs);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ImGui.Text($"Diffuse: ({Parameters.Diffuse?.ExportType}) {Parameters.Diffuse?.Name}");
|
||||
// ImGui.Text($"Normal: ({Parameters.Normal?.ExportType}) {Parameters.Normal?.Name}");
|
||||
// ImGui.Text($"Specular: ({Parameters.Specular?.ExportType}) {Parameters.Specular?.Name}");
|
||||
// if (Parameters.HasTopEmissiveTexture)
|
||||
// ImGui.Text($"Emissive: ({Parameters.Emissive?.ExportType}) {Parameters.Emissive?.Name}");
|
||||
// ImGui.Separator();
|
||||
// }
|
||||
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user