Hi,
I am having an issue with this code:
#version 330
#define NUM_CASCADES 4
layout (location = 0) out vec3 shadow;
in VsOut
{
vec4 frag_position_light_space[NUM_CASCADES];
vec4 frag_position_world_space;
} vs_out;
uniform sampler2DArrayShadow depth_map;
uniform float cascades[NUM_CASCADES];
float directional_shadow_calculation(
vec4 frag_position_light_space,
sampler2DArrayShadow depth_map,
int cascade
)
{
vec3 proj_coords = frag_position_light_space.xyz / frag_position_light_space.w;
proj_coords = proj_coords * 0.5 + 0.5;
float current_depth = proj_coords.z;
return texture(depth_map, vec4(proj_coords.xy, cascade, current_depth));
}
void main()
{
int cascade = -1;
float current_cascade_distance = length(vs_out.frag_position_world_space.xyz);
for(int i = 0; i<NUM_CASCADES; i++)
{
if(current_cascade_distance <= cascades[i])
{
cascade = i;
break;
}
}
if(cascade == -1)
{
//shadow = vec3(0.9999999, 1.0, 1.0); // <- ISSUE IS HERE
shadow = vec3(1.0, 1.0, 1.0);
}
else
{
shadow = vec3(1.0, 1.0, 1.0) * directional_shadow_calculation(
vs_out.frag_position_light_space[cascade],
depth_map,
cascade
);
}
}
when I run my program with vec3(0.99999, 1.0, 1.0)
it works as I intended (When an object lies within a shadowmap I will render with shadow information, else it will multiply the final color with effectively vec3(1.0, 1.0, 1.0)
).
However, if I run the code with vec3(1.0, 1.0, 1.0)
everything including the valid shadow information gets white except some few little weird artifacts.
Also, this issue doesn’t happen when I run it on a VirtualBox Lubuntu.
My machine:
System: Host: tsoj-pc Kernel: 4.19.80-1-MANJARO x86_64 bits: 64 Desktop: Xfce 4.14.1 Distro: Manjaro Linux
Machine: Type: Laptop System: Acer product: Swift SF314-52 v: V1.08 serial: <root required>
Mobo: KBL model: Suntory_KL v: V1.08 serial: <root required> UEFI: Insyde v: 1.08 date: 11/28/2017
Battery: ID-1: BAT0 charge: 21.5 Wh condition: 35.2/50.8 Wh (69%) // <- i hate this fucking battery
CPU: Topology: Quad Core model: Intel Core i5-8250U bits: 64 type: MT MCP L2 cache: 6144 KiB
Speed: 692 MHz min/max: 400/3400 MHz Core speeds (MHz): 1: 665 2: 633 3: 651 4: 622 5: 628 6: 616 7: 630 8: 633
Graphics: Device-1: Intel UHD Graphics 620 driver: i915 v: kernel
Display: x11 server: X.Org 1.20.5 driver: intel unloaded: modesetting resolution: 1920x1080~60Hz
OpenGL: renderer: Mesa DRI Intel UHD Graphics 620 (Kabylake GT2) v: 4.5 Mesa 19.2.2
Audio: Device-1: Intel Sunrise Point-LP HD Audio driver: snd_hda_intel
Sound Server: ALSA v: k4.19.80-1-MANJARO
Network: Device-1: Intel Wireless 7265 driver: iwlwifi
IF: wlp3s0 state: up mac: f8:59:71:6d:e5:8e
Drives: Local Storage: total: 238.47 GiB used: 182.60 GiB (76.6%)
ID-1: /dev/nvme0n1 vendor: Intel model: SSDPEKKW256G7 size: 238.47 GiB
Partition: ID-1: / size: 233.43 GiB used: 182.60 GiB (78.2%) fs: ext4 dev: /dev/nvme0n1p2
Sensors: System Temperatures: cpu: 46.0 C mobo: N/A
Fan Speeds (RPM): N/A
Info: Processes: 232 Uptime: 2h 01m Memory: 7.67 GiB used: 4.40 GiB (57.4%) Shell: bash inxi: 3.0.36