/***************************************************************************
*
* Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
EGLBoolean m_blendingStatus;
Shader* m_defaultShader;
Shader* m_defaultShaderNoUniformAlpha;
+ Shader* m_defaultShaderAddUniformChromaKey;
Layer* m_currentLayer;
#ifdef DRAW_LAYER_DEBUG
Shader* m_layerShader;
/***************************************************************************
*
* Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
, m_blendingStatus(false)
, m_defaultShader(0)
, m_defaultShaderNoUniformAlpha(0)
+, m_defaultShaderAddUniformChromaKey(0)
, m_currentLayer(0)
#ifdef DRAW_LAYER_DEBUG
, m_layerShader(0)
{
Shader * retShader = currentShader;
- if (currentShader == m_defaultShader && curUniforms.opacity == 1.0f)
+ LOG_DEBUG("GLESGraphicsystem", "shader:currentShader");
+ do
{
- //no need for multiply in shader, just use texture
- retShader = m_defaultShaderNoUniformAlpha;
- }
+ if (currentShader != m_defaultShader)
+ {
+ LOG_DEBUG("GLESGraphicsystem", "shader:default");
+ break;
+ }
- return retShader;
+ if (false == curUniforms.chromaKeyEnabled)
+ {
+ if (curUniforms.opacity == 1.0f)
+ {
+ //no need for multiply in shader, just use texture
+ retShader = m_defaultShaderNoUniformAlpha;
+ LOG_DEBUG("GLESGraphicsystem", "shader:defaultShaderNoUniformAlpha");
+ }
+ }
+ else
+ {
+ // Add chromakey to default fragment shader
+ retShader = m_defaultShaderAddUniformChromaKey;
+ LOG_DEBUG("GLESGraphicsystem", "shader:defaultShaderAddUniformChromaKey");
+ }
+ } while(0);
+ return retShader;
}
void GLESGraphicsystem::applyLayerMatrix(IlmMatrix& matrix)
uniforms.texOffset[1] = textureCoordinates[1];
uniforms.texUnit = 0;
uniforms.matrix = &layerMatrix.f[0];
-
+ uniforms.chromaKeyEnabled = (surface)->getChromaKeyEnabled();
+ if (true == uniforms.chromaKeyEnabled)
+ {
+ unsigned char red = 0;
+ unsigned char green = 0;
+ unsigned char blue = 0;
+ (surface)->getChromaKey(red, green, blue);
+ uniforms.chromaKey[0] = (float)red / 255.0f;
+ uniforms.chromaKey[1] = (float)green / 255.0f;
+ uniforms.chromaKey[2] = (float)blue / 255.0f;
+ }
//We only know about specific Shaders, only do this if we start with the defaultShader
if (shader == m_defaultShader && uniforms.opacity == 1.0f)
ShaderProgramFactory::setCreatorFunc(m_shaderCreatorFunc);
m_defaultShader = Shader::createShader("default", "default");
m_defaultShaderNoUniformAlpha = Shader::createShader("default", "default_no_uniform_alpha");
+ m_defaultShaderAddUniformChromaKey= Shader::createShader("default", "default_add_uniform_chromakey");
#ifdef DRAW_LAYER_DEBUG
std::string pluginLookupPath = getenv("LM_PLUGIN_PATH");
m_layerShader = Shader::createShader(vertexShaderPath, fragmentShaderPath);
#endif
if (
- !m_defaultShader || !m_defaultShaderNoUniformAlpha
+ !m_defaultShader || !m_defaultShaderNoUniformAlpha || !m_defaultShaderAddUniformChromaKey
#ifdef DRAW_LAYER_DEBUG
|| !m_layerShader
#endif
install (TARGETS WaylandGLESRenderer DESTINATION lib/layermanager/renderer)
install (FILES ../X11GLESRenderer/renderer_frag.glslf DESTINATION lib/layermanager/renderer)
install (FILES ../X11GLESRenderer/renderer_frag_no_ualpha.glslf DESTINATION lib/layermanager/renderer)
+install (FILES ../X11GLESRenderer/renderer_frag_add_uchromakey.glslf DESTINATION lib/layermanager/renderer)
install (FILES ../X11GLESRenderer/renderer_layer.glslf DESTINATION lib/layermanager/renderer)
install (FILES ../X11GLESRenderer/renderer_layer.glslv DESTINATION lib/layermanager/renderer)
install (FILES ../X11GLESRenderer/renderer_vert.glslv DESTINATION lib/layermanager/renderer)
############################################################################
#
# Copyright 2010-2012 BMW Car IT GmbH
+# Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
install (TARGETS X11GLESRenderer DESTINATION lib/layermanager/renderer)
install (FILES renderer_frag.glslf DESTINATION lib/layermanager/renderer)
install (FILES renderer_frag_no_ualpha.glslf DESTINATION lib/layermanager/renderer)
+install (FILES renderer_frag_add_uchromakey.glslf DESTINATION lib/layermanager/renderer)
install (FILES renderer_layer.glslf DESTINATION lib/layermanager/renderer)
install (FILES renderer_layer.glslv DESTINATION lib/layermanager/renderer)
install (FILES renderer_vert.glslv DESTINATION lib/layermanager/renderer)
--- /dev/null
+/***************************************************************************
+*
+* Copyright 2010,2011 BMW Car IT GmbH
+* Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+****************************************************************************/
+// alpha value of the surfaces
+uniform mediump float uAlphaVal;
+// textureunit which is accessed
+uniform mediump sampler2D uTexUnit;
+// chromakey of the surfaces
+uniform mediump vec3 uChromaKey;
+
+// texture coordinates sended by the vertex shader
+varying mediump vec2 vTexout;
+
+void main()
+{
+ // correct Texture Coords;
+ mediump vec4 tcolor = texture2D(uTexUnit, vTexout );
+ // if both match, discarding
+ if (tcolor.rgb == uChromaKey.rgb)
+ {
+ discard;
+ }
+ mediump vec4 color = tcolor * vec4(1.0,1.0,1.0,uAlphaVal);
+ gl_FragColor = color;
+}
/***************************************************************************
*
* Copyright 2010 BMW Car IT GmbH
+* Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
strcpy(fragmentShaderLocation,defaultShaderDir);
strcat(vertexShaderLocation,"/renderer_vert.glslv");
strcat(fragmentShaderLocation,"/renderer_frag_no_ualpha.glslf");
- progHandle = RenderUtilLoadShaderSources(vertexShaderLocation,fragmentShaderLocation, GL_TRUE); }
+ progHandle = RenderUtilLoadShaderSources(vertexShaderLocation,fragmentShaderLocation, GL_TRUE);
+ }
+ else if (vertName=="default" && fragName=="default_add_uniform_chromakey")
+ {
+ strcpy(vertexShaderLocation,defaultShaderDir);
+ strcpy(fragmentShaderLocation,defaultShaderDir);
+ strcat(vertexShaderLocation,"/renderer_vert.glslv");
+ strcat(fragmentShaderLocation,"/renderer_frag_add_uchromakey.glslf");
+ progHandle = RenderUtilLoadShaderSources(vertexShaderLocation,fragmentShaderLocation, GL_TRUE);
+ }
else
{
// load shader sources from file, compile and link them:
/***************************************************************************
*
* Copyright 2010,2011 BMW Car IT GmbH
+* Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
float texOffset[2];
int texUnit;
float* matrix;
+ float chromaKey[3];
+ bool chromaKeyEnabled;
};
/**
int m_texOffsetLoc;
int m_texUnitLoc;
int m_matrixLoc;
+ int m_chromaKeyLoc;
/// global list of programs
static ShaderProgramList m_programList;
};
/***************************************************************************
*
* Copyright 2010,2011 BMW Car IT GmbH
+ * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
, m_texOffsetLoc(0)
, m_texUnitLoc(0)
, m_matrixLoc(0)
+, m_chromaKeyLoc(0)
{
// void
}
{
uniformMatrix4fv(m_matrixLoc, 1, false, uniforms.matrix);
}
+ if (m_chromaKeyLoc>= 0)
+ {
+ uniform3fv(m_chromaKeyLoc, 1, uniforms.chromaKey);
+ }
}
void ShaderProgram::updateCommonUniformLocations(void)
m_texOffsetLoc = getUniformLocation("uTexOffset");
m_texUnitLoc = getUniformLocation("uTexUnit");
m_matrixLoc = getUniformLocation("uMatrix");
+ m_chromaKeyLoc = getUniformLocation("uChromaKey");
}