diff options
Diffstat (limited to 'res/effectlib/sampleLight.glsllib')
-rw-r--r-- | res/effectlib/sampleLight.glsllib | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/res/effectlib/sampleLight.glsllib b/res/effectlib/sampleLight.glsllib index 74bd733..3218cdf 100644 --- a/res/effectlib/sampleLight.glsllib +++ b/res/effectlib/sampleLight.glsllib @@ -1,20 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2014 NVIDIA Corporation. +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt 3D Studio. +** +** $QT_BEGIN_LICENSE:GPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef SAMPLE_LIGHT_GLSLLIB #define SAMPLE_LIGHT_GLSLLIB #define MAX_NUM_SHADOWS 8 -#ifndef UIC_ENABLE_SSM -#define UIC_ENABLE_SSM 0 +#ifndef QT3DS_ENABLE_SSM +#define QT3DS_ENABLE_SSM 0 #endif #include "SSAOCustomMaterial.glsllib" -#if UIC_ENABLE_SSM +#if QT3DS_ENABLE_SSM #include "shadowMapping.glsllib" #endif #include "funcsampleLightVars.glsllib" -#if UIC_ENABLE_SSM +#if QT3DS_ENABLE_SSM uniform sampler2D shadowMaps[MAX_NUM_SHADOWS]; uniform samplerCube shadowCubes[MAX_NUM_SHADOWS]; uniform int uNumShadowMaps; @@ -32,7 +62,7 @@ void sampleLight(in LightSource light, if (light.position.w == 0.0f) // directional light { wi = normalize(light.position.xyz); -#if UIC_ENABLE_SSM +#if QT3DS_ENABLE_SSM if ( light.shadowIdx >= 0 ) att *= sampleOrthographic( shadowMaps[light.shadowIdx], light.shadowControls, light.shadowView, pos, vec2(1.0, light.shadowControls.z) ); #endif @@ -66,7 +96,7 @@ void sampleLight(in LightSource light, att = length(wi) * 0.15915494309; // solid angle / 2*pi wi = normalize(wi); att *= clamp( dot( pos - light.position.xyz, light.direction.xyz ), 0.0, 1.0 ); -#if UIC_ENABLE_SSM +#if QT3DS_ENABLE_SSM if ( light.shadowIdx >= 0 ) att *= sampleCubemap( shadowCubes[light.shadowIdx], light.shadowControls, light.shadowView, light.position.xyz, pos, vec2(1.0, light.shadowControls.z) ); #endif @@ -77,14 +107,14 @@ void sampleLight(in LightSource light, float dist = length(wi); wi = wi / dist; // == normalize(wi); att = 1.0f / (light.constantAttenuation + (light.linearAttenuation + light.quadraticAttenuation * dist) * dist); - /* + /* if (light.spotCutoff < 180.0f) // spot light { float spot = max(0.0f, dot(wi, -light.direction.xyz)); att *= (spot >= cos(light.spotCutoff * PI / 180.0f)) ? pow(spot, light.spotExponent) : 0.0f; } - */ -#if UIC_ENABLE_SSM + */ +#if QT3DS_ENABLE_SSM if ( light.shadowIdx >= 0 ) att *= sampleCubemap( shadowCubes[light.shadowIdx], light.shadowControls, light.shadowView, light.position.xyz, pos, vec2(1.0, light.shadowControls.z) ); #endif |