Commit 05cd591d authored by Florian Oetke's avatar Florian Oetke
Browse files

fixed shader compilation after path-changes; better GI from emissive materials...

fixed shader compilation after path-changes; better GI from emissive materials by ignoring the normal of the hit surface (also using light from the back side)
parent 42f03feb
......@@ -43,7 +43,7 @@ vec3 calculate_gi(vec2 uv, vec3 radiance, vec3 specular,
vec3 diff = albedo * radiance*(1.0 - F0*brdf.x) / PI;
vec3 spec = specular.rgb * (F0*brdf.x + brdf.y);
diffuse = albedo * radiance/PI + F0*radiance / (2*PI*PI);
diffuse = albedo * radiance/PI + F0*radiance/(2.0*PI);
return clamp(diff + spec, vec3(0,0,0), vec3(10,10,10));
}
......
......@@ -98,7 +98,7 @@ void main() {
vec3 gi = calculate_gi(vertex_out.tex_coords, radiance, specular,
albedo_sampler, mat_data_sampler, brdf_sampler, diffuse);
out_input = vec4(gi, 0.0);
out_input = vec4(diffuse, 0.0);
float proj_prev_depth = abs(prev_pos.z);
float prev_depth = textureLod(prev_depth_sampler, prev_uv.xy, 0.0).r;
......
......@@ -178,6 +178,8 @@ vec3 calc_illumination_from(int lod, vec2 tex_size, ivec2 src_uv, vec2 shaded_uv
float NdotL_src = clamp(dot(N, dir), 0.0, 1.0); // cos(θ')
float NdotL_dst = clamp(dot(shaded_normal, -dir), 0.0, 1.0); // cos(θ)
NdotL_src = mix(max(clamp(dot(-N, dir), 0.0, 1.0), NdotL_src), NdotL_src, step(0.0001, mat_data.b));
float cos_alpha = Pn.z;
float cos_beta = dot(Pn, N);
float z = depth * global_uniforms.proj_planes.y;
......
......@@ -158,9 +158,10 @@ void main() {
vec2 hit_uv = raycast_hit_uv/depthSize + jitter.xy * mix(0.001, 0.02, min(L_len / 10.0, 1.0));
vec3 hit_N = decode_normal(textureLod(mat_data_sampler, hit_uv, 0).rg);
vec4 hit_mat_data = textureLod(mat_data_sampler, hit_uv, 0);
vec3 hit_N = decode_normal(hit_mat_data.rg);
float factor_normal = 1.0 - smoothstep(0.6, 0.9, abs(dot(N, hit_N)));
float factor_normal = mix(1, 1.0 - smoothstep(0.6, 0.9, abs(dot(N, hit_N))), step(0.0001, hit_mat_data.b));
vec3 color = cone_tracing(roughness, hit_uv, dir, coneTheta);
......
......@@ -33,5 +33,5 @@ void main() {
depth_out = vec4(-view_pos.z / global_uniforms.proj_planes.y, 0,0,1);
albedo_mat_id = vec4(albedo.rgb, 1.0);
mat_data = vec4(encode_normal(normalize(normal)), 0.5, 0);
mat_data = vec4(encode_normal(normalize(normal)), 0.0, 0.0);
}
# build shaders
file(GLOB_RECURSE GLSL_SOURCE_FILES
"${ROOT_DIR}/assets/assets/shader/*.frag"
"${ROOT_DIR}/assets/assets/shader/*.vert"
"${ROOT_DIR}/assets/core_assets/shader/*.frag"
"${ROOT_DIR}/assets/core_assets/shader/*.vert"
)
set(GLSL_COMPILER "glslc")
foreach(GLSL ${GLSL_SOURCE_FILES})
get_filename_component(FILE_NAME ${GLSL} NAME)
set(SPIRV "${ROOT_DIR}/assets/assets/shader/bin/${FILE_NAME}.spv")
set(SPIRV "${ROOT_DIR}/assets/core_assets/shader/bin/${FILE_NAME}.spv")
add_custom_command(
OUTPUT ${SPIRV}
COMMAND ${CMAKE_COMMAND} -E make_directory "${ROOT_DIR}/assets/assets/shader/bin/"
COMMAND ${CMAKE_COMMAND} -E make_directory "${ROOT_DIR}/assets/core_assets/shader/bin/"
COMMAND ${GLSL_COMPILER} ${GLSL} -o ${SPIRV}
DEPENDS ${GLSL})
list(APPEND SPIRV_BINARY_FILES ${SPIRV})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment