Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ae7aae6
Add node graph to model, render by traversing graph
ProtectedVariable Dec 11, 2025
8e0ddbf
UBO done, slight issue with lights in phong shader
ProtectedVariable Dec 11, 2025
9ae85cf
Copy full asset folder instead of individual files
ProtectedVariable Dec 11, 2025
c379313
Fix padding issue
ProtectedVariable Dec 11, 2025
cec6bf5
work on extracting bones
ProtectedVariable Dec 12, 2025
2903628
Merge branch 'animation-system' of github.com:ProtectedVariable/ICE i…
ProtectedVariable Dec 12, 2025
8a597d9
Add animation loading and animation system, untested
ProtectedVariable Dec 12, 2025
4f913f6
Fix eigen error in animationsystem
ProtectedVariable Dec 12, 2025
f27ba25
Start working on testbench for anims
ProtectedVariable Dec 12, 2025
2003ea2
First test of animation
ProtectedVariable Dec 12, 2025
9ae573a
add decompose utility, add animated bind to keep original intact
ProtectedVariable Dec 13, 2025
0d2db34
fix name mismatch
ProtectedVariable Dec 13, 2025
e59e29f
Trying with skeletal anim
ProtectedVariable Dec 13, 2025
34869f4
WIP on skeletal anim
ProtectedVariable Dec 13, 2025
08d4976
Skeletal animation first test passewd
ProtectedVariable Dec 13, 2025
875e731
fix segfault in test
ProtectedVariable Dec 14, 2025
4ec6d30
working fix for double-scaling in skeletal animation
ProtectedVariable Dec 15, 2025
2f778b4
another model another bug
ProtectedVariable Dec 15, 2025
1a58333
add default bind pose for skinned meshes, correct distinction in rend…
ProtectedVariable Dec 16, 2025
1ff4e31
big fix, each mesh has it's own IBM
ProtectedVariable Dec 17, 2025
2c526b7
updated vertex shader
ProtectedVariable Dec 17, 2025
cf4c115
add normal and tangent calculation
ProtectedVariable Dec 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Assets/Shaders/frag_uniforms.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#define MAX_LIGHTS 16

struct Light {
vec3 position;
vec3 rotation;
vec3 color;
float distance_dropoff;
int type;
};

layout(std140, binding = 1) uniform SceneLightsUBO {
Light lights[MAX_LIGHTS];
vec4 ambient_light;
int light_count;
};
2 changes: 1 addition & 1 deletion Assets/Shaders/lastpass.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#version 330 core
#version 420 core

out vec4 fragColor;

Expand Down
2 changes: 1 addition & 1 deletion Assets/Shaders/lastpass.vs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#version 330 core
#version 420 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aUV;

Expand Down
2 changes: 1 addition & 1 deletion Assets/Shaders/normal.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#version 330 core
#version 420 core

out vec4 frag_color;

Expand Down
8 changes: 4 additions & 4 deletions Assets/Shaders/normal.vs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#version 330 core
#version 420 core

#include "vert_uniforms.glsl"

layout (location = 0) in vec3 vertex;
layout (location = 1) in vec3 normal;

uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;

out vec3 f_normal;

void main() {
f_normal = abs(normal);
gl_Position = projection * view * model * vec4(vertex, 1.0);
gl_Position = uProjection * uView * model * vec4(vertex, 1.0);
}
18 changes: 4 additions & 14 deletions Assets/Shaders/phong.fs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#version 330 core
#define ICE_MAX_LIGHTS (16)
#version 420 core

out vec4 frag_color;
#include "frag_uniforms.glsl"

struct Light {
vec3 position;
vec3 rotation;
vec3 color;
int type; //0 = Point, 1 = Directional, 2 = Spot
float distance_dropoff;
};
out vec4 frag_color;

