mirror of
https://github.com/4sval/FModel.git
synced 2026-08-06 03:03:04 -05:00
Emissive Region
This commit is contained in:
parent
e5b66bb8d9
commit
35f3ce38fb
|
|
@ -1 +1 @@
|
|||
Subproject commit 3b341d780a08f1bf38b0246750d476d4b948b286
|
||||
Subproject commit 6afdce084527ba09c4b392bd250f49b889e46d1f
|
||||
|
|
@ -42,6 +42,7 @@ struct Parameters
|
|||
AoParams Ao;
|
||||
bool HasAo;
|
||||
|
||||
vec4 EmissiveRegion;
|
||||
float Specular;
|
||||
float Roughness;
|
||||
float EmissiveMult;
|
||||
|
|
@ -100,9 +101,19 @@ int LayerToIndex()
|
|||
return clamp(int(fTexLayer), 0, uNumTexCoords - 1);
|
||||
}
|
||||
|
||||
vec2 ScaledTexCoords()
|
||||
{
|
||||
return fTexCoords * uParameters.UVScale;
|
||||
}
|
||||
|
||||
vec4 SamplerToVector(sampler2D s, vec2 coords)
|
||||
{
|
||||
return texture(s, coords);
|
||||
}
|
||||
|
||||
vec4 SamplerToVector(sampler2D s)
|
||||
{
|
||||
return texture(s, fTexCoords * uParameters.UVScale);
|
||||
return SamplerToVector(s, ScaledTexCoords());
|
||||
}
|
||||
|
||||
vec3 ComputeNormals(int layer)
|
||||
|
|
@ -196,7 +207,7 @@ vec3 CalcSpotLight(int layer, vec3 normals, Light light)
|
|||
|
||||
if(theta > outer)
|
||||
{
|
||||
return CalcBaseLight(layer, normals, light.Base, attenuation, false);
|
||||
return CalcBaseLight(layer, normals, light.Base, attenuation, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -240,8 +251,19 @@ void main()
|
|||
result = mix(result * m.r * uParameters.Ao.AmbientOcclusion, result, m.g);
|
||||
}
|
||||
|
||||
vec4 emissive = SamplerToVector(uParameters.Emissive[layer].Sampler);
|
||||
result += uParameters.Emissive[layer].Color.rgb * emissive.rgb * uParameters.EmissiveMult;
|
||||
vec2 coords = ScaledTexCoords();
|
||||
if (coords.x > uParameters.EmissiveRegion.x &&
|
||||
coords.y > uParameters.EmissiveRegion.y &&
|
||||
coords.x < uParameters.EmissiveRegion.z &&
|
||||
coords.y < uParameters.EmissiveRegion.w)
|
||||
{
|
||||
coords.x -= uParameters.EmissiveRegion.x;
|
||||
coords.y -= uParameters.EmissiveRegion.y;
|
||||
coords.x *= 1.0 / (uParameters.EmissiveRegion.z - uParameters.EmissiveRegion.x);
|
||||
coords.y *= 1.0 / (uParameters.EmissiveRegion.w - uParameters.EmissiveRegion.y);
|
||||
vec4 emissive = SamplerToVector(uParameters.Emissive[layer].Sampler, coords);
|
||||
result += uParameters.Emissive[layer].Color.rgb * emissive.rgb * uParameters.EmissiveMult;
|
||||
}
|
||||
|
||||
if (!bVertexColors[1])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class Material : IDisposable
|
|||
|
||||
public Vector4[] DiffuseColor;
|
||||
public Vector4[] EmissiveColor;
|
||||
public Vector4 EmissiveRegion;
|
||||
|
||||
public AoParams Ao;
|
||||
public bool HasAo;
|
||||
|
|
@ -50,6 +51,7 @@ public class Material : IDisposable
|
|||
|
||||
DiffuseColor = Array.Empty<Vector4>();
|
||||
EmissiveColor = Array.Empty<Vector4>();
|
||||
EmissiveRegion = new Vector4(0, 0, 1, 1);
|
||||
}
|
||||
|
||||
public Material(UMaterialInterface unrealMaterial) : this()
|
||||
|
|
@ -112,11 +114,18 @@ public class Material : IDisposable
|
|||
if (Parameters.TryGetScalar(out var roughness, "Rough", "Roughness", "Ro Multiplier", "RO_mul", "Roughness_Mult"))
|
||||
Roughness = roughness;
|
||||
|
||||
if (Parameters.TryGetScalar(out var emissiveMultScalar, "emissive mult", "Emissive_Mult", "EmissiveIntensity"))
|
||||
if (Parameters.TryGetScalar(out var emissiveMultScalar, "emissive mult", "Emissive_Mult", "EmissiveIntensity", "EmissionIntensity"))
|
||||
EmissiveMult = emissiveMultScalar;
|
||||
else if (Parameters.TryGetLinearColor(out var emissiveMultColor, "Emissive Multiplier", "EmissiveMultiplier"))
|
||||
EmissiveMult = emissiveMultColor.R;
|
||||
|
||||
if (Parameters.TryGetLinearColor(out var EmissiveUVs,
|
||||
"EmissiveUVs_RG_UpperLeftCorner_BA_LowerRightCorner",
|
||||
"Emissive Texture UVs RG_TopLeft BA_BottomRight",
|
||||
"Emissive 2 UV Positioning (RG)UpperLeft (BA)LowerRight",
|
||||
"EmissiveUVPositioning (RG)UpperLeft (BA)LowerRight"))
|
||||
EmissiveRegion = new Vector4(EmissiveUVs.R, EmissiveUVs.G, EmissiveUVs.B, EmissiveUVs.A);
|
||||
|
||||
if (Parameters.TryGetScalar(out var uvScale, "UV Scale"))
|
||||
UVScale = uvScale;
|
||||
}
|
||||
|
|
@ -216,6 +225,7 @@ public class Material : IDisposable
|
|||
shader.SetUniform("uParameters.Ao.AmbientOcclusion", Ao.AmbientOcclusion);
|
||||
shader.SetUniform("uParameters.HasAo", HasAo);
|
||||
|
||||
shader.SetUniform("uParameters.EmissiveRegion", EmissiveRegion);
|
||||
shader.SetUniform("uParameters.Specular", Specular);
|
||||
shader.SetUniform("uParameters.Roughness", Roughness);
|
||||
shader.SetUniform("uParameters.EmissiveMult", EmissiveMult);
|
||||
|
|
@ -303,6 +313,8 @@ public class Material : IDisposable
|
|||
case 4:
|
||||
SnimGui.Layout("Color");ImGui.PushID(3);
|
||||
ImGui.ColorEdit4("", ref EmissiveColor[SelectedChannel], ImGuiColorEditFlags.NoAlpha);
|
||||
ImGui.PopID();SnimGui.Layout("Region");ImGui.PushID(4);
|
||||
ImGui.DragFloat4("", ref EmissiveRegion, _step, _zero, 1.0f, "%.2f", _clamp);
|
||||
ImGui.PopID();
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user