Exemple #1
0
void ScatterSky::_interpolateColors()
{
   mFogColor.set( 0, 0, 0, 0 );
   mAmbientColor.set( 0, 0, 0, 0 );
   mSunColor.set( 0, 0, 0, 0 );

   _getFogColor( &mFogColor );
   _getAmbientColor( &mAmbientColor );
   _getSunColor( &mSunColor );

   mAmbientColor *= mAmbientScale;
   mSunColor *= mSunScale;
   mFogColor *= mFogScale;

   mMieScattering = (mCurves[1].getVal( mTimeOfDay) * mSunSize ); //Scale the size of the sun's disk

   ColorF moonTemp = mMoonTint;
   ColorF nightTemp = mNightColor;

   moonTemp.interpolate( mNightColor, mMoonTint, mCurves[4].getVal( mTimeOfDay ) );
   nightTemp.interpolate( mMoonTint, mNightColor, mCurves[4].getVal( mTimeOfDay ) );

   mFogColor.interpolate( mFogColor, mNightFogColor, mCurves[3].getVal( mTimeOfDay ) );//mNightInterpolant );
   mFogColor.alpha = 1.0f;

   mAmbientColor.interpolate( mAmbientColor, mNightColor, mCurves[3].getVal( mTimeOfDay ) );//mNightInterpolant );
   mSunColor.interpolate( mSunColor, mMoonTint, mCurves[3].getVal( mTimeOfDay ) );//mNightInterpolant );
}
Exemple #2
0
void CFlowNode_ScreenFader::ProcessActivateEvent(SActivationInfo* activationInformation)
{
	if (InputEntityIsLocalPlayer(activationInformation) == false)
		return;

	if (IsPortActive(activationInformation, eInputPorts_FadeIn))
	{
		const float fadeInTime = GetPortFloat(activationInformation, eInputPorts_FadeInTime);
		const Vec3 fadeColor = GetPortVec3(activationInformation, eInputPorts_FadeColor);
		const string texture = GetPortString(activationInformation, eInputPorts_Texture);
		const bool useCurrentColor = GetPortBool(activationInformation, eInputPorts_UseCurrentColor);
		ColorF color;
		color.Set(fadeColor.x, fadeColor.y, fadeColor.z);
		m_environment.GetGame().FadeInScreen(texture, color, fadeInTime, useCurrentColor);
	}
	else if (IsPortActive(activationInformation, eInputPorts_FadeOut))
	{
		const float fadeOutTime = GetPortFloat(activationInformation, eInputPorts_FadeOutTime);
		const Vec3 fadeColor = GetPortVec3(activationInformation, eInputPorts_FadeColor);
		const string texture = GetPortString(activationInformation, eInputPorts_Texture);
		const bool useCurrentColor = GetPortBool(activationInformation, eInputPorts_UseCurrentColor);
		ColorF color;
		color.Set(fadeColor.x, fadeColor.y, fadeColor.z);
		m_environment.GetGame().FadeOutScreen(texture, color, fadeOutTime, useCurrentColor);	
	}

}
Exemple #3
0
	RectF TextureRegion::draw(const double x, const double y, const ColorF& color0, const ColorF& color1, const ColorF& color2, const ColorF& color3) const
	{
		Siv3DEngine::GetRenderer2D()->addTextureRegion(
			texture,
			{ x, y, x + size.x, y + size.y },
			uvRect,
			{ color0.toFloat4(), color1.toFloat4(), color2.toFloat4(), color3.toFloat4() }
		);

		return RectF{ x, y, size };
	}
