当前位置: 首页>>代码示例>>C++>>正文


C++ ShadeContext类代码示例

本文整理汇总了C++中ShadeContext的典型用法代码示例。如果您正苦于以下问题:C++ ShadeContext类的具体用法?C++ ShadeContext怎么用?C++ ShadeContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ShadeContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: EvalColor

AColor mrTwoSidedShader::EvalColor(ShadeContext& sc) {

	// Provide a good default for this (for the material editor peview)... 
	// Use the front color for the top half of the screen the the back color 
	// for the bottom half.
	if(m_mainPB != NULL) {
		Point2 screenUV;
		Point2 screenDUV;
		sc.ScreenUV(screenUV, screenDUV);

		// Front map is used for top part of the image
		bool useFront = (screenUV.y > 0.5f);

		TimeValue t = sc.CurTime();
		BOOL mapOn = m_mainPB->GetInt(useFront ? kMainPID_FrontMapOn : kMainPID_BackMapOn, t);
		if(mapOn) {
			Texmap* map = m_mainPB->GetTexmap(useFront ? kMainPID_FrontMap : kMainPID_BackMap, t);
			if(map != NULL) {
				return map->EvalColor(sc);
			}
		}

		// Return the color only
		AColor col = m_mainPB->GetAColor(useFront ? kMainPID_FrontColor : kMainPID_BackColor, t);
		return col;
	}
	
	return AColor(0,0,0);
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:29,代码来源:mrTwoSidedShader.cpp

示例2: EvalColor

RGBA Noise::EvalColor(ShadeContext& sc) {
	Point3 p,dp;
	if (!sc.doMaps) return black;

	AColor c;
	if (sc.GetCache(this,c)) 
		return c; 

	if (gbufID) sc.SetGBufferID(gbufID);

	//IPoint2 ps = sc.ScreenCoord();
  	UpdateCache(sc.CurTime());  // DS 10/3/00
	xyzGen->GetXYZ(sc,p,dp);
	p /= size;	   
	filter = sc.filterMaps;
	
	float smw;
	float limlev = LimitLevel(dp,smw);
    float d = NoiseFunction(p,limlev,smw);

	RGBA c0 = mapOn[0]&&subTex[0] ? subTex[0]->EvalColor(sc): col[0];
	RGBA c1 = mapOn[1]&&subTex[1] ? subTex[1]->EvalColor(sc): col[1];
	c = texout->Filter((1.0f-d)*c0 + d*c1);
	
	sc.PutCache(this,c); 
	return c;
	}
开发者ID:artemeliy,项目名称:inf4715,代码行数:27,代码来源:noise.cpp

示例3: EvalColor

AColor BerconNoise::EvalColor(ShadeContext& sc) {
	if (!sc.doMaps) return black;
	
	AColor c;
	if (sc.GetCache(this,c)) 
		return c; 	
	if (gbufID) sc.SetGBufferID(gbufID);

	// UVW and Distortion
	Point3 p, dpdx, dpdy, dp;	
	if(!berconXYZ.get(sc, p, dpdx, dpdy)) return AColor(0,0,0,0);

	if (useDistortion)
		applyDistortion(sc,p);	
	float nSize = (mapOn[4] && subtex[4]) ? subtex[4]->EvalMono(sc)*size : size;
	p /= nSize; dpdx /= nSize; dpdy /= nSize;
	
	Noise::alterUVW(p, uvwDist);
	NoiseParams np = EvalParameters(&sc);
		
	// Caluclate noise function
	float d = sc.filterMaps ? Noise::limitedNoise(p, dpdx, dpdy, np) : Noise::limitedNoise(p, np);	
	if (useCurve)
		d = curve->GetControlCurve(0)->GetValue(sc.CurTime(), d);

	// Get colors
	RGBA c0 = mapOn[0]&&subtex[0] ? subtex[0]->EvalColor(sc): col[0];
	RGBA c1 = mapOn[1]&&subtex[1] ? subtex[1]->EvalColor(sc): col[1];				
	c = texout->Filter((1.f-d)*c0 + d*c1);

	// Cache
	sc.PutCache(this,c); 
	return c;	
}
开发者ID:GeorgeR,项目名称:BerconMaps,代码行数:34,代码来源:BerconNoise.cpp

示例4: seedRandomGen

// Seed random number generator		
void BerconGradient::seedRandomGen(ShadeContext& sc) {
	int seed = 1;
	if (previewMatIDMode) {
		seed = sc.mtlNum;
	} else {
		if (p_randMat) { 		
			seed += sc.mtlNum;
		}
		if (p_randObj) {
			int hand = (int)sc.Node()->GetHandle();
			seed += hand*(hand*hand*15731 + 789221);
		}
		if (p_randPar) {
			Object *ob = sc.GetEvalObject();		
			if (ob && ob->IsParticleSystem()) {
				ParticleObject *obj = (ParticleObject*)ob;
				IChkMtlAPI* chkMtlAPI = static_cast<IChkMtlAPI*>(obj->GetInterface(I_NEWMTLINTERFACE));
				if ((chkMtlAPI && chkMtlAPI->SupportsParticleIDbyFace())) {
					int id = chkMtlAPI->GetParticleFromFace(sc.FaceNumber());
					seed += id*(id*id*571 + 789221);
				}			
			}
		}
		if (p_randTile) {
			seed += (int)(sc.UVW(99).z);
		}
	}

	seed *= p_seed;
	srand(seed*(seed*seed*15731 + 789221));	
}
开发者ID:GeorgeR,项目名称:BerconMaps,代码行数:32,代码来源:BerconGradient.cpp

示例5: Shade

void DumMtl::Shade(ShadeContext& sc)
{
	Color lightCol;
	Color diffwk(0.0f,0.0f,0.0f);
	Color specwk(0.0f,0.0f,0.0f);
	Point3 N = sc.Normal();
	Point3	R = sc.ReflectVector();
	LightDesc *l;
	for (int i = 0; i<sc.nLights; i++) {
		l = sc.Light(i);
		register float NL, diffCoef;
		Point3 L;
		if (!l->Illuminate(sc, N, lightCol, L, NL, diffCoef))
			continue;

		// diffuse
		if (l->affectDiffuse)
			diffwk += diffCoef*lightCol;
		// specular
		if (l->affectSpecular) {
			float c = DotProd(L,R);
			if (c>0.0f) {
				c = (float)pow((double)c, (double)phongexp); 
				specwk += c*lightCol*NL;   // multiply by NL to SOFTEN 
			}
		}
	}
	sc.out.t = Color(0.0f,0.0f,0.0f);
	sc.out.c = (.3f*sc.ambientLight + diffwk)*diff + specwk*spec;		
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:30,代码来源:evalcol.cpp

示例6: AffectReflection

void StraussShader::AffectReflection(ShadeContext &sc, IllumParams &ip, Color &rClr ) 
{
   float opac = ip.channels[ S_TR ].r;
   float g = ip.channels[ S_GL ].r;
   float m = ip.channels[ S_MT ].r;
   Color Cd = ip.channels[ S_DI ];

   float rn = opac - (1.0f - g * g * g) * opac;

   // the reflection of the reflection vector is just the view vector
   // so dot(v, r) is 1, to any power is still 1
   float a, b;
// NB: this has been transformed for existing in-pointing v
   float NV = Dot( sc.V(), sc.Normal() );
   Point3 R = sc.V() - 2.0f * NV * sc.Normal();
   float NR = Dot( sc.Normal(), R );
      a = (float)acos( NR ) * OneOverHalfPi;
      b = (float)acos( NV ) * OneOverHalfPi;
            
   float fa = F( a );
   float j = fa * G( a ) * G( b );
   float rj = Bound( rn + (rn+kj)*j );
   Color white( 1.0f, 1.0f, 1.0f );

   Color Cs = white + m * (1.0f - fa) * (Cd - white);
   rClr *= Cs * rj * REFL_BRIGHTNESS_ADJUST;
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:27,代码来源:shaderstrauss.cpp

示例7: if

//????????????????????????????????????????????????????????????????????????
// The submat with a higher index "cover" the ones "below".
// If the first submat taken from the end of the array has amount == 100,
// that's al it matters. Otherwise all until the second consecutive submat
// with amount == 100 matter
//
bool CompositeMat::IsOutputConst
( 
	ShadeContext& sc, // describes context of evaluation
	int stdID				// must be ID_AM, ect
)
{
	Mtl *sm = NULL;
	int numSubMatOn = 0;
	int numConsec = 0;
	bool bIsConst = true;
	Interval iv;

	// Iterate through the submats in reverse order because that is
	// the order of their significance
	for (int i = MAX_NUM_MTLS-1; i >= 0; i--)
	{
		BOOL enabled;
		float amount;
		
		// The first one is always enabled
		if ( i == 0 ) 
			enabled = 1;
		else 
			pblock2->GetValue( compmat_map_on, sc.CurTime(), enabled, iv, i-1 );
		
		if ( enabled )
		{
			pblock2->GetValue( compmat_mtls, sc.CurTime(), sm, iv, i );
			if ( sm != NULL ) 
			{
				numSubMatOn++;

				// All of the first on is always composited
				if ( i == 0 ) 
					amount = 100.f;
				else 
					pblock2->GetValue( compmat_amount, sc.CurTime(), amount, iv, i-1 );
				
				if ( numSubMatOn == 1 && amount == 100.0f )
					return sm->IsOutputConst( sc, stdID );
				else
				{
					if ( amount == 100.0f )
						numConsec++;
					else
						numConsec = 0;
					bool b = sm->IsOutputConst( sc, stdID );
					bIsConst = (bIsConst && b );
					if ( !bIsConst )
						return bIsConst;
					else if ( numConsec == 2 )
						return bIsConst;
				}
			}
		}
	}
	return bIsConst;
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:64,代码来源:composite_material.cpp

示例8: PostShade

void Matte::PostShade(ShadeContext& sc, IReshadeFragment* pFrag, int& nextTexIndex, IllumParams*)
{
   Color c,t;
   float atten;

   if (!opaque)
      sc.Execute(0x1000); // DS: 6/24/99:use black bg when AA filtering (#192348)

   sc.GetBGColor(c,t,fogBG && !fogObjDepth);
   if (!opaque)
      sc.Execute(0x1001); // DS: 6/24/99:use black bg when AA filtering (#192348)

   if (shadowBG && sc.shadow)
   {
//    sc.shadow = 0;
//    Color col0 = sc.DiffuseIllum();
//    sc.shadow = 1;
//    Color scol = sc.DiffuseIllum();
//    float f = Intens(col0);
//    atten = (f>0.0f)?Intens(scol)/f:1.0f;
//    if (atten>1.0f) atten = 1.0f/atten;
//    atten = amblev+(1.0f-amblev)*atten;
//    sc.out.c = c*atten + (1.0f-atten)*col;
      Color shadowClr;
      atten = IllumShadow( sc, shadowClr );
      atten = amblev + (1.0f-amblev) * atten;

      // key on black user-set shadow clr
      if( gUseLocalShadowClr || col.r != 0.0f || col.g != 0.0f || col.b != 0.0f )
            shadowClr = col;

      c *= atten;
      shadowClr *= 1.0f - atten;

      sc.out.c = c + shadowClr;

      if (shadowAlpha)
         t *= atten;
   } else
      sc.out.c  = c;

   sc.out.t = opaque ? black : t;  
   Clamp(sc.out.t);

   // code for compositing: -1 for opaque , else -2
   sc.out.ior = (opaque) ? -1.0f : -2.0f;
   if( reflmap ){
      if( useReflMap ){
         Color rc = pFrag->GetColorChannel( nextTexIndex++ );
         sc.out.c += rc * reflAmt;
      } else {
         nextTexIndex++;   // skip
      }
   }
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:55,代码来源:matte.cpp

示例9: EvalColor

AColor BerconTile::EvalColor(ShadeContext& sc) {	
	Point3 p;	
	if (!sc.doMaps) return black;

	// If we've already evalutated the color at this point we'll use it and stop here
	AColor c;
	if (sc.GetCache(this,c)) 
		return c; 	
	if (gbufID) sc.SetGBufferID(gbufID);

	// Evaulate maps and tiling parameters
	TileParam t	= EvalParameters(sc);

	// UVW, Distortion and size
	berconXYZ.get(sc,p);
	if (useDistortion) p += getDistVector(sc);
	p /= tileSize;

	// Caluclate tiling	
	TilePoint tp = Tile::draw(p, t);

	// Calculate color	
	if (tp.d < -.5f) // First check if we are on edge		
		c = mapOn[1]&&subtex[1]?subtex[1]->EvalColor(sc): col[1];
	else {
		RGBA c1, c2;

		if (tileParam.mapUV || tileParam.tileID || tileParam.center) { // Then if we map UV coordinates
			
			BerconSC bsc = BerconSC(&sc);			
			if (tileParam.mapUV)
				bsc.setUV1(tp.uvw, uvChan);
			if (tileParam.center)
				bsc.setUV2(tp.center, uvChan2);
			if (tileParam.tileID)
				bsc.setMultiTexture((float)tp.id);

			              c1 = getColor(bsc, 0);
			if (lockEdge) c2 = getColor(bsc, 1);
			else          c2 = getColor(bsc, 2);
		
		} else { // Normal eval
			              c1 = getColor(sc, 0);
			if (lockEdge) c2 = getColor(sc, 1);
			else		  c2 = getColor(sc, 2);
		}
		c = (1.0f-tp.d)*c2 + tp.d*c1;
	}

	c = texout->Filter(c);

	// Cache
	sc.PutCache(this,c); 
	return c;	
}
开发者ID:Bercon,项目名称:BerconMaps,代码行数:55,代码来源:BerconTile.cpp

示例10: EvalColor

AColor Gradient::EvalColor(ShadeContext& sc) {
	if (!sc.doMaps) 
		return black;
	AColor c;
	if (sc.GetCache(this,c)) 
		return c; 
	if (gbufID) sc.SetGBufferID(gbufID);
	c = texout->Filter(uvGen->EvalUVMap(sc,&mysamp));
	sc.PutCache(this,c); 
	return c;
	}
开发者ID:artemeliy,项目名称:inf4715,代码行数:11,代码来源:gradient.cpp

示例11: EvalMono

float Gradient::EvalMono(ShadeContext& sc) {
	if (!sc.doMaps) 
		return 0.0f;
	float f;
	if (sc.GetCache(this,f)) 
		return f; 
	if (gbufID) sc.SetGBufferID(gbufID);
	f = texout->Filter(uvGen->EvalUVMapMono(sc,&mysamp));
	sc.PutCache(this,f); 
	return f;
	}
开发者ID:artemeliy,项目名称:inf4715,代码行数:11,代码来源:gradient.cpp

示例12: EvalNormalPerturb

Point3 Splat::EvalNormalPerturb(ShadeContext& sc) {
    float del, d, f;
    Point3 p, dp, np;

    if (gbufID)
        sc.SetGBufferID(gbufID);

    xyzGen->GetXYZ(sc, p, dp);

    d = splatter(p);
    del = 0.1f;
//	float strength = (abs((int)col[1].r-(int)col[0].r)+
//				abs((int)col[1].g-(int)col[0].g)+
//				abs((int)col[1].b-(int)col[0].b)); ///100.0f; // 756.0f

//	f = strength/del;
    f = 1.0f/del;
    Point3 M[3];
    xyzGen->GetBumpDP(sc,M);
    np.x = f*(splatter(p+del*M[0]) - d);
    np.y = f*(splatter(p+del*M[1]) - d);
    np.z = f*(splatter(p+del*M[2]) - d);

    np = sc.VectorFromNoScale(np,REF_OBJECT);
    Texmap *sub0 = mapOn[0]?subTex[0]:NULL;
    Texmap *sub1 = mapOn[1]?subTex[1]:NULL;
    if (sub0||sub1) {
        // d((1-k)*a + k*b ) = dk*(b-a) + k*(db-da) + da
        float a,b;
        Point3 da,db;
        if (sub0) {
            a = sub0->EvalMono(sc);
            da = sub0->EvalNormalPerturb(sc);
        }
        else {
            a = Intens(col[0]);
            da = Point3(0.0f,0.0f,0.0f);
        }
        if (sub1) {
            b = sub1->EvalMono(sc);
            db = sub1->EvalNormalPerturb(sc);
        }
        else {
            b = Intens(col[1]);
            db= Point3(0.0f,0.0f,0.0f);
        }
        np = (b-a)*np + d*(db-da) + da;
    }
    else
        np *= Intens(col[1])-Intens(col[0]);
    return np;
}
开发者ID:vasilenkomike,项目名称:xray,代码行数:52,代码来源:splat.cpp

示例13: PreShade

void Matte::PreShade(ShadeContext& sc, IReshadeFragment* pFrag)
{
   // save reflection texture
   if ( reflmap ){
      AColor rcol;
      if (reflmap->HandleOwnViewPerturb()) {
         sc.TossCache(reflmap);
         rcol = reflmap->EvalColor(sc);
      } else 
         rcol = sc.EvalEnvironMap(reflmap, sc.ReflectVector());
      pFrag->AddColorChannel( rcol );
   }
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:13,代码来源:matte.cpp

示例14: EvalNormalPerturb

Point3 Water::EvalNormalPerturb(ShadeContext& sc) {
	if (gbufID) 
		sc.SetGBufferID(gbufID);

	Point3 p, dp, np;
	xyzGen->GetXYZ(sc, p, dp);

	VectorWave(p, np);
	Point3 M[3];
	xyzGen->GetBumpDP(sc,M);
	np = Point3( DotProd(np,M[0]),DotProd(np,M[1]),DotProd(np,M[2]));
	return sc.VectorFromNoScale(np,REF_OBJECT);
	}
开发者ID:artemeliy,项目名称:inf4715,代码行数:13,代码来源:water.cpp

示例15: EvalColor

AColor plLayerTex::EvalColor(ShadeContext& sc)
{
    if (!sc.doMaps)
        return AColor(0.0f, 0.0f, 0.0f, 1.0f);

    AColor color;
    if (sc.GetCache(this, color))
        return color;

    if (gbufID)
        sc.SetGBufferID(gbufID);

    //
    // Evaluate the Bitmap
    //
    if (fBitmapPB->GetInt(kBmpUseBitmap) && fBM)
    {
        plBMSampler mysamp(this, fBM);
        color = fUVGen->EvalUVMap(sc, &mysamp, FALSE);
        // We'd like to pass TRUE and actually filter the image, but that seems to be
        // tripping an odd crash in Max internals. *shrug*
    }
    else
        color.White();

    // Invert color if specified
    if (fBitmapPB->GetInt(kBmpInvertColor))
    {
        color.r = 1.0f - color.r;
        color.g = 1.0f - color.g;
        color.b = 1.0f - color.b;
    }
    // Discard color if specified
    if (fBitmapPB->GetInt(kBmpDiscardColor))
        color.r = color.g = color.b = 1.0f;

    // Invert alpha if specified
    if (fBitmapPB->GetInt(kBmpInvertAlpha))
        color.a = 1.0f - color.a;
    // Discard alpha if specified
    if (fBitmapPB->GetInt(kBmpDiscardAlpha))
        color.a = 1.0f;

    // If RGB output is set to alpha, show RGB as grayscale of the alpha
    if (fBitmapPB->GetInt(kBmpRGBOutput) == 1)
        color = AColor(color.a, color.a, color.a, 1.0f);

    sc.PutCache(this, color);
    return color;
}
开发者ID:MareinK,项目名称:Plasma,代码行数:50,代码来源:plLayerTex.cpp


注:本文中的ShadeContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。