diff options
Diffstat (limited to 'adapters/fparkan-render-vulkan/shaders/triangle.vert')
| -rw-r--r-- | adapters/fparkan-render-vulkan/shaders/triangle.vert | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/adapters/fparkan-render-vulkan/shaders/triangle.vert b/adapters/fparkan-render-vulkan/shaders/triangle.vert index ad564f82..b780601d 100644 --- a/adapters/fparkan-render-vulkan/shaders/triangle.vert +++ b/adapters/fparkan-render-vulkan/shaders/triangle.vert @@ -94,6 +94,11 @@ struct LightingTerms { vec3 specular; }; +// Terrain CShade converts coefficients before evaluating the lights. +vec3 infrared_coefficient(vec3 rgb) { + return vec3(0.0, ((rgb.b + rgb.g) + rgb.r) * 0.33 * 7.0, 0.0); +} + float native_range_compress(float value) { if (value <= 1.0) { return value; @@ -178,6 +183,14 @@ LightingTerms native_material_lighting( vec3 specular_rgb, float specular_power ) { + int lighting_flags = int(frame.lighting_floor.w); + vec3 lighting_floor = frame.lighting_floor.rgb; + if ((lighting_flags & 2) != 0) { + directional_rgb = infrared_coefficient(directional_rgb); + additive_rgb = infrared_coefficient(additive_rgb); + specular_rgb = infrared_coefficient(specular_rgb); + lighting_floor = infrared_coefficient(lighting_floor); + } vec3 accumulated = additive_rgb; vec3 specular = vec3(0.0); vec3 view_direction = normalized_or(frame.camera_position.xyz - world_position, vec3(0.0, 0.0, 1.0)); @@ -206,7 +219,7 @@ LightingTerms native_material_lighting( } } // The model viewport has its own lamps and does not sample the world's lights. - uint point_light_count = frame.lighting_floor.w > 0.5 ? 0u : point_light_buffer.header.x; + uint point_light_count = (lighting_flags & 1) != 0 ? 0u : point_light_buffer.header.x; for (uint index = 0u; index < point_light_count; ++index) { PointLightRecord point_light = point_light_buffer.records[index]; if (point_light.owner_scope != 0u && point_light.owner_scope != uint(gl_InstanceIndex)) { @@ -241,7 +254,7 @@ LightingTerms native_material_lighting( } } } - accumulated = max(accumulated, frame.lighting_floor.rgb); + accumulated = max(accumulated, lighting_floor); vec3 compressed = vec3( native_range_compress(accumulated.r), native_range_compress(accumulated.g), |