Exemple #4
0
ColorF CHUDFader::GetCurrentColor()
{
	float curVal = 1.0;
	if (m_duration != 0.0f)
	{
		curVal = m_curTime / m_duration;
		curVal = CLAMP(curVal, 0.0f, 1.0f);
	}
	ColorF col;
	col.lerpFloat(m_currentColor, m_targetColor, curVal);
	return col;
}
Exemple #5
0
	RectF TextureRegion::drawAt(const double x, const double y, const ColorF& color0, const ColorF& color1, const ColorF& color2, const ColorF& color3) const
	{
		const Vec2 sizeHalf = size * 0.5;

		Siv3DEngine::GetRenderer2D()->addTextureRegion(
			texture,
			{ x - sizeHalf.x, y - sizeHalf.y, x + sizeHalf.x, y + sizeHalf.y },
			uvRect,
			{ color0.toFloat4(), color1.toFloat4(), color2.toFloat4(), color3.toFloat4() }
		);

		return RectF{ x - sizeHalf.x, y - sizeHalf.y, size };
	}
void ImposterCapture::_colorAverageFilter( U32 dimensions, const U8 *inBmpBits, U8 *outBmpBits )
{
   ColorF color;
   U32 count = 0;
   U32 index, index2;

   for ( S32 y = 0; y < dimensions; y++ )
   {
      for( S32 x = 0; x < dimensions; x++ )
      {
         // We only blend on transparent pixels.
         index = ( ( y * dimensions ) + x ) * 4;
         if ( inBmpBits[index+3] > 84 )
         {
            outBmpBits[index+0] = inBmpBits[index+0];
            outBmpBits[index+1] = inBmpBits[index+1];
            outBmpBits[index+2] = inBmpBits[index+2];
            outBmpBits[index+3] = inBmpBits[index+3]; //hack
            continue;
         }

         color.set(0,0,0);
         count = 0;

         for ( S32 fy = y-6; fy <= y+6; fy++ )
         {
            for ( S32 fx = x-6; fx <= x+6; fx++ )
            {
               if (  fy >= 0 && fy < (dimensions-1) &&
                     fx >= 0 && fx < (dimensions-1) )
               {
                  index2 = ( ( fy * dimensions ) + fx ) * 4;
                  if ( inBmpBits[index2+3] > 84 )
                  {
                     color.red += inBmpBits[index2+0];
                     color.green += inBmpBits[index2+1];
                     color.blue += inBmpBits[index2+2];
                     ++count;
                  }
               }
            }
         }

         outBmpBits[index+0] = (U8)( (F32)color.red / (F32)count );
         outBmpBits[index+1] = (U8)( (F32)color.green / (F32)count );
         outBmpBits[index+2] = (U8)( (F32)color.blue / (F32)count );
         outBmpBits[index+3] = 0;
      }
   }
}
Exemple #7
0
//-----------------------------------------------------------------------------------------------------
// FIXME :
//		Check this works on consoles.
void C2DRenderUtils::InternalDrawLine(float fX1, float fY1, float fX2, float fY2, const ColorF& cfDiffuse)
{
#if C2DRU_USE_DVN_VB
    m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &fX1, &fY1 );
    m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &fX2, &fY2 );

    SVF_P3F_C4B_T2F aVertices[2];

    uint32 uiDiffuse = cfDiffuse.pack_argb8888();

    const float fOff = -0.5f;

    aVertices[0].color.dcolor = uiDiffuse;
    aVertices[0].xyz = Vec3(fX1+fOff, fY1+fOff, 0.0f);
    aVertices[0].st = Vec2(0, 0);

    aVertices[1].color.dcolor = uiDiffuse;
    aVertices[1].xyz = Vec3(fX2+fOff, fY2+fOff, 0.0f);
    aVertices[1].st = Vec2(1, 1);

    m_pRenderer->SelectTMU(0);

    /*
    if(iTextureID)
    {
    m_pRenderer->EnableTMU(true);
    m_pRenderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0);
    m_pRenderer->SetTexture(iTextureID);
    }
    else
    */
    {
        m_pRenderer->EnableTMU(false);
        m_pRenderer->SetWhiteTexture();
    }

    uint16 ausIndices[] = {0,1};

    m_pRenderer->DrawDynVB(aVertices,ausIndices,2,2,eptLineList);

