Skip to content

Commit

Permalink
emu: 3d fixes (#5)
Browse files Browse the repository at this point in the history
* test

* emu: Improvements 3d
  • Loading branch information
pent0 authored Jun 17, 2023
1 parent 49dd8c4 commit ee18a3a
Show file tree
Hide file tree
Showing 66 changed files with 2,059 additions and 347 deletions.
5 changes: 0 additions & 5 deletions Assets/Scripts/Driver.Unity/Audio/PCMSound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public PCMSound(AudioDriver driver, AudioSource assignedAudioSource, byte[] audi

if (isAdpcm)
{
if (bitsPerSample != 16)
{
throw new ArgumentException("Sample bits must be 16 bits for ADPCM audio!");
}

clip = AudioClip.Create("ADPCM sound", audioData.Length * 2 / channels, channels,
frequency, false);

Expand Down
12 changes: 8 additions & 4 deletions Assets/Scripts/Driver.Unity/Graphics/BufferPusher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private struct Vertex
public Vector3 normal;
public Color color;
public Vector2 uv;
public Color specularColor;
}

private Mesh bigMesh;
Expand All @@ -54,7 +55,8 @@ public BufferPusher(int maxVerticesCount = 10000, int maxIndiciesCount = 30000)
new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.Float32, 3),
new VertexAttributeDescriptor(VertexAttribute.Normal, VertexAttributeFormat.Float32, 3),
new VertexAttributeDescriptor(VertexAttribute.Color, VertexAttributeFormat.Float32, 4),
new VertexAttributeDescriptor(VertexAttribute.TexCoord0, VertexAttributeFormat.Float32, 2)
new VertexAttributeDescriptor(VertexAttribute.TexCoord0, VertexAttributeFormat.Float32, 2),
new VertexAttributeDescriptor(VertexAttribute.TexCoord1, VertexAttributeFormat.Float32, 4)
});

bigMesh.SetIndexBufferParams(maxIndiciesCount, IndexFormat.UInt32);
Expand Down Expand Up @@ -93,7 +95,8 @@ public int Push(MpMesh meshes)
position = meshes.vertices[i].ToUnity(),
uv = meshes.uvs.IsEmpty ? Vector2.zero : meshes.uvs[i].ToUnity(),
normal = meshes.normals.IsEmpty ? Vector3.one : meshes.normals[i].ToUnity(),
color = meshes.diffuses.IsEmpty ? Color.white : meshes.diffuses[i].ToUnity()
color = meshes.diffuses.IsEmpty ? Color.white : meshes.diffuses[i].ToUnity(),
specularColor = meshes.speculars.IsEmpty ? Color.white : meshes.speculars[i].ToUnity()
});
}

Expand All @@ -105,7 +108,7 @@ public int Push(MpMesh meshes)
return submeshes.Count - 1;
}

public int Push(List<Vector3> positions, List<Vector2> uvs, List<Vector3> normals, List<Color> colors, List<int> indiciesSpan)
public int Push(List<Vector3> positions, List<Vector2> uvs, List<Vector3> normals, List<Color> colors, List<Color> specularColors, List<int> indiciesSpan)
{
if ((vertices.Count + positions.Count > maxVerticesCount) || (indicies.Count + indiciesSpan.Count > maxIndiciesCount))
{
Expand All @@ -121,7 +124,8 @@ public int Push(List<Vector3> positions, List<Vector2> uvs, List<Vector3> normal
position = positions[i],
uv = uvs[i],
normal = normals[i],
color = colors[i]
color = colors[i],
specularColor = specularColors[i]
});
}

Expand Down
15 changes: 13 additions & 2 deletions Assets/Scripts/Driver.Unity/Graphics/ClientState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,28 @@ namespace Nofun.Driver.Unity.Graphics
{
public class ClientState
{
public const int MaximumLight = 8;

public MpCullMode cullMode = MpCullMode.CounterClockwise;
public MpBlendMode blendMode = MpBlendMode.Alpha;
public MpBlendMode blendMode = MpBlendMode.Replace;
public MpTextureBlendMode textureBlendMode = MpTextureBlendMode.Modulate;
public bool textureMode = false;
public MpCompareFunc depthCompareFunc = MpCompareFunc.Always;
public Rect scissorRect;
public Rect viewportRect;
public Matrix4x4 projectionMatrix3D;
public Matrix4x4 viewMatrix3D;
public Matrix4x4 lightMatrix3D;
public Texture mainTexture;

public MpExtendedMaterial extendedMaterial;
public bool lighting = false;
public bool specular = false;
public bool fog = false;
public SColor globalAmbient;
public MpLight[] lights = new MpLight[MaximumLight];
public Vector3 cameraPosition;
public bool transparentTest = false;

public ulong MaterialIdentifier
{
get
Expand Down
Loading

0 comments on commit ee18a3a

Please # to comment.