Implemented full-screen fade post-fx
This commit is contained in:
@@ -1149,15 +1149,11 @@
|
|||||||
E491016613C99B9E0098455B /* kraken */ = {
|
E491016613C99B9E0098455B /* kraken */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
E43F70E31824D9AB00136169 /* KRStreamer.mm */,
|
|
||||||
E43F70E41824D9AB00136169 /* KRStreamer.h */,
|
|
||||||
E488399915F92BA300BD66D5 /* Managers */,
|
E488399915F92BA300BD66D5 /* Managers */,
|
||||||
E461A173152E59DF00F2044A /* Math */,
|
E461A173152E59DF00F2044A /* Math */,
|
||||||
E461A170152E598200F2044A /* Resources */,
|
E461A170152E598200F2044A /* Resources */,
|
||||||
E4924C2415EE95E700B965C6 /* KROctree.cpp */,
|
E45134B41746A4A300443C21 /* KRBehavior.cpp */,
|
||||||
E4924C2515EE95E800B965C6 /* KROctree.h */,
|
E45134B51746A4A300443C21 /* KRBehavior.h */,
|
||||||
E4924C2915EE96AA00B965C6 /* KROctreeNode.cpp */,
|
|
||||||
E4924C2A15EE96AA00B965C6 /* KROctreeNode.h */,
|
|
||||||
E48C697115374F7E00232E28 /* KRContext.cpp */,
|
E48C697115374F7E00232E28 /* KRContext.cpp */,
|
||||||
E48C696E15374F5A00232E28 /* KRContext.h */,
|
E48C696E15374F5A00232E28 /* KRContext.h */,
|
||||||
E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */,
|
E43B0AD415DDCA0C00A5CB9F /* KRContextObject.cpp */,
|
||||||
@@ -1167,15 +1163,19 @@
|
|||||||
E46DBE841512B9E200D59F86 /* KREngine-common.h */,
|
E46DBE841512B9E200D59F86 /* KREngine-common.h */,
|
||||||
E491017213C99BDC0098455B /* KREngine.h */,
|
E491017213C99BDC0098455B /* KREngine.h */,
|
||||||
E491016F13C99BDC0098455B /* KREngine.mm */,
|
E491016F13C99BDC0098455B /* KREngine.mm */,
|
||||||
E4030E4B160A3CF000592648 /* KRStockGeometry.h */,
|
|
||||||
E4CA11731639CBD1005D9400 /* KRViewport.h */,
|
|
||||||
E4CA11771639CC8E005D9400 /* KRViewport.cpp */,
|
|
||||||
E4C454B7167BD235003586CD /* KRHitInfo.h */,
|
|
||||||
E4C454BA167BD248003586CD /* KRHitInfo.cpp */,
|
E4C454BA167BD248003586CD /* KRHitInfo.cpp */,
|
||||||
E44F38231683B22C00399B5D /* KRRenderSettings.h */,
|
E4C454B7167BD235003586CD /* KRHitInfo.h */,
|
||||||
|
E4924C2415EE95E700B965C6 /* KROctree.cpp */,
|
||||||
|
E4924C2515EE95E800B965C6 /* KROctree.h */,
|
||||||
|
E4924C2915EE96AA00B965C6 /* KROctreeNode.cpp */,
|
||||||
|
E4924C2A15EE96AA00B965C6 /* KROctreeNode.h */,
|
||||||
E44F38271683B24400399B5D /* KRRenderSettings.cpp */,
|
E44F38271683B24400399B5D /* KRRenderSettings.cpp */,
|
||||||
E45134B41746A4A300443C21 /* KRBehavior.cpp */,
|
E44F38231683B22C00399B5D /* KRRenderSettings.h */,
|
||||||
E45134B51746A4A300443C21 /* KRBehavior.h */,
|
E4030E4B160A3CF000592648 /* KRStockGeometry.h */,
|
||||||
|
E43F70E41824D9AB00136169 /* KRStreamer.h */,
|
||||||
|
E43F70E31824D9AB00136169 /* KRStreamer.mm */,
|
||||||
|
E4CA11771639CC8E005D9400 /* KRViewport.cpp */,
|
||||||
|
E4CA11731639CBD1005D9400 /* KRViewport.h */,
|
||||||
);
|
);
|
||||||
path = kraken;
|
path = kraken;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
|||||||
@@ -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);
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
|
||||||
|
|
||||||
// Enable additive blending
|
// Enable additive blending
|
||||||
GLDEBUG(glEnable(GL_BLEND));
|
GLDEBUG(glEnable(GL_BLEND));
|
||||||
|
|||||||
@@ -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);
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_light, 0.0f)) {
|
|
||||||
|
|
||||||
// Enable additive blending
|
// Enable additive blending
|
||||||
GLDEBUG(glEnable(GL_BLEND));
|
GLDEBUG(glEnable(GL_BLEND));
|
||||||
|
|||||||
@@ -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);
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
|
||||||
std::vector<KRMesh *> sphereModels = getContext().getMeshManager()->getModel("__sphere");
|
std::vector<KRMesh *> sphereModels = getContext().getMeshManager()->getModel("__sphere");
|
||||||
if(sphereModels.size()) {
|
if(sphereModels.size()) {
|
||||||
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {
|
for(int i=0; i < sphereModels[0]->getSubmeshCount(); i++) {
|
||||||
|
|||||||
@@ -55,6 +55,8 @@ KRCamera::KRCamera(KRScene &scene, std::string name) : KRNode(scene, name) {
|
|||||||
volumetricLightAccumulationTexture = 0;
|
volumetricLightAccumulationTexture = 0;
|
||||||
m_frame_times_filled = 0;
|
m_frame_times_filled = 0;
|
||||||
m_downsample = KRVector2::One();
|
m_downsample = KRVector2::One();
|
||||||
|
|
||||||
|
m_fade_color = KRVector4::Zero();
|
||||||
}
|
}
|
||||||
|
|
||||||
KRCamera::~KRCamera() {
|
KRCamera::~KRCamera() {
|
||||||
@@ -304,8 +306,7 @@ void KRCamera::renderFrame(float deltaTime, GLint renderBufferWidth, GLint rende
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(m_pSkyBoxTexture) {
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero());
|
||||||
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().getTextureManager()->selectTexture(0, m_pSkyBoxTexture, 0.0f, KRTexture::TEXTURE_USAGE_SKY_CUBE);
|
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();
|
KRMat4 matModel = KRMat4();
|
||||||
matModel.scale((*itr).first.size() * 0.5f);
|
matModel.scale((*itr).first.size() * 0.5f);
|
||||||
matModel.translate((*itr).first.center());
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
|
||||||
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)) {
|
|
||||||
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
|
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);
|
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;
|
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, 0, compositeDepthTexture);
|
||||||
m_pContext->getTextureManager()->selectTexture(GL_TEXTURE_2D, 1, compositeColorTexture);
|
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));
|
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);
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero());
|
||||||
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);
|
|
||||||
|
|
||||||
m_pContext->getTextureManager()->selectTexture(0, m_pContext->getTextureManager()->getTexture("font"), 0.0f, KRTexture::TEXTURE_USAGE_UI);
|
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;
|
m_downsample = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRCamera::setFadeColor(const KRVector4 &fade_color)
|
||||||
|
{
|
||||||
|
m_fade_color = fade_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
KRVector4 KRCamera::getFadeColor()
|
||||||
|
{
|
||||||
|
return m_fade_color;
|
||||||
|
}
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ public:
|
|||||||
KRVector2 getDownsample();
|
KRVector2 getDownsample();
|
||||||
void setDownsample(float v);
|
void setDownsample(float v);
|
||||||
|
|
||||||
|
void setFadeColor(const KRVector4 &fade_color);
|
||||||
|
KRVector4 getFadeColor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createBuffers(GLint renderBufferWidth, GLint renderBufferHeight);
|
void createBuffers(GLint renderBufferWidth, GLint renderBufferHeight);
|
||||||
|
|
||||||
@@ -95,6 +98,8 @@ private:
|
|||||||
|
|
||||||
KRVector2 m_downsample;
|
KRVector2 m_downsample;
|
||||||
|
|
||||||
|
KRVector4 m_fade_color;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GLfloat x;
|
GLfloat x;
|
||||||
GLfloat y;
|
GLfloat y;
|
||||||
|
|||||||
@@ -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);
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
|
||||||
|
|
||||||
// Enable additive blending
|
// Enable additive blending
|
||||||
GLDEBUG(glEnable(GL_BLEND));
|
GLDEBUG(glEnable(GL_BLEND));
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ KRContext::KRContext() : m_streamer(*this)
|
|||||||
m_bDetectedExtensions = false;
|
m_bDetectedExtensions = false;
|
||||||
m_current_frame = 0;
|
m_current_frame = 0;
|
||||||
m_last_memory_warning_frame = 0;
|
m_last_memory_warning_frame = 0;
|
||||||
|
m_last_fully_streamed_frame = 0;
|
||||||
m_absolute_time = 0.0f;
|
m_absolute_time = 0.0f;
|
||||||
|
|
||||||
m_pBundleManager = new KRBundleManager(*this);
|
m_pBundleManager = new KRBundleManager(*this);
|
||||||
@@ -285,6 +286,11 @@ long KRContext::getCurrentFrame() const
|
|||||||
return m_current_frame;
|
return m_current_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long KRContext::getLastFullyStreamedFrame() const
|
||||||
|
{
|
||||||
|
return m_last_fully_streamed_frame;
|
||||||
|
}
|
||||||
|
|
||||||
float KRContext::getAbsoluteTime() const
|
float KRContext::getAbsoluteTime() const
|
||||||
{
|
{
|
||||||
return m_absolute_time;
|
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 memoryRemaining = KRENGINE_GPU_MEM_TARGET;
|
||||||
long memoryRemainingThisFrame = KRENGINE_GPU_MEM_MAX - m_pTextureManager->getMemUsed() - m_pMeshManager->getMemUsed();
|
long memoryRemainingThisFrame = KRENGINE_GPU_MEM_MAX - m_pTextureManager->getMemUsed() - m_pMeshManager->getMemUsed();
|
||||||
|
long memoryRemainingThisFrameStart = memoryRemainingThisFrame;
|
||||||
m_pMeshManager->doStreaming(memoryRemaining, memoryRemainingThisFrame);
|
m_pMeshManager->doStreaming(memoryRemaining, memoryRemainingThisFrame);
|
||||||
m_pTextureManager->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;
|
m_last_memory_warning_frame = m_current_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ public:
|
|||||||
void endFrame(float deltaTime);
|
void endFrame(float deltaTime);
|
||||||
|
|
||||||
long getCurrentFrame() const;
|
long getCurrentFrame() const;
|
||||||
|
long getLastFullyStreamedFrame() const;
|
||||||
float getAbsoluteTime() const;
|
float getAbsoluteTime() const;
|
||||||
|
|
||||||
long getAbsoluteTimeMilliseconds();
|
long getAbsoluteTimeMilliseconds();
|
||||||
@@ -102,8 +103,9 @@ private:
|
|||||||
void detectExtensions();
|
void detectExtensions();
|
||||||
bool m_bDetectedExtensions;
|
bool m_bDetectedExtensions;
|
||||||
|
|
||||||
long m_current_frame;
|
long m_current_frame; // TODO - Does this need to be atomic?
|
||||||
long m_last_memory_warning_frame;
|
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;
|
float m_absolute_time;
|
||||||
|
|
||||||
mach_timebase_info_data_t m_timebase_info;
|
mach_timebase_info_data_t m_timebase_info;
|
||||||
|
|||||||
@@ -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 = KRMat4::Dot(matModelViewInverseTranspose, light_direction_view_space);
|
||||||
light_direction_view_space.normalize();
|
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);
|
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_DIRECTION_VIEW_SPACE, light_direction_view_space);
|
||||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);
|
||||||
|
|||||||
@@ -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);
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, particleModelMatrix, this_point_light, this_directional_light, this_spot_light, 0, renderPass, rim_color, 0.0f)) {
|
|
||||||
|
|
||||||
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_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()));
|
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);
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
|
||||||
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)) {
|
|
||||||
int slice_count = (int)(pCamera->settings.volumetric_environment_quality * 495.0) + 5;
|
int slice_count = (int)(pCamera->settings.volumetric_environment_quality * 495.0) + 5;
|
||||||
|
|
||||||
float slice_near = -pCamera->settings.getPerspectiveNearZ();
|
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();
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
|
||||||
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)) {
|
|
||||||
|
|
||||||
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
GLDEBUG(glGenQueriesEXT(1, &m_occlusionQuery));
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
@@ -336,8 +333,8 @@ void KRLight::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_light
|
|||||||
|
|
||||||
// Render light flare on transparency pass
|
// 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);
|
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_MATERIAL_ALPHA, 1.0f);
|
||||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_flareSize);
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, m_flareSize);
|
||||||
m_pContext->getTextureManager()->selectTexture(0, m_pFlareTexture, 0.0f, KRTexture::TEXTURE_USAGE_LIGHT_FLARE);
|
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
|
// 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);
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero());
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
getScene().render(pCamera, m_shadowViewports[iShadow].getVisibleBounds(), m_shadowViewports[iShadow], KRNode::RENDER_PASS_SHADOWMAP, true);
|
getScene().render(pCamera, m_shadowViewports[iShadow].getVisibleBounds(), m_shadowViewports[iShadow], KRNode::RENDER_PASS_SHADOWMAP, true);
|
||||||
|
|||||||
@@ -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);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
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;
|
KRVector3 rim_color; KRVector4 fade_color;
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pParticleShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
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);
|
pParticleShader->setUniform(KRShader::KRENGINE_UNIFORM_FLARE_SIZE, 1.0f);
|
||||||
|
|
||||||
KRDataBlock index_data;
|
KRDataBlock index_data;
|
||||||
|
|||||||
@@ -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());
|
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);
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, this_light, std::vector<KRDirectionalLight *>(), std::vector<KRSpotLight *>(), 0, renderPass, rim_color, 0.0f)) {
|
|
||||||
|
|
||||||
|
|
||||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_LIGHT_COLOR, m_color);
|
||||||
|
|||||||
@@ -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);
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, sphereModelMatrix, point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
|
||||||
|
|
||||||
// Enable additive blending
|
// Enable additive blending
|
||||||
GLDEBUG(glEnable(GL_BLEND));
|
GLDEBUG(glEnable(GL_BLEND));
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ void KRScene::render(KROctreeNode *pOctreeNode, unordered_map<KRAABB, int> &visi
|
|||||||
GLDEBUG(glDepthMask(GL_FALSE));
|
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));
|
GLDEBUG(glDrawArrays(GL_TRIANGLE_STRIP, 0, 14));
|
||||||
m_pContext->getMeshManager()->log_draw_call(renderPass, "octree", "occlusion_test", 14);
|
m_pContext->getMeshManager()->log_draw_call(renderPass, "octree", "occlusion_test", 14);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,8 @@ const char *KRShader::KRENGINE_UNIFORM_NAMES[] = {
|
|||||||
"particle_origin", // KRENGINE_UNIFORM_PARTICLE_ORIGIN
|
"particle_origin", // KRENGINE_UNIFORM_PARTICLE_ORIGIN
|
||||||
"bone_transforms", // KRENGINE_UNIFORM_BONE_TRANSFORMS
|
"bone_transforms", // KRENGINE_UNIFORM_BONE_TRANSFORMS
|
||||||
"rim_color", // KRENGINE_UNIFORM_RIM_COLOR
|
"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)
|
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) {
|
if(m_iProgram == 0) {
|
||||||
return false;
|
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_COLOR, rim_color);
|
||||||
setUniform(KRENGINE_UNIFORM_RIM_POWER, rim_power);
|
setUniform(KRENGINE_UNIFORM_RIM_POWER, rim_power);
|
||||||
|
|
||||||
|
// Fade parameters
|
||||||
|
setUniform(KRENGINE_UNIFORM_FADE_COLOR, fade_color);
|
||||||
|
|
||||||
// Fog parameters
|
// Fog parameters
|
||||||
setUniform(KRENGINE_UNIFORM_FOG_NEAR, camera.settings.fog_near);
|
setUniform(KRENGINE_UNIFORM_FOG_NEAR, camera.settings.fog_near);
|
||||||
setUniform(KRENGINE_UNIFORM_FOG_FAR, camera.settings.fog_far);
|
setUniform(KRENGINE_UNIFORM_FOG_FAR, camera.settings.fog_far);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
virtual ~KRShader();
|
virtual ~KRShader();
|
||||||
const char *getKey() const;
|
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 {
|
enum {
|
||||||
KRENGINE_UNIFORM_MATERIAL_AMBIENT = 0,
|
KRENGINE_UNIFORM_MATERIAL_AMBIENT = 0,
|
||||||
@@ -117,6 +117,7 @@ public:
|
|||||||
KRENGINE_UNIFORM_BONE_TRANSFORMS,
|
KRENGINE_UNIFORM_BONE_TRANSFORMS,
|
||||||
KRENGINE_UNIFORM_RIM_COLOR,
|
KRENGINE_UNIFORM_RIM_COLOR,
|
||||||
KRENGINE_UNIFORM_RIM_POWER,
|
KRENGINE_UNIFORM_RIM_POWER,
|
||||||
|
KRENGINE_UNIFORM_FADE_COLOR,
|
||||||
KRENGINE_NUM_UNIFORMS
|
KRENGINE_NUM_UNIFORMS
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
|
|||||||
iShadowQuality = pCamera->settings.m_cShadowBuffers;
|
iShadowQuality = pCamera->settings.m_cShadowBuffers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool bFadeColorEnabled = pCamera->getFadeColor().w >= 0.0f;
|
||||||
|
|
||||||
std::pair<std::string, std::vector<int> > key;
|
std::pair<std::string, std::vector<int> > key;
|
||||||
key.first = shader_name;
|
key.first = shader_name;
|
||||||
key.second.push_back(light_directional_count);
|
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_radius * 1000.0f);
|
||||||
key.second.push_back(pCamera->settings.vignette_falloff * 1000.0f);
|
key.second.push_back(pCamera->settings.vignette_falloff * 1000.0f);
|
||||||
key.second.push_back(bRimColor);
|
key.second.push_back(bRimColor);
|
||||||
|
key.second.push_back(bFadeColorEnabled);
|
||||||
|
|
||||||
|
|
||||||
KRShader *pShader = m_shaders[key];
|
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_DIFFUSE " << (pCamera->settings.bEnableDiffuse ? "1" : "0");
|
||||||
stream << "\n#define ENABLE_SPECULAR " << (pCamera->settings.bEnableSpecular ? "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_RIM_COLOR " << (bRimColor ? "1" : "0");
|
||||||
|
stream << "\n#define ENABLE_FADE_COLOR " << (bFadeColorEnabled ? "1" : "0");
|
||||||
stream << "\n#define FOG_TYPE " << pCamera->settings.fog_type;
|
stream << "\n#define FOG_TYPE " << pCamera->settings.fog_type;
|
||||||
switch(renderPass) {
|
switch(renderPass) {
|
||||||
case KRNode::RENDER_PASS_DEFERRED_GBUFFER:
|
case KRNode::RENDER_PASS_DEFERRED_GBUFFER:
|
||||||
@@ -204,7 +208,6 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
|
|||||||
stream << "\n#define VOLUMETRIC_ENVIRONMENT_DOWNSAMPLED " << (pCamera->settings.volumetric_environment_enable && pCamera->settings.volumetric_environment_downsample != 0 ? "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);
|
stream.setf(ios::fixed,ios::floatfield);
|
||||||
|
|
||||||
stream.precision(std::numeric_limits<long double>::digits10);
|
stream.precision(std::numeric_limits<long double>::digits10);
|
||||||
@@ -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());
|
KRContext::Log(KRContext::LOG_LEVEL_ERROR, "Fragment Shader Missing: %s", platform_shader_name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KRVector4 fade_color = pCamera->getFadeColor();
|
||||||
|
|
||||||
char szKey[256];
|
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);
|
pShader = new KRShader(getContext(), szKey, options, vertShaderSource, fragShaderSource);
|
||||||
|
|
||||||
@@ -240,16 +245,16 @@ KRShader *KRShaderManager::getShader(const std::string &shader_name, KRCamera *p
|
|||||||
return pShader;
|
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);
|
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) {
|
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 {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
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();
|
long getShaderHandlesUsed();
|
||||||
|
|
||||||
|
|||||||
@@ -130,8 +130,7 @@ void KRSprite::render(KRCamera *pCamera, std::vector<KRPointLight *> &point_ligh
|
|||||||
|
|
||||||
// Render light sprite on transparency pass
|
// 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);
|
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, KRVector3::Zero(), 0.0f, KRVector4::Zero())) {
|
||||||
if(getContext().getShaderManager()->selectShader(*pCamera, pShader, viewport, getModelMatrix(), point_lights, directional_lights, spot_lights, 0, renderPass, rim_color, 0.0f)) {
|
|
||||||
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, m_spriteAlpha);
|
pShader->setUniform(KRShader::KRENGINE_UNIFORM_MATERIAL_ALPHA, m_spriteAlpha);
|
||||||
m_pContext->getTextureManager()->selectTexture(0, m_pSpriteTexture, 0.0f, KRTexture::TEXTURE_USAGE_SPRITE);
|
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);
|
m_pContext->getMeshManager()->bindVBO(&m_pContext->getMeshManager()->KRENGINE_VBO_DATA_2D_SQUARE_VERTICES, 1.0f);
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
#include "KRVector3.h"
|
#include "KRVector3.h"
|
||||||
#include "tinyxml2.h"
|
#include "tinyxml2.h"
|
||||||
|
|
||||||
|
const KRVector3 KRVECTOR3_ZERO(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
//default constructor
|
//default constructor
|
||||||
KRVector3::KRVector3()
|
KRVector3::KRVector3()
|
||||||
{
|
{
|
||||||
@@ -154,8 +156,8 @@ KRVector3 KRVector3::Max() {
|
|||||||
return KRVector3(std::numeric_limits<float>::max());
|
return KRVector3(std::numeric_limits<float>::max());
|
||||||
}
|
}
|
||||||
|
|
||||||
KRVector3 KRVector3::Zero() {
|
const KRVector3 &KRVector3::Zero() {
|
||||||
return KRVector3(0.0f, 0.0f, 0.0f);
|
return KRVECTOR3_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRVector3 KRVector3::One() {
|
KRVector3 KRVector3::One() {
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public:
|
|||||||
static float Dot(const KRVector3 &v1, const KRVector3 &v2);
|
static float Dot(const KRVector3 &v1, const KRVector3 &v2);
|
||||||
static KRVector3 Min();
|
static KRVector3 Min();
|
||||||
static KRVector3 Max();
|
static KRVector3 Max();
|
||||||
static KRVector3 Zero();
|
static const KRVector3 &Zero();
|
||||||
static KRVector3 One();
|
static KRVector3 One();
|
||||||
static KRVector3 Forward();
|
static KRVector3 Forward();
|
||||||
static KRVector3 Backward();
|
static KRVector3 Backward();
|
||||||
|
|||||||
@@ -32,6 +32,8 @@
|
|||||||
#include "KREngine-common.h"
|
#include "KREngine-common.h"
|
||||||
#include "KRVector4.h"
|
#include "KRVector4.h"
|
||||||
|
|
||||||
|
const KRVector4 KRVECTOR4_ZERO(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
//default constructor
|
//default constructor
|
||||||
KRVector4::KRVector4()
|
KRVector4::KRVector4()
|
||||||
{
|
{
|
||||||
@@ -70,8 +72,8 @@ KRVector4 KRVector4::Max() {
|
|||||||
return KRVector4(std::numeric_limits<float>::max());
|
return KRVector4(std::numeric_limits<float>::max());
|
||||||
}
|
}
|
||||||
|
|
||||||
KRVector4 KRVector4::Zero() {
|
const KRVector4 &KRVector4::Zero() {
|
||||||
return KRVector4(0.0f, 0.0f, 0.0f, 0.0f);
|
return KRVECTOR4_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
KRVector4 KRVector4::One() {
|
KRVector4 KRVector4::One() {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public:
|
|||||||
static float Dot(const KRVector4 &v1, const KRVector4 &v2);
|
static float Dot(const KRVector4 &v1, const KRVector4 &v2);
|
||||||
static KRVector4 Min();
|
static KRVector4 Min();
|
||||||
static KRVector4 Max();
|
static KRVector4 Max();
|
||||||
static KRVector4 Zero();
|
static const KRVector4 &Zero();
|
||||||
static KRVector4 One();
|
static KRVector4 One();
|
||||||
static KRVector4 Forward();
|
static KRVector4 Forward();
|
||||||
static KRVector4 Backward();
|
static KRVector4 Backward();
|
||||||
|
|||||||
@@ -34,10 +34,14 @@
|
|||||||
varying mediump vec2 textureCoordinate;
|
varying mediump vec2 textureCoordinate;
|
||||||
precision lowp float;
|
precision lowp float;
|
||||||
|
|
||||||
#if ENABLE_VIDEO_BG == 0
|
#if ENABLE_VIDEO_BG == 1
|
||||||
uniform lowp sampler2D videoFrame;
|
uniform lowp sampler2D videoFrame;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_FADE_COLOR == 1
|
||||||
|
uniform lowp vec4 fade_color;
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform lowp sampler2D renderFrame;
|
uniform lowp sampler2D renderFrame;
|
||||||
uniform lowp sampler2D depthFrame;
|
uniform lowp sampler2D depthFrame;
|
||||||
|
|
||||||
@@ -171,11 +175,15 @@ void main()
|
|||||||
|
|
||||||
// Render vignette effect
|
// 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);
|
pixelColor *= vec4(vec3(clamp(1.0 - (distance(textureCoordinate, vec2(0.5, 0.5)) - VIGNETTE_RADIUS) / VIGNETTE_FALLOFF, 0.0, 1.0)), 1.0);
|
||||||
#endif
|
#endif
|
||||||
// ---- VIGNETTE END ----
|
// ---- VIGNETTE END ----
|
||||||
|
|
||||||
|
#if ENABLE_FADE_COLOR == 1
|
||||||
|
pixelColor.rgb = mix(pixelColor.rgb, fade_color.rgb, fade_color.a);
|
||||||
|
#endif
|
||||||
|
|
||||||
gl_FragColor = pixelColor;
|
gl_FragColor = pixelColor;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,13 +25,6 @@
|
|||||||
// or implied, of Kearwood Gilbert.
|
// or implied, of Kearwood Gilbert.
|
||||||
//
|
//
|
||||||
|
|
||||||
/*
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define ENABLE_VIDEO_BG 0
|
#define ENABLE_VIDEO_BG 0
|
||||||
#define PIXEL_SHIFT_1 0.001
|
#define PIXEL_SHIFT_1 0.001
|
||||||
#define PIXEL_SHIFT_2 0.002
|
#define PIXEL_SHIFT_2 0.002
|
||||||
@@ -41,10 +34,14 @@ void main()
|
|||||||
varying mediump vec2 textureCoordinate;
|
varying mediump vec2 textureCoordinate;
|
||||||
//precision lowp float;
|
//precision lowp float;
|
||||||
|
|
||||||
#if ENABLE_VIDEO_BG == 0
|
#if ENABLE_VIDEO_BG == 1
|
||||||
uniform lowp sampler2D videoFrame;
|
uniform lowp sampler2D videoFrame;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_FADE_COLOR == 1
|
||||||
|
uniform lowp vec4 fade_color;
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform lowp sampler2D renderFrame;
|
uniform lowp sampler2D renderFrame;
|
||||||
uniform lowp sampler2D depthFrame;
|
uniform lowp sampler2D depthFrame;
|
||||||
|
|
||||||
@@ -171,11 +168,15 @@ void main()
|
|||||||
|
|
||||||
// Render vignette effect
|
// 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);
|
pixelColor *= vec4(vec3(clamp(1.0 - (distance(textureCoordinate, vec2(0.5, 0.5)) - VIGNETTE_RADIUS) / VIGNETTE_FALLOFF, 0.0, 1.0)), 1.0);
|
||||||
#endif
|
#endif
|
||||||
// ---- VIGNETTE END ----
|
// ---- VIGNETTE END ----
|
||||||
|
|
||||||
|
#if ENABLE_FADE_COLOR == 1
|
||||||
|
pixelColor.rgb = mix(pixelColor.rgb, fade_color.rgb, fade_color.a);
|
||||||
|
#endif
|
||||||
|
|
||||||
gl_FragColor = pixelColor;
|
gl_FragColor = pixelColor;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user