Beispiel #1
0
void Circle::append(IndexedVertexBatch<XYZ.UV.RGBA, GLushort> &batch, const Matrix &matrix, float x, float y) const
{
    float aa = fabsf(a2 - a1);
    int n = ceilf(aa * r / segmentLength) + 1;

    batch.addVertex(matrix.transformPoint(x, y), getTextureCoords(batch.texture, 0, 0), color);

    for (int i = 0; i < n; i++)
    {
        float dd = a1 + fminf(aa, i * segmentLength / r);
        float xx = +sinf(dd) * r;
        float yy = +cosf(dd) * r;

        batch.addVertex(matrix.transformPoint(x + xx, y + yy), getTextureCoords(batch.texture, xx, yy), color);

        if (i < n - 1)
        {
            if (frontFace == CW)
            {
                batch.addIndices(i + 1, 0, i + 2);
            }
            else
            {
                batch.addIndices(0, i + 1, i + 2);
            }
        }
    }

    batch.incrementIndices(n + 1);
}
Beispiel #2
0
bool HDR_Pipeline::sceneToSceneScaled (ATOM_RenderDevice *device)
{
	ATOM_Vector2f sampleOffsets[MAX_SAMPLES];

	ATOM_Rect2Di rc;
	rc.point.x = (_source->getWidth() - _cropWidth) / 2;
	rc.point.y = (_source->getHeight() - _cropHeight) / 2;
	rc.size.w = rc.point.x + _cropWidth;
	rc.size.h = rc.point.y + _cropHeight;

	CoordRect coords;
	getTextureCoords (_source.get(), &rc, _sourceScaled.get(), 0, &coords);

	_hdrMaterial->setActiveEffect ("DownScale4x4");
	getSampleOffsets_DownScale4x4 (_source->getWidth(), _source->getHeight(), sampleOffsets);
	_hdrMaterial->getParameterTable()->setVectorArray ("g_avSampleOffsets", sampleOffsets, MAX_SAMPLES);
	_hdrMaterial->getParameterTable()->setTexture ("tex0", _source.get());

	device->setRenderTarget (0, _sourceScaled.get());

	//--- added ---//
	device->setViewport (0, ATOM_Rect2Di(0, 0,_sourceScaled->getWidth(), _sourceScaled->getHeight()));

	drawFullScreenQuad (device, coords);

#if DEBUG_HDR
	if( bsaveall )
	{
		device->setRenderTarget (0, 0);
		_sourceScaled->saveToFile ("/sceneScaled.dds");
	}
#endif

	return true;
}
void Storm3D_VideoStreamer::render(IStorm3D_Scene *scene)
{
	if(!data || !scene || data->finished)
		return;

	update();
	float x, y;
	getTextureCoords(x, y);
	scene->Render2D_Picture(data->material.get(), data->start, data->end, data->alpha, 0, 0,0,x,y);
}
Beispiel #4
0
bool HDR_Pipeline::sceneScaledToBrightPass (ATOM_RenderDevice *device)
{
	ATOM_Rect2Di rectSrc;
	rectSrc.point.x = 1;
	rectSrc.point.y = 1;
	rectSrc.size.w = _sourceScaled->getWidth()-2;
	rectSrc.size.h = _sourceScaled->getHeight()-2;

	ATOM_Rect2Di rectDest;
	rectDest.point.x = 1;
	rectDest.point.y = 1;
	rectDest.size.w = _brightPass->getWidth()-2;
	rectDest.size.h = _brightPass->getHeight()-2;

	CoordRect coords;
	getTextureCoords (_sourceScaled.get(), &rectSrc, _brightPass.get(), &rectDest, &coords);

	_hdrMaterial->setActiveEffect ("BrightPassFilter");
	_hdrMaterial->getParameterTable()->setFloat ("g_brightPassThreshold", _brightPassThreshold);
	_hdrMaterial->getParameterTable()->setFloat ("g_brightPassOffset", _brightPassOffset);
	//--- wangjian added ---//
	if( _use_filmic_mapping )
	{
		ATOM_Vector4f filmicCurveParam(_filmCurveShoulder,_filmCurveMiddleTone,_filmCurveToe,_filmCurveWhitePoint);
		_hdrMaterial->getParameterTable()->setVector ("g_filmicCurveParam", filmicCurveParam);
		_hdrMaterial->getParameterTable()->setFloat ("g_HDRSaturate", _HDRSaturate);
		_hdrMaterial->getParameterTable()->setFloat ("g_HDRContrast", _HDRContrast);
		_hdrMaterial->getParameterTable()->setVector ("g_HDRColorBalance", _HDRColorBalance);
	}
	//----------------------//
	_hdrMaterial->getParameterTable()->setFloat ("g_fMiddleGray", _keyValue);
	_hdrMaterial->getParameterTable()->setTexture ("tex0", _sourceScaled.get());
	_hdrMaterial->getParameterTable()->setTexture ("tex1", _adaptedLumCurrent.get());

	device->setRenderTarget (0, _brightPass.get());

	//--- added ---//
	device->setViewport (0, ATOM_Rect2Di(0, 0,_brightPass->getWidth(), _brightPass->getHeight()));

	beginScissorTest (device, rectDest.point.x, rectDest.point.y, rectDest.size.w, rectDest.size.h);
	drawFullScreenQuad (device, coords);
	endScissorTest (device);

#if DEBUG_HDR
	if( bsaveall )
	{
		device->setRenderTarget (0, 0);
		_brightPass->saveToFile ("/brightpass.dds");
	}
#endif

	return true;
}
Beispiel #5
0
//reads in an object from a .obj file
BasicObject::BasicObject(const std::string &filename, const float _shininess){

	shininess    = _shininess;

	_numVerticies = numVertices(filename.c_str());
	_numFaces 	  = numFaces(filename.c_str());
	_indexCount   = _numFaces * 3;

	verticies 	  = getVertices(filename.c_str(), _numVerticies);
	normals 	  = getNormals(filename.c_str(), _numVerticies);
	faces 		  = getFaces(filename.c_str(), _numFaces);
	texCoords 	  = getTextureCoords(filename.c_str(), _numVerticies);

}
Beispiel #6
0
sf::IntRect TileLoader::getTextureRect(int x, int y, const char* layerName)
{
	int gid = getGid(x, y, layerName);

	if (gid != 0)
	{
		sf::Vector2i coords = getTextureCoords(x, y, layerName);
		return sf::IntRect(coords.x * mTileWidth, coords.y *mTileHeight, mTileWidth, mTileHeight);
	}

	// No Texture
	return sf::IntRect(-1,-1,-1,-1);

}
Beispiel #7
0
bool HDR_Pipeline::starSourceToBloomSource (ATOM_RenderDevice *device)
{
	ATOM_Vector2f avSampleOffsets[MAX_SAMPLES];

	ATOM_Rect2Di rectSrc;
	rectSrc.point.x = 1;
	rectSrc.point.y = 1;
	rectSrc.size.w = _starSource->getWidth()-2;
	rectSrc.size.h = _starSource->getHeight()-2;

	ATOM_Rect2Di rectDest;
	rectDest.point.x = 1;
	rectDest.point.y = 1;
	rectDest.size.w = _bloomSource->getWidth()-2;
	rectDest.size.h = _bloomSource->getHeight()-2;

	CoordRect coords;
	getTextureCoords (_starSource.get(), &rectSrc, _bloomSource.get(), &rectDest, &coords);

	getSampleOffsets_DownScale2x2(_brightPass->getWidth(), _brightPass->getHeight(), avSampleOffsets);

	_hdrMaterial->setActiveEffect("DownScale2x2");
	_hdrMaterial->getParameterTable()->setVectorArray ("g_avSampleOffsets", avSampleOffsets, MAX_SAMPLES);
	_hdrMaterial->getParameterTable()->setTexture ("tex0", _starSource.get());

	device->setRenderTarget (0, _bloomSource.get());

	//--- added ---//
	device->setViewport (0, ATOM_Rect2Di(0, 0,_bloomSource->getWidth(), _bloomSource->getHeight()));

	beginScissorTest (device, rectDest.point.x, rectDest.point.y, rectDest.size.w, rectDest.size.h);
	drawFullScreenQuad (device, coords);
	endScissorTest (device);

#if DEBUG_HDR
	if( bsaveall )
	{
		device->setRenderTarget (0, 0);
		_bloomSource->saveToFile ("/bloomSource.dds");
	}
#endif

	return true;

}
Beispiel #8
0
bool HDR_Pipeline::renderBloom (ATOM_RenderDevice *device)
{
	ATOM_Vector2f avSampleOffsets[MAX_SAMPLES];
	ATOM_Vector4f avSampleWeights[MAX_SAMPLES];
	float afSampleOffsets[MAX_SAMPLES];

	_bloomTextures[0]->clear (0.f, 0.f, 0.f, 0.f);

	ATOM_Rect2Di rectSrc;
	rectSrc.point.x = 1;
	rectSrc.point.y = 1;
	rectSrc.size.w = _bloomSource->getWidth()-2;
	rectSrc.size.h = _bloomSource->getHeight()-2;

	ATOM_Rect2Di rectDest;
	rectDest.point.x = 1;
	rectDest.point.y = 1;
	rectDest.size.w = _bloomTextures[2]->getWidth()-2;
	rectDest.size.h = _bloomTextures[2]->getHeight()-2;

	CoordRect coords;
	getTextureCoords (_bloomSource.get(), &rectSrc, _bloomTextures[2].get(), &rectDest, &coords);

	getSampleOffsets_GaussBlur5x5(_bloomSource->getWidth(), _bloomSource->getHeight(), avSampleOffsets, avSampleWeights);

	_hdrMaterial->setActiveEffect ("GaussBlur5x5");
	_hdrMaterial->getParameterTable()->setVectorArray ("g_avSampleOffsets", avSampleOffsets, MAX_SAMPLES);
	_hdrMaterial->getParameterTable()->setVectorArray ("g_avSampleWeights", avSampleWeights, MAX_SAMPLES);
	_hdrMaterial->getParameterTable()->setTexture ("tex0", _bloomSource.get());
	device->setRenderTarget (0, _bloomTextures[2].get());

	//--- added ---//
	device->setViewport (0, ATOM_Rect2Di(0, 0,_bloomTextures[2]->getWidth(), _bloomTextures[2]->getHeight()));

	beginScissorTest (device, rectDest.point.x, rectDest.point.y, rectDest.size.w, rectDest.size.h);
	drawFullScreenQuad (device, coords);
	endScissorTest (device);

	// horizontal
	getSampleOffsets_Bloom (_bloomTextures[2]->getWidth(), afSampleOffsets, avSampleWeights, 3.f, 2.f);
	for (int i = 0; i < MAX_SAMPLES; ++i)
	{
		avSampleOffsets[i].set (afSampleOffsets[i], 0.f);
	}

	_hdrMaterial->setActiveEffect ("Bloom");
	_hdrMaterial->getParameterTable()->setVectorArray ("g_avSampleOffsets", avSampleOffsets, MAX_SAMPLES);
	_hdrMaterial->getParameterTable()->setVectorArray ("g_avSampleWeights", avSampleWeights, MAX_SAMPLES);
	_hdrMaterial->getParameterTable()->setTexture ("tex0", _bloomTextures[2].get());
	device->setRenderTarget (0, _bloomTextures[1].get());

	//--- added ---//
	device->setViewport (0, ATOM_Rect2Di(0, 0,_bloomTextures[1]->getWidth(), _bloomTextures[1]->getHeight()));

	beginScissorTest (device, rectDest.point.x, rectDest.point.y, rectDest.size.w, rectDest.size.h);
	drawFullScreenQuad (device, coords);
	endScissorTest (device);

	// vertical
	getSampleOffsets_Bloom (_bloomTextures[1]->getHeight(), afSampleOffsets, avSampleWeights, 3.f, 2.f);
	for (int i = 0; i < MAX_SAMPLES; ++i)
	{
		avSampleOffsets[i].set (0.f, afSampleOffsets[i]);
	}

	rectSrc.point.x = 1;
	rectSrc.point.y = 1;
	rectSrc.size.w = _bloomTextures[1]->getWidth()-2;
	rectSrc.size.h = _bloomTextures[1]->getHeight()-2;

	getTextureCoords (_bloomTextures[1].get(), &rectSrc, _bloomTextures[0].get(), 0, &coords);

	_hdrMaterial->setActiveEffect ("Bloom");
	_hdrMaterial->getParameterTable()->setVectorArray ("g_avSampleOffsets", avSampleOffsets, MAX_SAMPLES);
	_hdrMaterial->getParameterTable()->setVectorArray ("g_avSampleWeights", avSampleWeights, MAX_SAMPLES);
	device->setRenderTarget (0, _bloomTextures[0].get());
	device->setViewport (0, ATOM_Rect2Di(0, 0, _bloomTextures[0]->getWidth(), _bloomTextures[0]->getHeight()));
	_hdrMaterial->getParameterTable()->setTexture ("tex0", _bloomTextures[1].get());
	drawFullScreenQuad (device, coords);

#if DEBUG_HDR
	if( bsaveall )
	{
		device->setRenderTarget (0, 0);
		_bloomTextures[0]->saveToFile ("/BloomTexture0.png");
		_bloomTextures[1]->saveToFile ("/BloomTexture1.png");
		_bloomTextures[2]->saveToFile ("/BloomTexture2.png");
	}
#endif

	return true;

	/*
	_bloomTextures[0]->clear (0.f, 0.f, 0.f, 0.f);

	return true;
	*/
}