Implemented full-screen fade post-fx

This commit is contained in:
2014-06-25 00:45:00 -07:00
parent 2e169eeb9a
commit 77dac3cb2f
27 changed files with 124 additions and 82 deletions

View File

@@ -1149,15 +1149,11 @@
E491016613C99B9E0098455B /* kraken */ = {
isa = PBXGroup;
children = (
E43F70E31824D9AB00136169 /* KRStreamer.mm */,
E43F70E41824D9AB00136169 /* KRStreamer.h */,
E488399915F92BA300BD66D5 /* Managers */,
E461A173152E59DF00F2044A /* Math */,
E461A170152E598200F2044A /* Resources */,
E4924C2415EE95E700B965C6 /* KROctree.cpp */,
E4924C2515EE95E800B965C6 /* KROctree.h */,
E4924C2915EE96AA00B965C6 /* KROctreeNode.cpp */,
E4924C2A15EE96AA00B965C6 /* KROctreeNode.h */,
E45134B41746A4A300443C21 /* KRBehavior.cpp */,
E45134B51746A4A300443C21 /* KRBehavior.h */,
E48C697115374F7E00232E28 /* KRContext.cpp */,
E48C696E15374F5A00232E28 /* KRContext.h */,
E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */,
@@ -1167,15 +1163,19 @@
E46DBE841512B9E200D59F86 /* KREngine-common.h */,
E491017213C99BDC0098455B /* KREngine.h */,
E491016F13C99BDC0098455B /* KREngine.mm */,
E4030E4B160A3CF000592648 /* KRStockGeometry.h */,
E4CA11731639CBD1005D9400 /* KRViewport.h */,
E4CA11771639CC8E005D9400 /* KRViewport.cpp */,
E4C454B7167BD235003586CD /* KRHitInfo.h */,
E4C454BA167BD248003586CD /* KRHitInfo.cpp */,
E44F38231683B22C00399B5D /* KRRenderSettings.h */,
E4C454B7167BD235003586CD /* KRHitInfo.h */,
E4924C2415EE95E700B965C6 /* KROctree.cpp */,
E4924C2515EE95E800B965C6 /* KROctree.h */,
E4924C2915EE96AA00B965C6 /* KROctreeNode.cpp */,
E4924C2A15EE96AA00B965C6 /* KROctreeNode.h */,
E44F38271683B24400399B5D /* KRRenderSettings.cpp */,
E45134B41746A4A300443C21 /* KRBehavior.cpp */,
E45134B51746A4A300443C21 /* KRBehavior.h */,
E44F38231683B22C00399B5D /* KRRenderSettings.h */,
E4030E4B160A3CF000592648 /* KRStockGeometry.h */,
E43F70E41824D9AB00136169 /* KRStreamer.h */,
E43F70E31824D9AB00136169 /* KRStreamer.mm */,
E4CA11771639CC8E005D9400 /* KRViewport.cpp */,
E4CA11731639CBD1005D9400 /* KRViewport.h */,
);
path = kraken;
sourceTree = "<group>";

View File

@@ -98,8 +98,7 @@ void KRAmbientZone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRVector3 rim_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
// Enable additive blending
GLDEBUG(glEnable(GL_BLEND));

View File

@@ -211,8 +211,7 @@ void KRAudioSource::render(KRCamera *pCamera, std::vector<KRPointLight *> &point
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRVector3 rim_light;
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_light, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
// Enable additive blending
GLDEBUG(glEnable(GL_BLEND));

View File

@@ -63,8 +63,7 @@ void KRBone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRVector3 rim_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
std::vector<KRMesh *> sphereModels = getContext().getMeshManager()->getModel("__sphere");
if(sphereModels.size()) {
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {

View File

@@ -55,6 +55,8 @@ KRCamera::KRCamera(KRScene &scene, std::string name) : KRNode(scene, name) {
volumetricLightAccumulationTexture = 0;
m_frame_times_filled = 0;
m_downsample = KRVector2::One();
m_fade_color = KRVector4::Zero();
}
KRCamera::~KRCamera() {
@@ -304,8 +306,7 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
}
if(m_pSkyBoxTexture) {
KRVector3 rim_color;
getContext().getShaderManager()->selectShader("sky_box", *this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, m_viewport, KRMat4(), false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_OPAQUE, rim_color, 0.0f);
getContext().getShaderManager()->selectShader("sky_box", *this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, m_viewport, KRMat4(), false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_OPAQUE, KRVector3::Zero(), 0.0f, KRVector4::Zero());
getContext().getTextureManager()->selectTexture(0, m_pSkyBoxTexture, 0.0f, KRTexture::TEXTURE_USAGE_SKY_CUBE);
@@ -473,8 +474,7 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
KRMat4 matModel = KRMat4();
matModel.scale((*itr).first.size() * 0.5f);
matModel.translate((*itr).first.center());
KRVector3 rim_color;
if(getContext().getShaderManager()->selectShader(*this, pVisShader, m_viewport, matModel, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, rim_color, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*this, pVisShader, m_viewport, matModel, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
}
}
@@ -685,7 +685,7 @@ void KRCamera::renderPost()
KRShader *postShader = m_pContext->getShaderManager()->getShader("PostShader", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
KRVector3 rim_color;
getContext().getShaderManager()->selectShader(*this, postShader, m_viewport, KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, rim_color, 0.0f);
getContext().getShaderManager()->selectShader(*this, postShader, m_viewport, KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, rim_color, 0.0f, m_fade_color);
m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 0, compositeDepthTexture);
m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 1, compositeColorTexture);
@@ -869,8 +869,7 @@ void KRCamera::renderPost()
GLDEBUG(glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
KRShader *fontShader = m_pContext->getShaderManager()->getShader("debug_font", this, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
KRVector3 rim_color;
getContext().getShaderManager()->selectShader(*this, fontShader, m_viewport, KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, rim_color, 0.0f);
getContext().getShaderManager()->selectShader(*this, fontShader, m_viewport, KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, KRVector3::Zero(), 0.0f, KRVector4::Zero());
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"), 0.0f, KRTexture::TEXTURE_USAGE_UI);
@@ -1096,3 +1095,13 @@ void KRCamera::setDownsample(float v)
{
m_downsample = v;
}
void KRCamera::setFadeColor(const KRVector4 &fade_color)
{
m_fade_color = fade_color;
}
KRVector4 KRCamera::getFadeColor()
{
return m_fade_color;
}

View File

@@ -71,6 +71,9 @@ public:
void flushSkybox(); // this will delete the skybox and cause the camera to reload a new skybox based on the settings
KRVector2 getDownsample();
void setDownsample(float v);
void setFadeColor(const KRVector4 &fade_color);
KRVector4 getFadeColor();
private:
void createBuffers(GLint renderBufferWidth, GLint renderBufferHeight);
@@ -95,6 +98,8 @@ private:
KRVector2 m_downsample;
KRVector4 m_fade_color;
typedef struct {
GLfloat x;
GLfloat y;

View File

@@ -199,8 +199,7 @@ void KRCollider::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_li
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRVector3 rim_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
// Enable additive blending
GLDEBUG(glEnable(GL_BLEND));

View File

@@ -33,6 +33,7 @@ KRContext::KRContext() : m_streamer(*this)
m_bDetectedExtensions = false;
m_current_frame = 0;
m_last_memory_warning_frame = 0;
m_last_fully_streamed_frame = 0;
m_absolute_time = 0.0f;
m_pBundleManager = new KRBundleManager(*this);
@@ -285,6 +286,11 @@ long KRContext::getCurrentFrame() const
return m_current_frame;
}
long KRContext::getLastFullyStreamedFrame() const
{
return m_last_fully_streamed_frame;
}
float KRContext::getAbsoluteTime() const
{
return m_absolute_time;
@@ -372,12 +378,18 @@ void KRContext::doStreaming()
*/
long streaming_start_frame = m_current_frame;
long memoryRemaining = KRENGINE_GPU_MEM_TARGET;
long memoryRemainingThisFrame = KRENGINE_GPU_MEM_MAX - m_pTextureManager->getMemUsed() - m_pMeshManager->getMemUsed();
long memoryRemainingThisFrameStart = memoryRemainingThisFrame;
m_pMeshManager->doStreaming(memoryRemaining, memoryRemainingThisFrame);
m_pTextureManager->doStreaming(memoryRemaining, memoryRemainingThisFrame);
if(memoryRemainingThisFrame != memoryRemainingThisFrame && memoryRemainingThisFrame > 0) {
m_last_fully_streamed_frame = streaming_start_frame;
}
}
}
@@ -385,3 +397,5 @@ void KRContext::receivedMemoryWarning()
{
m_last_memory_warning_frame = m_current_frame;
}

View File

@@ -63,6 +63,7 @@ public:
void endFrame(float deltaTime);
long getCurrentFrame() const;
long getLastFullyStreamedFrame() const;
float getAbsoluteTime() const;
long getAbsoluteTimeMilliseconds();
@@ -102,8 +103,9 @@ private:
void detectExtensions();
bool m_bDetectedExtensions;
long m_current_frame;
long m_last_memory_warning_frame;
long m_current_frame; // TODO - Does this need to be atomic?
long m_last_memory_warning_frame; // TODO - Does this need to be atomic?
long m_last_fully_streamed_frame; // TODO - Does this need to be atomic?
float m_absolute_time;
mach_timebase_info_data_t m_timebase_info;

View File

@@ -107,10 +107,8 @@ void KRDirectionalLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &
light_direction_view_space = KRMat4::Dot(matModelViewInverseTranspose, light_direction_view_space);
light_direction_view_space.normalize();
KRVector3 rim_color;
KRShader *pShader = getContext().getShaderManager()->getShader("light_directional", pCamera, std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, renderPass, rim_color, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), std::vector<KRPointLight *>(), this_light, std::vector<KRSpotLight *>(), 0, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_DIRECTION_VIEW_SPACE, light_direction_view_space);
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);

View File

@@ -222,8 +222,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, this_point_light, this_directional_light, this_spot_light, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRVector3 rim_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, particleModelMatrix, this_point_light, this_directional_light, this_spot_light, 0, renderPass, rim_color, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, particleModelMatrix, this_point_light, this_directional_light, this_spot_light, 0, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color * pCamera->settings.dust_particle_intensity * m_dust_particle_intensity * m_intensity);
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_PARTICLE_ORIGIN, KRMat4::DotWDiv(KRMat4::Invert(particleModelMatrix), KRVector3::Zero()));
@@ -259,8 +258,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
KRShader *pFogShader = m_pContext->getShaderManager()->getShader(shader_name, pCamera, this_point_light, this_directional_light, this_spot_light, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_ADDITIVE_PARTICLES);
KRVector3 rim_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pFogShader, viewport, KRMat4(), this_point_light, this_directional_light, this_spot_light, 0, KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE, rim_color, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*pCamera, pFogShader, viewport, KRMat4(), this_point_light, this_directional_light, this_spot_light, 0, KRNode::RENDER_PASS_VOLUMETRIC_EFFECTS_ADDITIVE, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
int slice_count = (int)(pCamera->settings.volumetric_environment_quality * 495.0) + 5;
float slice_near = -pCamera->settings.getPerspectiveNearZ();
@@ -288,8 +286,7 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
occlusion_test_sphere_matrix *= m_parentNode->getModelMatrix();
}
KRVector3 rim_color;
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, occlusion_test_sphere_matrix, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass, rim_color, 0.0f)) {
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, occlusion_test_sphere_matrix, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
#if TARGET_OS_IPHONE
@@ -336,8 +333,8 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
// Render light flare on transparency pass
KRShader *pShader = getContext().getShaderManager()->getShader("flare", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRVector3 rim_light;
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_light, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, 1.0f);
pShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_flareSize);
m_pContext->getTextureManager()->selectTexture(0, m_pFlareTexture, 0.0f, KRTexture::TEXTURE_USAGE_LIGHT_FLARE);
@@ -454,8 +451,7 @@ void KRLight::renderShadowBuffers(KRCamera *pCamera)
// Use shader program
KRShader *shadowShader = m_pContext->getShaderManager()->getShader("ShadowShader", pCamera, std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT);
KRVector3 rim_light;
getContext().getShaderManager()->selectShader(*pCamera, shadowShader, m_shadowViewports[iShadow], KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_SHADOWMAP, rim_light, 0.0f);
getContext().getShaderManager()->selectShader(*pCamera, shadowShader, m_shadowViewports[iShadow], KRMat4(), std::vector<KRPointLight *>(), std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, KRNode::RENDER_PASS_SHADOWMAP, KRVector3::Zero(), 0.0f, KRVector4::Zero());
getScene().render(pCamera, m_shadowViewports[iShadow].getVisibleBounds(), m_shadowViewports[iShadow], KRNode::RENDER_PASS_SHADOWMAP, true);

