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


C++ Spectrum::HasNaNs方法代码示例

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


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

示例1: AddSplat

void Film::AddSplat(const Point2f &p, const Spectrum &v) {
    if (v.HasNaNs()) {
        Warning("Film ignoring splatted spectrum with NaN values");
        return;
    }
    ProfilePhase pp(Prof::SplatFilm);
    if (!InsideExclusive((Point2i)p, croppedPixelBounds)) return;
    Float xyz[3];
    v.ToXYZ(xyz);
    Pixel &pixel = GetPixel((Point2i)p);
    for (int i = 0; i < 3; ++i) pixel.splatXYZ[i].Add(xyz[i]);
}
开发者ID:Drooids,项目名称:pbrt-v3,代码行数:12,代码来源:film.cpp

示例2: EstimateDirectIllumination


//.........这里部分代码省略.........
		// light source sampling evaluation
		Objects * light;
		light = thisScene->AquireOneOfEmissiveObjects();


		double light_pdf = 0; // to be added
		double brdf_pdf = 0;
		double light_weight = 0;
		double brdf_weight = 0;

		Pnt3D pointOnLight;
		int i = 0;
		while ( i < 2 && occludedByObjects == true )
		{
			pointOnLight = light->samplePointOnObject();
			occludedByObjects = thisScene->Occluded(
				intersectionInfo->intersectionPoint,
				pointOnLight,
				light
			);

			i++;
		}

		if ( occludedByObjects == false )
		{
			newRayDirection = pointOnLight - intersectionInfo->intersectionPoint;

			brdf->BRDF(
				ray.direction,
				newRayDirection,
				attenuationFactor
			);

			attenuationFactor.Scaled_by_Spectrum_Value( obj->material_type->color );

			// light pdf 
			light_pdf = light->PDF_in_solid_angle ( pointOnLight, intersectionInfo->intersectionPoint, newRayDirection );

			//	brdf_pdf = obj->brdf_model->PDF ( ray.direction , newRayDirection );

			// geomery term????
			// according to PBRT page 765, geometric term cancel out ???

			Vector normal_on_light;
			light->getNormalDirection( pointOnLight, normal_on_light );
			double geometryTerm = GeometricTerm( ray, normalDirection, pointOnLight, normal_on_light );

			lightIntensity = light->emission;
			lightSourceSamplingContribution =
				Attenuate_Light_Spectrum(
					attenuationFactor,
					lightIntensity
				) * geometryTerm / light_pdf;
		}

		// evaluate BRDF sampling
		if ( light->isDeltaEmitter == false )
		{
			attenuationFactor = brdf->SampleBRDF(
				ray.direction,
				newRayDirection,
				normalDirection
			);

			Ray newRay( intersectionInfo->intersectionPoint, newRayDirection );

			Intersection newIntersectionInfo;

			if ( thisScene->IntersectionWithScene( newRay, newIntersectionInfo ) )
				if ( newIntersectionInfo.object->emitter == true )
				{
					{
						brdf_pdf = obj->brdf_model->PDF( ray.direction, newIntersectionInfo.normal, newRayDirection );
						//	weight = BalanceHeuristic ( 1 , brdf_pdf , 1 , light_pdf );
						attenuationFactor.Scaled_by_Spectrum_Value( obj->material_type->color );

						double cos_i = AbsDot( ray.direction, normalDirection );

						brdfSamplingContribution += Attenuate_Light_Spectrum(
							attenuationFactor,
							newIntersectionInfo.object->emission
						) * cos_i / brdf_pdf;
					}
				}
		}

		light_weight = light_pdf / ( brdf_pdf + light_pdf );
		brdf_weight = brdf_pdf / ( brdf_pdf + light_pdf );

		intensity += lightSourceSamplingContribution * light_weight;
		intensity += brdfSamplingContribution * brdf_weight;

		if ( intensity.HasNaNs() )
		//	printf ( "has nan" );
			return Spectrum();

		return intensity;
	}
}
开发者ID:wangchi87,项目名称:Chi_render_vs2015,代码行数:101,代码来源:LightTransSim.cpp


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