这篇教程C++ Color3函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Color3函数的典型用法代码示例。如果您正苦于以下问题:C++ Color3函数的具体用法?C++ Color3怎么用?C++ Color3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Color3函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: shared_ptr<Image3>& ImageStats::getImageMean(int ft, bool normalize){ if (normalize){ for (int c = 0 ; c < COLOR_CHS ; c++){ m_meanMin[ft][c] = std::numeric_limits<float>::max(); m_meanMax[ft][c] = std::numeric_limits<float>::min(); for (int x = 0 ; x < m_w ; x++){ for (int y = 0 ; y < m_h ; y++){ if ( m_dataMn[ft][c][x][y] < m_meanMin[ft][c]) m_meanMin[ft][c] = m_dataMn[ft][c][x][y]; if ( m_dataMn[ft][c][x][y] > m_meanMax[ft][c]) m_meanMax[ft][c] = m_dataMn[ft][c][x][y]; } } } for (int x = 0 ; x < m_w ; x++) for (int y = 0 ; y < m_h ; y++) m_imageMean[ft]->fastSet(x,y,Color3((m_dataMn[ft][RED][x][y] - m_meanMin[ft][RED])/(m_meanMax[ft][RED] - m_meanMin[ft][RED]), (m_dataMn[ft][GREEN][x][y] - m_meanMin[ft][GREEN])/(m_meanMax[ft][GREEN] - m_meanMin[ft][GREEN]), (m_dataMn[ft][BLUE][x][y] - m_meanMin[ft][BLUE])/(m_meanMax[ft][BLUE] - m_meanMin[ft][BLUE]))); } else{ for (int x = 0 ; x < m_w ; x++) for (int y = 0 ; y < m_h ; y++) m_imageMean[ft]->fastSet(x,y,Color3(m_dataMn[ft][RED][x][y],m_dataMn[ft][GREEN][x][y],m_dataMn[ft][BLUE][x][y])); } return m_imageMean[ft];}
开发者ID:quirozmd,项目名称:ASR-PathTracer,代码行数:25,
示例2: switchExporter::Result Exporter::exportLight(NiNodeRef parent, INode *node, GenLight* light){ TimeValue t = 0; NiLightRef niLight; switch (light->Type()) { case OMNI_LIGHT: { if (light->GetAmbientOnly()) { niLight = new NiAmbientLight(); } else { NiPointLightRef pointLight = new NiPointLight(); float atten = light->GetAtten(t, ATTEN_START); switch (light->GetDecayType()) { case 0: pointLight->SetConstantAttenuation(1.0f); break; case 1: pointLight->SetLinearAttenuation( atten / 4.0f ); break; case 2: pointLight->SetQuadraticAttenuation( sqrt(atten / 4.0f) ); break; } niLight = StaticCast<NiLight>(pointLight); } } break; case TSPOT_LIGHT: case FSPOT_LIGHT: niLight = new NiSpotLight(); break; case DIR_LIGHT: case TDIR_LIGHT: niLight = new NiDirectionalLight(); break; } if (niLight == NULL) return Skip; niLight->SetName(node->GetName()); Matrix3 tm = getObjectTransform(node, t, !mFlattenHierarchy); niLight->SetLocalTransform( TOMATRIX4(tm, false) ); niLight->SetDimmer( light->GetIntensity(0) ); Color3 rgbcolor = TOCOLOR3( light->GetRGBColor(0) ); if (light->GetAmbientOnly()) { niLight->SetDiffuseColor(Color3(0,0,0)); niLight->SetSpecularColor(Color3(0,0,0)); niLight->SetAmbientColor(rgbcolor); } else { niLight->SetDiffuseColor(rgbcolor); niLight->SetSpecularColor(rgbcolor); niLight->SetAmbientColor(Color3(0,0,0)); } parent->AddChild( DynamicCast<NiAVObject>(niLight) ); return Ok;}
开发者ID:Anchoys1,项目名称:max_nif_plugin,代码行数:60,
示例3: Color3 void Triangle::getMaterialProperties(MaterialProp& mp, const real_t mult[3],const Vector2& texCoord, const Material* materials[3]) { mp.diffuse = Color3(0,0,0); mp.ambient = Color3(0,0,0); mp.specular= Color3(0,0,0); mp.refractive_index= 0; mp.texColor = Color3(0,0,0); for ( int i = 0; i < 3; ++i ) { if(materials[i]) { mp.diffuse += materials[i]->diffuse*mult[i]; mp.ambient += materials[i]->ambient*mult[i]; mp.specular += materials[i]->specular*mult[i]; mp.refractive_index += materials[i]->refractive_index*mult[i]; if(materials[i]->get_texture_data()) { int width,height; materials[i]->get_texture_size(&width, &height ); mp.texColor += mult[i]*materials[i]->get_texture_pixel( texCoord[0]*width, texCoord[1]*height); } else mp.texColor+=Color3(1,1,1)*mult[i]; } } }
开发者ID:AbhishekChugh,项目名称:15618_Project,代码行数:30,
示例4: evalFourier3Color3 evalFourier3(float * const coeffs[3], size_t nCoeffs, Float phi) { #if FOURIER_SCALAR == 1 double cosPhi = std::cos((double) phi), cosPhi_prev = cosPhi, cosPhi_cur = 1.0f; double Y = 0, R = 0, B = 0; for (size_t i=0; i<nCoeffs; ++i) { Y += coeffs[0][i] * cosPhi_cur; R += coeffs[1][i] * cosPhi_cur; B += coeffs[2][i] * cosPhi_cur; double cosPhi_next = 2*cosPhi*cosPhi_cur - cosPhi_prev; cosPhi_prev = cosPhi_cur; cosPhi_cur = cosPhi_next; } double G = 1.39829f*Y -0.100913f*B - 0.297375f*R; return Color3((Float) R, (Float) G, (Float) B); #else double cosPhi = std::cos((double) phi); __m256d cosPhi_prev = _mm256_set1_pd(cosPhi), cosPhi_cur = _mm256_set1_pd(1.0), Y = _mm256_set_sd((double) coeffs[0][0]), R = _mm256_set_sd((double) coeffs[1][0]), B = _mm256_set_sd((double) coeffs[2][0]), factorPhi_prev, factorPhi_cur; initializeRecurrence(cosPhi, factorPhi_prev, factorPhi_cur); for (size_t i=1; i<nCoeffs; i+=4) { __m256d cosPhi_next = _mm256_add_pd(_mm256_mul_pd(factorPhi_prev, cosPhi_prev), _mm256_mul_pd(factorPhi_cur, cosPhi_cur)); Y = _mm256_add_pd(Y, _mm256_mul_pd(cosPhi_next, _mm256_cvtps_pd(_mm_load_ps(coeffs[0]+i)))); R = _mm256_add_pd(R, _mm256_mul_pd(cosPhi_next, _mm256_cvtps_pd(_mm_load_ps(coeffs[1]+i)))); B = _mm256_add_pd(B, _mm256_mul_pd(cosPhi_next, _mm256_cvtps_pd(_mm_load_ps(coeffs[2]+i)))); cosPhi_prev = _mm256_splat2_pd(cosPhi_next); cosPhi_cur = _mm256_splat3_pd(cosPhi_next); } MM_ALIGN32 struct { double Y; double R; double B; double unused; } tmp; simd::hadd(Y, R, B, _mm256_setzero_pd(), (double *) &tmp); double G = 1.39829*tmp.Y -0.100913*tmp.B - 0.297375*tmp.R; return Color3((Float) tmp.R, (Float) G, (Float) tmp.B); #endif}
开发者ID:marwan-abdellah,项目名称:layerlab,代码行数:59,
示例5: Color3Material::Material(){ ambient = Color3(0,0,0); diffuse = Color3(0,0,0); specular = Color3(0,0,0); shininess = 1; reflect = Color3(0,0,0); refract = Color3(0,0,0); refract_index = 1;}
开发者ID:mrroach9,项目名称:Raytracing,代码行数:9,
示例6: SpriteSheetshared_ptr<SpriteSheet> SpriteSheet::create(const Any& a, Table<ModelID, shared_ptr<Model> >& modelTable) { a.verifyName("SpriteSheet"); const shared_ptr<SpriteSheet>& s = shared_ptr<SpriteSheet>(new SpriteSheet()); s->m_source = a.source(); AnyTableReader r(a); // Read the textures Texture::Specification spec; if (r.getIfPresent("emissive", spec)) { spec.generateMipMaps = false; spec.encoding.format = ImageFormat::RGBA_DXT5(); s->m_emissive = Texture::create(spec); } else { s->m_emissive = Texture::opaqueBlack(); } if (r.getIfPresent("color", spec)) { spec.generateMipMaps = false; spec.encoding.format = ImageFormat::RGBA_DXT5(); s->m_color = Texture::create(spec); } else { s->m_color = Texture::createColor(Color4unorm8(Color4::zero())); } String bumpFilename; spec = Texture::Specification("<white>"); if (r.getFilenameIfPresent("bump", bumpFilename)) { spec.filename = bumpFilename; } spec.generateMipMaps = false; spec.preprocess = Texture::Preprocess::normalMap(); spec.encoding.format = ImageFormat::RGBA8(); spec.encoding.readMultiplyFirst = Color3(2.0f); spec.encoding.readAddSecond = Color3(-1.0f); s->m_normal = Texture::create(spec); // Read the animation table Table<String, Any> tbl; r.getIfPresent("modelTable", tbl); for (Table<String, Any>::Iterator it = tbl.begin(); it.hasMore(); ++it) { if (modelTable.containsKey(it.key())) { String msg = format("Two models with the same name, '%s': ", it.key().c_str()); msg += format("the first %s:%d and ", modelTable[it.key()]->source().filename.c_str(), modelTable[it.key()]->source().line); msg += format("and the second from %s:%d.", it.value().source().filename.c_str(), it.value().source().line); report(msg, ReportLevel::ERROR); } else { modelTable.set(it.key(), Model::create(s, it.key(), it.value())); } } r.verifyDone(); return s;}
开发者ID:franmgee,项目名称:openheist,代码行数:55,
示例7: Color3/* * Trace a ray, calculating the color of this ray. * This function is called recursively for recursive light. * * @param scene The scene object, which contains all geometries information. * @param recursion The level of recursive light. If the level is larger or * equal to 4, stop recursion. * @param ray_dir Direction vector of ray. * @param ray_pos Start point of ray. * @param tMin Minimum legal time cost for this ray. * @param tMax Maximum legal time cost for this ray. * * @return The color of this ray. */Color3 Raytracer::trace_ray(Scene const*scene, // geometries const int recursion, // recursion level const Vector3 &ray_dir, const Vector3 &ray_pos, // ray const float tMin, const float tMax // ray range ){ // if this function go beyond the last recursive level, stop and return black color. if (recursion <= 0) return Color3(0, 0, 0); // intersection point information HitVertexInfor hit_vertex; // if not hit any geometry, return background color bool bHit = ray_hit(scene, ray_dir, ray_pos, tMin, tMax, hit_vertex); if (!bHit) return scene->background_color; // if hit, compute color and return it Color3 DI_light (0, 0, 0); Color3 reflected_light(0, 0, 0); Color3 refracted_light(0, 0, 0); // 1. direct illumination if (hit_vertex.refractive_index == 0) DI_light = calculate_DI_light(scene, hit_vertex); // 2. reflection light if (hit_vertex.specular != Color3(0, 0, 0)) // avoid non-necessary reflection calculation { // reflection ray direction Vector3 rfl_ray_dir = normalize( ray_dir - 2 * dot(ray_dir, hit_vertex.normal) * hit_vertex.normal); reflected_light = hit_vertex.specular * hit_vertex.tex_color * trace_ray(scene, recursion-1, rfl_ray_dir, hit_vertex.position, SLOPE_FACTOR, 1000000); } if (hit_vertex.refractive_index == 0) // avoid non-necessary refraction calculation return DI_light + reflected_light; // 3. refraction light Vector3 rfr_ray_dir; // refractive ray direction float R; if (refraction_happened(scene, ray_dir, hit_vertex, rfr_ray_dir, R)) refracted_light = hit_vertex.tex_color * trace_ray(scene, recursion-1, rfr_ray_dir, hit_vertex.position, SLOPE_FACTOR, 1000000); return DI_light + R * reflected_light + (1-R) * refracted_light;}
开发者ID:dtbinh,项目名称:AnimViewer,代码行数:66,
示例8: Color3namespace aed {const Color3 Color3::Black = Color3( 0.0, 0.0, 0.0 );const Color3 Color3::White = Color3( 1.0, 1.0, 1.0 );const Color3 Color3::Red = Color3( 1.0, 0.0, 0.0 );const Color3 Color3::Green = Color3( 0.0, 1.0, 0.0 );const Color3 Color3::Blue = Color3( 0.0, 0.0, 1.0 );Color3::Color3( const unsigned char* arr ){ static const real_t inv = 1.0 / 255.0; r = arr[0] * inv; g = arr[1] * inv; b = arr[2] * inv;}void Color3::to_array( unsigned char arr[4] ) const{ // clamp values Color3 tmp = clamp( *this, 0.0, 1.0 ); // convert to ints arr[0] = static_cast<unsigned char>( tmp.r * 0xff ); arr[1] = static_cast<unsigned char>( tmp.g * 0xff ); arr[2] = static_cast<unsigned char>( tmp.b * 0xff ); arr[3] = 0xff;}void Color3::to_array( float arr[DIM] ) const{ arr[0] = float( r ); arr[1] = float( g ); arr[2] = float( b );}Color3 clamp( const Color3& c, real_t min, real_t max ){ return Color3( clamp( c.r, min, max ), clamp( c.g, min, max ), clamp( c.b, min, max ) );}std::ostream& operator<<( std::ostream& os, const Color3& c ){ return os << '(' << c.r << ',' << c.g << ',' << c.b << ')';}} /* aed */
开发者ID:bballmitch2,项目名称:CudaP7,代码行数:50,
示例9: DrawBoxvoid GraphicsLinux::DrawBox(const Color4 &cColor, const Vector2i &vPos1, const Vector2i &vPos2, uint32 nRoundX, uint32 nRoundY){ // Check if native window handle is valid if (m_nNativeWindowHandle) { // Set graphics options ::XGCValues sGCValues; sGCValues.function = GXcopy; sGCValues.foreground = ToolsLinux::GetXColor(Color3(cColor), m_nColorDepth); sGCValues.background = ToolsLinux::GetXColor(Color3(cColor), m_nColorDepth); XChangeGC(m_pDisplay, m_sGC, GCFunction | GCForeground | GCBackground, &sGCValues); // Draw box XFillRectangle(m_pDisplay, m_nNativeWindowHandle, m_sGC, vPos1.x, vPos1.y, vPos2.x-vPos1.x+1, vPos2.y-vPos1.y+1); }}
开发者ID:ByeDream,项目名称:pixellight,代码行数:15,
示例10: calcPhongLightingColor3 LightShadeModel::calcColor( Vector3D pos, Vector3D dir, Vector3D n, Color3 color, LightSource *ls, Model *m, UINT face_id, UINT colorMask){ if (lightModel == PhongLighting){ Vector3D l = ls->pos - pos; l.normalize(); return calcPhongLighting(n, Vector3D(0,0,0) - dir, l, color, ls->color, &(m->material), colorMask); } else { return Color3(0,0,0); } return Color3(0,0,0);}
开发者ID:mrroach9,项目名称:Raytracing,代码行数:15,
示例11: finalGatheringstatic Color3 finalGathering(KdTree<Photon> *map , Scene& scene , Intersection& inter , RNG& rng , const Vector3& wo , int gatherSamples , int knn , Real maxSqrDis){ Color3 res = Color3(0.0 , 0.0 , 0.0); for (int i = 0; i < gatherSamples; i++) { Real pdf; Vector3 wi = sampleCosHemisphere(rng.randVector3() , &pdf); Ray ray = Ray(inter.p + wi * EPS , wi); Intersection _inter; Geometry *_g = scene.intersect(ray , _inter); if (_g == NULL) continue; Color3 tmp = estimate(map , 0 , knn , scene , _inter , -wi , maxSqrDis); BSDF bsdf(wi , _inter , scene); Real cosine , bsdfPdf; Color3 brdf = bsdf.f(scene , wo , cosine , &bsdfPdf); if (brdf.isBlack()) continue; pdf *= bsdfPdf; res = res + (tmp | brdf) * (cosine / pdf); } res = res / gatherSamples; return res;}
开发者ID:winmad,项目名称:Winmad-s-raytracer-v1.0,代码行数:31,
示例12: windowvoid App::main() { window()->setCaption("Q3 Renderer"); setDebugMode(true); debugController.setActive(true); dumpPolygons = false; clipMovement = true; sky = Sky::create(renderDevice, dataDir + "sky/"); debugCamera.setNearPlaneZ(-0.5f); debugCamera.setFarPlaneZ(-100);//(float)-inf()); debugController.init(renderDevice, userInput); debugController.setMoveRate(500 * BSPMAP::LOAD_SCALE); debugController.setActive(true); renderDevice->setColorClearValue(Color3(0.1f, 0.5f, 1.0f)); // Load the map map = new BSPMAP::Map(); bool ret = map->load("D:/games/dojo/scratch/data-files/q3/", "ut_ricochet.bsp");// bool ret = map->load("D:/media/models/q3/maps/urbanterror/", "ut_ricochet.bsp"); debugAssert(ret); (void)ret; debugController.setPosition(map->getStartingPosition()); debugController.lookAt(map->getStartingPosition() - Vector3::unitZ()); debugCamera.setCoordinateFrame(debugController.getCoordinateFrame()); applet->run();}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:30,
示例13: tmpvoid RayTracer::traceOnePixel(int x, int y, int threadID) { //used for constructing viewport Vector2 tmp(m_settings.width, m_settings.height); Ray primaryRay; // If one ray per pixel: (kinda debugging mode with blue color for places with no surfel hit if (m_settings.raysPerPixel == 1){ //Get the primary ray from the pixel x,y primaryRay = m_camera->worldRay(x + 0.5f, y + 0.5f, Rect2D(tmp)); //Get the first surfel hit. //Can't call L_i unfortunately because we want the blue background for debugging const shared_ptr<Surfel>& s = RayTracer::castRay(primaryRay, finf(), 0); //If there is a surfel hit, get the direct illumination value and apply to the pixel if (s){ //Call L_scatteredDirect to get direct illumination. Invert primaryRay to get the direction for incident light m_image->set(Point2int32(x,y), L_o(s, -primaryRay.direction(), m_settings.recursiveBounces, *(m_rnd[threadID]))); } else{ //Set the pixels with no surfel hit. Include this line so we could make it a specific color for debug purposes. m_image->set(Point2int32(x,y), Color3(0,0,1)); } } else { Radiance3 L(0,0,0); //If more than one ray, randomly generate required number of rays within the pixel for (int i = 0; i < m_settings.raysPerPixel; ++i){ primaryRay = m_camera->worldRay(x + m_rnd[threadID]->uniform(), y + m_rnd[threadID]->uniform(), Rect2D(tmp)); L += L_i(primaryRay.origin(), primaryRay.direction(), m_settings.recursiveBounces, *(m_rnd[threadID])); } m_image->set(Point2int32(x,y), L/m_settings.raysPerPixel); }}
开发者ID:fjnoyp,项目名称:ProceduralCityGenerator-100-hours,代码行数:34,
示例14: lightingvoid Demo::onGraphics(RenderDevice* rd) { LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM)); rd->setProjectionAndCameraMatrix(app->debugCamera); // Cyan background rd->setColorClearValue(Color3(0.1f, 0.5f, 1.0f)); rd->clear(app->sky.isNull(), true, true); if (app->sky.notNull()) { app->sky->render(rd, lighting); } // Setup lighting rd->enableLighting(); rd->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor)); rd->setAmbientLightColor(lighting.ambient); Draw::axes(CoordinateFrame(Vector3(0, 4, 0)), rd); rd->disableLighting(); if (app->sky.notNull()) { app->sky->renderLensFlare(rd, lighting); }}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:26,
示例15: scenevoid App::configureShaderArgs(Args& args) { const shared_ptr<Light>& light = scene()->lightingEnvironment().lightArray[0]; const Color3& lambertianColor = colorList[lambertianColorIndex].element(0).color(Color3::white()).rgb(); const Color3& glossyColor = colorList[glossyColorIndex].element(0).color(Color3::white()).rgb(); // Viewer args.setUniform("wsEyePosition", m_debugCamera->frame().translation); // Lighting args.setUniform("wsLight", light->position().xyz().direction()); args.setUniform("lightColor", light->color); args.setUniform("ambient", Color3(0.3f)); args.setUniform("environmentMap", scene()->lightingEnvironment().environmentMapArray[0], Sampler::cubeMap()); // Material args.setUniform("lambertianColor", lambertianColor); args.setUniform("lambertianScalar", lambertianScalar); args.setUniform("glossyColor", glossyColor); args.setUniform("glossyScalar", glossyScalar); args.setUniform("smoothness", smoothness); args.setUniform("reflectScalar", reflect);}
开发者ID:jackpoz,项目名称:G3D-backup,代码行数:25,
示例16: ifTexture::Encoding::Encoding(const Any& a) { *this = Encoding(); if (a.type() == Any::STRING) { format = ImageFormat::fromString(a); } else if (a.nameBeginsWith("Color4")) { readMultiplyFirst = a; } else if (anyNameIsColor3Variant(a)) { readMultiplyFirst = Color4(Color3(a), 1.0f); } else if (a.type() == Any::NUMBER) { readMultiplyFirst = Color4::one() * float(a.number()); } else { AnyTableReader r(a); r.getIfPresent("frame", frame); r.getIfPresent("readMultiplyFirst", readMultiplyFirst); r.getIfPresent("readAddSecond", readAddSecond); String fmt; if (r.getIfPresent("format", fmt)) { format = ImageFormat::fromString(fmt); } }}
开发者ID:elfprince13,项目名称:G3D10,代码行数:25,
示例17: Vector3Vector3 BidirPathTracing::generateCameraSample(const int pathIndex , BidirPathState& cameraState){ Camera& camera = scene.camera; int y = pathIndex % width; int x = pathIndex / width; Vector3 jitter = rng.randVector3(); Vector3 sample = Vector3((Real)x + jitter.x , (Real)y + jitter.y , 0.f); Ray ray = camera.generateRay(sample.x , sample.y); Real cosAtCamera = camera.forward ^ ray.dir; Real imagePointToCameraDist = camera.imagePlaneDist / cosAtCamera; Real imageToSolidAngleFactor = SQR(imagePointToCameraDist) / cosAtCamera; Real cameraPdf = imageToSolidAngleFactor; cameraState.origin = ray.origin; cameraState.dir = ray.dir; cameraState.pathLength = 1; cameraState.specularPath = 1; cameraState.specularVertexNum = 0; cameraState.throughput = Color3(1); cameraState.dVCM = mis(lightPathNum / cameraPdf); cameraState.dVC = 0.f; return sample;}
开发者ID:winmad,项目名称:Winmad-s-raytracer-v1.0,代码行数:35,
示例18: rboolShadingSystemImpl::set_colorspace (ustring colorspace){ for (int i = 0; colorSystems[i].name; ++i) { if (colorspace == colorSystems[i].name) { m_Red.setValue (colorSystems[i].xRed, colorSystems[i].yRed, 0.0f); m_Green.setValue (colorSystems[i].xGreen, colorSystems[i].yGreen, 0.0f); m_Blue.setValue (colorSystems[i].xBlue, colorSystems[i].yBlue, 0.0f); m_White.setValue (colorSystems[i].xWhite, colorSystems[i].yWhite, 0.0f); // set z values to normalize m_Red[2] = 1.0f - (m_Red[0] + m_Red[1]); m_Green[2] = 1.0f - (m_Green[0] + m_Green[1]); m_Blue[2] = 1.0f - (m_Blue[0] + m_Blue[1]); m_White[2] = 1.0f - (m_White[0] + m_White[1]); const Color3 &R(m_Red), &G(m_Green), &B(m_Blue), &W(m_White); // xyz -> rgb matrix, before scaling to white. Color3 r (G[1]*B[2] - B[1]*G[2], B[0]*G[2] - G[0]*B[2], G[0]*B[1] - B[0]*G[1]); Color3 g (B[1]*R[2] - R[1]*B[2], R[0]*B[2] - B[0]*R[2], B[0]*R[1] - R[0]*B[1]); Color3 b (R[1]*G[2] - G[1]*R[2], G[0]*R[2] - R[0]*G[2], R[0]*G[1] - G[0]*R[1]); Color3 w (r.dot(W), g.dot(W), b.dot(W)); // White scaling factor if (W[1] != 0.0f) // divide by W[1] to scale luminance to 1.0 w *= 1.0f/W[1]; // xyz -> rgb matrix, correctly scaled to white. r /= w[0]; g /= w[1]; b /= w[2]; m_XYZ2RGB = Matrix33 (r[0], g[0], b[0], r[1], g[1], b[1], r[2], g[2], b[2]); m_RGB2XYZ = m_XYZ2RGB.inverse(); m_luminance_scale = Color3 (m_RGB2XYZ[0][1], m_RGB2XYZ[1][1], m_RGB2XYZ[2][1]); // Precompute a table of blackbody values m_blackbody_table.clear (); float lastT = 0; for (int i = 0; lastT <= BB_MAX_TABLE_RANGE; ++i) { float T = powf (float(i), BB_TABLE_XPOWER) * BB_TABLE_SPACING + BB_DRAPER; lastT = T; bb_spectrum spec (T); Color3 rgb = XYZ_to_RGB (spectrum_to_XYZ (spec)); clamp_zero (rgb); rgb = colpow (rgb, 1.0f/BB_TABLE_YPOWER); m_blackbody_table.push_back (rgb); // std::cout << "Table[" << i << "; T=" << T << "] = " << rgb << "/n"; } // std::cout << "Made " << m_blackbody_table.size() << " table entries for blackbody/n";#if 0 // Sanity checks std::cout << "m_XYZ2RGB = " << m_XYZ2RGB << "/n"; std::cout << "m_RGB2XYZ = " << m_RGB2XYZ << "/n"; std::cout << "m_luminance_scale = " << m_luminance_scale << "/n";#endif return true; } } return false;}
开发者ID:DingTo,项目名称:OpenShadingLanguage,代码行数:59,
示例19: osl_allocate_weighted_closure_component_floatOSL_SHADEOP ClosureColor *osl_allocate_weighted_closure_component_float (ShaderGlobals *sg, int id, int size, int nattrs, float w){ if (w == 0.0f) return NULL; return sg->context->closure_component_allot(id, size, nattrs, Color3(w,w,w));}
开发者ID:Wangwentao1,项目名称:OpenShadingLanguage,代码行数:8,
示例20: clampColor3 clamp( const Color3& c, real_t min, real_t max ){ return Color3( clamp( c.r, min, max ), clamp( c.g, min, max ), clamp( c.b, min, max ) );}
开发者ID:bballmitch2,项目名称:CudaP7,代码行数:8,
示例21: Color3Color3ShadingSystemImpl::to_rgb (ustring fromspace, float a, float b, float c){ if (fromspace == Strings::RGB || fromspace == Strings::rgb) return Color3 (a, b, c); if (fromspace == Strings::hsv) return hsv_to_rgb (a, b, c); if (fromspace == Strings::hsl) return hsl_to_rgb (a, b, c); if (fromspace == Strings::YIQ) return YIQ_to_rgb (a, b, c); if (fromspace == Strings::XYZ) return XYZ_to_RGB (a, b, c); if (fromspace == Strings::xyY) return XYZ_to_RGB (xyY_to_XYZ (Color3(a,b,c))); error ("Unknown color space /"%s/"", fromspace.c_str()); return Color3 (a, b, c);}
开发者ID:DingTo,项目名称:OpenShadingLanguage,代码行数:18,
示例22: resColor3 BidirPathTracing::connectToCamera(BidirPathState& lightState , const Vector3& hitPos , BSDF& bsdf){ Color3 res(0); Camera& camera = scene.camera; Vector3 dirToCamera = camera.pos - hitPos; if (((-dirToCamera) ^ camera.forward) <= 0) return res; Real distEye2 = dirToCamera.sqrLength(); Real dist = std::sqrt(distEye2); dirToCamera = dirToCamera / dist; Real cosToCamera , bsdfDirPdf , bsdfRevPdf; Color3 bsdfFactor = bsdf.f(scene , dirToCamera , cosToCamera , &bsdfDirPdf , &bsdfRevPdf); if (bsdfFactor.isBlack()) return res; bsdfRevPdf *= bsdf.continueProb; Real cosAtCamera = ((-dirToCamera) ^ camera.forward); Real imagePointToCameraDist = camera.imagePlaneDist / cosAtCamera; Real imageToSolidAngleFactor = SQR(imagePointToCameraDist) / cosAtCamera; Real imageToSurfaceFactor = imageToSolidAngleFactor * std::abs(cosToCamera) / distEye2; Real cameraPdfA = imageToSurfaceFactor /* * 1.f */; // pixel area is 1 Real surfaceToImageFactor = 1.f / imageToSurfaceFactor; // We divide the contribution by surfaceToImageFactor to convert the (already // divided) pdf from surface area to image plane area, w.r.t. which the // pixel integral is actually defined. We also divide by the number of samples // this technique makes res = (lightState.throughput | bsdfFactor) / (lightPathNum * surfaceToImageFactor); if (res.isBlack()) return res; if (scene.occluded(hitPos , dirToCamera , camera.pos)) return Color3(0); Real wLight = mis(cameraPdfA / lightPathNum) * (lightState.dVCM + mis(bsdfRevPdf) * lightState.dVC); Real weight = 1.f / (wLight + 1.f); //fprintf(fp , "weight = %.6f/n" , weight); return res * weight;}
开发者ID:winmad,项目名称:Winmad-s-raytracer-v1.0,代码行数:56,
示例23: resizevoid Image1::copyArray(const Color3uint8* src, int w, int h) { resize(w, h); int N = w * h; Color1* dst = data.getCArray(); // Convert int8 -> float for (int i = 0; i < N; ++i) { dst[i] = Color1(Color3(src[i]).average()); }}
开发者ID:Cryptoh,项目名称:server,代码行数:10,
示例24: drawLinevoid DebugDraw::drawLine(const btVector3& from, const btVector3& to, const btVector3& fromColor, const btVector3& toColor) { _bufferData.emplace_back(from); _bufferData.push_back(Color3(fromColor)); _bufferData.emplace_back(to); _bufferData.push_back(Color3(toColor)); /* The flushLines() API was added at some point between 2.83 and 2.83.4, but that's below the resolution of the constant below. Moreover, 284 corresponds to 2.83.6, while 2.84 is 285. Fun, right? Relevant commit: https://github.com/bulletphysics/bullet3/commit/7b28e86c7b9ab3c4bb8d479f843b9b5c2e1c9a06 The Bullet API and documentation and everything is utter crap, so I'm not bothering more here. Yes, every call to drawLine() will cause a new drawcall with a single line segment to be submitted. Just to be clear why I did that: Ubuntu 14.04, which is now the oldest supported platform, has only 2.81 in the repositories. */ #if BT_BULLET_VERSION < 284 flushLines(); #endif}
开发者ID:mosra,项目名称:magnum-integration,代码行数:19,
注:本文中的Color3函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ Color3f函数代码示例 C++ CollisionProp函数代码示例 |