UI_base* W_colorBand::OnLButtonDown(int x, int y) { if (Hittest(x,y)) { colorbandItem* pCurrentColorbandItem; for(std::list<colorbandItem*>::iterator iter = listofcolorbandItems.begin(); iter != listofcolorbandItems.end(); iter ++) { pCurrentColorbandItem = *iter; if (y > posy - height+pCurrentColorbandItem->pos*height-4.0f && y < posy - height+pCurrentColorbandItem->pos*height+4.0f) { if (pActiveColorBandItem != pCurrentColorbandItem) { pActiveColorBandItem = pCurrentColorbandItem; } draggingcolorbandItem = true; pInterceptChild = this; return this; } } if (!draggingcolorbandItem) { float r,g,b,a; GetColorAt(&r,&g,&b,&a,(float)(y+height-posy)/(float)(height)); colorbandItem* tempnode = NewColorbandItem((float)(y+height-posy)/(float)(height),r,g,b,a); listofcolorbandItems.push_back( tempnode); SortList(); pActiveColorBandItem = tempnode; //if (pParentUI_base) pParentUI_base->Callback(this,2); draggingcolorbandItem = true; pInterceptChild = this; return this; } } pInterceptChild = 0; return 0; }
SFVEC3F CPOSTSHADER_SSAO::Shade( const SFVEC2I &aShaderPos ) const { // Test source code //return SFVEC3F( GetShadowFactorAt( aShaderPos ) ); //return GetColorAt( aShaderPos ); //return SFVEC3F( 1.0f - GetDepthNormalizedAt( aShaderPos ) ); //return SFVEC3F( (1.0f / GetDepthAt( aShaderPos )) * 0.5f ); //return SFVEC3F( 1.0f - GetDepthNormalizedAt( aShaderPos ) + // (1.0f / GetDepthAt( aShaderPos )) * 0.5f ); #if 1 float cdepth = GetDepthAt( aShaderPos ); if( cdepth > FLT_EPSILON ) { float cNormalizedDepth = GetDepthNormalizedAt( aShaderPos ); wxASSERT( cNormalizedDepth <= 1.0f ); wxASSERT( cNormalizedDepth >= 0.0f ); cdepth = ( (1.50f - cNormalizedDepth) + ( 1.0f - (1.0f / (cdepth + 1.0f) ) ) * 2.5f ); // Test source code //cdepth = ( (1.75f - cNormalizedDepth) + (1.0f / cdepth) * 2.0f ); //cdepth = 1.5f - cNormalizedDepth; //cdepth = (1.0f / cdepth) * 2.0f; // read current normal,position and color. const SFVEC3F n = GetNormalAt( aShaderPos ); const SFVEC3F p = GetPositionAt( aShaderPos ); //const SFVEC3F col = GetColorAt( aShaderPos ); const float shadowFactor = GetShadowFactorAt( aShaderPos ); // initialize variables: float ao = 0.0f; SFVEC3F gi = SFVEC3F(0.0f); // This calculated the "window range" of the shader. So it will get // more or less sparsed samples const int incx = 3; const int incy = 3; //3 rounds of 8 samples each. for( unsigned int i = 0; i < 3; ++i ) { static const int mask[3] = { 0x01, 0x03, 0x03 }; const int pw = 1 + (Fast_rand() & mask[i]); const int ph = 1 + (Fast_rand() & mask[i]); const int npw = (int)((pw + incx * i) * cdepth ); const int nph = (int)((ph + incy * i) * cdepth ); const SFVEC3F ddiff = GetPositionAt( aShaderPos + SFVEC2I( npw, nph ) ) - p; const SFVEC3F ddiff2 = GetPositionAt( aShaderPos + SFVEC2I( npw,-nph ) ) - p; const SFVEC3F ddiff3 = GetPositionAt( aShaderPos + SFVEC2I(-npw, nph ) ) - p; const SFVEC3F ddiff4 = GetPositionAt( aShaderPos + SFVEC2I(-npw,-nph ) ) - p; const SFVEC3F ddiff5 = GetPositionAt( aShaderPos + SFVEC2I( 0, nph ) ) - p; const SFVEC3F ddiff6 = GetPositionAt( aShaderPos + SFVEC2I( 0,-nph ) ) - p; const SFVEC3F ddiff7 = GetPositionAt( aShaderPos + SFVEC2I( npw, 0 ) ) - p; const SFVEC3F ddiff8 = GetPositionAt( aShaderPos + SFVEC2I(-npw, 0 ) ) - p; ao+= aoFF( aShaderPos, ddiff , n, npw, nph, shadowFactor ); ao+= aoFF( aShaderPos, ddiff2, n, npw,-nph, shadowFactor ); ao+= aoFF( aShaderPos, ddiff3, n, -npw, nph, shadowFactor ); ao+= aoFF( aShaderPos, ddiff4, n, -npw,-nph, shadowFactor ); ao+= aoFF( aShaderPos, ddiff5, n, 0, nph, shadowFactor ); ao+= aoFF( aShaderPos, ddiff6, n, 0,-nph, shadowFactor ); ao+= aoFF( aShaderPos, ddiff7, n, npw, 0, shadowFactor ); ao+= aoFF( aShaderPos, ddiff8, n, -npw, 0, shadowFactor ); gi+= giFF( aShaderPos, ddiff , n, npw, nph) * giColorCurve( GetColorAt( aShaderPos + SFVEC2I( npw, nph ) ) ); gi+= giFF( aShaderPos, ddiff2, n, npw, -nph) * giColorCurve( GetColorAt( aShaderPos + SFVEC2I( npw,-nph ) ) ); gi+= giFF( aShaderPos, ddiff3, n,-npw, nph) * giColorCurve( GetColorAt( aShaderPos + SFVEC2I( -npw, nph ) ) ); gi+= giFF( aShaderPos, ddiff4, n,-npw, -nph) * giColorCurve( GetColorAt( aShaderPos + SFVEC2I( -npw,-nph ) ) ); gi+= giFF( aShaderPos, ddiff5, n, 0.0f, nph) * giColorCurve( GetColorAt( aShaderPos + SFVEC2I( 0, nph ) ) ); gi+= giFF( aShaderPos, ddiff6, n, 0.0f,-nph) * giColorCurve( GetColorAt( aShaderPos + SFVEC2I( 0,-nph ) ) ); gi+= giFF( aShaderPos, ddiff7, n, npw, 0.0f) * giColorCurve( GetColorAt( aShaderPos + SFVEC2I( npw, 0) ) ); gi+= giFF( aShaderPos, ddiff8, n,-npw, 0.0f) * giColorCurve( GetColorAt( aShaderPos + SFVEC2I( -npw, 0) ) ); } ao = (ao / 24.0f) + 0.0f; // Apply a bias for the ambient oclusion gi = (gi * 5.0f / 24.0f); // Apply a bias for the global illumination //return SFVEC3F(ao); return SFVEC3F( SFVEC3F(ao) - gi); // Test source code //return SFVEC3F( col ); //return SFVEC3F( col - SFVEC3F(ao) + gi * 5.0f ); //return SFVEC3F( SFVEC3F(1.0f) - SFVEC3F(ao) + gi * 5.0f ); //return SFVEC3F(cdepth); //return 1.0f - SFVEC3F(ao); //return SFVEC3F(ao); } else return SFVEC3F(0.0f); #endif }