File include/jen/settings.h changed (mode: 100644) (index 3083bab..be2dfd1) |
... |
... |
struct jen::GraphicsSettings |
123 |
123 |
{ |
{ |
124 |
124 |
/// @brief Shading options for general 3D pipeline. |
/// @brief Shading options for general 3D pipeline. |
125 |
125 |
enum class Shading : uint32_t { |
enum class Shading : uint32_t { |
126 |
|
/// Default shading with clustered forward rendering and shadow mapping |
|
|
126 |
|
/// Default shading with clustered forward rendering |
127 |
127 |
DEFAULT, |
DEFAULT, |
|
128 |
|
/// DEFAULT + shadow mapping. Experimental |
|
129 |
|
SHADOW_MAPPING, |
128 |
130 |
/// No lighting system |
/// No lighting system |
129 |
131 |
NO_LIGHTING, |
NO_LIGHTING, |
130 |
132 |
/// Render weird-looking colors instead of textures to detect |
/// Render weird-looking colors instead of textures to detect |
File src/graphics/shaders/default.frag changed (mode: 100644) (index 1b6596e..4de2053) |
... |
... |
layout(location = 4) in vec4 scales; |
61 |
61 |
layout(location = 0) out vec4 out_color; |
layout(location = 0) out vec4 out_color; |
62 |
62 |
|
|
63 |
63 |
const uint DEFAULT = 0; |
const uint DEFAULT = 0; |
64 |
|
const uint NO_LIGHTING = 1; |
|
65 |
|
const uint DEBUG_TEXTURE_COORDINATES = 2; |
|
66 |
|
const uint DEBUG_CLUSTERS_DEPTH = 3; |
|
67 |
|
const uint DEBUG_CLUSTERS_NUM_LIGHTS = 4; |
|
|
64 |
|
const uint SHADOW_MAPPING = 1; |
|
65 |
|
const uint NO_LIGHTING = 2; |
|
66 |
|
const uint DEBUG_TEXTURE_COORDINATES = 3; |
|
67 |
|
const uint DEBUG_CLUSTERS_DEPTH = 4; |
|
68 |
|
const uint DEBUG_CLUSTERS_NUM_LIGHTS = 5; |
68 |
69 |
layout (constant_id = 0) const uint TYPE = DEFAULT; |
layout (constant_id = 0) const uint TYPE = DEFAULT; |
69 |
70 |
layout (constant_id = 1) const float BIAS = 0.01; |
layout (constant_id = 1) const float BIAS = 0.01; |
70 |
71 |
layout (constant_id = 2) const uint BLOCKER_SEARCH_DETAIL = 0; |
layout (constant_id = 2) const uint BLOCKER_SEARCH_DETAIL = 0; |
|
... |
... |
vec3 compute_light_with_shadow() |
564 |
565 |
push.light.z_near, push.light.z_far); |
push.light.z_near, push.light.z_far); |
565 |
566 |
|
|
566 |
567 |
float diffuse = dot(in_normal, to_light) / to_light_distance; |
float diffuse = dot(in_normal, to_light) / to_light_distance; |
567 |
|
float visibility = compute_light_visibility(to_light, d_norm, diffuse); |
|
|
568 |
|
float visibility; |
|
569 |
|
if (TYPE == SHADOW_MAPPING) |
|
570 |
|
visibility = compute_light_visibility(to_light, d_norm, diffuse); |
|
571 |
|
else |
|
572 |
|
visibility = 1; |
568 |
573 |
float intensivity = compute_light_attenuation(d_norm); |
float intensivity = compute_light_attenuation(d_norm); |
569 |
574 |
|
|
570 |
575 |
float scale = max(diffuse, 0.04) * intensivity * visibility; |
float scale = max(diffuse, 0.04) * intensivity * visibility; |
|
... |
... |
void main() |
664 |
669 |
vec3 coord = vec3(UV, push.textureIndex); |
vec3 coord = vec3(UV, push.textureIndex); |
665 |
670 |
vec3 texel = texture(textureSampler, coord).rgb; |
vec3 texel = texture(textureSampler, coord).rgb; |
666 |
671 |
#endif |
#endif |
667 |
|
if (TYPE == DEFAULT) |
|
|
672 |
|
if (TYPE <= SHADOW_MAPPING) |
668 |
673 |
out_color = vec4(texel * compute_lights(), 1); |
out_color = vec4(texel * compute_lights(), 1); |
669 |
674 |
else if (TYPE == NO_LIGHTING) |
else if (TYPE == NO_LIGHTING) |
670 |
675 |
out_color = vec4(texel, 1); |
out_color = vec4(texel, 1); |