Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
7564d92018 |
@ -19,8 +19,6 @@
|
|||||||
<None Include="shaders\shader_blur.vert" />
|
<None Include="shaders\shader_blur.vert" />
|
||||||
<None Include="shaders\shader_normal.frag" />
|
<None Include="shaders\shader_normal.frag" />
|
||||||
<None Include="shaders\shader_normal.vert" />
|
<None Include="shaders\shader_normal.vert" />
|
||||||
<None Include="shaders\shader_parallax.frag" />
|
|
||||||
<None Include="shaders\shader_parallax.vert" />
|
|
||||||
<None Include="shaders\shader_particle.frag" />
|
<None Include="shaders\shader_particle.frag" />
|
||||||
<None Include="shaders\shader_particle.vert" />
|
<None Include="shaders\shader_particle.vert" />
|
||||||
<None Include="shaders\shader_skybox.frag" />
|
<None Include="shaders\shader_skybox.frag" />
|
||||||
@ -34,8 +32,6 @@
|
|||||||
<ClCompile Include="src\Box.cpp" />
|
<ClCompile Include="src\Box.cpp" />
|
||||||
<ClCompile Include="src\Camera.cpp" />
|
<ClCompile Include="src\Camera.cpp" />
|
||||||
<ClCompile Include="src\main.cpp" />
|
<ClCompile Include="src\main.cpp" />
|
||||||
<ClCompile Include="src\Object.cpp" />
|
|
||||||
<ClCompile Include="src\Physics.cpp" />
|
|
||||||
<ClCompile Include="src\picopng.cpp" />
|
<ClCompile Include="src\picopng.cpp" />
|
||||||
<ClCompile Include="src\Render_Utils.cpp" />
|
<ClCompile Include="src\Render_Utils.cpp" />
|
||||||
<ClCompile Include="src\Shader_Loader.cpp" />
|
<ClCompile Include="src\Shader_Loader.cpp" />
|
||||||
@ -46,9 +42,7 @@
|
|||||||
<ClInclude Include="src\Camera.h" />
|
<ClInclude Include="src\Camera.h" />
|
||||||
<ClInclude Include="src\mesh.h" />
|
<ClInclude Include="src\mesh.h" />
|
||||||
<ClInclude Include="src\model.h" />
|
<ClInclude Include="src\model.h" />
|
||||||
<ClInclude Include="src\Object.h" />
|
|
||||||
<ClInclude Include="src\objload.h" />
|
<ClInclude Include="src\objload.h" />
|
||||||
<ClInclude Include="src\Physics.h" />
|
|
||||||
<ClInclude Include="src\picopng.h" />
|
<ClInclude Include="src\picopng.h" />
|
||||||
<ClInclude Include="src\Render_Utils.h" />
|
<ClInclude Include="src\Render_Utils.h" />
|
||||||
<ClInclude Include="src\Shader_Loader.h" />
|
<ClInclude Include="src\Shader_Loader.h" />
|
||||||
|
@ -66,12 +66,6 @@
|
|||||||
<None Include="shaders\shader_asteroid.vert">
|
<None Include="shaders\shader_asteroid.vert">
|
||||||
<Filter>Shader Files</Filter>
|
<Filter>Shader Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="shaders\shader_parallax.frag">
|
|
||||||
<Filter>Shader Files</Filter>
|
|
||||||
</None>
|
|
||||||
<None Include="shaders\shader_parallax.vert">
|
|
||||||
<Filter>Shader Files</Filter>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\Box.cpp">
|
<ClCompile Include="src\Box.cpp">
|
||||||
@ -95,12 +89,6 @@
|
|||||||
<ClCompile Include="src\main.cpp">
|
<ClCompile Include="src\main.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="src\Physics.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="src\Object.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="src\stb_image.h">
|
<ClInclude Include="src\stb_image.h">
|
||||||
@ -133,11 +121,5 @@
|
|||||||
<ClInclude Include="Skybox.h">
|
<ClInclude Include="Skybox.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Physics.h">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Object.h">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
BIN
models/arm.blend
Normal file
BIN
models/arm.fbx
Normal file
@ -22,5 +22,4 @@ d 1.000000
|
|||||||
illum 2
|
illum 2
|
||||||
map_Kd textures\\humster_BaseColor.png
|
map_Kd textures\\humster_BaseColor.png
|
||||||
map_Ns textures\\humster_Roughness.png
|
map_Ns textures\\humster_Roughness.png
|
||||||
bump textures\\humster_Height.png
|
|
||||||
refl textures\\humster_Metallic.png
|
refl textures\\humster_Metallic.png
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
# Blender MTL File: 'uploads_files_927450_space_humster.blend'
|
|
||||||
# Material Count: 1
|
|
||||||
|
|
||||||
newmtl humster
|
|
||||||
Ns 225.000000
|
|
||||||
Ka 1.000000 1.000000 1.000000
|
|
||||||
Kd 0.800000 0.800000 0.800000
|
|
||||||
Ks 0.420000 0.420000 0.420000
|
|
||||||
Ke 0.000000 0.000000 0.000000
|
|
||||||
Ni 1.450000
|
|
||||||
d 1.000000
|
|
||||||
illum 2
|
|
||||||
map_Kd textures\\humster_BaseColor.png
|
|
||||||
map_Ns textures\\humster_Roughness.png
|
|
||||||
refl textures\\humster_Metallic.png
|
|
||||||
bump textures\\humster_Height.png
|
|
@ -1,42 +0,0 @@
|
|||||||
# Blender MTL File: 'uploads_files_911030_stargate002.blend'
|
|
||||||
# Material Count: 4
|
|
||||||
|
|
||||||
newmtl event_horizon.cycles
|
|
||||||
Ns 225.000000
|
|
||||||
Ka 1.000000 1.000000 1.000000
|
|
||||||
Kd 0.800000 0.800000 0.800000
|
|
||||||
Ks 0.500000 0.500000 0.500000
|
|
||||||
Ke 0.000000 0.000000 0.000000
|
|
||||||
Ni 1.000000
|
|
||||||
d 1.000000
|
|
||||||
illum 2
|
|
||||||
|
|
||||||
newmtl gate.cycles
|
|
||||||
Ns 225.000000
|
|
||||||
Ka 1.000000 1.000000 1.000000
|
|
||||||
Kd 0.800000 0.800000 0.800000
|
|
||||||
Ks 0.500000 0.500000 0.500000
|
|
||||||
Ke 0.000000 0.000000 0.000000
|
|
||||||
Ni 1.000000
|
|
||||||
d 1.000000
|
|
||||||
illum 2
|
|
||||||
|
|
||||||
newmtl gate_grey.cycles
|
|
||||||
Ns 225.000000
|
|
||||||
Ka 1.000000 1.000000 1.000000
|
|
||||||
Kd 0.259800 0.259800 0.259800
|
|
||||||
Ks 0.500000 0.500000 0.500000
|
|
||||||
Ke 0.000000 0.000000 0.000000
|
|
||||||
Ni 1.000000
|
|
||||||
d 1.000000
|
|
||||||
illum 2
|
|
||||||
|
|
||||||
newmtl glow.cycles
|
|
||||||
Ns 225.000000
|
|
||||||
Ka 1.000000 1.000000 1.000000
|
|
||||||
Kd 1.000000 0.491265 0.000000
|
|
||||||
Ks 0.000000 0.000000 0.000000
|
|
||||||
Ke 0.000000 0.000000 0.000000
|
|
||||||
Ni 1.000000
|
|
||||||
d 1.000000
|
|
||||||
illum 1
|
|
46869
models/stargate.obj
Before Width: | Height: | Size: 3.0 MiB |
Before Width: | Height: | Size: 2.8 MiB |
Before Width: | Height: | Size: 793 KiB |
Before Width: | Height: | Size: 4.2 MiB |
Before Width: | Height: | Size: 434 KiB |
Before Width: | Height: | Size: 434 KiB |
Before Width: | Height: | Size: 1.0 MiB |
Before Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 3.5 MiB |
@ -41,13 +41,15 @@ void main()
|
|||||||
// then retrieve perpendicular vector B with the cross product of T and N
|
// then retrieve perpendicular vector B with the cross product of T and N
|
||||||
vec3 B = cross(N, T);
|
vec3 B = cross(N, T);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(T, B, N));
|
mat3 TBN = mat3(T, B, N);
|
||||||
|
|
||||||
for(int i=0; i<LightsCount; i++)
|
for(int i=0; i<LightsCount; i++)
|
||||||
LightPosTS[i] = TBN * pointLights[i].position;
|
LightPosTS[i] = TBN * pointLights[i].position;
|
||||||
fragPos = (aInstanceMatrix*vec4(vertexPosition,1)).xyz;
|
|
||||||
CameraPosTS = TBN * cameraPos;
|
CameraPosTS = TBN * cameraPos;
|
||||||
FragPosTS = TBN * fragPos;
|
FragPosTS = TBN * fragPos;
|
||||||
|
|
||||||
|
|
||||||
|
fragPos = (aInstanceMatrix*vec4(vertexPosition,1)).xyz;
|
||||||
vTexCoord = vertexTexCoord;
|
vTexCoord = vertexTexCoord;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ uniform sampler2D scene;
|
|||||||
uniform sampler2D bloomBlur;
|
uniform sampler2D bloomBlur;
|
||||||
uniform vec2 screenSize;
|
uniform vec2 screenSize;
|
||||||
|
|
||||||
|
//
|
||||||
float FXAA_SPAN_MAX = 100.0f;
|
float FXAA_SPAN_MAX = 100.0f;
|
||||||
//sila dzialania
|
//sila dzialania
|
||||||
float FXAA_REDUCE_MUL = 1.0f/8.0f;
|
float FXAA_REDUCE_MUL = 1.0f/8.0f;
|
||||||
@ -57,7 +58,7 @@ vec3 fastAA()
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
const float gamma = 0.7f;
|
const float gamma = 0.8;
|
||||||
vec3 hdrColor = fastAA(); //texture(scene, vTexCoords).rgb;
|
vec3 hdrColor = fastAA(); //texture(scene, vTexCoords).rgb;
|
||||||
vec3 bloomColor = texture(bloomBlur, vTexCoords).rgb;
|
vec3 bloomColor = texture(bloomBlur, vTexCoords).rgb;
|
||||||
hdrColor += bloomColor;
|
hdrColor += bloomColor;
|
||||||
|
@ -19,7 +19,6 @@ uniform mat4 modelMatrix;
|
|||||||
uniform vec3 cameraPos;
|
uniform vec3 cameraPos;
|
||||||
uniform PointLight pointLights[MAX_POINT_LIGHTS];
|
uniform PointLight pointLights[MAX_POINT_LIGHTS];
|
||||||
uniform int LightsCount;
|
uniform int LightsCount;
|
||||||
uniform mat3 normalMatrix;
|
|
||||||
|
|
||||||
|
|
||||||
out vec3 fragPos;
|
out vec3 fragPos;
|
||||||
@ -32,19 +31,24 @@ void main()
|
|||||||
{
|
{
|
||||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||||
|
|
||||||
|
mat3 normalMatrix = transpose(inverse(mat3(modelMatrix)));
|
||||||
|
|
||||||
vec3 T = normalize(normalMatrix * aTangent);
|
vec3 T = normalize(normalMatrix * aTangent);
|
||||||
vec3 N = normalize(normalMatrix * vertexNormal);
|
vec3 N = normalize(normalMatrix * vertexNormal);
|
||||||
|
// re-orthogonalize T with respect to N
|
||||||
T = normalize(T - dot(T, N) * N);
|
T = normalize(T - dot(T, N) * N);
|
||||||
|
// then retrieve perpendicular vector B with the cross product of T and N
|
||||||
vec3 B = cross(N, T);
|
vec3 B = cross(N, T);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(T, B, N));
|
mat3 TBN = mat3(T, B, N);
|
||||||
|
|
||||||
for(int i=0; i<LightsCount; i++)
|
for(int i=0; i<LightsCount; i++)
|
||||||
LightPosTS[i] = TBN * pointLights[i].position;
|
LightPosTS[i] = TBN * pointLights[i].position;
|
||||||
|
|
||||||
fragPos = (modelMatrix*vec4(vertexPosition,1)).xyz;
|
|
||||||
CameraPosTS = TBN * cameraPos;
|
CameraPosTS = TBN * cameraPos;
|
||||||
FragPosTS = TBN * fragPos;
|
FragPosTS = TBN * fragPos;
|
||||||
|
|
||||||
|
|
||||||
|
fragPos = (modelMatrix*vec4(vertexPosition,1)).xyz;
|
||||||
vTexCoord = vertexTexCoord;
|
vTexCoord = vertexTexCoord;
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,19 @@
|
|||||||
#version 430 core
|
#version 330 core
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
layout (location = 0) out vec4 FragColor;
|
in VS_OUT {
|
||||||
layout (location = 1) out vec4 BrightColor;
|
vec3 FragPos;
|
||||||
|
vec2 TexCoords;
|
||||||
|
vec3 TangentLightPos;
|
||||||
|
vec3 TangentViewPos;
|
||||||
|
vec3 TangentFragPos;
|
||||||
|
} fs_in;
|
||||||
|
|
||||||
struct PointLight {
|
|
||||||
vec3 position;
|
|
||||||
vec3 color;
|
|
||||||
float intensity;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MAX_POINT_LIGHTS 16
|
|
||||||
|
|
||||||
uniform vec3 cameraPos;
|
|
||||||
uniform sampler2D diffuseTexture;
|
uniform sampler2D diffuseTexture;
|
||||||
uniform sampler2D normalTexture;
|
uniform sampler2D normalTexture;
|
||||||
uniform sampler2D depthTexture;
|
uniform sampler2D depthTexture;
|
||||||
|
|
||||||
uniform PointLight pointLights[MAX_POINT_LIGHTS];
|
uniform float heightScale;
|
||||||
uniform int LightsCount;
|
|
||||||
|
|
||||||
in vec3 fragPos;
|
|
||||||
in vec2 vTexCoord;
|
|
||||||
in vec3 LightPosTS[MAX_POINT_LIGHTS];
|
|
||||||
in vec3 CameraPosTS;
|
|
||||||
in vec3 FragPosTS;
|
|
||||||
|
|
||||||
vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir)
|
vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir)
|
||||||
{
|
{
|
||||||
@ -36,7 +26,7 @@ vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir)
|
|||||||
// depth of current layer
|
// depth of current layer
|
||||||
float currentLayerDepth = 0.0;
|
float currentLayerDepth = 0.0;
|
||||||
// the amount to shift the texture coordinates per layer (from vector P)
|
// the amount to shift the texture coordinates per layer (from vector P)
|
||||||
vec2 P = viewDir.xy / viewDir.z * 0.001;
|
vec2 P = viewDir.xy / viewDir.z * heightScale;
|
||||||
vec2 deltaTexCoords = P / numLayers;
|
vec2 deltaTexCoords = P / numLayers;
|
||||||
|
|
||||||
// get initial values
|
// get initial values
|
||||||
@ -69,38 +59,27 @@ vec2 ParallaxMapping(vec2 texCoords, vec3 viewDir)
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec3 fragColor = vec3(0,0,0);
|
vec3 fragColor = vec3(0,0,0);
|
||||||
vec3 V = normalize(CameraPosTS-FragPosTS);
|
vec3 viewDir = normalize(fs_in.TangentViewPos - fs_in.TangentFragPos);
|
||||||
vec2 texCoords = ParallaxMapping(vTexCoord, V);
|
vec2 texCoords = ParallaxMapping(fs_in.TexCoords, viewDir);
|
||||||
if(texCoords.x > 1.0 || texCoords.y > 1.0 || texCoords.x < 0.0 || texCoords.y < 0.0)
|
if(texCoords.x > 1.0 || texCoords.y > 1.0 || texCoords.x < 0.0 || texCoords.y < 0.0)
|
||||||
discard;
|
discard;
|
||||||
|
|
||||||
vec3 texture = texture2D(diffuseTexture, texCoords).rgb;
|
vec3 texture = texture2D(diffuseTexture, texCoords).rgb;
|
||||||
//vec3 texture = vec3(textureColor.x, textureColor.y, textureColor.z);
|
vec3 ambient = vec3(0.1, 0.1, 0.1) * texture;
|
||||||
vec3 ambient = vec3(0.1, 0.1, 0.1) * texture;
|
|
||||||
|
|
||||||
|
// obtain normal from normal map
|
||||||
vec3 normal = texture2D(normalTexture, texCoords).rgb;
|
vec3 normal = texture2D(normalTexture, texCoords).rgb;
|
||||||
normal = normalize(normal * 2.0 - 1.0);
|
normal = normalize(normal * 2.0 - 1.0);
|
||||||
for(int i = 0; i < LightsCount; i++)
|
|
||||||
{
|
|
||||||
vec3 lightDir = normalize(LightPosTS[i] - FragPosTS);
|
|
||||||
|
|
||||||
|
vec3 lightDir = normalize(fs_in.TangentLightPos[0] - fs_in.TangentFragPos);
|
||||||
|
float diff = max(0,dot(normal,normalize(lightDir)));
|
||||||
|
vec3 diffuse = diff * texture;
|
||||||
|
// specular
|
||||||
|
vec3 reflectDir = reflect(-lightDir, normal);
|
||||||
|
vec3 halfwayDir = normalize(lightDir + viewDir);
|
||||||
|
float spec = pow(max(dot(normal, halfwayDir), 0.0), 32.0);
|
||||||
|
|
||||||
vec3 R = reflect(-lightDir,normal);
|
vec3 specular = vec3(0.2) * spec;
|
||||||
|
FragColor = vec4(ambient + diffuse + specular, 1.0);
|
||||||
float dist = distance(fragPos, pointLights[i].position);
|
|
||||||
float distance = (1/dist) * (1/dist);
|
|
||||||
|
|
||||||
float spec = pow(max(0,dot(R,V)),2);
|
|
||||||
float diff = max(0,dot(normal,lightDir));
|
|
||||||
|
|
||||||
vec3 diffuse = pointLights[i].color * diff * distance * pointLights[i].intensity;
|
|
||||||
vec3 specular = spec * pointLights[i].color * (pointLights[i].intensity/dist);
|
|
||||||
|
|
||||||
|
|
||||||
fragColor += texture*(diffuse+specular);
|
|
||||||
}
|
|
||||||
|
|
||||||
BrightColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
||||||
FragColor = vec4(fragColor+ambient,1.0);
|
|
||||||
}
|
}
|
@ -1,51 +1,44 @@
|
|||||||
#version 430 core
|
#version 330 core
|
||||||
|
|
||||||
layout(location = 0) in vec3 vertexPosition;
|
layout(location = 0) in vec3 vertexPosition;
|
||||||
layout(location = 1) in vec2 vertexTexCoord;
|
layout(location = 1) in vec2 vertexTexCoord;
|
||||||
layout(location = 2) in vec3 vertexNormal;
|
layout(location = 2) in vec3 vertexNormal;
|
||||||
layout (location = 3) in vec3 aTangent;
|
layout (location = 3) in vec3 aTangent;
|
||||||
layout (location = 4) in vec3 aBitangent;
|
layout (location = 4) in vec3 aBitangent;
|
||||||
|
|
||||||
struct PointLight {
|
out VS_OUT {
|
||||||
vec3 position;
|
vec3 FragPos;
|
||||||
vec3 color;
|
vec2 TexCoords;
|
||||||
float intensity;
|
vec3 TangentLightPos;
|
||||||
};
|
vec3 TangentViewPos;
|
||||||
|
vec3 TangentFragPos;
|
||||||
|
} vs_out;
|
||||||
|
|
||||||
#define MAX_POINT_LIGHTS 16
|
uniform mat4 projection;
|
||||||
|
uniform mat4 view;
|
||||||
uniform mat4 transformation;
|
|
||||||
uniform mat4 modelMatrix;
|
uniform mat4 modelMatrix;
|
||||||
uniform vec3 cameraPos;
|
uniform mat4 transformation;
|
||||||
uniform PointLight pointLights[MAX_POINT_LIGHTS];
|
|
||||||
uniform int LightsCount;
|
|
||||||
uniform mat3 normalMatrix;
|
|
||||||
|
|
||||||
|
|
||||||
out vec3 fragPos;
|
uniform vec3 lightPos;
|
||||||
out vec2 vTexCoord;
|
uniform vec3 viewPos;
|
||||||
out vec3 LightPosTS[MAX_POINT_LIGHTS];
|
|
||||||
out vec3 CameraPosTS;
|
|
||||||
out vec3 FragPosTS;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||||
|
mat3 normalMatrix = transpose(inverse(mat3(modelMatrix)));
|
||||||
|
|
||||||
vec3 T = normalize(normalMatrix * aTangent);
|
gl_Position = projection * view * modelMatrix * vec4(vertexPosition, 1.0);
|
||||||
|
vs_out.FragPos = vec3(modelMatrix * vec4(vertexPosition, 1.0));
|
||||||
|
vs_out.TexCoords = vertexTexCoord;
|
||||||
|
|
||||||
|
vec3 T = normalize(normalMatrix * aTangent);
|
||||||
vec3 N = normalize(normalMatrix * vertexNormal);
|
vec3 N = normalize(normalMatrix * vertexNormal);
|
||||||
// re-orthogonalize T with respect to N
|
|
||||||
T = normalize(T - dot(T, N) * N);
|
T = normalize(T - dot(T, N) * N);
|
||||||
// then retrieve perpendicular vector B with the cross product of T and N
|
|
||||||
vec3 B = cross(N, T);
|
vec3 B = cross(N, T);
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(T, B, N));
|
mat3 TBN = mat3(T, B, N);
|
||||||
|
|
||||||
for(int i=0; i<LightsCount; i++)
|
vs_out.TangentLightPos = TBN * lightPos;
|
||||||
LightPosTS[i] = TBN * pointLights[i].position;
|
vs_out.TangentViewPos = TBN * viewPos;
|
||||||
|
vs_out.TangentFragPos = (modelMatrix*vec4(vertexPosition,1)).xyz;
|
||||||
fragPos = (modelMatrix*vec4(vertexPosition,1)).xyz;
|
|
||||||
CameraPosTS = TBN * cameraPos;
|
|
||||||
FragPosTS = TBN * fragPos;
|
|
||||||
vTexCoord = vertexTexCoord;
|
|
||||||
}
|
}
|
BIN
skybox/back1.jpg
Before Width: | Height: | Size: 216 KiB |
Before Width: | Height: | Size: 191 KiB |
Before Width: | Height: | Size: 203 KiB |
BIN
skybox/left1.jpg
Before Width: | Height: | Size: 208 KiB |
Before Width: | Height: | Size: 203 KiB |
BIN
skybox/top1.jpg
Before Width: | Height: | Size: 224 KiB |
148
src/Object.cpp
@ -1,148 +0,0 @@
|
|||||||
#include "Object.h"
|
|
||||||
|
|
||||||
void Object::Draw(glm::mat4 perspectiveMatrix, glm::mat4 cameraMatrix)
|
|
||||||
{
|
|
||||||
if (!exists) return;
|
|
||||||
|
|
||||||
glUseProgram(shaderID);
|
|
||||||
|
|
||||||
glm::mat4 transformation = perspectiveMatrix * cameraMatrix * modelM;
|
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderID, "modelMatrix"), 1, GL_FALSE, (float*)&modelM);
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderID, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
|
||||||
glUniformMatrix3fv(glGetUniformLocation(shaderID, "normalMatrix"), 1, GL_FALSE, (float*)&invModelM);
|
|
||||||
|
|
||||||
glUniform3f(glGetUniformLocation(shaderID, "objectColor"), color.r, color.g, color.b);
|
|
||||||
if (textureDiffuseID != -1)
|
|
||||||
Core::SetActiveTexture(textureDiffuseID, "diffuseTexture", shaderID, 0);
|
|
||||||
if (textureNormalID != -1)
|
|
||||||
Core::SetActiveTexture(textureNormalID, "normalTexture", shaderID, 1);
|
|
||||||
if (textureDepthID != -1)
|
|
||||||
Core::SetActiveTexture(textureDepthID, "depthTexture", shaderID, 2);
|
|
||||||
|
|
||||||
modelParent->Draw(shaderID);
|
|
||||||
glUseProgram(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::ChangePosition(glm::vec3 movement)
|
|
||||||
{
|
|
||||||
modelM = glm::translate(modelM, movement);
|
|
||||||
this->position += movement;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::SetPosition(glm::vec3 position)
|
|
||||||
{
|
|
||||||
this->position = position;
|
|
||||||
SetMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::ChangeScale(glm::vec3 scale)
|
|
||||||
{
|
|
||||||
modelM = glm::scale(modelM, scale);
|
|
||||||
this->scale += scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::SetScale(glm::vec3 scale)
|
|
||||||
{
|
|
||||||
this->scale = scale;
|
|
||||||
SetMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::ChangeRotation(glm::vec3 rotate, float angle)
|
|
||||||
{
|
|
||||||
modelM = glm::rotate(modelM, angle, rotate);
|
|
||||||
this->rotation += rotate;
|
|
||||||
this->angle += angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::SetRotation(glm::vec3 rotate, float angle)
|
|
||||||
{
|
|
||||||
this->rotation = rotate;
|
|
||||||
this->angle = angle;
|
|
||||||
SetMatrix();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::SetMatrix()
|
|
||||||
{
|
|
||||||
modelM = glm::translate(glm::mat4(1.0f), position);
|
|
||||||
modelM = glm::rotate(modelM, angle, rotation);
|
|
||||||
modelM = glm::scale(modelM, scale);
|
|
||||||
invModelM = glm::inverseTranspose(modelM);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Object::SetMatrix(glm::vec3 position, glm::vec3 scale, glm::vec3 rotate, float angle)
|
|
||||||
{
|
|
||||||
this->position = position;
|
|
||||||
this->rotation = rotate;
|
|
||||||
this->scale = scale;
|
|
||||||
this->angle = angle;
|
|
||||||
SetMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
Object::Object( std::string name,
|
|
||||||
std::shared_ptr<Model> modelParent,
|
|
||||||
GLuint textureID,
|
|
||||||
GLuint shaderID,
|
|
||||||
glm::vec3 color,
|
|
||||||
glm::vec3 position,
|
|
||||||
glm::vec3 rotation,
|
|
||||||
glm::vec3 scale,
|
|
||||||
float angle,
|
|
||||||
bool dynamic,
|
|
||||||
bool kinematic)
|
|
||||||
{
|
|
||||||
this->name = name;
|
|
||||||
SetMatrix(position, scale, rotation, angle);
|
|
||||||
this->modelParent = modelParent;
|
|
||||||
this->textureDiffuseID = textureID;
|
|
||||||
this->shaderID = shaderID;
|
|
||||||
this->color = color;
|
|
||||||
this->dynamic = dynamic;
|
|
||||||
this->kinematic = kinematic;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object::Object( std::string name,
|
|
||||||
std::shared_ptr<Model> modelParent,
|
|
||||||
GLuint shaderID,
|
|
||||||
glm::vec3 color,
|
|
||||||
glm::vec3 position,
|
|
||||||
glm::vec3 rotation,
|
|
||||||
glm::vec3 scale,
|
|
||||||
float angle,
|
|
||||||
bool dynamic,
|
|
||||||
bool kinematic)
|
|
||||||
{
|
|
||||||
this->name = name;
|
|
||||||
SetMatrix(position, scale, rotation, angle);
|
|
||||||
this->textureDiffuseID = -1;
|
|
||||||
this->modelParent = modelParent;
|
|
||||||
this->shaderID = shaderID;
|
|
||||||
this->color = color;
|
|
||||||
this->dynamic = dynamic;
|
|
||||||
this->kinematic = kinematic;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
glm::vec3 Object::getScaleFromMatrix(glm::mat4 modelMatrix)
|
|
||||||
{
|
|
||||||
float x = glm::length(glm::vec3(modelMatrix[0][0], modelMatrix[1][0], modelMatrix[2][0]));
|
|
||||||
float y = glm::length(glm::vec3(modelMatrix[0][1], modelMatrix[1][1], modelMatrix[2][1]));
|
|
||||||
float z = glm::length(glm::vec3(modelMatrix[0][2], modelMatrix[1][2], modelMatrix[2][2]));
|
|
||||||
|
|
||||||
return glm::vec3(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 Object::getPositionFromMatrix(glm::mat4 modelMatrix)
|
|
||||||
{
|
|
||||||
return glm::vec3(modelMatrix[3][0], modelMatrix[3][1], modelMatrix[3][2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 Object::findOrbit(float time, glm::vec3 center, glm::vec3 orbit, glm::vec3 radius)
|
|
||||||
{
|
|
||||||
glm::mat4 planetModelMatrix = glm::mat4(1.0f);
|
|
||||||
planetModelMatrix = glm::translate(planetModelMatrix, center);
|
|
||||||
planetModelMatrix = glm::rotate(planetModelMatrix, time, orbit);
|
|
||||||
planetModelMatrix = glm::translate(planetModelMatrix, radius);
|
|
||||||
return getPositionFromMatrix(planetModelMatrix);
|
|
||||||
}
|
|
84
src/Object.h
@ -1,84 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <iostream>
|
|
||||||
#include <cmath>
|
|
||||||
#include <string>
|
|
||||||
#include <fstream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "glew.h"
|
|
||||||
#include "freeglut.h"
|
|
||||||
#include "glm.hpp"
|
|
||||||
#include "ext.hpp"
|
|
||||||
#include "model.h"
|
|
||||||
#include "Texture.h"
|
|
||||||
|
|
||||||
|
|
||||||
class Object
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
void Draw(glm::mat4 perspectiveMatrix, glm::mat4 cameraMatrix);
|
|
||||||
void ChangePosition(glm::vec3 movement);
|
|
||||||
void SetPosition(glm::vec3 position);
|
|
||||||
|
|
||||||
void ChangeScale(glm::vec3 scale);
|
|
||||||
void SetScale(glm::vec3 scale);
|
|
||||||
|
|
||||||
void ChangeRotation(glm::vec3 rotate, float angle);
|
|
||||||
void SetRotation(glm::vec3 rotate, float angle);
|
|
||||||
|
|
||||||
void SetMatrix(glm::vec3 position, glm::vec3 scale, glm::vec3 rotate, float angle);
|
|
||||||
void SetMatrix(glm::mat4 _mat) { this->modelM = _mat;
|
|
||||||
this->invModelM = glm::inverseTranspose(_mat); }
|
|
||||||
|
|
||||||
void manualSetRotationM(glm::mat4 rot) {this->rotationM = rot;}
|
|
||||||
void manualSetPosition(glm::vec3 pos) { this->position = pos; }
|
|
||||||
glm::mat4 getRotationM() { return rotationM; }
|
|
||||||
|
|
||||||
std::string GetName() { return this->name; }
|
|
||||||
glm::mat4 GetMatrix() { return this->modelM; }
|
|
||||||
glm::mat4 GetInvMatrix() { return this->invModelM; }
|
|
||||||
glm::vec3 GetColor() { return this->color; }
|
|
||||||
glm::vec3 GetPosition() { return position; }
|
|
||||||
glm::vec3 GetRotation() { return rotation; }
|
|
||||||
glm::vec3 GetScale() { return scale; }
|
|
||||||
bool isDynamic() { return dynamic; }
|
|
||||||
bool isKinematic() { return kinematic; }
|
|
||||||
std::shared_ptr<Model> GetParent() { return modelParent; }
|
|
||||||
|
|
||||||
Object( std::string name, std::shared_ptr<Model> modelParent, GLuint textureID, GLuint shaderID, glm::vec3 color,
|
|
||||||
glm::vec3 position, glm::vec3 rotation, glm::vec3 scale, float angle, bool dynamic, bool kinematic);
|
|
||||||
|
|
||||||
Object(std::string name, std::shared_ptr<Model> modelParent, GLuint shaderID, glm::vec3 color, glm::vec3 position,
|
|
||||||
glm::vec3 rotation, glm::vec3 scale, float angle, bool dynamic, bool kinematic);
|
|
||||||
|
|
||||||
bool exists = true;
|
|
||||||
GLuint textureDiffuseID = -1;
|
|
||||||
GLuint textureNormalID = -1;
|
|
||||||
GLuint textureDepthID = -1;
|
|
||||||
|
|
||||||
glm::vec3 getScaleFromMatrix(glm::mat4 modelMatrix);
|
|
||||||
glm::vec3 getPositionFromMatrix(glm::mat4 modelMatrix);
|
|
||||||
glm::vec3 findOrbit(float time, glm::vec3 center, glm::vec3 orbit, glm::vec3 radius);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void SetMatrix();
|
|
||||||
std::shared_ptr<Model> modelParent;
|
|
||||||
std::string name;
|
|
||||||
glm::mat4 modelM;
|
|
||||||
glm::mat3 invModelM;
|
|
||||||
glm::mat4 rotationM;
|
|
||||||
GLuint shaderID;
|
|
||||||
glm::vec3 color;
|
|
||||||
glm::vec3 position;
|
|
||||||
glm::vec3 rotation;
|
|
||||||
glm::vec3 scale;
|
|
||||||
float angle;
|
|
||||||
bool dynamic;
|
|
||||||
bool kinematic;
|
|
||||||
|
|
||||||
};
|
|
@ -1,36 +0,0 @@
|
|||||||
#include "Physics.h"
|
|
||||||
|
|
||||||
#define PX_RELEASE(x) if(x) { x->release(); x = NULL; }
|
|
||||||
|
|
||||||
Physics::Physics(float gravity,
|
|
||||||
PxSimulationFilterShader simulationFilterShader,
|
|
||||||
PxSimulationEventCallback *simulationEventCallback)
|
|
||||||
{
|
|
||||||
foundation = PxCreateFoundation(PX_PHYSICS_VERSION, allocator, errorCallback);
|
|
||||||
|
|
||||||
physics = PxCreatePhysics(PX_PHYSICS_VERSION, *foundation, PxTolerancesScale(), true);
|
|
||||||
|
|
||||||
PxSceneDesc sceneDesc(physics->getTolerancesScale());
|
|
||||||
sceneDesc.gravity = PxVec3(0.0f, -gravity, 0.0f);
|
|
||||||
dispatcher = PxDefaultCpuDispatcherCreate(2);
|
|
||||||
sceneDesc.cpuDispatcher = dispatcher;
|
|
||||||
sceneDesc.filterShader = simulationFilterShader;
|
|
||||||
sceneDesc.kineKineFilteringMode = PxPairFilteringMode::eKEEP; // So kin-kin contacts with be reported
|
|
||||||
sceneDesc.staticKineFilteringMode = PxPairFilteringMode::eKEEP; // So static-kin constacts will be reported
|
|
||||||
sceneDesc.simulationEventCallback = simulationEventCallback;
|
|
||||||
scene = physics->createScene(sceneDesc);
|
|
||||||
}
|
|
||||||
|
|
||||||
Physics::~Physics()
|
|
||||||
{
|
|
||||||
PX_RELEASE(scene);
|
|
||||||
PX_RELEASE(dispatcher);
|
|
||||||
PX_RELEASE(physics);
|
|
||||||
PX_RELEASE(foundation);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Physics::step(float dt)
|
|
||||||
{
|
|
||||||
scene->simulate(dt);
|
|
||||||
scene->fetchResults(true);
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "PxPhysicsAPI.h"
|
|
||||||
using namespace physx;
|
|
||||||
|
|
||||||
class Physics
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Physics(float gravity,
|
|
||||||
PxSimulationFilterShader simulationFilterShader,
|
|
||||||
PxSimulationEventCallback *simulationEventCallback);
|
|
||||||
virtual ~Physics();
|
|
||||||
PxPhysics* physics = nullptr;
|
|
||||||
PxScene* scene = nullptr;
|
|
||||||
|
|
||||||
void step(float dt);
|
|
||||||
|
|
||||||
private:
|
|
||||||
PxDefaultAllocator allocator;
|
|
||||||
PxDefaultErrorCallback errorCallback;
|
|
||||||
PxFoundation* foundation = nullptr;
|
|
||||||
PxDefaultCpuDispatcher* dispatcher = nullptr;
|
|
||||||
};
|
|
839
src/main.cpp
30
src/model.h
@ -1,27 +1,31 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <iostream>
|
|
||||||
#include <cmath>
|
|
||||||
#include <string>
|
|
||||||
#include <fstream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
#include <assimp/Importer.hpp>
|
|
||||||
#include <assimp/scene.h>
|
|
||||||
#include <assimp/postprocess.h>
|
|
||||||
|
|
||||||
#include "glew.h"
|
#include "glew.h"
|
||||||
#include "freeglut.h"
|
#include "freeglut.h"
|
||||||
#include "glm.hpp"
|
#include "glm.hpp"
|
||||||
#include "ext.hpp"
|
#include "ext.hpp"
|
||||||
|
#include <iostream>
|
||||||
|
#include <cmath>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
#include <assimp/postprocess.h>
|
||||||
|
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
static unsigned int TextureFromFile(const char* path, const string& directory, bool gamma = false);
|
unsigned int TextureFromFile(const char* path, const string& directory, bool gamma = false);
|
||||||
|
|
||||||
class Model
|
class Model
|
||||||
{
|
{
|
||||||
@ -212,7 +216,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static unsigned int TextureFromFile(const char* path, const string& directory, bool gamma)
|
unsigned int TextureFromFile(const char* path, const string& directory, bool gamma)
|
||||||
{
|
{
|
||||||
string filename = string(path);
|
string filename = string(path);
|
||||||
filename = directory + '/' + filename;
|
filename = directory + '/' + filename;
|
||||||
|
BIN
textures/Icy.png
Before Width: | Height: | Size: 2.0 MiB |
BIN
textures/earth2_normal.png
Normal file
After Width: | Height: | Size: 456 KiB |
BIN
textures/earth2_specular.png
Normal file
After Width: | Height: | Size: 132 KiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 3.5 MiB |