position planets and disable depth_mask, created signs shader for stars and hearts, improved generation of planetoids
This commit is contained in:
parent
ec113f9da1
commit
875b220344
@ -49,6 +49,8 @@
|
|||||||
<None Include="shaders\shader_5_tex.vert" />
|
<None Include="shaders\shader_5_tex.vert" />
|
||||||
<None Include="shaders\shader_skybox.frag" />
|
<None Include="shaders\shader_skybox.frag" />
|
||||||
<None Include="shaders\shader_skybox.vert" />
|
<None Include="shaders\shader_skybox.vert" />
|
||||||
|
<None Include="shaders\signs.frag" />
|
||||||
|
<None Include="shaders\signs.vert" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}</ProjectGuid>
|
<ProjectGuid>{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}</ProjectGuid>
|
||||||
|
@ -127,5 +127,11 @@
|
|||||||
<None Include="shaders\rocket.frag">
|
<None Include="shaders\rocket.frag">
|
||||||
<Filter>Shader Files</Filter>
|
<Filter>Shader Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="shaders\signs.frag">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="shaders\signs.vert">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
0
cw 7/shaders/particle.frag
Normal file
0
cw 7/shaders/particle.frag
Normal file
0
cw 7/shaders/particle.vert
Normal file
0
cw 7/shaders/particle.vert
Normal file
@ -1,38 +1,121 @@
|
|||||||
#version 430 core
|
|
||||||
|
|
||||||
float AMBIENT = 0.2;
|
float AMBIENT = 0.03;
|
||||||
|
float PI = 3.14;
|
||||||
|
|
||||||
|
uniform sampler2D depthMap;
|
||||||
|
|
||||||
|
uniform vec3 cameraPos;
|
||||||
|
|
||||||
uniform vec3 color;
|
uniform vec3 color;
|
||||||
uniform float metalness;
|
|
||||||
uniform float roughness;
|
|
||||||
uniform vec3 lightPos;
|
uniform vec3 lightPos;
|
||||||
uniform vec3 lightColor;
|
uniform vec3 lightColor;
|
||||||
in vec3 viewDirTS;
|
|
||||||
in vec3 lightDirTS;
|
uniform vec3 spotlightPos;
|
||||||
|
uniform vec3 spotlightColor;
|
||||||
|
uniform vec3 spotlightConeDir;
|
||||||
|
uniform vec3 spotlightPhi;
|
||||||
|
|
||||||
|
uniform float metallic;
|
||||||
|
uniform float roughness;
|
||||||
|
|
||||||
|
uniform float exposition;
|
||||||
|
|
||||||
|
in vec3 vecNormal;
|
||||||
in vec3 worldPos;
|
in vec3 worldPos;
|
||||||
|
|
||||||
out vec4 outColor;
|
out vec4 outColor;
|
||||||
in mat3 TBN;
|
|
||||||
|
|
||||||
|
in vec3 viewDirTS;
|
||||||
|
in vec3 lightDirTS;
|
||||||
|
in vec3 spotlightDirTS;
|
||||||
|
in vec3 sunDirTS;
|
||||||
|
|
||||||
|
in vec3 test;
|
||||||
|
|
||||||
|
float GGX(vec3 normal, vec3 H, float roughness){
|
||||||
|
float a = roughness*roughness;
|
||||||
|
float a2 = a*a;
|
||||||
|
float NdotH = max(dot(normal, H), 0.0);
|
||||||
|
float NdotH2 = NdotH*NdotH;
|
||||||
|
|
||||||
|
float num = a2;
|
||||||
|
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
|
||||||
|
denom = PI * denom * denom;
|
||||||
|
|
||||||
|
return num / denom;
|
||||||
|
}
|
||||||
|
float Gs_GGX(float NdotV, float roughness){
|
||||||
|
float r = (roughness + 1.0);
|
||||||
|
float k = (r*r) / 8.0;
|
||||||
|
|
||||||
|
float num = NdotV;
|
||||||
|
float denom = NdotV * (1.0 - k) + k;
|
||||||
|
|
||||||
|
return num / denom;
|
||||||
|
}
|
||||||
|
float GS(vec3 normal, vec3 V, vec3 lightDir, float roughness){
|
||||||
|
float NdotV = max(dot(normal, V), 0.0);
|
||||||
|
float NdotL = max(dot(normal, lightDir), 0.0);
|
||||||
|
float ggx2 = Gs_GGX(NdotV, roughness);
|
||||||
|
float ggx1 = Gs_GGX(NdotL, roughness);
|
||||||
|
|
||||||
|
return ggx1 * ggx2;
|
||||||
|
}
|
||||||
|
vec3 fS(float cosTheta, vec3 F0){
|
||||||
|
return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){
|
||||||
|
float diffuse=max(0,dot(normal,lightDir));
|
||||||
|
|
||||||
|
//vec3 V = normalize(cameraPos-worldPos);
|
||||||
|
vec3 F0 = vec3(0.04);
|
||||||
|
F0 = mix(F0, color, metallic);
|
||||||
|
|
||||||
|
vec3 H = normalize(V + lightDir);
|
||||||
|
|
||||||
|
float NDF = GGX(normal, H, roughness);
|
||||||
|
float G = GS(normal, V, lightDir, roughness);
|
||||||
|
vec3 F = fS(max(dot(H, V), 0.0), F0);
|
||||||
|
|
||||||
|
vec3 kS = F;
|
||||||
|
vec3 kD = vec3(1.0) - kS;
|
||||||
|
kD *= 1.0 - metallic;
|
||||||
|
|
||||||
|
vec3 numerator = NDF * G * F;
|
||||||
|
float denominator = 4.0 * max(dot(normal, V), 0.0) * max(dot(normal, lightDir), 0.0) + 0.0001;
|
||||||
|
vec3 specular = numerator / denominator;
|
||||||
|
|
||||||
|
float NdotL = max(dot(normal, lightDir), 0.0);
|
||||||
|
return (kD * color / PI + specular) * radiance * NdotL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec3 normal = normalize(TBN * vec3(0, 0, 1)); // Normal z TBN
|
vec3 normal = normalize(vecNormal);
|
||||||
vec3 L = normalize(lightPos - worldPos);
|
|
||||||
vec3 V = normalize(viewDirTS);
|
|
||||||
vec3 H = normalize(L + V);
|
|
||||||
|
|
||||||
float k = pow((roughness + 1), 2.0) / 8.0;
|
vec3 viewDir = normalize(cameraPos-worldPos);
|
||||||
|
|
||||||
float D = (roughness * roughness) / (3.14159 * pow(pow(dot(normal, H), 2.0) * (roughness * roughness - 1.0) + 1.0, 2.0));
|
vec3 lightDir = normalize(lightPos-worldPos);
|
||||||
float G = dot(normal, L) / (dot(normal, L) * (1.0 - k) + k);
|
|
||||||
vec3 F0 = mix(vec3(0.04), color, metalness);
|
|
||||||
vec3 F = F0 + (1.0 - F0) * pow(1 - dot(V, H), 5.0);
|
vec3 ambient = AMBIENT*color;
|
||||||
|
vec3 attenuatedlightColor = lightColor/pow(length(lightPos-worldPos),2);
|
||||||
|
vec3 ilumination;
|
||||||
|
ilumination = ambient+PBRLight(lightDir,attenuatedlightColor,normal,viewDir);
|
||||||
|
|
||||||
|
vec3 spotlightDir= normalize(spotlightPos-worldPos);
|
||||||
|
|
||||||
|
|
||||||
|
float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1);
|
||||||
|
attenuatedlightColor = angle_atenuation*spotlightColor/pow(length(spotlightPos-worldPos),2);
|
||||||
|
ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir);
|
||||||
|
|
||||||
vec3 specular = lightColor * (D * G * F) / (4 * dot(normal, L) * dot(normal, V) + 0.00001);
|
|
||||||
vec3 kD = vec3(1.0) - F;
|
|
||||||
|
|
||||||
vec3 diffuse = lightColor * kD * (color / 3.1458493);
|
|
||||||
|
|
||||||
vec3 finalColor = (diffuse + specular) * min(1.0, AMBIENT + max(dot(normal, L), 0.0));
|
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
|
||||||
|
}
|
||||||
outColor = vec4(finalColor, 1.0);
|
|
||||||
}
|
|
||||||
|
@ -2,40 +2,42 @@
|
|||||||
|
|
||||||
layout(location = 0) in vec3 vertexPosition;
|
layout(location = 0) in vec3 vertexPosition;
|
||||||
layout(location = 1) in vec3 vertexNormal;
|
layout(location = 1) in vec3 vertexNormal;
|
||||||
|
layout(location = 2) in vec2 vertexTexCoord;
|
||||||
layout(location = 3) in vec3 vertexTangent;
|
layout(location = 3) in vec3 vertexTangent;
|
||||||
layout(location = 4) in vec3 vertexBitangent;
|
layout(location = 4) in vec3 vertexBitangent;
|
||||||
|
|
||||||
uniform mat4 transformation;
|
uniform mat4 transformation;
|
||||||
uniform mat4 modelMatrix;
|
uniform mat4 modelMatrix;
|
||||||
|
|
||||||
|
out vec3 vecNormal;
|
||||||
out vec3 worldPos;
|
out vec3 worldPos;
|
||||||
out vec2 vecTex;
|
|
||||||
|
|
||||||
uniform vec3 lightPos;
|
uniform vec3 lightPos;
|
||||||
|
uniform vec3 spotlightPos;
|
||||||
uniform vec3 cameraPos;
|
uniform vec3 cameraPos;
|
||||||
|
uniform vec3 sunDir;
|
||||||
|
|
||||||
out vec3 viewDirTS;
|
out vec3 viewDirTS;
|
||||||
out vec3 lightDirTS;
|
out vec3 lightDirTS;
|
||||||
out mat3 TBN;
|
out vec3 spotlightDirTS;
|
||||||
|
out vec3 sunDirTS;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec3 tangent = normalize(mat3(modelMatrix) * vertexTangent);
|
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
|
||||||
vec3 bitangent = normalize(mat3(modelMatrix) * vertexBitangent);
|
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
|
||||||
vec3 normal = normalize(mat3(modelMatrix) * vertexNormal);
|
|
||||||
|
|
||||||
mat3 TBN = transpose(mat3(tangent, bitangent, normal));
|
|
||||||
|
|
||||||
vec3 worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
|
|
||||||
|
|
||||||
vec3 viewDir = normalize(cameraPos - worldPos);
|
|
||||||
vec3 lightDir = normalize(lightPos - worldPos);
|
|
||||||
|
|
||||||
viewDirTS = vec3(TBN * viewDir);
|
|
||||||
lightDirTS = vec3(TBN * lightDir);
|
|
||||||
|
|
||||||
vecTex = vec2((worldPos.x + 10.0) / 20.0, 1.0 - (worldPos.y + 10.0) / 20.0);
|
|
||||||
|
|
||||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||||
}
|
|
||||||
|
vec3 w_tangent = normalize(mat3(modelMatrix)*vertexTangent);
|
||||||
|
vec3 w_bitangent = normalize(mat3(modelMatrix)*vertexBitangent);
|
||||||
|
mat3 TBN = transpose(mat3(w_tangent, w_bitangent, vecNormal));
|
||||||
|
|
||||||
|
vec3 V = normalize(cameraPos-worldPos);
|
||||||
|
viewDirTS = TBN*V;
|
||||||
|
vec3 L = normalize(lightPos-worldPos);
|
||||||
|
lightDirTS = TBN*L;
|
||||||
|
vec3 SL = normalize(spotlightPos-worldPos);
|
||||||
|
spotlightDirTS = TBN*SL;
|
||||||
|
sunDirTS = TBN*sunDir;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#version 430 core
|
#version 430 core
|
||||||
|
|
||||||
float AMBIENT = 0.1;
|
float AMBIENT = 0.1;
|
||||||
|
float MAX_DISTANCE = 6.0;
|
||||||
uniform vec3 color;
|
uniform vec3 color;
|
||||||
uniform vec3 lightPos;
|
uniform vec3 lightPos;
|
||||||
uniform sampler2D colorTexture;
|
uniform sampler2D colorTexture;
|
||||||
@ -16,6 +16,10 @@ void main()
|
|||||||
vec3 lightDir = normalize(lightPos-worldPos);
|
vec3 lightDir = normalize(lightPos-worldPos);
|
||||||
vec3 normal = normalize(vecNormal);
|
vec3 normal = normalize(vecNormal);
|
||||||
vec3 textureColor = texture2D(colorTexture, vecTex).xyz;
|
vec3 textureColor = texture2D(colorTexture, vecTex).xyz;
|
||||||
|
if (distanceToCamera > MAX_DISTANCE)
|
||||||
|
{
|
||||||
|
discard;
|
||||||
|
}
|
||||||
float diffuse=max(0,dot(normal,lightDir));
|
float diffuse=max(0,dot(normal,lightDir));
|
||||||
outColor = vec4(textureColor*min(1,AMBIENT+diffuse), 1.0);
|
outColor = vec4(textureColor*min(1,AMBIENT+diffuse), 1.0);
|
||||||
}
|
}
|
||||||
|
36
cw 7/shaders/signs.frag
Normal file
36
cw 7/shaders/signs.frag
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
float AMBIENT = 0.2;
|
||||||
|
|
||||||
|
uniform vec3 color;
|
||||||
|
uniform float metalness;
|
||||||
|
uniform float roughness;
|
||||||
|
uniform vec3 lightPos;
|
||||||
|
uniform vec3 lightColor;
|
||||||
|
in vec3 viewDirTS;
|
||||||
|
in vec3 lightDirTS;
|
||||||
|
in vec3 worldPos;
|
||||||
|
|
||||||
|
out vec4 outColor;
|
||||||
|
in mat3 TBN;
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec3 normal = normalize(TBN * vec3(0, 0, 1)); // Normal z TBN
|
||||||
|
vec3 L = normalize(lightPos - worldPos);
|
||||||
|
vec3 V = normalize(viewDirTS);
|
||||||
|
vec3 H = normalize(L + V);
|
||||||
|
|
||||||
|
float k = pow((roughness + 1), 2.0) / 8.0;
|
||||||
|
|
||||||
|
float D = (roughness * roughness) / (3.14159 * pow(pow(dot(normal, H), 2.0) * (roughness * roughness - 1.0) + 1.0, 2.0));
|
||||||
|
float G = dot(normal, L) / (dot(normal, L) * (1.0 - k) + k);
|
||||||
|
vec3 F0 = mix(vec3(0.04), color, metalness);
|
||||||
|
vec3 F = F0 + (1.0 - F0) * pow(1 - dot(V, H), 5.0);
|
||||||
|
|
||||||
|
vec3 specular = lightColor * (D * G * F) / (4 * dot(normal, L) * dot(normal, V) + 0.00001);
|
||||||
|
vec3 kD = vec3(1.0) - F;
|
||||||
|
|
||||||
|
vec3 diffuse = lightColor * kD * (color / 3.1458493);
|
||||||
|
|
||||||
|
vec3 finalColor = (diffuse + specular) * min(1.0, AMBIENT + max(dot(normal, L), 0.0));
|
||||||
|
|
||||||
|
outColor = vec4(finalColor, 1.0);
|
||||||
|
}
|
41
cw 7/shaders/signs.vert
Normal file
41
cw 7/shaders/signs.vert
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#version 430 core
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 vertexPosition;
|
||||||
|
layout(location = 1) in vec3 vertexNormal;
|
||||||
|
layout(location = 3) in vec3 vertexTangent;
|
||||||
|
layout(location = 4) in vec3 vertexBitangent;
|
||||||
|
|
||||||
|
uniform mat4 transformation;
|
||||||
|
uniform mat4 modelMatrix;
|
||||||
|
|
||||||
|
out vec3 worldPos;
|
||||||
|
out vec2 vecTex;
|
||||||
|
|
||||||
|
uniform vec3 lightPos;
|
||||||
|
uniform vec3 cameraPos;
|
||||||
|
|
||||||
|
out vec3 viewDirTS;
|
||||||
|
out vec3 lightDirTS;
|
||||||
|
out mat3 TBN;
|
||||||
|
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec3 tangent = normalize(mat3(modelMatrix) * vertexTangent);
|
||||||
|
vec3 bitangent = normalize(mat3(modelMatrix) * vertexBitangent);
|
||||||
|
vec3 normal = normalize(mat3(modelMatrix) * vertexNormal);
|
||||||
|
|
||||||
|
mat3 TBN = transpose(mat3(tangent, bitangent, normal));
|
||||||
|
|
||||||
|
vec3 worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
|
||||||
|
|
||||||
|
vec3 viewDir = normalize(cameraPos - worldPos);
|
||||||
|
vec3 lightDir = normalize(lightPos - worldPos);
|
||||||
|
|
||||||
|
viewDirTS = vec3(TBN * viewDir);
|
||||||
|
lightDirTS = vec3(TBN * lightDir);
|
||||||
|
|
||||||
|
vecTex = vec2((worldPos.x + 10.0) / 20.0, 1.0 - (worldPos.y + 10.0) / 20.0);
|
||||||
|
|
||||||
|
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||||
|
}
|
@ -21,7 +21,8 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
namespace texture {
|
namespace texture {
|
||||||
GLuint earth;
|
GLuint earth;
|
||||||
GLuint clouds;
|
GLuint clouds;
|
||||||
@ -58,6 +59,8 @@ GLuint programTex;
|
|||||||
GLuint programEarth;
|
GLuint programEarth;
|
||||||
GLuint programProcTex;
|
GLuint programProcTex;
|
||||||
GLuint programSkyBox;
|
GLuint programSkyBox;
|
||||||
|
GLuint programSign;
|
||||||
|
|
||||||
Core::Shader_Loader shaderLoader;
|
Core::Shader_Loader shaderLoader;
|
||||||
|
|
||||||
Core::RenderContext shipContext;
|
Core::RenderContext shipContext;
|
||||||
@ -67,6 +70,7 @@ Core::RenderContext starContext;
|
|||||||
Core::RenderContext saberContext;
|
Core::RenderContext saberContext;
|
||||||
Core::RenderContext heartContext;
|
Core::RenderContext heartContext;
|
||||||
Core::RenderContext rocketContext;
|
Core::RenderContext rocketContext;
|
||||||
|
|
||||||
glm::vec3 cameraPos = glm::vec3(-3.f, 0, 0);
|
glm::vec3 cameraPos = glm::vec3(-3.f, 0, 0);
|
||||||
glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f);
|
glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f);
|
||||||
|
|
||||||
@ -78,13 +82,21 @@ float a = 3;
|
|||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
std::mt19937 gen(rd());
|
std::mt19937 gen(rd());
|
||||||
//std::uniform_real_distribution<float> distribution(-0.5f, 0.5f);
|
//std::uniform_real_distribution<float> distribution(-0.5f, 0.5f);
|
||||||
std::uniform_real_distribution<float> radiusDistribution(-5.f, 5.f);
|
std::uniform_real_distribution<float> radiusDistribution(-6.f, 6.f);
|
||||||
std::uniform_real_distribution<float> planetoidsYDistribution(-3.f, 3.f);
|
std::uniform_real_distribution<float> planetoidsYDistribution(-5.f, 5.f);
|
||||||
std::uniform_real_distribution<float> planetoidsXDistribution(-2.f, 10.f);
|
std::uniform_real_distribution<float> planetoidsXDistribution(-2.f, 11.f);
|
||||||
std::uniform_real_distribution<float> planetoidsScaleDistribution(0.1f, 0.2f);
|
std::uniform_real_distribution<float> planetoidsScaleDistribution(0.2f, 0.25f);
|
||||||
|
std::vector<glm::vec4> shearVectors;
|
||||||
|
std::vector<glm::vec3> scaleVectors;
|
||||||
std::vector<glm::vec3> ammunitionPositions;
|
std::vector<glm::vec3> ammunitionPositions;
|
||||||
std::vector<glm::mat4> ammunitionModelMatrices;
|
std::vector<glm::mat4> ammunitionModelMatrices;
|
||||||
float planetoidsArray[400][5];
|
|
||||||
|
const int arraySize = 200;
|
||||||
|
const int planetoidParams = 5;
|
||||||
|
std::vector<std::vector<float>> planetoidsVector(arraySize, std::vector<float>(planetoidParams));
|
||||||
|
|
||||||
|
float tempPlanArray[200][2];
|
||||||
|
|
||||||
glm::vec3 asteroid_Calc = spaceshipDir * glm::vec3(a, a, a);
|
glm::vec3 asteroid_Calc = spaceshipDir * glm::vec3(a, a, a);
|
||||||
glm::vec3 asteroid_Pos = spaceshipPos + glm::vec3(0, a, 0) + asteroid_Calc;
|
glm::vec3 asteroid_Pos = spaceshipPos + glm::vec3(0, a, 0) + asteroid_Calc;
|
||||||
glm::vec3 distance = asteroid_Pos - spaceshipPos;
|
glm::vec3 distance = asteroid_Pos - spaceshipPos;
|
||||||
@ -110,10 +122,14 @@ float starMetalness = 0.8;
|
|||||||
float starRoughness = 0.1;
|
float starRoughness = 0.1;
|
||||||
glm::vec3 lightPos = glm::vec3(-8, 4, 2);
|
glm::vec3 lightPos = glm::vec3(-8, 4, 2);
|
||||||
glm::vec3 lightColor = glm::vec3(0.9, 0.7, 0.8) * 100;
|
glm::vec3 lightColor = glm::vec3(0.9, 0.7, 0.8) * 100;
|
||||||
glm::vec3 lightDir = glm::vec3(0, 0, 0);
|
|
||||||
|
|
||||||
|
glm::vec3 spotlightPos = glm::vec3(0, 0, 0);
|
||||||
|
glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0);
|
||||||
|
glm::vec3 spotlightColor = glm::vec3(0.5, 0.9, 0.8) * 10;
|
||||||
|
float exposition = 1.f;
|
||||||
float spotlightPhi = 3.14 / 3;
|
float spotlightPhi = 3.14 / 3;
|
||||||
|
|
||||||
|
|
||||||
double easeInExpo(double x) {
|
double easeInExpo(double x) {
|
||||||
return pow(2, 10 * x - 10);
|
return pow(2, 10 * x - 10);
|
||||||
}
|
}
|
||||||
@ -156,24 +172,46 @@ glm::mat4 createPerspectiveMatrix()
|
|||||||
return perspectiveMatrix;
|
return perspectiveMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float metalness, float roughness, glm::vec3 lightstarPos) {
|
void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float metalness, float roughness, glm::vec3 cameraPos) {
|
||||||
glUseProgram(program);
|
glUseProgram(program);
|
||||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||||
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||||
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||||
glUniform3f(glGetUniformLocation(program, "lightPos"), lightstarPos.x, lightstarPos.y, lightstarPos.z);
|
glUniform3f(glGetUniformLocation(program, "lightPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||||
|
glUniform1f(glGetUniformLocation(program, "exposition"), exposition);
|
||||||
glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
|
glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
|
||||||
glUniform3f(glGetUniformLocation(program, "lightColor"), lightColor.r, lightColor.g, lightColor.b);
|
|
||||||
glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
|
||||||
glUniform1f(glGetUniformLocation(program, "metalness"), metalness);
|
glUniform1f(glGetUniformLocation(program, "metalness"), metalness);
|
||||||
glUniform1f(glGetUniformLocation(program, "roughness"), roughness);
|
glUniform1f(glGetUniformLocation(program, "roughness"), roughness);
|
||||||
|
glUniform3f(glGetUniformLocation(program, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(program, "spotlightConeDir"), spotlightConeDir.x, spotlightConeDir.y, spotlightConeDir.z);
|
||||||
|
glUniform3f(glGetUniformLocation(program, "spotlightPos"), spotlightPos.x, spotlightPos.y, spotlightPos.z);
|
||||||
|
glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z);
|
||||||
|
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi);
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||||
|
Core::DrawContext(context);
|
||||||
|
|
||||||
|
}
|
||||||
|
void drawObjectSigns(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float metalness, float roughness, glm::vec3 lightstarPos) {
|
||||||
|
glUseProgram(programSign);
|
||||||
|
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||||
|
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programSign, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programSign, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||||
|
glUniform3f(glGetUniformLocation(programSign, "lightPos"), lightstarPos.x, lightstarPos.y, lightstarPos.z);
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(programSign, "color"), color.x, color.y, color.z);
|
||||||
|
glUniform3f(glGetUniformLocation(programSign, "lightColor"), lightColor.r, lightColor.g, lightColor.b);
|
||||||
|
glUniform3f(glGetUniformLocation(programSign, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||||
|
glUniform1f(glGetUniformLocation(programSign, "metalness"), metalness);
|
||||||
|
glUniform1f(glGetUniformLocation(programSign, "roughness"), roughness);
|
||||||
|
|
||||||
|
|
||||||
// Przesyłanie informacji o widoku (view) do shadera
|
// Przesyłanie informacji o widoku (view) do shadera
|
||||||
|
|
||||||
Core::DrawContext(context);
|
Core::DrawContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,14 +269,9 @@ void drawObjectSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint t
|
|||||||
Core::DrawContext(sphereContext);
|
Core::DrawContext(sphereContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateAsteroids(glm::vec3 asteroid_Pos, glm::vec3 distance, double step) {
|
|
||||||
glm::vec3 normalizedDir = glm::normalize(distance);
|
|
||||||
asteroid_Pos = asteroid_Pos - normalizedDir *step;
|
|
||||||
drawObjectTexture(sphereContext, glm::translate(asteroid_Pos) * glm::scale(glm::vec3(0.1f)), texture::moon, texture::moonNormal, texture::metalnessSphere, texture::roughnessSphere);
|
|
||||||
|
|
||||||
}
|
|
||||||
//float speed = 0.03;
|
//float speed = 0.03;
|
||||||
float speed = 0.01;
|
float speed = 0.02;
|
||||||
float starind = 50;
|
float starind = 50;
|
||||||
|
|
||||||
|
|
||||||
@ -253,22 +286,29 @@ void generatePlanetoidBelt() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 150; ++i) {
|
for (int i = 0; i < 200; ++i) {
|
||||||
float z = planetoidsArray[i][0];
|
float z = tempPlanArray[i][0];
|
||||||
float y = planetoidsArray[i][1];
|
float y = tempPlanArray[i][1];
|
||||||
float pScale = planetoidsArray[i][2];
|
glm::vec3 Scale = scaleVectors[i];
|
||||||
bool collision = false;
|
bool collision = false;
|
||||||
planetoidsArray[i][3] -= speed;
|
planetoidsVector[i][3] -= speed;
|
||||||
float x = planetoidsArray[i][3];
|
float x = planetoidsVector[i][3];
|
||||||
if (planetoidsArray[i][3] < -3.f) {
|
|
||||||
|
if (planetoidsVector[i][3] < -3.f) {
|
||||||
//planetoidsArray[i][0] += spaceshipPos.z - planetoidsArray[i][0];
|
//planetoidsArray[i][0] += spaceshipPos.z - planetoidsArray[i][0];
|
||||||
//planetoidsArray[i][1] += spaceshipPos.y - planetoidsArray[i][1];
|
//planetoidsArray[i][1] += spaceshipPos.y - planetoidsArray[i][1];
|
||||||
planetoidsArray[i][3] = 10.f;
|
|
||||||
planetoidsArray[i][4] == 0;
|
tempPlanArray[i][0] = spaceshipPos.z + planetoidsVector[i][0];
|
||||||
|
tempPlanArray[i][1] = spaceshipPos.y + planetoidsVector[i][1];
|
||||||
|
planetoidsVector[i][3] = 11.f;
|
||||||
|
z = tempPlanArray[i][0];
|
||||||
|
y = tempPlanArray[i][1];
|
||||||
|
x = planetoidsVector[i][3];
|
||||||
|
planetoidsVector[i][4] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (planetoidsArray[i][4] == 1) {
|
if (planetoidsVector[i][4] == 1) {
|
||||||
// Planeta ju<6A> uczestniczy<7A>a w kolizji, przejd<6A> do kolejnej iteracji
|
// Planeta ju<6A> uczestniczy<7A>a w kolizji, przejd<6A> do kolejnej iteracji
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -276,28 +316,29 @@ void generatePlanetoidBelt() {
|
|||||||
|
|
||||||
|
|
||||||
for (int j = 0; j < i; ++j) {
|
for (int j = 0; j < i; ++j) {
|
||||||
float prevZ = planetoidsArray[j][0];
|
float prevZ = tempPlanArray[j][0];
|
||||||
float prevY = planetoidsArray[j][1];
|
float prevY = tempPlanArray[j][1];
|
||||||
float prevScale = planetoidsArray[j][2];
|
glm::vec3 prevScale = scaleVectors[j];
|
||||||
float prevX = planetoidsArray[j][3];
|
float prevX = planetoidsVector[j][3];
|
||||||
|
float dx = x - prevX;
|
||||||
|
float dy = y - prevY;
|
||||||
|
float dz = z - prevZ;
|
||||||
|
float distanceSquared = dx * dx + dy * dy + dz * dz;
|
||||||
|
|
||||||
float distance = std::sqrt((z - prevZ) * (z - prevZ) + (y - prevY) * (y - prevY) + (x - prevX) * (x - prevX));
|
float sumRadiiSquared = glm::length2(Scale + prevScale);
|
||||||
|
|
||||||
float sumRadii = pScale + prevScale;
|
|
||||||
|
|
||||||
|
|
||||||
|
if (distanceSquared < sumRadiiSquared) {
|
||||||
if (distance < sumRadii) {
|
|
||||||
collision = true;
|
collision = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!collision) {
|
if (!collision) {
|
||||||
if (fmod(i, starind) == 0) {
|
if (fmod(i, starind) == 0) {
|
||||||
if (checkCollision(glm::vec3(x, y, z), 0.1f, spaceshipPos, 0.025f, true)) {
|
if (checkCollision(glm::vec3(x, y, z), 0.1f, spaceshipPos, 0.08f, true)) {
|
||||||
// Kolizja z gwiazd<7A>
|
// Kolizja z gwiazd<7A>
|
||||||
//std::cout << "Collision with star " << i << std::endl;
|
//std::cout << "Collision with star " << i << std::endl;
|
||||||
planetoidsArray[i][4] = 1;
|
planetoidsVector[i][4] = 1;
|
||||||
star_counter++;
|
star_counter++;
|
||||||
if (star_counter == 3) {
|
if (star_counter == 3) {
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -305,12 +346,12 @@ void generatePlanetoidBelt() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (checkCollision(glm::vec3(x, y, z), 0.1f, spaceshipPos, 0.025f, true))
|
else if (checkCollision(glm::vec3(x, y, z), 0.1f, spaceshipPos, 0.08f, true))
|
||||||
{
|
{
|
||||||
//kolizja z asteroida
|
//kolizja z asteroida
|
||||||
std::cout << "Collision with asteroid " << i << std::endl;
|
std::cout << "Collision with asteroid " << i << std::endl;
|
||||||
colission--;
|
colission--;
|
||||||
planetoidsArray[i][4] = 1;
|
planetoidsVector[i][4] = 1;
|
||||||
if (colission == 0)
|
if (colission == 0)
|
||||||
{
|
{
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -320,11 +361,11 @@ void generatePlanetoidBelt() {
|
|||||||
{
|
{
|
||||||
for (int n = 0; n < ammunitionPositions.size(); ++n)
|
for (int n = 0; n < ammunitionPositions.size(); ++n)
|
||||||
{
|
{
|
||||||
if (checkCollision(glm::vec3(x, y, z), 0.1f, ammunitionPositions[n], 0.025f, true))
|
if (checkCollision(glm::vec3(x, y, z), 0.1f, ammunitionPositions[n], 0.08f, true))
|
||||||
{
|
{
|
||||||
// Asteroida zestrzelona
|
// Asteroida zestrzelona
|
||||||
std::cout << "Collision with ammo " << i << std::endl;
|
std::cout << "Collision with ammo " << i << std::endl;
|
||||||
planetoidsArray[i][4] = 1;
|
planetoidsVector[i][4] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -333,7 +374,7 @@ void generatePlanetoidBelt() {
|
|||||||
if (fmod(i, starind) == 0) {
|
if (fmod(i, starind) == 0) {
|
||||||
float time = glfwGetTime();
|
float time = glfwGetTime();
|
||||||
glm::mat4 modelMatrix = glm::translate(glm::vec3(x, y, z)) * glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 1.0f));
|
glm::mat4 modelMatrix = glm::translate(glm::vec3(x, y, z)) * glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 1.0f));
|
||||||
drawObjectColor(starContext, modelMatrix * glm::eulerAngleX(time) * glm::scale(glm::vec3(0.03f)), glm::vec3(1, 1, 0.7), starMetalness, starRoughness, spaceshipPos);
|
drawObjectColor(starContext, modelMatrix * glm::eulerAngleX(time) * glm::scale(glm::vec3(0.03f)), glm::vec3(0.1, 1.f, 1.0), starMetalness, starRoughness, spaceshipPos);
|
||||||
if (star == 0)
|
if (star == 0)
|
||||||
{
|
{
|
||||||
star++;
|
star++;
|
||||||
@ -343,14 +384,13 @@ void generatePlanetoidBelt() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
drawObjectTexture(sphereContext, glm::translate(glm::vec3(x, y, z)) * glm::scale(glm::vec3(pScale)), texture::moon, texture::moonNormal, texture::metalnessSphere, texture::roughnessSphere);
|
drawObjectTexture(sphereContext, glm::translate(glm::vec3(x, y, z)) * glm::scale(Scale),
|
||||||
|
texture::moon, texture::moonNormal, texture::metalnessSphere, texture::roughnessSphere);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -370,9 +410,9 @@ void drawStars(int star_number) {
|
|||||||
float scaleFactor = 0.03f;
|
float scaleFactor = 0.03f;
|
||||||
|
|
||||||
for (int i = 0; i < star_number; ++i) {
|
for (int i = 0; i < star_number; ++i) {
|
||||||
drawObjectColor(starContext, glm::translate(glm::vec3(2.3f, yOffset, (zOffset) - i * 0.5f ))
|
drawObjectSigns(starContext, glm::translate(glm::vec3(2.3f, yOffset, (zOffset) - i * 0.5f ))
|
||||||
* glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f))
|
* glm::rotate(glm::mat4(), glm::radians(90.0f), glm::vec3(1.0f, 0.0f, 0.0f))
|
||||||
* glm::scale(glm::vec3(scaleFactor)), glm::vec3(1, 1, 0.7), starMetalness, starRoughness,glm::vec3(1.0f, yOffset, zOffset));
|
* glm::scale(glm::vec3(scaleFactor)), glm::vec3(0.1, 1.f, 1.0), starMetalness, starRoughness,glm::vec3(1.0f, yOffset, zOffset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +423,7 @@ void drawHearts(int collision_number) {
|
|||||||
|
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
if (collision_number > i) {
|
if (collision_number > i) {
|
||||||
drawObjectColor(heartContext, glm::translate(glm::vec3(3.5f, yOffset, (zOffset) - i * 0.5f))
|
drawObjectSigns(heartContext, glm::translate(glm::vec3(3.5f, yOffset, (zOffset) - i * 0.5f))
|
||||||
* glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f))
|
* glm::rotate(glm::mat4(), glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f))
|
||||||
* glm::scale(glm::vec3(0.025f)), glm::vec3(1, 0, 0), starMetalness, starRoughness, glm::vec3(1.0f, yOffset, zOffset));
|
* glm::scale(glm::vec3(0.025f)), glm::vec3(1, 0, 0), starMetalness, starRoughness, glm::vec3(1.0f, yOffset, zOffset));
|
||||||
}
|
}
|
||||||
@ -402,7 +442,7 @@ void renderAmmunition() {
|
|||||||
|
|
||||||
for (int i = ammunitionPositions.size() - 1; i >= 0; --i) {
|
for (int i = ammunitionPositions.size() - 1; i >= 0; --i) {
|
||||||
ammunitionPositions[i] = ammunitionPositions[i] + glm::vec3(0.025f, 0.f, 0.f);
|
ammunitionPositions[i] = ammunitionPositions[i] + glm::vec3(0.025f, 0.f, 0.f);
|
||||||
if (ammunitionPositions[i].x > 8.f) {
|
if (ammunitionPositions[i].x > 3.f) {
|
||||||
ammunitionPositions.erase(ammunitionPositions.begin() + i);
|
ammunitionPositions.erase(ammunitionPositions.begin() + i);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -420,21 +460,21 @@ void renderScene(GLFWwindow* window)
|
|||||||
float time = glfwGetTime();
|
float time = glfwGetTime();
|
||||||
|
|
||||||
drawObjectSkyBox(cubeContext, glm::translate(cameraPos));
|
drawObjectSkyBox(cubeContext, glm::translate(cameraPos));
|
||||||
|
glDepthMask(GL_FALSE);
|
||||||
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(20.0f, 0.0f, 0.0f)) * glm::scale(glm::mat4(), glm::vec3(2)), texture::sun);
|
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(16.0f, -4.0f, -13.0f)) * glm::scale(glm::mat4(), glm::vec3(2)), texture::sun);
|
||||||
|
|
||||||
drawObjectTexture(sphereContext, glm::translate(spaceshipPos + glm::vec3(18.0f, 0.0f, 3.0f)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.3f)), texture::earth, texture::earthNormal, texture::metalnessSphere, texture::roughnessSphere);
|
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(12.0f, -4.2f, -8.0f)) * glm::scale(glm::vec3(0.3f)), texture::earth);
|
||||||
//drawObjectTexture(sphereContext,
|
//drawObjectTexture(sphereContext,
|
||||||
// glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(8.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)), texture::moon, texture::moonNormal, texture::metalnessSphere, texture::roughnessSphere);
|
// glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(8.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)), texture::moon, texture::moonNormal, texture::metalnessSphere, texture::roughnessSphere);
|
||||||
|
|
||||||
drawObjectTexture(sphereContext, glm::translate(spaceshipPos + glm::vec3(18.f, 0, -3.0f)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.15f)), texture::mercury, texture::rustNormal, texture::metalnessSphere, texture::roughnessSphere);
|
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(14.f, -4.5, -9.f)) * glm::scale(glm::vec3(0.15f)), texture::mercury);
|
||||||
drawObjectTexture(sphereContext, glm::translate(spaceshipPos + glm::vec3(17.f, 0, -4.0f)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.2f)), texture::mars, texture::rustNormal, texture::metalnessSphere, texture::roughnessSphere);
|
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(9.f, -5.f, -7.0f)) * glm::scale(glm::vec3(0.1f)), texture::mars);
|
||||||
drawObjectTexture(sphereContext, glm::translate(spaceshipPos + glm::vec3(17.f, 0, 4.0f)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.3f)), texture::venus, texture::rustNormal, texture::metalnessSphere, texture::roughnessSphere);
|
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(12.f, -2.f, -4.5f)) * glm::scale(glm::vec3(0.3f)), texture::venus);
|
||||||
drawObjectTexture(sphereContext, glm::translate(spaceshipPos + glm::vec3(15.f, 0, -6.0f)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.9f)), texture::jupiter, texture::rustNormal, texture::metalnessSphere, texture::roughnessSphere);
|
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(4.f, -2.f, 3.0f)) * glm::scale(glm::vec3(0.6f)), texture::jupiter);
|
||||||
drawObjectTexture(sphereContext, glm::translate(spaceshipPos + glm::vec3(15.f, 0, 6.0f)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.9f)), texture::saturn, texture::rustNormal, texture::metalnessSphere, texture::roughnessSphere);
|
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(15.f, -2.f, 6.0f)) * glm::scale(glm::vec3(0.9f)), texture::saturn);
|
||||||
drawObjectTexture(sphereContext, glm::translate(spaceshipPos + glm::vec3(13.f, 0, 8.0f)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.6f)), texture::uranus, texture::rustNormal, texture::metalnessSphere, texture::roughnessSphere);
|
//drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(13.f, -8.0f, 8.0f)) * glm::scale(glm::vec3(0.6f)), texture::uranus);
|
||||||
drawObjectTexture(sphereContext, glm::translate(spaceshipPos + glm::vec3(13.f, 0, -8.0f)) * glm::eulerAngleY(time) * glm::scale(glm::vec3(0.6f)), texture::neptune, texture::rustNormal, texture::metalnessSphere, texture::roughnessSphere);
|
drawObjectSun(sphereContext, glm::translate(spaceshipPos + glm::vec3(13.f, 0.f, 3.0f)) * glm::scale(glm::vec3(0.3f)), texture::neptune);
|
||||||
|
glDepthMask(GL_TRUE);
|
||||||
|
|
||||||
spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||||
spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
|
spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
|
||||||
@ -508,7 +548,7 @@ void init(GLFWwindow* window)
|
|||||||
programProcTex = shaderLoader.CreateProgram("shaders/shader_5_tex.vert", "shaders/shader_5_tex.frag");
|
programProcTex = shaderLoader.CreateProgram("shaders/shader_5_tex.vert", "shaders/shader_5_tex.frag");
|
||||||
programSkyBox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
|
programSkyBox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
|
||||||
programSun = shaderLoader.CreateProgram("shaders/shader_5_sun.vert", "shaders/shader_5_sun.frag");
|
programSun = shaderLoader.CreateProgram("shaders/shader_5_sun.vert", "shaders/shader_5_sun.frag");
|
||||||
|
programSign = shaderLoader.CreateProgram("shaders/signs.vert", "shaders/signs.frag");
|
||||||
loadModelToContext("./models/sphere.obj", sphereContext);
|
loadModelToContext("./models/sphere.obj", sphereContext);
|
||||||
loadModelToContext("./models/spaceship_new.obj", shipContext);
|
loadModelToContext("./models/spaceship_new.obj", shipContext);
|
||||||
loadModelToContext("./models/cube.obj", cubeContext);
|
loadModelToContext("./models/cube.obj", cubeContext);
|
||||||
@ -543,17 +583,28 @@ void init(GLFWwindow* window)
|
|||||||
texture::roughnessShip = Core::LoadTexture("textures/ship/spaceship_rough.jpg");
|
texture::roughnessShip = Core::LoadTexture("textures/ship/spaceship_rough.jpg");
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < 400; ++i) {
|
for (int i = 0; i < 200; ++i) {
|
||||||
float z = radiusDistribution(gen);
|
float z = radiusDistribution(gen);
|
||||||
float x = planetoidsXDistribution(gen);
|
float x = planetoidsXDistribution(gen);
|
||||||
float y = planetoidsYDistribution(gen);
|
float y = planetoidsYDistribution(gen);
|
||||||
float pScale = planetoidsScaleDistribution(gen);
|
planetoidsVector[i][0] = z;
|
||||||
planetoidsArray[i][0] = z;
|
planetoidsVector[i][1] = y;
|
||||||
planetoidsArray[i][1] = y;
|
planetoidsVector[i][3] = x;
|
||||||
planetoidsArray[i][2] = pScale;
|
glm::vec3 scaleVector = glm::vec3(planetoidsScaleDistribution(gen), planetoidsScaleDistribution(gen), planetoidsScaleDistribution(gen));
|
||||||
planetoidsArray[i][3] = x;
|
scaleVectors.push_back(scaleVector);
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
const int arraySize = 200;
|
||||||
|
const int planetoidParams = 5;
|
||||||
|
std::sort(planetoidsVector.begin(), planetoidsVector.end(),
|
||||||
|
[](const auto& a, const auto& b) {
|
||||||
|
return a[3] < b[3];
|
||||||
|
});
|
||||||
|
|
||||||
|
for (int i = 0; i < arraySize; ++i) {
|
||||||
|
tempPlanArray[i][0] = planetoidsVector[i][0];
|
||||||
|
tempPlanArray[i][1] = planetoidsVector[i][1];
|
||||||
|
}
|
||||||
|
|
||||||
glGenTextures(1, &textureID);
|
glGenTextures(1, &textureID);
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
|
||||||
|
Loading…
Reference in New Issue
Block a user