shader + plants spawn on whole planet

This commit is contained in:
dompia5 2024-02-07 22:32:03 +01:00
parent 4823629510
commit ad3be0a00b
2 changed files with 7 additions and 7 deletions

View File

@ -4,6 +4,7 @@ layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inNormal;
layout(location = 2) in vec2 inTexCoord;
layout(location = 6) in mat4 transformations;
layout(location = 10) in mat4 modelMatrix;
out vec2 texCoords;
@ -12,9 +13,8 @@ out vec3 fragPosition;
uniform sampler2D colorTexture;
void main()
{
mat4 modelMat = transformations;
gl_Position = modelMat* vec4(inPosition, 1.0);
fragPosition = (transformations* vec4(inPosition,1)).xyz;
gl_Position = transformations * vec4(inPosition, 1.0);
fragPosition = (modelMatrix* vec4(inPosition,1)).xyz;
texCoords = inTexCoord;
fragNormal = (modelMat* vec4(inNormal,0)).xyz;
fragNormal = (modelMatrix* vec4(inNormal,0)).xyz;
}

View File

@ -155,7 +155,7 @@ bool sortFunction(std::tuple<int, float> objA, std::tuple<int, float> objB)
PlanetParams populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plants)
{
float probability=0.5f;
int HOW_MANY_PLANTS = 1000;
int HOW_MANY_PLANTS = 10000;
int PRECISION = 10000;
float NOTHING_SPAWNS_CUTOFF = 0.0;
int sum = 0;
@ -197,7 +197,7 @@ PlanetParams populatePlanet(PlanetParams planet, std::vector<Plant::Plant> plant
{
Plant::Plant plant = plants[winnerId];
plant_count += 1;
plant.pos = glm::vec3((1.0 * (rand() / (RAND_MAX + 1.0))), (1.0 * (rand() / (RAND_MAX + 1.0))), (1.0 * (rand() / (RAND_MAX + 1.0))));
plant.pos = glm::vec3((2.0 * (rand() / (RAND_MAX + 1.0))-1), (2.0 * (rand() / (RAND_MAX + 1.0))-1), (2.0 * (rand() / (RAND_MAX + 1.0)))-1);
planet.Plant_info.push_back(std::make_tuple(winnerId,plant.pos));
}
@ -320,7 +320,7 @@ glm::mat4 createPerspectiveMatrix()
glm::mat4 perspectiveMatrix;
float n = 0.05;
float f = 300.;
float f = 500.;
float a1 = glm::min(aspectRatio, 1.f);
float a2 = glm::min(1 / aspectRatio, 1.f);
perspectiveMatrix = glm::mat4({