2016-07-19 17:35:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2020-12-13 23:02:57 +00:00
|
|
|
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-07-19 17:35:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file cpostshader_ssao.h
|
|
|
|
* @brief Implements a post shader screen space ambient occlusion on software
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CPOSTSHADER_SSAO_H
|
|
|
|
#define CPOSTSHADER_SSAO_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "cpostshader.h"
|
|
|
|
|
|
|
|
|
2020-12-13 23:02:57 +00:00
|
|
|
class CPOSTSHADER_SSAO : public CPOSTSHADER
|
2016-07-19 17:35:25 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit CPOSTSHADER_SSAO( const CCAMERA &aCamera );
|
|
|
|
|
2016-09-24 18:53:15 +00:00
|
|
|
SFVEC3F Shade(const SFVEC2I &aShaderPos ) const override;
|
2020-12-13 23:02:57 +00:00
|
|
|
SFVEC3F ApplyShadeColor( const SFVEC2I &aShaderPos, const SFVEC3F &aInputColor,
|
|
|
|
const SFVEC3F &aShadeColor ) const override;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-07-14 16:40:28 +00:00
|
|
|
SFVEC3F Blur( const SFVEC2I& aShaderPos ) const;
|
|
|
|
|
|
|
|
void SetShadedBuffer( SFVEC3F* aShadedBuffer )
|
|
|
|
{
|
|
|
|
m_shadedBuffer = aShadedBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetShadowsEnabled( bool aIsShadowsEnabled )
|
|
|
|
{
|
|
|
|
m_isUsingShadows = aIsShadowsEnabled;
|
|
|
|
}
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
private:
|
2020-12-13 23:02:57 +00:00
|
|
|
SFVEC3F posFromDepth( const SFVEC2F& coord ) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-13 23:02:57 +00:00
|
|
|
float ec_depth( const SFVEC2F& tc ) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-13 23:02:57 +00:00
|
|
|
float aoFF( const SFVEC2I& aShaderPos, const SFVEC3F& ddiff, const SFVEC3F& cnorm,
|
|
|
|
const float aShadowAtSamplePos, const float aShadowAtCenterPos,
|
|
|
|
int c1, int c2 ) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2020-12-13 23:02:57 +00:00
|
|
|
float giFF( const SFVEC2I& aShaderPos, const SFVEC3F& ddiff, const SFVEC3F& cnorm,
|
|
|
|
const float aShadow, int c1, int c2 ) const;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
|
|
|
/**
|
2020-12-13 23:02:57 +00:00
|
|
|
* Apply a curve transformation to the original color.
|
|
|
|
*
|
|
|
|
* It will attenuate the bright colors (works as a gamma function):
|
2016-07-19 17:35:25 +00:00
|
|
|
* http://fooplot.com/#W3sidHlwZSI6MCwiZXEiOiIxLjAtKDEvKHgqMS4wKzEuMCkpK3gqMC4zMCIsImNvbG9yIjoiIzAwMDAwMCJ9LHsidHlwZSI6MTAwMCwid2luZG93IjpbIi0wLjA2MjE4NDYxNTM4NDYxNTUwNSIsIjEuMTQyOTg0NjE1Mzg0NjE0NiIsIi0wLjEyNzA5OTk5OTk5OTk5OTc3IiwiMS4xMzI2Il19XQ--
|
2020-12-13 23:02:57 +00:00
|
|
|
*
|
|
|
|
* @param aColor input color.
|
|
|
|
* @return transformed color.
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
|
|
|
SFVEC3F giColorCurve( const SFVEC3F &aColor ) const;
|
2020-07-14 16:40:28 +00:00
|
|
|
|
|
|
|
SFVEC3F* m_shadedBuffer;
|
|
|
|
|
|
|
|
bool m_isUsingShadows;
|
2016-07-19 17:35:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CPOSTSHADER_SSAO_H
|