continued with asset loader
This commit is contained in:
3095
default_assets/meshes/corvette.obj
Normal file
3095
default_assets/meshes/corvette.obj
Normal file
File diff suppressed because it is too large
Load Diff
48
default_assets/shaders/phong.frag
Normal file
48
default_assets/shaders/phong.frag
Normal file
@@ -0,0 +1,48 @@
|
||||
#version 400
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 TexCoord;
|
||||
in vec3 Normal;
|
||||
|
||||
uniform sampler2D diffuseMap;
|
||||
uniform sampler2D specularMap;
|
||||
|
||||
uniform vec3 viewPosition;
|
||||
|
||||
uniform vec3 phongAmbient;
|
||||
uniform vec3 phongDiffuse;
|
||||
uniform vec3 phongSpecular;
|
||||
uniform float phongShininess;
|
||||
|
||||
uniform vec3 lightPosition;
|
||||
uniform vec3 lightDirection;
|
||||
uniform vec3 lightAmbient;
|
||||
uniform vec3 lightDiffuse;
|
||||
uniform vec3 lightSpecular;
|
||||
|
||||
void main() {
|
||||
vec3 diffuseColor = texture(diffuseMap, TexCoord).rgb;
|
||||
vec3 specularColor = texture(specularMap, TexCoord).rgb;
|
||||
|
||||
vec3 norm = normalize(Normal);
|
||||
vec3 lightDir = normalize(-lightDirection);
|
||||
vec3 viewDir = normalize(viewPosition - Position);
|
||||
vec3 halfwayDir = normalize(lightDir + viewDir);
|
||||
|
||||
vec3 ambient = lightAmbient * (diffuseColor * phongAmbient);
|
||||
|
||||
float diffImpact = max(dot(norm, lightDir), 0.0);
|
||||
vec3 diffuse = lightDiffuse * (diffImpact * diffuseColor * phongDiffuse);
|
||||
|
||||
vec3 reflectDir = reflect(-lightDir, norm);
|
||||
float effectiveShininess = max(phongShininess, 1.0);
|
||||
float spec = pow(max(dot(norm, halfwayDir), 0.0), effectiveShininess);
|
||||
vec3 specular = lightSpecular * (spec * specularColor * phongSpecular);
|
||||
|
||||
vec3 result = ambient + diffuse + specular;
|
||||
|
||||
float gamma = 2.2;
|
||||
FragColor.rgb = pow(result.rgb, vec3(1.0/gamma));
|
||||
}
|
||||
5
default_assets/shaders/phong.shader
Normal file
5
default_assets/shaders/phong.shader
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "phong",
|
||||
"vertex": "phong.vert",
|
||||
"fragment": "phong.frag"
|
||||
}
|
||||
22
default_assets/shaders/phong.vert
Normal file
22
default_assets/shaders/phong.vert
Normal file
@@ -0,0 +1,22 @@
|
||||
#version 400
|
||||
|
||||
layout (location = 0) in vec3 position;
|
||||
layout (location = 1) in vec2 uv;
|
||||
layout (location = 2) in vec3 normal;
|
||||
|
||||
out vec3 Position;
|
||||
out vec2 TexCoord;
|
||||
out vec3 Normal;
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
void main() {
|
||||
Position = vec3(model * vec4(position, 1.0));
|
||||
Normal = mat3(transpose(inverse(model))) * normal;
|
||||
|
||||
TexCoord = uv;
|
||||
|
||||
gl_Position = projection * view * vec4(Position, 1.0);
|
||||
}
|
||||
BIN
default_assets/textures/corvette.png
Normal file
BIN
default_assets/textures/corvette.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.3 MiB |
Reference in New Issue
Block a user