View File

@@ -321,7 +321,9 @@ bool KRMaterial::bind(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
KRShader *pShader = getContext().getShaderManager()->getShader("ObjectShader", pCamera, point_lights, directional_lights, spot_lights, bones.size(), bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, m_diffuseMapScale != default_scale && bDiffuseMap, m_specularMapScale != default_scale && bSpecMap, m_normalMapScale != default_scale && bNormalMap, m_reflectionMapScale != default_scale && bReflectionMap, m_diffuseMapOffset != default_offset && bDiffuseMap, m_specularMapOffset != default_offset && bSpecMap, m_normalMapOffset != default_offset && bNormalMap, m_reflectionMapOffset != default_offset && bReflectionMap, bAlphaTest, bAlphaBlend, renderPass, rim_power != 0.0f);
if(!getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, matModel, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, rim_power)) {
KRVector4 fade_color;
if(!getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, matModel, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, rim_power, fade_color)) {
return false;
}

View File

@@ -75,8 +75,8 @@ void KRParticleSystemNewtonian::render(KRCamera *pCamera, std::vector<KRPointLig
KRShader *pParticleShader = m_pContext->getShaderManager()->getShader("dust_particle", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRVector3 rim_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
KRVector3 rim_color; KRVector4 fade_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, 1.0f);
KRDataBlock index_data;

View File

@@ -70,8 +70,7 @@ void KRPointLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_
bool bInsideLight = view_light_position.sqrMagnitude() <= (influence_radius + pCamera->settings.getPerspectiveNearZ()) * (influence_radius + pCamera->settings.getPerspectiveNearZ());
KRShader *pShader = getContext().getShaderManager()->getShader(bVisualize ? "visualize_overlay" : (bInsideLight ? "light_point_inside" : "light_point"), pCamera, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRVector3 rim_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, renderPass, rim_color, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);

View File

@@ -97,8 +97,7 @@ void KRReverbZone::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_
KRShader *pShader = getContext().getShaderManager()->getShader("visualize_overlay", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRVector3 rim_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
// Enable additive blending
GLDEBUG(glEnable(GL_BLEND));

View File

@@ -306,7 +306,7 @@ void KRScene::render(KROctreeNode *pOctreeNode, unordered_map<KRAABB, int> &visi
GLDEBUG(glDepthMask(GL_FALSE));
}
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, matModel, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, KRVector3::Zero(), 0.0f)) {
if(getContext().getShaderManager()->selectShader("occlusion_test", *pCamera, point_lights, directional_lights, spot_lights, 0, viewport, matModel, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, KRNode::RENDER_PASS_FORWARD_TRANSPARENT, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
m_pContext->getMeshManager()->log_draw_call(renderPass, "octree", "occlusion_test", 14);
}

View File

@@ -104,7 +104,8 @@ const char *KRShader::KRENGINE_UNIFORM_NAMES[] = {
"particle_origin", // KRENGINE_UNIFORM_PARTICLE_ORIGIN
"bone_transforms", // KRENGINE_UNIFORM_BONE_TRANSFORMS
"rim_color", // KRENGINE_UNIFORM_RIM_COLOR
"rim_power" // KRENGINE_UNIFORM_RIM_POWER
"rim_power", // KRENGINE_UNIFORM_RIM_POWER
"fade_color", // KRENGINE_UNIFORM_FADE_COLOR
};
KRShader::KRShader(KRContext &context, char *szKey, std::string options, std::string vertShaderSource, const std::string fragShaderSource) : KRContextObject(context)
@@ -346,7 +347,7 @@ void KRShader::setUniform(int location, const KRMat4 &value)
}
}
bool KRShader::bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power) {
bool KRShader::bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power, const KRVector4 &fade_color) {
if(m_iProgram == 0) {
return false;
}
@@ -515,6 +516,9 @@ bool KRShader::bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &
setUniform(KRENGINE_UNIFORM_RIM_COLOR, rim_color);
setUniform(KRENGINE_UNIFORM_RIM_POWER, rim_power);
// Fade parameters
setUniform(KRENGINE_UNIFORM_FADE_COLOR, fade_color);
// Fog parameters
setUniform(KRENGINE_UNIFORM_FOG_NEAR, camera.settings.fog_near);
setUniform(KRENGINE_UNIFORM_FOG_FAR, camera.settings.fog_far);

View File

@@ -47,7 +47,7 @@ public:
virtual ~KRShader();
const char *getKey() const;
bool bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power);
bool bind(KRCamera &camera, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power, const KRVector4 &fade_color);
enum {
KRENGINE_UNIFORM_MATERIAL_AMBIENT = 0,
@@ -117,6 +117,7 @@ public:
KRENGINE_UNIFORM_BONE_TRANSFORMS,
KRENGINE_UNIFORM_RIM_COLOR,
KRENGINE_UNIFORM_RIM_POWER,
KRENGINE_UNIFORM_FADE_COLOR,
KRENGINE_NUM_UNIFORMS
};
/*

View File

@@ -70,6 +70,8 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
iShadowQuality = pCamera->settings.m_cShadowBuffers;
}
bool bFadeColorEnabled = pCamera->getFadeColor().w >= 0.0f;
std::pair<std::string, std::vector<int> > key;
key.first = shader_name;
key.second.push_back(light_directional_count);
@@ -115,6 +117,7 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
key.second.push_back(pCamera->settings.vignette_radius * 1000.0f);
key.second.push_back(pCamera->settings.vignette_falloff * 1000.0f);
key.second.push_back(bRimColor);
key.second.push_back(bFadeColorEnabled);
KRShader *pShader = m_shaders[key];
@@ -182,6 +185,7 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
stream << "\n#define ENABLE_DIFFUSE " << (pCamera->settings.bEnableDiffuse ? "1" : "0");
stream << "\n#define ENABLE_SPECULAR " << (pCamera->settings.bEnableSpecular ? "1" : "0");
stream << "\n#define ENABLE_RIM_COLOR " << (bRimColor ? "1" : "0");
stream << "\n#define ENABLE_FADE_COLOR " << (bFadeColorEnabled ? "1" : "0");
stream << "\n#define FOG_TYPE " << pCamera->settings.fog_type;
switch(renderPass) {
case KRNode::RENDER_PASS_DEFERRED_GBUFFER:
@@ -202,7 +206,6 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
stream << "\n#define ENABLE_FLASH " << (pCamera->settings.bEnableFlash ? "1" : "0");
stream << "\n#define ENABLE_VIGNETTE " << (pCamera->settings.bEnableVignette ? "1" : "0");
stream << "\n#define VOLUMETRIC_ENVIRONMENT_DOWNSAMPLED " << (pCamera->settings.volumetric_environment_enable && pCamera->settings.volumetric_environment_downsample != 0 ? "1" : "0");
stream.setf(ios::fixed,ios::floatfield);
@@ -230,8 +233,10 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
KRContext::Log(KRContext::LOG_LEVEL_ERROR, "Fragment Shader Missing: %s", platform_shader_name.c_str());
}
KRVector4 fade_color = pCamera->getFadeColor();
char szKey[256];
sprintf(szKey, "%i_%i_%i_%i_%i_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%i_%s_%i_%d_%d_%f_%f_%f_%f_%f_%f_%f", light_directional_count, light_point_count, light_spot_count, bone_count, pCamera->settings.fog_type, pCamera->settings.bEnablePerPixel,bAlphaTest, bAlphaBlend, bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, pCamera->settings.bDebugPSSM, iShadowQuality, pCamera->settings.bEnableAmbient, pCamera->settings.bEnableDiffuse, pCamera->settings.bEnableSpecular, bLightMap, bDiffuseMapScale, bSpecMapScale, bReflectionMapScale, bNormalMapScale, bDiffuseMapOffset, bSpecMapOffset, bReflectionMapOffset, bNormalMapOffset,pCamera->settings.volumetric_environment_enable && pCamera->settings.volumetric_environment_downsample != 0, renderPass, shader_name.c_str(),pCamera->settings.dof_quality,pCamera->settings.bEnableFlash,pCamera->settings.bEnableVignette,pCamera->settings.dof_depth,pCamera->settings.dof_falloff,pCamera->settings.flash_depth,pCamera->settings.flash_falloff,pCamera->settings.flash_intensity,pCamera->settings.vignette_radius,pCamera->settings.vignette_falloff);
sprintf(szKey, "%i_%i_%i_%i_%i_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%d_%i_%s_%i_%d_%d_%f_%f_%f_%f_%f_%f_%f_%f_%f_%f_%f", light_directional_count, light_point_count, light_spot_count, bone_count, pCamera->settings.fog_type, pCamera->settings.bEnablePerPixel,bAlphaTest, bAlphaBlend, bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, pCamera->settings.bDebugPSSM, iShadowQuality, pCamera->settings.bEnableAmbient, pCamera->settings.bEnableDiffuse, pCamera->settings.bEnableSpecular, bLightMap, bDiffuseMapScale, bSpecMapScale, bReflectionMapScale, bNormalMapScale, bDiffuseMapOffset, bSpecMapOffset, bReflectionMapOffset, bNormalMapOffset,pCamera->settings.volumetric_environment_enable && pCamera->settings.volumetric_environment_downsample != 0, renderPass, shader_name.c_str(),pCamera->settings.dof_quality,pCamera->settings.bEnableFlash,pCamera->settings.bEnableVignette,pCamera->settings.dof_depth,pCamera->settings.dof_falloff,pCamera->settings.flash_depth,pCamera->settings.flash_falloff,pCamera->settings.flash_intensity,pCamera->settings.vignette_radius,pCamera->settings.vignette_falloff, fade_color.x, fade_color.y, fade_color.z, fade_color.w);
pShader = new KRShader(getContext(), szKey, options, vertShaderSource, fragShaderSource);
@@ -240,16 +245,16 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
return pShader;
}
bool KRShaderManager::selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const KRVector3 &rim_color, float rim_power)
bool KRShaderManager::selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const KRVector3 &rim_color, float rim_power, const KRVector4 &fade_color)
{
KRShader *pShader = getShader(shader_name, &camera, point_lights, directional_lights, spot_lights, bone_count, bDiffuseMap, bNormalMap, bSpecMap, bReflectionMap, bReflectionCubeMap, bLightMap, bDiffuseMapScale, bSpecMapScale, bNormalMapScale, bReflectionMapScale, bDiffuseMapOffset, bSpecMapOffset, bNormalMapOffset, bReflectionMapOffset, bAlphaTest, bAlphaBlend, renderPass, rim_power != 0.0f);
return selectShader(camera, pShader, viewport, matModel, point_lights, directional_lights, spot_lights, bone_count, renderPass, rim_color, rim_power);
return selectShader(camera, pShader, viewport, matModel, point_lights, directional_lights, spot_lights, bone_count, renderPass, rim_color, rim_power, fade_color);
}
bool KRShaderManager::selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power)
bool KRShaderManager::selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power, const KRVector4 &fade_color)
{
if(pShader) {
return pShader->bind(camera, viewport, matModel, point_lights, directional_lights, spot_lights, renderPass, rim_color, rim_power);
return pShader->bind(camera, viewport, matModel, point_lights, directional_lights, spot_lights, renderPass, rim_color, rim_power, fade_color);
} else {
return false;
}

View File

@@ -60,9 +60,9 @@ public:
KRShader *getShader(const std::string &shader_name, KRCamera *pCamera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, bool bRimColor = false);
bool selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power);
bool selectShader(KRCamera &camera, KRShader *pShader, const KRViewport &viewport, const KRMat4 &matModel, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRNode::RenderPass &renderPass, const KRVector3 &rim_color, float rim_power, const KRVector4 &fade_color);
bool selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const KRVector3 &rim_color, float rim_power);
bool selectShader(const std::string &shader_name, KRCamera &camera, const std::vector<KRPointLight *> &point_lights, const std::vector<KRDirectionalLight *> &directional_lights, const std::vector<KRSpotLight *>&spot_lights, int bone_count, const KRViewport &viewport, const KRMat4 &matModel, bool bDiffuseMap, bool bNormalMap, bool bSpecMap, bool bReflectionMap, bool bReflectionCubeMap, bool bLightMap, bool bDiffuseMapScale,bool bSpecMapScale, bool bNormalMapScale, bool bReflectionMapScale, bool bDiffuseMapOffset, bool bSpecMapOffset, bool bNormalMapOffset, bool bReflectionMapOffset, bool bAlphaTest, bool bAlphaBlend, KRNode::RenderPass renderPass, const KRVector3 &rim_color, float rim_power, const KRVector4 &fade_color);
long getShaderHandlesUsed();

View File

@@ -130,8 +130,7 @@ void KRSprite::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
// Render light sprite on transparency pass
KRShader *pShader = getContext().getShaderManager()->getShader("sprite", pCamera, point_lights, directional_lights, spot_lights, 0, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, renderPass);
KRVector3 rim_color;
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, m_spriteAlpha);
m_pContext->getTextureManager()->selectTexture(0, m_pSpriteTexture, 0.0f, KRTexture::TEXTURE_USAGE_SPRITE);
m_pContext->getMeshManager()->bindVBO(&m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES, 1.0f);

View File

@@ -33,6 +33,8 @@
#include "KRVector3.h"
#include "tinyxml2.h"
const KRVector3 KRVECTOR3_ZERO(0.0f, 0.0f, 0.0f);
//default constructor
KRVector3::KRVector3()
{
@@ -154,8 +156,8 @@ KRVector3 KRVector3::Max() {
return KRVector3(std::numeric_limits<float>::max());
}
KRVector3 KRVector3::Zero() {
return KRVector3(0.0f, 0.0f, 0.0f);
const KRVector3 &KRVector3::Zero() {
return KRVECTOR3_ZERO;
}
KRVector3 KRVector3::One() {

View File

@@ -111,7 +111,7 @@ public:
static float Dot(const KRVector3 &v1, const KRVector3 &v2);
static KRVector3 Min();
static KRVector3 Max();
static KRVector3 Zero();
static const KRVector3 &Zero();
static KRVector3 One();
static KRVector3 Forward();
static KRVector3 Backward();

View File

@@ -32,6 +32,8 @@
#include "KREngine-common.h"
#include "KRVector4.h"
const KRVector4 KRVECTOR4_ZERO(0.0f, 0.0f, 0.0f, 0.0f);
//default constructor
KRVector4::KRVector4()
{
@@ -70,8 +72,8 @@ KRVector4 KRVector4::Max() {
return KRVector4(std::numeric_limits<float>::max());
}
KRVector4 KRVector4::Zero() {
return KRVector4(0.0f, 0.0f, 0.0f, 0.0f);
const KRVector4 &KRVector4::Zero() {
return KRVECTOR4_ZERO;
}
KRVector4 KRVector4::One() {

View File

@@ -88,7 +88,7 @@ public:
static float Dot(const KRVector4 &v1, const KRVector4 &v2);
static KRVector4 Min();
static KRVector4 Max();
static KRVector4 Zero();
static const KRVector4 &Zero();
static KRVector4 One();
static KRVector4 Forward();
static KRVector4 Backward();

View File

@@ -34,10 +34,14 @@
varying mediump vec2 textureCoordinate;
precision lowp float;
#if ENABLE_VIDEO_BG == 0
#if ENABLE_VIDEO_BG == 1
uniform lowp sampler2D videoFrame;
#endif
#if ENABLE_FADE_COLOR == 1
uniform lowp vec4 fade_color;
#endif
uniform lowp sampler2D renderFrame;
uniform lowp sampler2D depthFrame;
@@ -171,11 +175,15 @@ void main()
// Render vignette effect
#if ENABLE_VIGNETTE
#if ENABLE_VIGNETTE == 1
pixelColor *= vec4(vec3(clamp(1.0 - (distance(textureCoordinate, vec2(0.5, 0.5)) - VIGNETTE_RADIUS) / VIGNETTE_FALLOFF, 0.0, 1.0)), 1.0);
#endif
// ---- VIGNETTE END ----
#if ENABLE_FADE_COLOR == 1
pixelColor.rgb = mix(pixelColor.rgb, fade_color.rgb, fade_color.a);
#endif
gl_FragColor = pixelColor;

View File

@@ -25,13 +25,6 @@
// or implied, of Kearwood Gilbert.
//
/*
void main()
{
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
}
*/
#define ENABLE_VIDEO_BG 0
#define PIXEL_SHIFT_1 0.001
#define PIXEL_SHIFT_2 0.002
@@ -41,10 +34,14 @@ void main()
varying mediump vec2 textureCoordinate;
//precision lowp float;
#if ENABLE_VIDEO_BG == 0
#if ENABLE_VIDEO_BG == 1
uniform lowp sampler2D videoFrame;
#endif
#if ENABLE_FADE_COLOR == 1
uniform lowp vec4 fade_color;
#endif
uniform lowp sampler2D renderFrame;
uniform lowp sampler2D depthFrame;
@@ -171,11 +168,15 @@ void main()
// Render vignette effect
#if ENABLE_VIGNETTE
#if ENABLE_VIGNETTE == 1
pixelColor *= vec4(vec3(clamp(1.0 - (distance(textureCoordinate, vec2(0.5, 0.5)) - VIGNETTE_RADIUS) / VIGNETTE_FALLOFF, 0.0, 1.0)), 1.0);
#endif
// ---- VIGNETTE END ----
#if ENABLE_FADE_COLOR == 1
pixelColor.rgb = mix(pixelColor.rgb, fade_color.rgb, fade_color.a);
#endif
gl_FragColor = pixelColor;