Skip to content

Commit

Permalink
fix texture misalignment + negative far plane
Browse files Browse the repository at this point in the history
  • Loading branch information
4sval committed Nov 2, 2022
1 parent cc89bec commit 2f3b076
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion EpicManifestParser
9 changes: 5 additions & 4 deletions FModel/Resources/default.frag
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,23 @@ uniform Material material;
uniform Light light;
uniform vec3 viewPos;
uniform bool display_vertex_colors;
uniform int numTexCoords;

out vec4 FragColor;

int LayerToIndex(int max)
int LayerToIndex()
{
return min(int(fTexLayer), max);
return min(int(fTexLayer), numTexCoords - 1);
}

vec4 SamplerSelector(sampler2D array[8])
{
return texture(array[LayerToIndex(7)], fTexCoords);
return texture(array[LayerToIndex()], fTexCoords);
}

vec4 VectorSelector(vec4 array[8])
{
return array[LayerToIndex(7)];
return array[LayerToIndex()];
}

vec3 getNormalFromMap()
Expand Down
4 changes: 4 additions & 0 deletions FModel/Views/Snooper/Material.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@ private void Fill(Cache cache, int numTexCoords, ref Texture[] array, bool top,
if (top)
{
for (int i = 0; i < array.Length; i++)
{
if (Parameters.TryGetTexture2d(out var o, triggers[i]) && cache.TryGetCachedTexture(o, out var t))
array[i] = t;
else if (i > 0 && array[i - 1] != null)
array[i] = array[i - 1];
}
}
else if (Parameters.Textures.TryGetValue(fallback, out var u) && u is UTexture2D o && cache.TryGetCachedTexture(o, out var t))
{
Expand Down
1 change: 1 addition & 0 deletions FModel/Views/Snooper/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public void Render(Shader shader)
_vao.Bind();
shader.SetUniform("uMorphTime", MorphTime);
shader.SetUniform("display_vertex_colors", DisplayVertexColors);
shader.SetUniform("numTexCoords", NumTexCoords);

GL.PolygonMode(MaterialFace.FrontAndBack, Wireframe ? PolygonMode.Line : PolygonMode.Fill);
for (int section = 0; section < Sections.Length; section++)
Expand Down
2 changes: 1 addition & 1 deletion FModel/Views/Snooper/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void Render(Camera cam)

private Camera SetupCamera(FBox box)
{
var far = box.Max.Max();
var far = Math.Abs(box.Max.Max());
var center = box.GetCenter();
return new Camera(
new Vector3(0f, center.Z, box.Max.Y * 3),
Expand Down

0 comments on commit 2f3b076

Please sign in to comment.