// Dump a micro polygon void CqMPDump::dump(const CqMicroPolygon& mp) { CqColor c; short id = 1; if (m_outFile==NULL) { Aqsis::log() << error << "Attempted to write to unopened mpdump file." << std::endl; return; } m_mpcount++; size_t len_written = fwrite((void*)&id, sizeof(short), 1, m_outFile); if(len_written != 1) AQSIS_THROW_XQERROR(XqInvalidFile, EqE_System, "Error writing mpdump file"); // Dump vertices in a funny circular order for backward-compatibility // rather than in the usual bilinear patch type order. CqVector3D P[4]; mp.GetVertices(P); dumpVec3(P[0]); dumpVec3(P[1]); dumpVec3(P[3]); dumpVec3(P[2]); if (mp.pGrid()->pVar(EnvVars_Ci)!=NULL) c = *mp.colColor(); else c = CqColor(0.9,0.9,1); dumpCol(c); if (mp.pGrid()->pVar(EnvVars_Oi)!=NULL) c = *mp.colOpacity(); else c = CqColor(0.9,0.9,1); dumpCol(c); }
void CqShaderExecEnv::SO_crandom( IqShaderData* Result, IqShader* pShader ) { bool __fVarying; TqUint __iGrid; __fVarying=(Result)->Class()==class_varying; __iGrid = 0; const CqBitVector& RS = RunningState(); do { if(!__fVarying || RS.Value( __iGrid ) ) { TqFloat a, b, c; a = m_random.RandomFloat(); b = m_random.RandomFloat(); c = m_random.RandomFloat(); (Result)->SetColor(CqColor(a,b,c),__iGrid); } } while( ( ++__iGrid < shadingPointCount() ) && __fVarying); }
//--------------------------------------------------------------------- void CqImagersource::Initialise( const CqRegion& DRegion, IqChannelBuffer* buffer ) { AQSIS_TIME_SCOPE(Imager_shading); // We use one less than the bucket width and height here, since these // resolutions really represent one less than the number of shaded points // in each direction. (Usually they describe the number of micropolygons // on a grid which is one less than the number of shaded vertices. This // concept has no real analogue in context of an imager shader.) TqInt uGridRes = DRegion.width()-1; TqInt vGridRes = DRegion.height()-1; TqInt x = DRegion.xMin(); TqInt y = DRegion.yMin(); m_uYOrigin = static_cast<TqInt>( y ); m_uXOrigin = static_cast<TqInt>( x ); m_uGridRes = uGridRes; m_vGridRes = vGridRes; TqInt mode = QGetRenderContext() ->poptCurrent()->GetIntegerOption( "System", "DisplayMode" ) [ 0 ]; TqFloat components; TqInt j, i; TqFloat shuttertime = QGetRenderContext() ->poptCurrent()->GetFloatOption( "System", "Shutter" ) [ 0 ]; components = mode & DMode_RGB ? 3 : 0; components += mode & DMode_A ? 1 : 0; components = mode & DMode_Z ? 1 : components; TqInt Uses = ( 1 << EnvVars_P ) | ( 1 << EnvVars_Ci ) | ( 1 << EnvVars_Oi | ( 1 << EnvVars_ncomps ) | ( 1 << EnvVars_time ) | ( 1 << EnvVars_alpha ) | ( 1 << EnvVars_s ) | ( 1 << EnvVars_t ) ); m_pShaderExecEnv->Initialise( uGridRes, vGridRes, uGridRes * vGridRes, (uGridRes+1)*(vGridRes+1), true, IqAttributesPtr(), IqTransformPtr(), m_pShader.get(), Uses ); // Initialise the geometric parameters in the shader exec env. TqInt numShadingPoints = (uGridRes+1) * (vGridRes+1); P() ->Initialise( numShadingPoints ); Ci() ->Initialise( numShadingPoints ); Oi() ->Initialise( numShadingPoints ); alpha() ->Initialise( numShadingPoints ); s() ->Initialise( numShadingPoints ); t() ->Initialise( numShadingPoints ); //TODO dtime is not initialised yet //dtime().Initialise(uGridRes, vGridRes, i); ncomps() ->SetFloat( components ); time() ->SetFloat( shuttertime ); m_pShader->Initialise( uGridRes, vGridRes, (uGridRes+1)*(vGridRes+1), m_pShaderExecEnv.get() ); TqUint CiIndex = buffer->getChannelIndex("Ci"); TqUint OiIndex = buffer->getChannelIndex("Oi"); TqUint coverageIndex = buffer->getChannelIndex("coverage"); for ( j = 0; j < vGridRes+1; j++ ) { for ( i = 0; i < uGridRes+1; i++ ) { TqInt off = j * ( uGridRes + 1 ) + i; P() ->SetPoint( CqVector3D( x + i, y + j, 0.0 ), off ); Ci() ->SetColor( CqColor((*buffer)(i, j, CiIndex)[0], (*buffer)(i, j, CiIndex)[1], (*buffer)(i, j, CiIndex)[2]), off ); CqColor opa((*buffer)(i, j, OiIndex)[0], (*buffer)(i, j, OiIndex)[1], (*buffer)(i, j, OiIndex)[2]); Oi() ->SetColor( opa, off ); TqFloat avopa = ( opa.r() + opa.g() + opa.b() ) /3.0f; alpha() ->SetFloat( (*buffer)(i, j, coverageIndex)[0] * avopa, off ); s() ->SetFloat( x + i + 0.5, off ); t() ->SetFloat( y + j + 0.5, off ); } } // Execute the Shader VM if ( m_pShader ) { m_pShader->Evaluate( m_pShaderExecEnv.get() ); alpha() ->SetFloat( 1.0f ); /* by default 3delight/bmrt set it to 1.0 */ } }
void SqOptionCache::cacheOptions(const IqOptions& opts) { // Filter size const TqFloat* filtSize = opts.GetFloatOption("System", "FilterWidth"); assert(filtSize); xFiltSize = filtSize[0]; yFiltSize = filtSize[1]; // Number of pixel samples. const TqInt* pixelSamps = opts.GetIntegerOption("System", "PixelSamples"); assert(pixelSamps); xSamps = pixelSamps[0]; ySamps = pixelSamps[1]; // Location of the clipping planes. const TqFloat* clipLoc = opts.GetFloatOption("System", "Clipping"); assert(clipLoc); clipNear = clipLoc[0]; clipFar = clipLoc[1]; // Shutter times. const TqFloat* shutterTimes = opts.GetFloatOption("System", "Shutter"); assert(shutterTimes); shutterOpen = shutterTimes[0]; shutterClose = shutterTimes[1]; // Bucket size. xBucketSize = 16; yBucketSize = 16; if(const TqInt* bktSize = opts.GetIntegerOption("limits", "bucketsize")) { xBucketSize = bktSize[0]; yBucketSize = bktSize[1]; } // Eye split bound maxEyeSplits = 10; if(const TqInt* splits = opts.GetIntegerOption("limits", "eyesplits")) maxEyeSplits = splits[0]; // Display mode. const TqInt* dMode = opts.GetIntegerOption("System", "DisplayMode"); assert(dMode); displayMode = static_cast<EqDisplayMode>(dMode[0]); // Depth filter depthFilter = Filter_Min; if(const CqString* filtStr = opts.GetStringOption("Hider", "depthfilter")) { Aqsis::log() << debug << "Depth filter = " << *filtStr << "\n"; if(*filtStr == "min") depthFilter = Filter_Min; else if(*filtStr == "midpoint") depthFilter = Filter_MidPoint; else if(*filtStr == "max") depthFilter = Filter_Max; else if(*filtStr == "average") depthFilter = Filter_Average; else { Aqsis::log() << warning << "Invalid depthfilter \"" << *filtStr << "\", depthfilter set to \"min\"\n"; } } // Cache zthreshold. The default threshold of 1,1,1 means that any objects // which are partially transparent won't appear in shadow maps. zThreshold = CqColor(1.0f); if(const CqColor* zTh = opts.GetColorOption("limits", "zthreshold")) zThreshold = zTh[0]; }