Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl')
-rw-r--r--source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl84
1 files changed, 44 insertions, 40 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl
index fcbb6661b14..d345cd5c808 100644
--- a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl
@@ -20,56 +20,60 @@ layout(location = 1) out vec4 outTransmittance;
void main()
{
- ivec3 volume_cell = ivec3(gl_FragCoord.xy, slice);
+ ivec3 volume_cell = ivec3(gl_FragCoord.xy, slice);
- /* Emission */
- outScattering = texelFetch(volumeEmission, volume_cell, 0);
- outTransmittance = texelFetch(volumeExtinction, volume_cell, 0);
- vec3 s_scattering = texelFetch(volumeScattering, volume_cell, 0).rgb;
- vec3 volume_ndc = volume_to_ndc((vec3(volume_cell) + volJitter.xyz) * volInvTexSize.xyz);
- vec3 worldPosition = get_world_space_from_depth(volume_ndc.xy, volume_ndc.z);
- vec3 wdir = cameraVec;
+ /* Emission */
+ outScattering = texelFetch(volumeEmission, volume_cell, 0);
+ outTransmittance = texelFetch(volumeExtinction, volume_cell, 0);
+ vec3 s_scattering = texelFetch(volumeScattering, volume_cell, 0).rgb;
+ vec3 volume_ndc = volume_to_ndc((vec3(volume_cell) + volJitter.xyz) * volInvTexSize.xyz);
+ vec3 worldPosition = get_world_space_from_depth(volume_ndc.xy, volume_ndc.z);
+ vec3 wdir = cameraVec;
- vec2 phase = texelFetch(volumePhase, volume_cell, 0).rg;
- float s_anisotropy = phase.x / max(1.0, phase.y);
+ vec2 phase = texelFetch(volumePhase, volume_cell, 0).rg;
+ float s_anisotropy = phase.x / max(1.0, phase.y);
- /* Environment : Average color. */
- outScattering.rgb += irradiance_volumetric(worldPosition) * s_scattering * phase_function_isotropic();
+ /* Environment : Average color. */
+ outScattering.rgb += irradiance_volumetric(worldPosition) * s_scattering *
+ phase_function_isotropic();
#ifdef VOLUME_LIGHTING /* Lights */
- for (int i = 0; i < MAX_LIGHT && i < laNumLight; ++i) {
+ for (int i = 0; i < MAX_LIGHT && i < laNumLight; ++i) {
- LightData ld = lights_data[i];
+ LightData ld = lights_data[i];
- vec4 l_vector;
- l_vector.xyz = (ld.l_type == SUN) ? -ld.l_forward : ld.l_position - worldPosition;
- l_vector.w = length(l_vector.xyz);
+ vec4 l_vector;
+ l_vector.xyz = (ld.l_type == SUN) ? -ld.l_forward : ld.l_position - worldPosition;
+ l_vector.w = length(l_vector.xyz);
- float Vis = light_visibility(ld, worldPosition, l_vector);
+ float Vis = light_visibility(ld, worldPosition, l_vector);
- vec3 Li = light_volume(ld, l_vector) * light_volume_shadow(ld, worldPosition, l_vector, volumeExtinction);
+ vec3 Li = light_volume(ld, l_vector) *
+ light_volume_shadow(ld, worldPosition, l_vector, volumeExtinction);
- outScattering.rgb += Li * Vis * s_scattering * phase_function(-wdir, l_vector.xyz / l_vector.w, s_anisotropy);
- }
+ outScattering.rgb += Li * Vis * s_scattering *
+ phase_function(-wdir, l_vector.xyz / l_vector.w, s_anisotropy);
+ }
#endif
- /* Temporal supersampling */
- /* Note : this uses the cell non-jittered position (texel center). */
- vec3 curr_ndc = volume_to_ndc(vec3(gl_FragCoord.xy, float(slice) + 0.5) * volInvTexSize.xyz);
- vec3 wpos = get_world_space_from_depth(curr_ndc.xy, curr_ndc.z);
- vec3 prev_ndc = project_point(pastViewProjectionMatrix, wpos);
- vec3 prev_volume = ndc_to_volume(prev_ndc * 0.5 + 0.5);
-
- if ((volHistoryAlpha > 0.0) && all(greaterThan(prev_volume, vec3(0.0))) && all(lessThan(prev_volume, vec3(1.0)))) {
- vec4 h_Scattering = texture(historyScattering, prev_volume);
- vec4 h_Transmittance = texture(historyTransmittance, prev_volume);
- outScattering = mix(outScattering, h_Scattering, volHistoryAlpha);
- outTransmittance = mix(outTransmittance, h_Transmittance, volHistoryAlpha);
- }
-
- /* Catch NaNs */
- if (any(isnan(outScattering)) || any(isnan(outTransmittance))) {
- outScattering = vec4(0.0);
- outTransmittance = vec4(1.0);
- }
+ /* Temporal supersampling */
+ /* Note : this uses the cell non-jittered position (texel center). */
+ vec3 curr_ndc = volume_to_ndc(vec3(gl_FragCoord.xy, float(slice) + 0.5) * volInvTexSize.xyz);
+ vec3 wpos = get_world_space_from_depth(curr_ndc.xy, curr_ndc.z);
+ vec3 prev_ndc = project_point(pastViewProjectionMatrix, wpos);
+ vec3 prev_volume = ndc_to_volume(prev_ndc * 0.5 + 0.5);
+
+ if ((volHistoryAlpha > 0.0) && all(greaterThan(prev_volume, vec3(0.0))) &&
+ all(lessThan(prev_volume, vec3(1.0)))) {
+ vec4 h_Scattering = texture(historyScattering, prev_volume);
+ vec4 h_Transmittance = texture(historyTransmittance, prev_volume);
+ outScattering = mix(outScattering, h_Scattering, volHistoryAlpha);
+ outTransmittance = mix(outTransmittance, h_Transmittance, volHistoryAlpha);
+ }
+
+ /* Catch NaNs */
+ if (any(isnan(outScattering)) || any(isnan(outTransmittance))) {
+ outScattering = vec4(0.0);
+ outTransmittance = vec4(1.0);
+ }
}