Skip to content

Commit

Permalink
ufbx texture loading, sprite renderer update
Browse files Browse the repository at this point in the history
  • Loading branch information
beaumanvienna committed Jun 3, 2024
1 parent 89feffc commit 5001c68
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 63 deletions.
18 changes: 12 additions & 6 deletions application/lucre/sceneDescriptions/island.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,9 @@
}
}
]
}
],
"ufbx files":
[
},
{
"filename": "application/lucre/models/external_3D_files/node hierarchy/fbx/node hierarchy.fbx",
"filename": "application/lucre/models/external_3D_files/node hierarchy/gltf/node hierarchy.glb",
"instances":
[
{
Expand All @@ -144,7 +141,16 @@
-0.779968, 2.25822, 0.946633
]
}
},
}
]
}
],
"ufbx files":
[
{
"filename": "application/lucre/models/external_3D_files/node hierarchy/fbx/node hierarchy.fbx",
"instances":
[
{
"transform":
{
Expand Down
203 changes: 199 additions & 4 deletions application/lucre/sceneDescriptions/terrain.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,72 @@
"file format identifier": 1.2,
"description": "terrain scene",
"author": "Copyright (c) 2024 Engine Development Team",
"terrainPngPath": "application/lucre/models/assets/terrain/heightmap.png",
"terrainPngPath": "application/lucre/models/assets/terrain/heightmap2.png",
"fastgltf files":
[
{
"filename": "application/lucre/models/funkyKong/sports car/cube.glb",
"instances":
[
{
"transform":
{
"scale":
[
0.141, 0.141, 0.141
],
"rotation":
[
3.14159, 1.07215, 3.14159
],
"translation":
[
-0.779968, 2.25822, -4
]
}
},
{
"transform":
{
"scale":
[
0.140998, 0.140998, 0.140998
],
"rotation":
[
3.01614, 1.00771, 2.99355
],
"translation":
[
-0.494322, 2.28222, -3.408
]
}
}
]
},
{
"filename": "application/lucre/models/external_3D_files/lights/gltf/lights.glb",
"instances":
[
{
"transform":
{
"scale":
[
0.084, 0.084, 0.084
],
"rotation":
[
0, -0, 0
],
"translation":
[
-0.745493, 2.37433, -0.536219
]
}
}
]
},
{
"filename": "application/lucre/models/guybrush_animated_gltf/animation/guybrush.glb",
"instances":
Expand Down Expand Up @@ -81,12 +144,121 @@
}
}
]
},
{
"filename": "application/lucre/models/external_3D_files/node hierarchy/gltf/node hierarchy.glb",
"instances":
[
{
"transform":
{
"scale":
[
0.141, 0.141, 0.141
],
"rotation":
[
3.14159, 1.07215, 3.14159
],
"translation":
[
-0.779968, 2.25822, 0.946633
]
}
}
]
}
],
"gltf files":
[
{
"filename": "application/lucre/models/funkyKong/sports car/cube.glb",
"instances":
[
{
"transform":
{
"scale":
[
0.141, 0.141, 0.141
],
"rotation":
[
3.14159, 1.07215, 3.14159
],
"translation":
[
-0.779968, 5.25822, -4
]
}
},
{
"transform":
{
"scale":
[
0.140998, 0.140998, 0.140998
],
"rotation":
[
3.01614, 1.00771, 2.99355
],
"translation":
[
-0.494322, 5.28222, -3.408
]
}
}
]
}
],
"fbx files":
[
{
"filename": "application/lucre/models/funkyKong/sports car/cube.fbx",
"instances":
[
{
"transform":
{
"scale":
[
0.141, 0.141, 0.141
],
"rotation":
[
3.14159, 1.07215, 3.14159
],
"translation":
[
-0.779968, 4.25822, -4
]
}
},
{
"transform":
{
"scale":
[
0.140998, 0.140998, 0.140998
],
"rotation":
[
3.01614, 1.00771, 2.99355
],
"translation":
[
-0.494322, 4.28222, -3.408
]
}
}
]
}
],
"ufbx files":
[
{
"filename": "application/lucre/models/external_3D_files/node hierarchy/fbx/node hierarchy.fbx",
"filename": "application/lucre/models/funkyKong/sports car/cube.fbx",
"instances":
[
{
Expand All @@ -102,10 +274,33 @@
],
"translation":
[
-0.779968, 2.25822, 0.946633
-0.779968, 3.25822, -4
]
}
},
{
"transform":
{
"scale":
[
0.140998, 0.140998, 0.140998
],
"rotation":
[
3.01614, 1.00771, 2.99355
],
"translation":
[
-0.494322, 3.28222, -3.408
]
}
}
]
},
{
"filename": "application/lucre/models/external_3D_files/node hierarchy/fbx/node hierarchy.fbx",
"instances":
[
{
"transform":
{
Expand All @@ -126,4 +321,4 @@
]
}
]
}
}
20 changes: 10 additions & 10 deletions engine/platform/Vulkan/shaders/spriteRenderer.frag
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ layout(location = 0) in vec4 fragColor;
layout(location = 1) in vec3 fragPositionWorld;
layout(location = 2) in vec3 fragNormalWorld;
layout(location = 3) in vec2 fragUV;
layout(location = 4) in float fragAmplification;
layout(location = 5) flat in int fragUnlit;
layout(location = 6) in vec3 toCameraDirection;
layout(location = 4) in vec3 toCameraDirection;

