diff options
author | Määttä Antti <antti.maatta@qt.io> | 2018-10-22 13:53:59 +0300 |
---|---|---|
committer | Antti Määttä <antti.maatta@qt.io> | 2018-10-22 12:51:31 +0000 |
commit | 36930d786c0bb99b47f0411abcf385f4f825f42c (patch) | |
tree | 94519e30a0c62bc82a8a47cac283b31a0fa9b7b0 /res | |
parent | 5651638d8a9d45af8ea6cdc71dc9b8b843103d2b (diff) |
Fix default material fresnel calculations
Task-number: QT3DS-2526
Change-Id: Ia46bfbcbd4f50bcaf3e27c3e116d0e117105dcb2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'res')
-rw-r--r-- | res/DataModelMetadata/en-us/MetaData.xml | 2 | ||||
-rw-r--r-- | res/effectlib/defaultMaterialFresnel.glsllib | 3 | ||||
-rw-r--r-- | res/effectlib/gles2/defaultMaterialFresnel.glsllib | 43 |
3 files changed, 2 insertions, 46 deletions
diff --git a/res/DataModelMetadata/en-us/MetaData.xml b/res/DataModelMetadata/en-us/MetaData.xml index 37b841a..aba9772 100644 --- a/res/DataModelMetadata/en-us/MetaData.xml +++ b/res/DataModelMetadata/en-us/MetaData.xml @@ -257,7 +257,7 @@ <Property name="specularroughness" formalName="Specular Roughness" description="Softening applied to reflections and\nhighlights" min='0.001' max='1' category="Material" /> <Property name="roughnessmap" formalName="Roughness Map" description="Image to vary the specular roughness across\nthe material" type="Image" category="Material" /> <Property name="fresnelPower" formalName="Fresnel Power" description="Damping of head-on reflections" category="Material" /> - <Property name="ior" formalName="Index of Refraction" description="Angle at which fresnel reflection damping\napplies" min="0" max="1" default=".2" category="Material" /> + <Property name="ior" formalName="Index of Refraction" description="Index of refraction of the material" min="1" default="1.5" category="Material" /> <Property name="bumpmap" formalName="Bump Map" description="Grayscale image simulating roughness in the\nlighting" type="Image" category="Material" /> <Property name="normalmap" formalName="Normal Map" description="Special RGB image describing surface\nroughness" type="Image" category="Material" /> <Property name="bumpamount" formalName="Bump Amount" description="Strength of bump/normal map effect" type="float" default=".5" category="Material" /> diff --git a/res/effectlib/defaultMaterialFresnel.glsllib b/res/effectlib/defaultMaterialFresnel.glsllib index 303a55b..e0eff4f 100644 --- a/res/effectlib/defaultMaterialFresnel.glsllib +++ b/res/effectlib/defaultMaterialFresnel.glsllib @@ -35,11 +35,10 @@ float defaultMaterialSimpleFresnel( in vec3 N, in vec3 viewDir, in float ior, fl { float F = ((1.0-ior) * (1.0-ior)) / ((1.0+ior) * (1.0+ior)); float VdotN = dot(viewDir, N); - float dvn = abs( dFdx(VdotN) * dFdy(VdotN) ); VdotN = clamp( VdotN, 0.0, 1.0 ); float ratio = F + (1.0 - F) * pow(1.0 - VdotN, fresnelPower); - return clamp( ratio * pow( VdotN, dvn * fresnelPower ), 0.0, 1.0 ); + return ratio; } #endif diff --git a/res/effectlib/gles2/defaultMaterialFresnel.glsllib b/res/effectlib/gles2/defaultMaterialFresnel.glsllib deleted file mode 100644 index 90958a3..0000000 --- a/res/effectlib/gles2/defaultMaterialFresnel.glsllib +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** 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 DEFAULT_MATERIAL_FRESNEL_NO_DVN_GLSLLIB -#define DEFAULT_MATERIAL_FRESNEL_NO_DVN_GLSLLIB - -float defaultMaterialSimpleFresnel( in vec3 N, in vec3 viewDir, in float ior, float fresnelPower ) -{ - float F = ((1.0-ior) * (1.0-ior)) / ((1.0+ior) * (1.0+ior)); - float VdotN = dot(viewDir, N); - VdotN = clamp( VdotN, 0.0, 1.0 ); - float ratio = F + (1.0 - F) * pow(1.0 - VdotN, fresnelPower); - return clamp( ratio * pow( VdotN, fresnelPower ), 0.0, 1.0 ); -} - -#endif |