Vector3 floor_rotation_axis;
float floor_rotation;
+Model coffin_model;
+Vector3 coffin_position;
+Vector3 coffin_scale;
+Vector3 coffin_rotation_axis;
+float coffin_rotation;
+int coffin_material_count;
+
Shader shader;
int cam_position_shader_loc;
int screen_dims_shader_loc;
+int map_center_shader_loc;
Vector3 player_velocity;
Vector3 player_rotation;
+Vector3 map_center;
float forward_speed = 0.015f;
float forward_speed_decay = 0.05f;
float rotate_speed = 0.8f;
float rotate_speed_decay = 0.10f;
-Vector3 unit_vec3 = {1.0f, 1.0f, 1.0f};
+Vector3 vec3_unit = {1.0f, 1.0f, 1.0f};
+Vector3 vec3_010 = {0.0f, 1.0f, 0.0f};
void process_inputs()
{
cam.target.y -= DEG2RAD * 20.0;
}
+ if (IsKeyDown(KEY_R))
+ {
+ player_velocity.z += 0.005f;
+ }
+ else if (IsKeyDown(KEY_F))
+ {
+ player_velocity.z -= 0.005f;
+ }
+
if (IsKeyDown(KEY_SPACE) || IsKeyDown(KEY_LEFT_SHIFT) || IsKeyDown(KEY_RIGHT_SHIFT))
{
//player_velocity.x *= 2.0f;
shader.locs[SHADER_LOC_MATRIX_MVP] = GetShaderLocation(shader, "mvp");
cam_position_shader_loc = GetShaderLocation(shader, "cam_position");
screen_dims_shader_loc = GetShaderLocation(shader, "screen_dims");
+ map_center_shader_loc = GetShaderLocation(shader, "map_center");
while(!IsShaderReady(shader)){}
barrow_position = (Vector3){0.0f, 0.0f, 0.0f};
barrow_rotation_axis = (Vector3){1.0f, 0.0f, 0.0f};
barrow_rotation = 180.0f;
+ map_center = barrow_scale;
+ map_center.x /= 2.0f;
+ map_center.z /= -2.0f;
+ map_center.y = -2.0f;
+
while(!IsImageReady(barrow_image)){}
barrow_texture = LoadTextureFromImage(barrow_image);
while(!IsTextureReady(floor_albedo)){}
/* Might want to replace barrow_scale with just img dimensions. */
- barrow_meshes[0U] = GenMeshHeightmap(barrow_image, unit_vec3);
+ barrow_meshes[0U] = GenMeshHeightmap(barrow_image, vec3_unit);
barrow_model = LoadModelFromMesh(barrow_meshes[0]);
barrow_model.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = barrow_albedo;
barrow_model.materials[0].maps[MATERIAL_MAP_ROUGHNESS].texture = barrow_albedo;
barrow_model.materials[0].shader = shader;
- floor_meshes[0U] = GenMeshHeightmap(floor_image, unit_vec3);
+ floor_meshes[0U] = GenMeshHeightmap(floor_image, vec3_unit);
floor_model = LoadModelFromMesh(floor_meshes[0]);
floor_model.materials[0].maps[MATERIAL_MAP_ALBEDO].texture = floor_albedo;
floor_model.materials[0].maps[MATERIAL_MAP_ROUGHNESS].texture = floor_albedo;
floor_model.materials[0].shader = shader;
+ coffin_scale = (Vector3){1.5f, 1.5f, 1.5f};
+ coffin_position = (Vector3){barrow_scale.x/2.0f, floor_position.y, -barrow_scale.z/2.0f};
+ coffin_rotation_axis = (Vector3){0.0f, 0.0f, 0.0f};
+ coffin_rotation = 0.0f;
+ coffin_model = LoadModel("./assets/coffin_1.glb");
+ while(!IsModelReady(coffin_model)){}
+ //coffin_model.materials[0] = *LoadMaterials("./assets/coffin_1.mtl", &coffin_material_count);
+ //while(!IsMaterialReady(coffin_model.materials[0])){}
+ coffin_model.materials[0].shader = shader;
+
cam = (Camera3D){0};
cam.position = barrow_position;
cam.position.y -= 0.5f;
while (!WindowShouldClose())
{
process_inputs();
+
SetShaderValue(shader, cam_position_shader_loc, &cam.position, SHADER_UNIFORM_VEC3);
SetShaderValue(shader, screen_dims_shader_loc, &fscreen_dims, SHADER_UNIFORM_VEC2);
+ SetShaderValue(shader, map_center_shader_loc, &map_center, SHADER_UNIFORM_VEC3);
UpdateCameraPro(&cam, player_velocity, player_rotation, 0.0f);
-
BeginDrawing();
ClearBackground(BLACK);
BeginMode3D(cam);
BeginShaderMode(shader);
- DrawGrid(barrow_scale.x, 1.0f);
+ DrawModelEx(coffin_model, coffin_position, coffin_rotation_axis, coffin_rotation, coffin_scale, DARKGRAY);
DrawModelEx(barrow_model, barrow_position, barrow_rotation_axis, barrow_rotation, barrow_scale, DARKGRAY);
DrawModelEx(floor_model, floor_position, floor_rotation_axis, floor_rotation, floor_scale, DARKGRAY);
+ //DrawSphere(map_center, 1.0f, RED);
EndShaderMode();
EndMode3D();
#version 330
-asdfasdf
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
in vec4 fragColor;
-in vec4 vertexCoord;
+in vec3 fragPosition;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
uniform vec3 cam_position;
uniform vec2 screen_dims;
+uniform vec3 map_center;
-adasd
// Output fragment color
out vec4 finalColor;
const vec3 v3_unit = vec3(1.0f, 1.0f, 1.0f);
+const float max_lum = 0.8f;
+const float max_lit_distance = 6.5f;
+const float max_center_distance = 8.0f;
+//const vec4 candle_color = vec4(255.0f/255.0f, 0.001f/255.0f, 0.001f/255.0f, 255.0f/255.0f);
+const vec4 candle_color = vec4(228.0f/255.0f, 103.0f/255.0f, 1.0f/255.0f, 255.0f/255.0f);
float lumWeight = 0.0f;
const vec2 candle_pos = vec2(0.5, 0.5);
return (x == 0.0) ? 0.0 : pow(2, 10 * x - 10);
}
+float easeOutExpo(float x)
+{
+ return 1.0f - easeInExpo(x);
+}
+
float easeInCirc(float x)
{
return 1 - sqrt(1 - pow(x, 2));
return x * x * x * x;
}
+float easeOutQuad(float x)
+{
+ return 1.0f - (1.0f - x) * (1.0f - x);
+}
+
+float easeInQuad(float x)
+{
+ return (1.0f - x) * (1.0f - x);
+}
+
void main()
{
// Texel color fetching from texture sampler
vec4 texelColor = texture(texture0, fragTexCoord);
-
- const float max_dist = 7.5f;
- const float lit_dist = 2.5f;
- const float max_lum = 1.0f;
- float cam_dist_z = gl_FragCoord.z/gl_FragCoord.w;
- float norm_dist_z = (cam_dist_z/max_dist);
-
- vec2 uv = gl_FragCoord.xy/screen_dims;
+ vec4 lighting_color = texelColor*colDiffuse;
+ float camera_distance = distance(fragPosition, cam_position);
+ float normalized_lit_distance = camera_distance/max_lit_distance;
+ float center_distance = distance(fragPosition, map_center);
+ float normalized_center_distance = center_distance/max_center_distance;
+ float candle_weight = 0.0f;
+ vec4 lumWeights = vec4(1.0f);
finalColor = texelColor*colDiffuse;
- if(cam_dist_z < max_dist)
+ if(normalized_center_distance <= 1.0f)
{
- float norm_x_dist = abs(gl_FragCoord.x - (screen_dims.x/2))/(screen_dims.x/2);
- lumWeight = min(max_lum, 1.0f - easeInQuart(norm_dist_z));
+ lumWeight = easeInQuad(normalized_center_distance) + 0.9f;
}
- vec3 lumWeights = v3_unit * lumWeight;
-
- // All single color channel variations with this looks cool as FUCK
- // turns this into three levels going b-r-g
- float norm_y_dist = uv.y;
- finalColor.b = 0.0f;
- if(cam_dist_z < lit_dist)
+ if(normalized_lit_distance <= 1.0f)
{
- float norm_x_dist = abs(gl_FragCoord.x - (screen_dims.x/2))/(screen_dims.x/2);
- lumWeights.r = 1.8f * (1.0f - norm_dist_z);
+ lumWeight = max(lumWeight, min(0.5f, easeOutExpo(normalized_lit_distance)));
+ candle_weight = 1.0f - normalized_lit_distance;
}
- float lum = dot(finalColor.rgb, lumWeights);
- float rand = random(fragTexCoord);
- lumWeights *= lum;
- finalColor.rgb = mix(vec3(227/255, 60/255, 0/255), finalColor.rgb, lumWeights);
- finalColor.a = 1.0f;
+ lumWeight = min(lumWeight, max_lum);
+ lumWeights = vec4(1.0f) * lumWeight;
+ lumWeights *= dot(finalColor, lumWeights);
+
+ lighting_color = vec4(mix(candle_color.rgb * candle_weight, lumWeights.rgb, 0.2f), 1.0f);
+ finalColor = finalColor * lighting_color;
+
+ // All single color channel variations with this looks cool as FUCK
+ // turns this into three levels going b-r-g
+ finalColor.b = 0.0f;
}