Compare commits

..

No commits in common. "39f187689e7c2de27d25b3a6f87f14a23d927dc3" and "5d36d1c73bfbcf0bb0e7495118624bcbc8e31171" have entirely different histories.

6 changed files with 902 additions and 939 deletions

View File

@ -178,7 +178,7 @@ draw_tacoma_tab :: (theme: *GR.Overall_Theme, total_r: GR.Rect) {
#if HAS_TACOMA {
if GR.button(r, "Render with Tacoma", *theme.button_theme) {
cam := get_level_editor_camera();
gen_reference(tacomaResolution, tacomaResolution, .{tacomaExposure, tacomaContrast, tacomaSaturation, 1.0, 1.0}, .{cam.target, cam.position, tacomaSamples, true}, curworld.world.*);
gen_reference(tacomaResolution, tacomaResolution, .{tacomaExposure, tacomaContrast, tacomaSaturation}, .{cam.target, cam.position, tacomaSamples, true}, curworld.world.*);
}
r.y += r.h;
if current_screenshot.valid {

View File

@ -158,15 +158,13 @@ backend_draw_ground :: (wc: *World_Config) {
world_config_to_shader_type(wc, *world_conf);
fs_params : Plane_Fs_Params;
fs_params.mvp_shadow = shadow_mvp.floats;
vs_params.mvp_shadow = shadow_mvp.floats;
vs_params.mvp = mvp.floats;
sg_apply_pipeline(gPipelines.plane.pipeline);
gPipelines.plane.bind.samplers[2] = g_shadowmap_sampler;
gPipelines.plane.bind.images[2] = g_shadowmap;
sg_apply_bindings(*gPipelines.plane.bind);
sg_apply_uniforms(UB_plane_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params)) }));
sg_apply_uniforms(UB_plane_fs_params, *(sg_range.{ ptr = *fs_params, size = size_of(type_of(fs_params)) }));
sg_apply_uniforms(UB_plane_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))}));
sg_apply_uniforms(UB_plane_data, *(sg_range.{ptr = *plane_data, size = size_of(type_of(plane_data))}));
sg_draw(0, 6, 1);

View File

@ -461,8 +461,8 @@ create_plane_pipeline :: () {
g_shadowmap_sampler = sg_make_sampler(*(sg_sampler_desc.{
wrap_u = .CLAMP_TO_EDGE,
wrap_v = .CLAMP_TO_EDGE,
min_filter = .LINEAR,
mag_filter = .LINEAR,
min_filter = .NEAREST,
mag_filter = .NEAREST,
compare = .LESS,
}));

View File

@ -71,8 +71,9 @@ create_shadow_viewproj :: (cam: *Camera, conf: *World_Config) -> Matrix4 {
max_v.y = max(max_v.y, transformed_corner.y);
max_v.z = max(max_v.z, transformed_corner.z);
}
max_v.xy = avg.xy + Vector2.{50, 50};
min_v.xy = avg.xy - Vector2.{50, 50};
max_v *= 2;
min_v *= 2;
proj := matrix_ortho(min_v.x, max_v.x, min_v.y, max_v.y, -max_v.z-100, -min_v.z);
return view*proj;

File diff suppressed because it is too large Load Diff

View File

@ -5,14 +5,21 @@ in vec4 position;
layout(binding=0) uniform plane_vs_params {
mat4 mvp;
mat4 mvp_shadow;
};
out vec4 pos;
out flat int idx;
out vec4 light_proj_pos;
void main() {
vec3 multisize = vec3(position.xyz * 1000.0);
gl_Position = mvp * vec4(multisize, 1.0);
vec3 texelMultisize = round(multisize* 16.0) / 16.0;
light_proj_pos = mvp_shadow * vec4(texelMultisize, 1.0);
// #if !SOKOL_GLSL
// light_proj_pos.y = -light_proj_pos.y;
// #endif
pos = vec4(multisize, 1.0);
idx = gl_InstanceIndex;
}
@ -22,12 +29,9 @@ void main() {
in vec4 pos;
in flat int idx;
in vec4 light_proj_pos;
out vec4 frag_color;
layout(binding=3) uniform plane_fs_params {
mat4 mvp_shadow;
};
uint murmurHash12(uvec2 src) {
const uint M = 0x5bd1e995u;
uint h = 1190494759u;
@ -129,7 +133,7 @@ vec3 get_ground_sample(vec4 pos, float dirX, float dirY) {
}
void main() {
vec4 npos = floor(pos * 16.0) / 16.0;
vec4 npos = round(pos * 16.0) / 16.0;
vec2 tileCenter = vec2(floor(npos.x) + 0.5, floor(npos.z) + 0.5);
vec2 toCenter = npos.xz - tileCenter;
@ -150,11 +154,9 @@ void main() {
vec3 b23 = mix(c2, c3, u);
vec3 bf = mix(b01, b23, v);
vec4 light_proj_pos = mvp_shadow * vec4(npos.xyz + vec3(1.0/32.0, 0.0, 1.0/32.0), 1.0);
vec3 light_pos = light_proj_pos.xyz / light_proj_pos.w;
light_pos = light_pos * 0.5 + 0.5;
float bias = 0.0005;
float shadowp = max(0.7, texture(sampler2DShadow(shadow, shadowsmp), vec3(light_pos.xy, light_pos.z - bias)));
float shadowp = texture(sampler2DShadow(shadow, shadowsmp), light_pos);
if(planeType == 1) {
frag_color = vec4(bf * shadowp, 1.0);