#else

    const float fOff = 0.0f;

    m_pLayoutManager->ConvertFromVirtualToNormalisedScreenSpace( &fX1, &fY1 );
    m_pLayoutManager->ConvertFromVirtualToNormalisedScreenSpace( &fX2, &fY2 );

    const Vec3 p1(fX1+fOff, fY1+fOff, 0.0f);
    const Vec3 p2(fX2+fOff, fY2+fOff, 0.0f);

    const ColorB lineCol = cfDiffuse;

    m_pAuxGeom->DrawLine( p1, lineCol, p2, lineCol, 1.0f );
#endif
}
Exemple #8
0
	RectF TextureRegion::draw(const double x, const double y, const ColorF& diffuse) const
	{
		Siv3DEngine::GetRenderer2D()->addTextureRegion(
			texture,
			{ x, y, x + size.x, y + size.y },
			uvRect,
			diffuse.toFloat4()
		);

		return RectF{ x, y, size };
	}
Exemple #9
0
	RectF TextureRegion::drawAt(const double x, const double y, const ColorF& diffuse) const
	{
		const Vec2 sizeHalf = size * 0.5;

		Siv3DEngine::GetRenderer2D()->addTextureRegion(
			texture,
			{ x - sizeHalf.x, y - sizeHalf.y, x + sizeHalf.x, y + sizeHalf.y },
			uvRect,
			diffuse.toFloat4()
		);

		return RectF{ x - sizeHalf.x, y - sizeHalf.y, size };
	}
Exemple #10
0
//-----------------------------------------------------------------------------------------------------
void C2DRenderUtils::InternalDrawTriangle(float fX0,float fY0,float fX1,float fY1,float fX2,float fY2,const ColorF& cfColor)
{
#if C2DRU_USE_DVN_VB

    m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &fX0, &fY0 );
    m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &fX1, &fY1 );
    m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &fX2, &fY2 );

    SVF_P3F_C4B_T2F aVertices[3];

    uint32 uiColor = cfColor.pack_argb8888();

    const float fOff = -0.5f;

    aVertices[0].color.dcolor = uiColor;
    aVertices[0].xyz = Vec3(fX0+fOff, fY0+fOff, 0.0f);
    aVertices[0].st = Vec2(0, 0);

    aVertices[1].color.dcolor = uiColor;
    aVertices[1].xyz = Vec3(fX1+fOff, fY1+fOff, 0.0f);
    aVertices[1].st = Vec2(0, 0);

    aVertices[2].color.dcolor = uiColor;
    aVertices[2].xyz = Vec3(fX2+fOff, fY2+fOff, 0.0f);
    aVertices[2].st = Vec2(0, 0);

    uint16 ausIndices[] = {0,1,2};

    m_pRenderer->SetWhiteTexture();
    m_pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST);
    m_pRenderer->DrawDynVB(aVertices,ausIndices,3,sizeof(ausIndices)/sizeof(ausIndices[0]),eptTriangleList);

#else // C2DRU_USE_DVN_VB

    const float fOff = 0.0;

    m_pLayoutManager->ConvertFromVirtualToNormalisedScreenSpace( &fX0, &fY0 );
    m_pLayoutManager->ConvertFromVirtualToNormalisedScreenSpace( &fX1, &fY1 );
    m_pLayoutManager->ConvertFromVirtualToNormalisedScreenSpace( &fX2, &fY2 );

    Vec3 p0(fX0+fOff, fY0+fOff, 0.0f);
    Vec3 p1(fX1+fOff, fY1+fOff, 0.0f);
    Vec3 p2(fX2+fOff, fY2+fOff, 0.0f);
    //std::swap(p0.y,p0.z);
    //std::swap(p1.y,p1.z);
    //std::swap(p2.y,p2.z);
    m_pAuxGeom->DrawTriangle( p0, cfColor, p1, cfColor, p2, cfColor );