struct PointLight
{
Expand Down Expand Up @@ -71,6 +69,8 @@ layout(push_constant) uniform Push

void main()
{
float amplification = 1.0;
bool unlit = false;

vec3 ambientLightColor = ubo.m_AmbientLightColor.xyz * ubo.m_AmbientLightColor.w;

Expand Down Expand Up @@ -117,15 +117,15 @@ void main()
// ------------------------------

vec3 pixelColor;
float alpha = texture(tex1,fragUV).w;
float alpha = texture(tex1,fragUV).w;
if (alpha == 0.0) discard;
pixelColor = texture(tex1,fragUV).xyz;
pixelColor *= fragAmplification;
if (fragUnlit != 0)
{
diffusedLightColor = vec3(1.0, 1.0, 1.0);
specularLightColor = vec3(0.0, 0.0, 0.0);
pixelColor *= amplification;

if (unlit)
{
diffusedLightColor = vec3(1.0, 1.0, 1.0);
specularLightColor = vec3(0.0, 0.0, 0.0);
}

outColor.xyz = ambientLightColor*pixelColor.xyz + (diffusedLightColor * pixelColor.xyz) + specularLightColor;
Expand Down
6 changes: 1 addition & 5 deletions engine/platform/Vulkan/shaders/spriteRenderer.vert
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ layout(location = 0) out vec4 fragColor;
layout(location = 1) out vec3 fragPositionWorld;
layout(location = 2) out vec3 fragMormalWorld;
layout(location = 3) out vec2 fragUV;
layout(location = 4) out float fragAmplification;
layout(location = 5) out int fragUnlit;
layout(location = 6) out vec3 toCameraDirection;
layout(location = 4) out vec3 toCameraDirection;

void main()
{
Expand All @@ -81,8 +79,6 @@ void main()
fragPositionWorld = positionWorld.xyz;
fragMormalWorld = normalize(mat3(push.m_NormalMatrix) * normal);
fragColor = color;
fragAmplification = amplification;
fragUnlit = unlit;

// projection * view * model * position
gl_Position = ubo.m_Projection * ubo.m_View * push.m_ModelMatrix * vec4(position, 1.0);
Expand Down
4 changes: 2 additions & 2 deletions engine/renderer/builder/builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ namespace GfxRenderEngine
submesh.m_VertexCount = m_Vertices.size();
submesh.m_InstanceCount = 1;

submesh.m_Material.m_PbrMaterial.m_Roughness = 0.5f;
submesh.m_Material.m_PbrMaterial.m_Metallic = 0.1f;
submesh.m_Material.m_PbrMaterial.m_Roughness = 0.1f;
submesh.m_Material.m_PbrMaterial.m_Metallic = 0.9f;
submesh.m_Material.m_PbrMaterial.m_NormalMapIntensity = 1.0f;

{ // create material descriptor
Expand Down
Loading

0 comments on commit 5001c68

Please sign in to comment.