Textures fixed

This commit is contained in:
2025-06-01 18:26:22 +02:00
parent f164071fb0
commit 983117fa9b
7 changed files with 15 additions and 3 deletions
+1 -1
View File
@@ -17,5 +17,5 @@ void main ()
result = mix (result, texture2D (materials[2], f_uv), f_material[1]);
result = mix (result, texture2D (materials[3], f_uv), f_material[2]);
gl_FragColor = result * vec4(f_height, f_height, f_height, 1.0);
gl_FragColor = result;
}
+1 -1
View File
@@ -12,7 +12,7 @@ varying float f_height;
void main ()
{
f_uv = position.xy / 8.0;
f_uv = position.xz / 4.0;
f_material = material;
f_height = position.y;
+1 -1
View File
@@ -23,7 +23,7 @@ Chunk_noise (Chunk *chunk, int xoffset, int yoffset)
(void) xoffset; (void) yoffset;
float val = sinf (x) + sinf (y);
(void) val;
chunk->heightmap[INDEX (x, y)] = (val + 0.5);
chunk->heightmap[INDEX (x, y)] = val;
chunk->materialmap[INDEX (x, y)] = (int) val;
}
}
+1
View File
@@ -6,6 +6,7 @@
#include "../math_3d.h"
#include "chunk.h"
/* TODO: set to + 1 */
#define CHUNKMESH_DIM (CHUNK_DIM+1)
#define CHUNKMESH_SIZE (CHUNKMESH_DIM*CHUNKMESH_DIM)
#define CMINDEX(x, y) (CHUNKMESH_DIM * (y) + (x))
+4
View File
@@ -78,6 +78,10 @@ SDL_AppInit (void **appstate, int argc, char **argv)
Chunk_noise (&chunk, 0, 0);
test_chunkmesh = ChunkMesh_from_Chunk_and_neighbors (&chunk, NULL, NULL, NULL);
program_use (resources.programs[1]);
int arr[4] = { 0, 1, 2, 3 };
program_set_int_array (resources.programs[1], "materials", 4, arr);
/* Set up game state. */
game_state.last_time = SDL_GetTicks ();
+6
View File
@@ -72,6 +72,12 @@ program_create (const char *v_src, const char *f_src)
return program;
}
void
program_set_int_array (int program, const char *name, size_t count, int *value)
{
glUniform1iv (glGetUniformLocation (program, name), count, value);
}
void
program_set_mat4 (int program, const char *name, mat4_t value)
{
+1
View File
@@ -11,5 +11,6 @@
void shader_fail (int shader);
void program_fail (int program);
int program_create (const char *v_src, const char *f_src);
void program_set_int_array (int program, const char *name, size_t count, int *value);
void program_set_mat4 (int program, const char *name, mat4_t value);
void program_print (int program);