#endif // C2DRU_USE_DVN_VB
}
Exemple #11
0
	RectF TextureRegion::drawClipped(const double x, const double y, const RectF& clipRect, const ColorF& diffuse) const
	{
		const double clipRight = clipRect.x + clipRect.w;
		const double clipBottom = clipRect.y + clipRect.h;

		const double left = std::max(x, clipRect.x);
		const double right = std::min(x + size.x, clipRight);
		const double top = std::max(y, clipRect.y);
		const double bottom = std::min(y + size.y, clipBottom);

		if (clipRight <= left
			|| right <= clipRect.x
			|| clipBottom <= top
			|| bottom <= clipRect.y)
		{
			return RectF(left, top, 0, 0);
		}

		const float xLeftTrimmed	= static_cast<float>(left - x);
		const float xRightTrimmed	= static_cast<float>((x + size.x) - right);
		const float yTopTrimmed		= static_cast<float>(top - y);
		const float yBottomTrimmed	= static_cast<float>((y + size.y) - bottom);

		const float uLeftTrimmed	= xLeftTrimmed / size.x * (uvRect.right - uvRect.left);
		const float uRightTrimmed	= xRightTrimmed / size.x * (uvRect.right - uvRect.left);
		const float vTopTrimmed		= yTopTrimmed / size.y * (uvRect.bottom - uvRect.top);
		const float vBottomTrimmed	= yBottomTrimmed / size.y * (uvRect.bottom - uvRect.top);

		Siv3DEngine::GetRenderer2D()->addTextureRegion(
			texture,
			FloatRect(left, top, right, bottom),
			FloatRect(uvRect.left + uLeftTrimmed, uvRect.top + vTopTrimmed, uvRect.right - uRightTrimmed, uvRect.bottom - vBottomTrimmed),
			diffuse.toFloat4()
		);

		return RectF(left, top, right - left, bottom - top);
	}
Exemple #12
0
void TimeOfDay::_initColors()
{
   // NOTE: The elevation targets represent distances 
   // from PI/2 radians (strait up).

   ColorF c;
   ColorF bc;

   // e is for elevation
   F32 e = M_PI_F / 13.0f; // (semicircle in radians)/(number of color target entries);

   // Day
   c.set(1.0f,1.0f,1.0f);
   _addColorTarget(0, c, 1.0f, c); // High noon at equanox
   c.set(.9f,.9f,.9f);
   _addColorTarget(e * 1.0f, c, 1.0f, c);
   c.set(.9f,.9f,.9f);
   _addColorTarget(e * 2.0f, c, 1.0f, c);
   c.set(.8f,.75f,.75f);
   _addColorTarget(e * 3.0f, c, 1.0f, c);
   c.set(.7f,.65f,.65f);
   _addColorTarget(e * 4.0f, c, 1.0f, c);

   //Dawn and Dusk (3 entries)
   c.set(.7f,.65f,.65f);
   bc.set(.8f,.6f,.3f);
   _addColorTarget(e * 5.0f, c, 3.0f, bc);
   c.set(.65f,.54f,.4f);
   bc.set(.75f,.5f,.4f);
   _addColorTarget(e * 6.0f, c, 2.75f, bc);
   c.set(.55f,.45f,.25f);
   bc.set(.65f,.3f,.3f);
   _addColorTarget(e * 7.0f, c, 2.5f, bc);

   //NIGHT
   c.set(.3f,.3f,.3f);
   bc.set(.7f,.4f,.2f);
   _addColorTarget(e * 8.0f, c, 1.25f, bc);
   c.set(.25f,.25f,.3f);
   bc.set(.8f,.3f,.2f);
   _addColorTarget(e * 9.0f, c, 1.00f, bc);
   c.set(.25f,.25f,.4f);
   _addColorTarget(e * 10.0f, c, 1.0f, c);
   c.set(.2f,.2f,.35f);
   _addColorTarget(e * 11.0f, c, 1.0f, c);
   c.set(.15f,.15f,.2f);
   _addColorTarget(M_PI_F, c, 1.0f, c); // Midnight at equanox.
}
Exemple #13
0
//-----------------------------------------------------------------------
void gkAuxRenderer::SetDrawColor( ColorF& color )
{
	m_curColor = (DWORD)color.pack_argb8888();
}
Exemple #14
0
//-----------------------------------------------------------------------------------------------------
void C2DRenderUtils::InternalDrawQuad(	float fX, float fY,
                                        float fSizeX, float fSizeY,
                                        const ColorF& cfDiffuse,
#                                   if C2DRU_USE_DVN_VB
                                        const ColorF& cfDiffuseTL,
                                        const ColorF& cfDiffuseTR,
                                        const ColorF& cfDiffuseDL,
                                        const ColorF& cfDiffuseDR,
#                                   endif // C2DRU_USE_DVN_VB
                                        int iTextureID
#                                   if C2DRU_USE_DVN_VB
                                        ,
                                        float fUTexCoordsTL, float fVTexCoordsTL,
                                        float fUTexCoordsTR, float fVTexCoordsTR,
                                        float fUTexCoordsDL, float fVTexCoordsDL,
                                        float fUTexCoordsDR, float fVTexCoordsDR
#                                    endif
                                     )
{
#if C2DRU_USE_DVN_VB
    SVF_P3F_C4B_T2F aVertices[4];
#endif

    const float fOff = 0.0f;//-0.5f;

    Vec2 p1( fX+fOff, fY+fOff );
    Vec2 p2( fX+fSizeX+fOff, fY+fSizeY+fOff );
    m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &(p1.x), &(p1.y) );
    m_pLayoutManager->ConvertFromVirtualToRenderScreenSpace( &(p2.x), &(p2.y) );
    const float z  = 0.0f;

    uint32 uiDiffuse = cfDiffuse.pack_argb8888();
