Vector3 coffin_scale;
Vector3 coffin_rotation_axis;
float coffin_rotation;
-int coffin_material_count;
+int coffin_material_count;
+
+Image hand_01_image;
+Texture hand_01_texture;
+Vector2 hand_position;
+float hand_rotation;
+float hand_scale;
Shader shader;
int cam_position_shader_loc;
int screen_dims_shader_loc;
int map_center_shader_loc;
+int orb_color_shader_loc;
+int orb_intensity_shader_loc;
+int orb_directionality_shader_loc;
Vector3 player_collide_point;
Ray player_collide_ray;
RayCollision player_collision;
Vector3 player_velocity;
Vector3 player_rotation;
+Vector3 player_angles;
Vector3 map_center;
float forward_speed = 0.015f;
Vector3 vec3_up = {0.0f, 1.0f, 0.0f};
Vector3 vec3_down = {0.0f, -1.0f, 0.0f};
+Color orb_color = BLUE;
+Vector4 orb_normal_color;
+float orb_intensity = 1.0f; /* TODO: normalized distance from center, but lighting shader already has this. */
+Vector3 orb_directionality = {1.0f, 1.0f, 1.0f};
+
typedef void(*renderfunc)();
typedef void(*controlfunc)();
#define MAX_RENDERFUNCS 2U
*/
void drawing_game_mode()
{
+ Vector2 from_center_coords = (Vector2){cam.position.x, cam.position.z};
+ from_center_coords.x -= barrow_scale.x/2;
+ from_center_coords.y += barrow_scale.z/2;
+ /* -PI, PI */
+ player_angles.y = Vector2Angle(Vector2Normalize(from_center_coords), (Vector2){1.0f, 0.0f});
+
ClearBackground(BLACK);
BeginMode3D(cam);
BeginShaderMode(shader);
- DrawModelEx(coffin_model, coffin_position, coffin_rotation_axis, coffin_rotation, coffin_scale, DARKGRAY);
+ // 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);
- DrawRay(player_collide_ray, WHITE);
+ // DrawRay(player_collide_ray, WHITE);
EndShaderMode();
EndMode3D();
+ orb_normal_color = ColorNormalize(orb_color);
+ orb_intensity = 64.0f; /* TODO: normalized distance from center, but lighting shader already has this. */
+ orb_directionality = player_angles;
+
+ DrawTextureEx(hand_01_texture, hand_position, hand_rotation, hand_scale, orb_color);
+
#define DEBUG_GAME_INFO 1
#if DEBUG_GAME_INFO==1
Rectangle minimap_dest = {.width = 64.0f*img_export_scale.x, .height = 64.0f*img_export_scale.y, .x = 0.0f, .y = 0.0f};
DrawFPS(fscreen_dims.x - 80, 10);
DrawText(TextFormat("cam x %f\ncam y %f\ncam z %f", cam.position.x, cam.position.y, cam.position.z), 0, 128, 16, GREEN);
DrawText(TextFormat("tgt x %f\ntgt y %f\ntgt z %f", cam.target.x, cam.target.y, cam.target.z), 0, 128+64, 16, GREEN);
- DrawText(TextFormat("ray hit %d\nlength %f", player_collision.hit, player_collision.distance), 0, 256, 16, GREEN);
+ DrawText(TextFormat("rot x %f\nrot y %f\nrot z %f", player_angles.x, player_angles.y, player_angles.z), 0, 128+(64*2), 16, GREEN);
+ DrawText(TextFormat("ray hit %d\nlength %f", player_collision.hit, player_collision.distance), 0, 128+(64*3), 16, GREEN);
#endif /* DEBUG_GAME_INFO */
}
cam.target.y -= DEG2RAD * 20.0;
}
+ if (IsKeyReleased(KEY_ONE))
+ orb_color = RED;
+ if (IsKeyReleased(KEY_TWO))
+ orb_color = BLUE;
+ if (IsKeyReleased(KEY_THREE))
+ orb_color = GREEN;
+
/* Collision test */
/* Cast straight up */
player_collide_ray = (Ray){cam.position, vec3_up};
cam_position_shader_loc = GetShaderLocation(shader, "cam_position");
screen_dims_shader_loc = GetShaderLocation(shader, "screen_dims");
map_center_shader_loc = GetShaderLocation(shader, "map_center");
+ orb_color_shader_loc = GetShaderLocation(shader, "orb_color");
+ orb_intensity_shader_loc = GetShaderLocation(shader, "orb_intensity");
+ orb_directionality_shader_loc = GetShaderLocation(shader, "orb_directionality");
}
void wait_initialize_resources()
coffin_model = LoadModel("./assets/coffin_1.glb");
while(!IsModelReady(coffin_model)){}
coffin_model.materials[0].shader = shader;
+
+ hand_01_image = LoadImage("./assets/hand_1.png");
+ while(!IsImageReady(hand_01_image)){}
+ hand_01_texture = LoadTextureFromImage(hand_01_image);
+ while(!IsTextureReady(hand_01_texture)){}
+ hand_scale = 4.0f;
+ hand_position = (Vector2){0, fscreen_dims.y - (hand_01_image.height * hand_scale)};
+ hand_rotation = 0.0f;
}
/* Mode handler setup */
cam.position = barrow_position;
cam.position.y -= 0.5f;
cam.position.x = barrow_scale.x/2.0f;
- cam.position.z = (-barrow_scale.z/2.0f) - 4.0f;
+ cam.position.z = (-barrow_scale.z/2.0f);
cam.target = (Vector3){barrow_scale.x/2.0f, cam.position.y - 7.0f, cam.position.z/2.0f};
cam.up = (Vector3){0.0f, 1.0f, 0.0f};
cam.fovy = 90.0f;
void start_render_loop()
{
initialize_prerenderer();
+ SetTraceLogLevel(LOG_ALL);
InitWindow(fscreen_dims.x, fscreen_dims.y, screen_title);
wait_initialize_shaders();
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);
+ SetShaderValue(shader, orb_color_shader_loc, &orb_normal_color, SHADER_UNIFORM_VEC4);
+ SetShaderValue(shader, orb_intensity_shader_loc, &orb_intensity, SHADER_UNIFORM_FLOAT);
+ SetShaderValue(shader, orb_directionality_shader_loc, &orb_directionality, SHADER_UNIFORM_VEC3);
UpdateCameraPro(&cam, player_velocity, player_rotation, 0.0f);
BeginDrawing();
in vec2 fragTexCoord;
in vec4 fragColor;
in vec3 fragPosition;
+layout(pixel_center_integer) in vec4 gl_FragCoord;
// Input uniform values
uniform sampler2D texture0;
uniform vec3 cam_position;
uniform vec2 screen_dims;
uniform vec3 map_center;
+uniform vec4 orb_color;
+uniform float orb_intensity;
+uniform vec3 orb_directionality;
// Output fragment color
out vec4 finalColor;
const float max_lum = 1.0f;
const float max_lit_distance = 7.5f;
const float max_center_distance = 8.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;
+vec4 candle_color = vec4(228.0f/255.0f, 103.0f/255.0f, 1.0f/255.0f, 255.0f/255.0f);
+
+vec2 orb_pos = vec2(3.0 * (screen_dims.x/16), 8 * (screen_dims.y/16));
-const vec2 candle_pos = vec2(0.5, 0.5);
+float lumWeight = 0.0f;
// A single iteration of Bob Jenkins' One-At-A-Time hashing algorithm.
uint hash( uint x ) {
candle_weight = 1.0f - normalized_lit_distance;
}
+ float normal_distance_from_orb = distance(orb_pos, gl_FragCoord.xy)/orb_intensity;
+ if(normal_distance_from_orb < 1.0f)
+ {
+ lumWeight = 3.0f;
+ finalColor *= (orb_color * lumWeight);
+ finalColor.a = 1.5 - easeOutExpo(normal_distance_from_orb);
+ }
+
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.4f), 1.0f);
+ lighting_color = vec4(mix(orb_color.rgb * candle_weight, lumWeights.rgb, 0.4f), 1.0f);
+ //lighting_color = vec4(mix(candle_color.rgb * candle_weight, lumWeights.rgb, 0.4f), 1.0f);
finalColor = finalColor * lighting_color;
// All single color channel variations with this looks cool as FUCK