void DeferredShader::lightingStage(Scene & scene, Camera & camera)
{
	stateManager.setRenderingStage(StateManager::LIGHTING_STAGE);
	bindPBuffer();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glDisable(GL_CULL_FACE);								// Disable Cull Face
	glDisable(GL_DEPTH_TEST);								// Disable Z-Buffer

	shaderManager.bindStageShader();

	shaderManager.setCgParam(gbDepth,"depthMap",FRAGMENT);
	shaderManager.setCgParam(gbDiffuse,"diffuseMap",FRAGMENT);
	shaderManager.setCgParam(gbSpecular,"specularMap",FRAGMENT);
	shaderManager.setCgParam(gbNormal,"normalMap",FRAGMENT);

	shaderManager.setCgParam(camera.getZNear(),"near",FRAGMENT);
	shaderManager.setCgParam(camera.getZFar(),"far",FRAGMENT);
	drawLighting(scene,camera);
	unbindPBuffer();
}
Beispiel #2
0
void FELighting::applySoftware()
{
    FilterEffect* in = inputEffect(0);

    Uint8ClampedArray* srcPixelArray = createPremultipliedImageResult();
    if (!srcPixelArray)
        return;

    setIsAlphaImage(false);

    IntRect effectDrawingRect = requestedRegionOfInputImageData(in->absolutePaintRect());
    in->copyPremultipliedImage(srcPixelArray, effectDrawingRect);

    // FIXME: support kernelUnitLengths other than (1,1). The issue here is that the W3
    // standard has no test case for them, and other browsers (like Firefox) has strange
    // output for various kernelUnitLengths, and I am not sure they are reliable.
    // Anyway, feConvolveMatrix should also use the implementation

    IntSize absolutePaintSize = absolutePaintRect().size();
    drawLighting(srcPixelArray, absolutePaintSize.width(), absolutePaintSize.height());
}
Beispiel #3
0
void FELighting::apply(Filter* filter)
{
    m_in->apply(filter);
    if (!m_in->resultImage())
        return;

    if (!getEffectContext())
        return;

    setIsAlphaImage(false);

    IntRect effectDrawingRect = calculateDrawingIntRect(m_in->scaledSubRegion());
    RefPtr<ImageData> srcImageData(m_in->resultImage()->getUnmultipliedImageData(effectDrawingRect));
    CanvasPixelArray* srcPixelArray(srcImageData->data());

    // FIXME: support kernelUnitLengths other than (1,1). The issue here is that the W3
    // standard has no test case for them, and other browsers (like Firefox) has strange
    // output for various kernelUnitLengths, and I am not sure they are reliable.
    // Anyway, feConvolveMatrix should also use the implementation

    if (drawLighting(srcPixelArray, effectDrawingRect.width(), effectDrawingRect.height()))
        resultImage()->putUnmultipliedImageData(srcImageData.get(), IntRect(IntPoint(), resultImage()->size()), IntPoint());
}