#if C2DRU_USE_DVN_VB
    uint32 uiDiffuseTL = cfDiffuseTL.pack_argb8888();
    uint32 uiDiffuseTR = cfDiffuseTR.pack_argb8888();
    uint32 uiDiffuseDL = cfDiffuseDL.pack_argb8888();
    uint32 uiDiffuseDR = cfDiffuseDR.pack_argb8888();

    aVertices[0].color.dcolor = uiDiffuse ? uiDiffuse : uiDiffuseTL;
    aVertices[0].xyz = Vec3( p1.x, p1.y, z );
    aVertices[0].st = Vec2(fUTexCoordsTL, fVTexCoordsTL);

    aVertices[1].color.dcolor = uiDiffuse ? uiDiffuse : uiDiffuseTR;
    aVertices[1].xyz = Vec3( p2.x, p1.y, z );
    aVertices[1].st = Vec2(fUTexCoordsTR, fVTexCoordsTR);

    aVertices[2].color.dcolor = uiDiffuse ? uiDiffuse : uiDiffuseDL;
    aVertices[2].xyz = Vec3( p1.x, p2.y, z );
    aVertices[2].st = Vec2(fUTexCoordsDL, fVTexCoordsDL);

    aVertices[3].color.dcolor = uiDiffuse ? uiDiffuse : uiDiffuseDR;
    aVertices[3].xyz = Vec3( p2.x, p2.y, z );
    aVertices[3].st = Vec2(fUTexCoordsDR, fVTexCoordsDR);

    m_pRenderer->SelectTMU(0);

    if(iTextureID >= 0)
    {
        m_pRenderer->EnableTMU(true);
        m_pRenderer->SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0);
        m_pRenderer->SetTexture(iTextureID);
    }
    else
    {
        m_pRenderer->EnableTMU(false);
        m_pRenderer->SetWhiteTexture(); // needed for XBox? Seems to use previous texture otherwise.
    }

    uint16 ausIndices[] = {0,1,2,3};

    m_pRenderer->SetState(GS_BLSRC_SRCALPHA | GS_BLDST_ONEMINUSSRCALPHA | GS_NODEPTHTEST);
    //m_pRenderer->DrawDynVB(aVertices,ausIndices,4,4,R_PRIMV_TRIANGLE_STRIP);
#else
    InternalDrawImage(iTextureID,fX,fY,fSizeX,fSizeY,0.0f,cfDiffuse,0,0,1,1);
#endif //C2DRU_USE_DVN_VB
}
Exemple #15
0
 inline void tglColor(const ColorF& color)
 {
     // Colors are floating-point values.
     glColor4f(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
 }