Beispiel #1
0
void Stage::renderScene(ShaderProgram *currentShader, Camera* renderCamera, Light* renderLight, Light* light, Camera* shadowMapCamera, BaseShadowMap* shadowMap) {
	if (currentShader != 0) {
		currentShader->bind();
		renderCamera->bindMatrices(currentShader, "projectionMatrix", "viewMatrix");
		if (light != 0) light->bind(currentShader);
		if (shadowMapCamera != 0) shadowMapCamera->bindMatrices(currentShader, "lightProjView");
		if (shadowMap != 0) {
			shadowMap->bindTexture(currentShader, 3, "shadowMap");
			glm::vec2 pixelOffset(1.0f / float(shadowMap->getWidth()), 1.0f / float(shadowMap->getHeight()));
			glUniform2fv(currentShader->getUniformLocation("pixelOffset"), 1, glm::value_ptr(pixelOffset));
		}
		for (unsigned int j = 0; j < m_meshes.size(); ++j) {
			if (renderLight != 0 && renderLight->getBoundingSphere().radius > 0) {
				if (!renderLight->getBoundingSphere().intersect(m_meshes[j]->getBoundingSphere())) {
					continue;
				}
			}
			if (m_meshes[j]->bothSides == true) {
				glUniform1i(currentShader->getUniformLocation("bothSides"), GL_TRUE);
				glDisable(GL_CULL_FACE);
			} else {
				glUniform1i(currentShader->getUniformLocation("bothSides"), GL_FALSE);
				glEnable(GL_CULL_FACE);
			}
			glm::mat3 normalMatrix = glm::mat3(glm::transpose(glm::inverse(m_camera->getTransform() * m_meshes[j]->getTransform())));
			glUniformMatrix3fv(currentShader->getUniformLocation("normalMatrix"), 1, GL_FALSE, glm::value_ptr(normalMatrix));
			m_meshes[j]->render(currentShader);
		}
		if (shadowMap != 0) shadowMap->unbindTexture();
		currentShader->unbind();
	}
}
void FractureBox::boldenLines()
{
    const int width = ilGetInteger(IL_IMAGE_WIDTH);
    const int height = ilGetInteger(IL_IMAGE_HEIGHT);
    const int depth = 3; //ilGetInteger(IL_IMAGE_DEPTH);
    ILubyte *newData = new ILubyte[width * height * depth];
    ILubyte *oldData = ilGetData();

    //Now loop through the data and when a black pixel is detected, copy the pixel into
    //the buffer surrounded by pixels
    for(int y = 0; y < height; y++)
    {
        for(int x = 0; x < width; x++)
        {
            const int i = (depth * x) + (y * depth * width);
            if(oldData[i] == 0 && oldData[i+1] == 0 && oldData[i+2] == 0)
            {
                const int top = pixelOffset(i, 0, -1, width, height, depth);
                const int topLeft = pixelOffset(i, -1, -1, width, height, depth);
                const int topRight = pixelOffset(i, 1, -1, width, height, depth);

                const int bottom = pixelOffset(i, 0, 1, width, height, depth);
                const int bottomLeft = pixelOffset(i, -1, 1, width, height, depth);
                const int bottomRight = pixelOffset(i, 1, 1, width, height, depth);

                const int left = pixelOffset(i, -1, 0, width, height, depth);
                const int right = pixelOffset(i, 1, 0, width, height, depth);
                newData[i] = 0;
                newData[i + 1] = 0;
                newData[i + 2] = 0;
                setPixelBlack(top, newData);
                setPixelBlack(topLeft, newData);
                setPixelBlack(topRight, newData);

                setPixelBlack(bottom, newData);
                setPixelBlack(bottomLeft, newData);
                setPixelBlack(bottomRight, newData);

                setPixelBlack(left, newData);
                setPixelBlack(right, newData);
            }
            else
            {
                newData[i] = oldData[i];
                newData[i+1] = oldData[i+1];
                newData[i+2] = oldData[i+2];
            }
        }
    }
    ilSetData(newData);
    delete[] newData;
}