struct Material {
vec4 albedo;
Expand All @@ -26,9 +19,6 @@ struct Material {
sampler2D normal_map;
};

uniform vec3 ambient_light;
uniform Light lights[ICE_MAX_LIGHTS];
uniform int light_count;
uniform Material material;

in vec3 fnormal;
Expand Down Expand Up @@ -88,7 +78,7 @@ void main() {
normal = fnormal;
}
//ambient
vec4 color_accumulator = material.ambient * vec4(ambient_light, 1.0);
vec4 color_accumulator = material.ambient * ambient_light;
if(material.use_ambient_map) {
color_accumulator *= texture(material.ambient_map, ftex_coords);
}
Expand Down
59 changes: 52 additions & 7 deletions Assets/Shaders/phong.vs
Original file line number Diff line number Diff line change
@@ -1,22 +1,67 @@
#version 330 core
#version 420 core

#include "vert_uniforms.glsl"
#define MAX_BONES 100
#define MAX_BONE_INFLUENCE 4

layout (location = 0) in vec3 vertex;
layout (location = 1) in vec3 normal;
layout (location = 2) in vec2 tex_coords;
layout (location = 3) in vec3 tangent;
layout (location = 4) in vec3 bitangent;
layout (location = 5) in ivec4 bone_ids;
layout (location = 6) in vec4 bone_weights;

uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
uniform mat4 bonesTransformMatrices[MAX_BONES];
uniform mat4 bonesOffsetMatrices[MAX_BONES];

out vec3 fnormal;
out vec3 ftangent;
out vec3 fbitangent;
out vec3 fposition;
out vec3 fview;
out vec2 ftex_coords;

void main() {
fview = (inverse(view) * vec4(0, 0, 0, 1)).xyz;
fnormal = normalize(mat3(transpose(inverse(model))) * normal);
fposition = (model * vec4(vertex, 1.0)).xyz;
vec4 totalPosition = vec4(0.0f);
vec3 totalNormal = vec3(0.0f);
vec3 totalTangent = vec3(0.0f);
vec3 totalBitangent = vec3(0.0f);

if(bone_ids == ivec4(-1)) {
totalPosition = vec4(vertex, 1.0f);
totalNormal = normal;
} else {
for(int i = 0 ; i < MAX_BONE_INFLUENCE ; i++) {
if(bone_ids[i] == -1) continue;

if(bone_ids[i] >= MAX_BONES) {
totalPosition = vec4(vertex, 1.0f);
totalNormal = normal;
break;
}

mat4 finalBonesMatrix = bonesTransformMatrices[bone_ids[i]] * bonesOffsetMatrices[bone_ids[i]];

totalPosition += finalBonesMatrix * vec4(vertex, 1.0f) * bone_weights[i];

mat3 normalMatrix = mat3(transpose(inverse(finalBonesMatrix)));
totalNormal += normalMatrix * normal * bone_weights[i];
totalTangent += normalMatrix * tangent * bone_weights[i];
totalBitangent += normalMatrix * bitangent * bone_weights[i];
}
}


fposition = (model * totalPosition).xyz;
mat3 normalModelMatrix = mat3(transpose(inverse(model)));
fnormal = normalize(normalModelMatrix * totalNormal);
ftangent = normalize(normalModelMatrix * totalTangent);
fbitangent = normalize(normalModelMatrix * totalBitangent);

gl_Position = uProjection * uView * model * totalPosition;

fview = (inverse(uView) * vec4(0, 0, 0, 1)).xyz;
ftex_coords = tex_coords;
gl_Position = projection * view * model * vec4(vertex, 1.0);
}
2 changes: 1 addition & 1 deletion Assets/Shaders/picking.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#version 330 core
#version 420 core

uniform int objectID;

Expand Down
8 changes: 4 additions & 4 deletions Assets/Shaders/picking.vs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#version 330 core
#version 420 core

#include "vert_uniforms.glsl"

layout (location = 0) in vec3 vertex;
layout (location = 1) in vec3 normal;

uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;

void main() {
gl_Position = projection * view * model * vec4(vertex, 1.0);
gl_Position = uProjection * uView * model * vec4(vertex, 1.0);
}
2 changes: 1 addition & 1 deletion Assets/Shaders/skybox.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#version 330 core
#version 420 core
out vec4 FragColor;

in vec3 TexCoords;
Expand Down
10 changes: 6 additions & 4 deletions Assets/Shaders/skybox.vs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#version 330 core
#version 420 core

#include "vert_uniforms.glsl"


layout (location = 0) in vec3 aPos;

out vec3 TexCoords;

uniform mat4 projection;
uniform mat4 view;

void main()
{
TexCoords = aPos;
gl_Position = projection * view * vec4(aPos, 1.0);
gl_Position = uProjection * uView * vec4(aPos, 1.0);
}
2 changes: 1 addition & 1 deletion Assets/Shaders/solid.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#version 330 core
#version 420 core

out vec4 frag_color;

Expand Down
8 changes: 4 additions & 4 deletions Assets/Shaders/solid.vs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#version 330 core
#version 420 core

#include "vert_uniforms.glsl"

layout (location = 0) in vec3 vertex;
layout (location = 1) in vec3 normal;
layout (location = 2) in vec2 tex_coords;

uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;

void main() {
gl_Position = projection * view * model * vec4(vertex, 1.0);
gl_Position = uProjection * uView * model * vec4(vertex, 1.0);
}
4 changes: 4 additions & 0 deletions Assets/Shaders/vert_uniforms.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
layout(std140, binding = 0) uniform SceneData {
mat4 uProjection;
mat4 uView;
};
Loading