fixes to shadows
This commit is contained in:
parent
5d36d1c73b
commit
5075374773
@ -178,7 +178,7 @@ draw_tacoma_tab :: (theme: *GR.Overall_Theme, total_r: GR.Rect) {
|
|||||||
#if HAS_TACOMA {
|
#if HAS_TACOMA {
|
||||||
if GR.button(r, "Render with Tacoma", *theme.button_theme) {
|
if GR.button(r, "Render with Tacoma", *theme.button_theme) {
|
||||||
cam := get_level_editor_camera();
|
cam := get_level_editor_camera();
|
||||||
gen_reference(tacomaResolution, tacomaResolution, .{tacomaExposure, tacomaContrast, tacomaSaturation}, .{cam.target, cam.position, tacomaSamples, true}, curworld.world.*);
|
gen_reference(tacomaResolution, tacomaResolution, .{tacomaExposure, tacomaContrast, tacomaSaturation, 1.0, 1.0}, .{cam.target, cam.position, tacomaSamples, true}, curworld.world.*);
|
||||||
}
|
}
|
||||||
r.y += r.h;
|
r.y += r.h;
|
||||||
if current_screenshot.valid {
|
if current_screenshot.valid {
|
||||||
|
|||||||
@ -158,13 +158,15 @@ backend_draw_ground :: (wc: *World_Config) {
|
|||||||
|
|
||||||
world_config_to_shader_type(wc, *world_conf);
|
world_config_to_shader_type(wc, *world_conf);
|
||||||
|
|
||||||
vs_params.mvp_shadow = shadow_mvp.floats;
|
fs_params : Plane_Fs_Params;
|
||||||
|
fs_params.mvp_shadow = shadow_mvp.floats;
|
||||||
vs_params.mvp = mvp.floats;
|
vs_params.mvp = mvp.floats;
|
||||||
sg_apply_pipeline(gPipelines.plane.pipeline);
|
sg_apply_pipeline(gPipelines.plane.pipeline);
|
||||||
gPipelines.plane.bind.samplers[2] = g_shadowmap_sampler;
|
gPipelines.plane.bind.samplers[2] = g_shadowmap_sampler;
|
||||||
gPipelines.plane.bind.images[2] = g_shadowmap;
|
gPipelines.plane.bind.images[2] = g_shadowmap;
|
||||||
sg_apply_bindings(*gPipelines.plane.bind);
|
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_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_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_apply_uniforms(UB_plane_data, *(sg_range.{ptr = *plane_data, size = size_of(type_of(plane_data))}));
|
||||||
sg_draw(0, 6, 1);
|
sg_draw(0, 6, 1);
|
||||||
|
|||||||
@ -72,8 +72,8 @@ create_shadow_viewproj :: (cam: *Camera, conf: *World_Config) -> Matrix4 {
|
|||||||
max_v.z = max(max_v.z, transformed_corner.z);
|
max_v.z = max(max_v.z, transformed_corner.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
max_v *= 2;
|
max_v *= 3;
|
||||||
min_v *= 2;
|
min_v *= 3;
|
||||||
|
|
||||||
proj := matrix_ortho(min_v.x, max_v.x, min_v.y, max_v.y, -max_v.z-100, -min_v.z);
|
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;
|
return view*proj;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -5,21 +5,14 @@ in vec4 position;
|
|||||||
|
|
||||||
layout(binding=0) uniform plane_vs_params {
|
layout(binding=0) uniform plane_vs_params {
|
||||||
mat4 mvp;
|
mat4 mvp;
|
||||||
mat4 mvp_shadow;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
out vec4 pos;
|
out vec4 pos;
|
||||||
out flat int idx;
|
out flat int idx;
|
||||||
out vec4 light_proj_pos;
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 multisize = vec3(position.xyz * 1000.0);
|
vec3 multisize = vec3(position.xyz * 1000.0);
|
||||||
gl_Position = mvp * vec4(multisize, 1.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);
|
pos = vec4(multisize, 1.0);
|
||||||
idx = gl_InstanceIndex;
|
idx = gl_InstanceIndex;
|
||||||
}
|
}
|
||||||
@ -29,9 +22,12 @@ void main() {
|
|||||||
|
|
||||||
in vec4 pos;
|
in vec4 pos;
|
||||||
in flat int idx;
|
in flat int idx;
|
||||||
in vec4 light_proj_pos;
|
|
||||||
out vec4 frag_color;
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
layout(binding=3) uniform plane_fs_params {
|
||||||
|
mat4 mvp_shadow;
|
||||||
|
};
|
||||||
|
|
||||||
uint murmurHash12(uvec2 src) {
|
uint murmurHash12(uvec2 src) {
|
||||||
const uint M = 0x5bd1e995u;
|
const uint M = 0x5bd1e995u;
|
||||||
uint h = 1190494759u;
|
uint h = 1190494759u;
|
||||||
@ -133,7 +129,7 @@ vec3 get_ground_sample(vec4 pos, float dirX, float dirY) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 npos = round(pos * 16.0) / 16.0;
|
vec4 npos = floor(pos * 16.0) / 16.0;
|
||||||
vec2 tileCenter = vec2(floor(npos.x) + 0.5, floor(npos.z) + 0.5);
|
vec2 tileCenter = vec2(floor(npos.x) + 0.5, floor(npos.z) + 0.5);
|
||||||
vec2 toCenter = npos.xz - tileCenter;
|
vec2 toCenter = npos.xz - tileCenter;
|
||||||
|
|
||||||
@ -153,10 +149,12 @@ void main() {
|
|||||||
vec3 b01 = mix(c0, c1, u);
|
vec3 b01 = mix(c0, c1, u);
|
||||||
vec3 b23 = mix(c2, c3, u);
|
vec3 b23 = mix(c2, c3, u);
|
||||||
vec3 bf = mix(b01, b23, v);
|
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;
|
vec3 light_pos = light_proj_pos.xyz / light_proj_pos.w;
|
||||||
light_pos = light_pos * 0.5 + 0.5;
|
light_pos = light_pos * 0.5 + 0.5;
|
||||||
float shadowp = texture(sampler2DShadow(shadow, shadowsmp), light_pos);
|
float bias = 0.0005;
|
||||||
|
float shadowp = max(0.7, texture(sampler2DShadow(shadow, shadowsmp), vec3(light_pos.xy, light_pos.z - bias)));
|
||||||
|
|
||||||
if(planeType == 1) {
|
if(planeType == 1) {
|
||||||
frag_color = vec4(bf * shadowp, 1.0);
|
frag_color = vec4(bf * shadowp, 1.0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user