default checker texture instead of red + same vertex color texture

This commit is contained in:
Asval 2023-08-30 18:47:18 +02:00
parent 6b6403e9c1
commit cf512a3d3d
9 changed files with 24 additions and 22 deletions

View File

@ -77,6 +77,7 @@
<None Remove="Resources\linux.png" />
<None Remove="Resources\stateofdecay2.png" />
<None Remove="Resources\T_Placeholder_Item_Image.png" />
<None Remove="Resources\checker.png" />
<None Remove="Resources\T_ClipSize_Weapon_Stats.png" />
<None Remove="Resources\T_DamagePerBullet_Weapon_Stats.png" />
<None Remove="Resources\T_ReloadTime_Weapon_Stats.png" />
@ -207,6 +208,7 @@
<Resource Include="Resources\linux.png" />
<Resource Include="Resources\stateofdecay2.png" />
<Resource Include="Resources\T_Placeholder_Item_Image.png" />
<Resource Include="Resources\checker.png" />
<Resource Include="Resources\T_ClipSize_Weapon_Stats.png" />
<Resource Include="Resources\T_DamagePerBullet_Weapon_Stats.png" />
<Resource Include="Resources\T_ReloadTime_Weapon_Stats.png" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

View File

@ -228,7 +228,7 @@ void main()
}
else if (bVertexColors[4])
{
FragColor = vec4(fTexCoords, 0.0, 1.0);
FragColor = SamplerToVector(uParameters.Diffuse[0].Sampler);
}
else
{

View File

@ -110,7 +110,6 @@ public class Skeleton : IDisposable
_vaoHandle = GL.GenVertexArray();
GL.BindVertexArray(_vaoHandle);
_vbo = new BufferObject<float>(_vertexSize * BoneCount, BufferTarget.ArrayBuffer);
var sf = sizeof(float);
@ -224,18 +223,10 @@ public class Skeleton : IDisposable
_vbo.Bind();
foreach (var (boneName, bone) in BonesByLoweredName)
{
Matrix4x4 boneMatrix;
Matrix4x4 parentBoneMatrix;
if (IsAnimated)
{
boneMatrix = _boneMatriceAtFrame[bone.Index];
parentBoneMatrix = bone.IsRoot ? boneMatrix : _boneMatriceAtFrame[bone.ParentIndex];
}
else
{
boneMatrix = bone.Rest.Matrix;
parentBoneMatrix = bone.IsRoot ? boneMatrix : BonesByLoweredName[bone.LoweredParentName].Rest.Matrix;
}
var boneMatrix = IsAnimated ? _boneMatriceAtFrame[bone.Index] : bone.Rest.Matrix;
var parentBoneMatrix = bone.IsRoot ? boneMatrix :
IsAnimated ? _boneMatriceAtFrame[bone.ParentIndex] :
BonesByLoweredName[bone.LoweredParentName].Rest.Matrix;
var count = 0;
var baseIndex = bone.Index * _vertexSize;

View File

@ -31,7 +31,7 @@ public interface IRenderableModel : IDisposable
public void Setup(Options options);
public void SetupInstances();
public void Render(Shader shader, bool outline = false);
public void Render(Shader shader, Texture checker = null, bool outline = false);
public void PickingRender(Shader shader);
public void Update(Options options);
public void AddInstance(Transform transform);

View File

@ -227,7 +227,7 @@ public abstract class UModel : IRenderableModel
IsSetup = true;
}
public virtual void Render(Shader shader, bool outline = false)
public virtual void Render(Shader shader, Texture checker = null, bool outline = false)
{
if (outline) GL.Disable(EnableCap.DepthTest);
if (IsTwoSided) GL.Disable(EnableCap.CullFace);
@ -252,8 +252,16 @@ public abstract class UModel : IRenderableModel
if (!section.Show) continue;
if (!outline)
{
shader.SetUniform("uSectionColor", section.Color);
Materials[section.MaterialIndex].Render(shader);
if (checker != null)
{
shader.SetUniform("uParameters.Diffuse[0].Sampler", 0);
checker.Bind(TextureUnit.Texture0);
}
else
{
shader.SetUniform("uSectionColor", section.Color);
Materials[section.MaterialIndex].Render(shader);
}
}
GL.DrawElementsInstanced(PrimitiveType.Triangles, section.FacesCount, DrawElementsType.UnsignedInt, section.FirstFaceIndexPtr, TransformsCount);

View File

@ -43,6 +43,7 @@ public class Options
{
["material"] = new ("materialicon"),
["noimage"] = new ("T_Placeholder_Item_Image"),
["checker"] = new ("checker"),
["pointlight"] = new ("pointlight"),
["spotlight"] = new ("spotlight"),
["link_on"] = new ("link_on"),

View File

@ -245,7 +245,7 @@ public class Renderer : IDisposable
foreach (var model in Options.Models.Values)
{
if (!model.IsVisible) continue;
model.Render(_shader);
model.Render(_shader, Color == VertexColor.TextureCoordinates ? Options.Icons["checker"] : null);
}
{ // light pass
@ -271,7 +271,7 @@ public class Renderer : IDisposable
}
_outline.Render(viewMatrix, CameraOp.Position, projMatrix);
selected.Render(_outline, true);
selected.Render(_outline, Color == VertexColor.TextureCoordinates ? Options.Icons["checker"] : null, true);
}
// picking pass (dedicated FBO, binding to 0 afterward)

View File

@ -76,11 +76,11 @@ public class Material : IDisposable
if (uvCount < 1 || Parameters.IsNull)
{
Diffuse = new[] { new Texture(new FLinearColor(1f, 0f, 0f, 1f)) };
Diffuse = new[] { options.Icons["checker"] };
Normals = new[] { new Texture(new FLinearColor(0.498f, 0.498f, 0.996f, 1f)) };
SpecularMasks = new [] { new Texture(new FLinearColor(1f, 0.5f, 0.5f, 1f)) };
Emissive = new Texture[1];
DiffuseColor = new[] { new Vector4(0.5f) };
DiffuseColor = new[] { Vector4.One };
EmissiveColor = new[] { Vector4.One };
}
else