CAtmoColorPicker::CAtmoColorPicker(HINSTANCE hInst, HWND parent, CAtmoDynData *pAtmoDynData, int red,int green,int blue):
	CAtmoCustomColorPicker(hInst,parent,IDD_COLORPICKER,pAtmoDynData,red,green,blue)
{
	this->m_pAtmoDynData = pAtmoDynData;
	outputColor(red,green,blue);
	m_iRed   = red;
	m_iGreen = green;
	m_iBlue  = blue;
}
Пример #2
0
void tracer::Pathtracer::render(unsigned width, unsigned height) {
	// initialize output texture
	m_output.clear();
	m_output.resize(width * height);
	std::fill(m_output.begin(), m_output.end(), glm::vec4(0.0f));

	// pinhole camera
	Camera& camera = m_scene.getCamera();
	camera.setImagingPlaneResolution(width, height);
	
	// random number generation
	std::random_device rd;
	std::mt19937 engine(rd());
	
	// progress printing
	std::cout.precision(2);
	std::cout.setf(std::ios::fixed, std::ios::floatfield);
	std::string status = "Rendering, done: ";
	float percentage = 0.0f, fraction = 100.0f/height;
	
	// rendering loop
	#pragma omp parallel for schedule(dynamic)
	for (unsigned y = 0; y < height; y++) {
		for (unsigned x = 0; x < width; x++) {
			glm::vec3 outputColor(0.0f);
			for (unsigned s = 0; s < m_samples; s++) {
				Ray ray = camera.castRay(x, y);
				outputColor += radiance(ray, engine) / (float)m_samples;
			}
			m_output[y*width+x] = glm::vec4(color::gammaCompress(glm::clamp(outputColor, 0.0f, 1.0f)), 1.0f);
		}
		#pragma omp critical
		{
		percentage += fraction;
		std::cout << "\r" << status << percentage << "%";
		}
	}
	std::cout << std::endl << std::endl;
}
Пример #3
0
Vector3f
CubeMap::getTexel(const Vector3f &direction) const
{
    Vector3f dir = direction.normalized();
    Vector3f outputColor(0.0f, 0.0f, 0.0f);
    if ((std::abs(dir[0]) >= std::abs(dir[1])) && (std::abs(dir[0]) >= std::abs(dir[2]))) {
        if (dir[0] > 0.0f) {
            outputColor = 
                _t[RIGHT].getTexel((dir[2] / dir[0] + 1.0f) * 0.5f, 
                                   (dir[1] / dir[0] + 1.0f) * 0.5f);
        } else if (dir[0] < 0.0f) {
            outputColor = 
                _t[LEFT].getTexel(       (dir[2] / dir[0] + 1.0f) * 0.5f, 
                                  1.0f - (dir[1] / dir[0] + 1.0f) * 0.5f);
        }
    } else if ((std::abs(dir[1]) >= std::abs(dir[0])) && (std::abs(dir[1]) >= std::abs(dir[2]))) {
        if (dir[1] > 0.0f) {
            outputColor = 
                _t[UP].getTexel((dir[0] / dir[1] + 1.0f) * 0.5f, 
                                (dir[2] / dir[1] + 1.0f) * 0.5f);
        } else if (dir[1] < 0.0f) {
            outputColor = 
                _t[DOWN].getTexel(1.0f - (dir[0] / dir[1] + 1.0f) * 0.5f, 
                                  1.0f - (dir[2] / dir[1] + 1.0f) * 0.5f);
        }
    } else if ((std::abs(dir[2]) >= std::abs(dir[0])) && (std::abs(dir[2]) >= std::abs(dir[1]))) {
        if (dir[2] > 0.0f) {
            outputColor = 
                _t[FRONT].getTexel(1.0f - (dir[0] / dir[2] + 1.0f) * 0.5f, 
                                          (dir[1] / dir[2] + 1.0f) * 0.5f);
        } else if (dir[2] < 0.0f) {
            outputColor = 
                _t[BACK].getTexel(       (dir[0] / dir[2] + 1.0f) * 0.5f, 
                                  1.0f - (dir[1] / dir[2] + 1.0f) * 0.5f);
        }
    }

    return outputColor;
}
void CAtmoColorPicker::HandleHorzScroll(int code,int position,HWND scrollBarHandle)
{
	// WM_HSCROLL handler!
	//  WM_HSCROLL
	HWND hwndCtrl;

	int dlgItemId = GetDlgCtrlID(scrollBarHandle);
	switch(dlgItemId) 
	{
	case IDC_SL_RED:

		this->m_iRed   = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
		break;

	case IDC_SL_GREEN:
		this->m_iGreen = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
		break;

	case IDC_SL_BLUE:
		this->m_iBlue  = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
		break;
	default:
		return;

	}
	UpdateColorControls(ATMO_FALSE, ATMO_TRUE);


	// if(IDC_RADIO2){
	//      this->m_iRed = 10;
	//this->m_iGreen = 10;
	//this->m_iBlue = 10;
	// }

	hwndCtrl = this->getDlgItem(IDC_CHK_VIEWCOLOR);
	if(SendMessage(hwndCtrl, BM_GETSTATE, 0, 0) == BST_CHECKED) outputColor(this->m_iRed, this->m_iGreen, this->m_iBlue);
}
ATMO_BOOL CAtmoColorPicker::ExecuteCommand(HWND hControl,int wmId, int wmEvent)
{
	switch(wmId) 
	{
	case IDOK:
		{
			EndDialog(this->m_hDialog, wmId);
			break;
		}

	case IDCANCEL: 
		{
			EndDialog(this->m_hDialog, wmId);
			break;
		}

	case IDC_EDT_RED: 
		{
			if(wmEvent == EN_CHANGE)
			{
				char buffer[20];
				if(Edit_GetText(hControl,buffer,sizeof(buffer))>0)
				{
					int value = atoi(buffer);
					if((value>=0) && (value<=255)) 
					{
						this->m_iRed = value;
						UpdateColorControls(ATMO_TRUE, ATMO_FALSE);
						outputColor(this->m_iRed, this->m_iGreen, this->m_iBlue);
					} 
					else 
					{
						MessageBeep(MB_ICONEXCLAMATION);
					}
				}
			}
			break;
		}

	case IDC_EDT_GREEN: 
		{
			if(wmEvent == EN_CHANGE) 
			{
				char buffer[20];
				if(Edit_GetText(hControl,buffer,sizeof(buffer))>0) 
				{
					int value = atoi(buffer);
					if((value>=0) && (value<=255))
					{
						this->m_iGreen = value;
						UpdateColorControls(ATMO_TRUE, ATMO_FALSE);
						outputColor(this->m_iRed, this->m_iGreen, this->m_iBlue);
					} 
					else 
					{
						MessageBeep(MB_ICONEXCLAMATION);
					}
				}
			}
			break;
		}

	case IDC_EDT_BLUE: 
		{
			if(wmEvent == EN_CHANGE) 
			{
				char buffer[20];
				if(Edit_GetText(hControl,buffer,sizeof(buffer))>0) 
				{
					int value = atoi(buffer);
					if((value>=0) && (value<=255))
					{
						this->m_iBlue = value;
						UpdateColorControls(ATMO_TRUE, ATMO_FALSE);
						outputColor(this->m_iRed, this->m_iGreen, this->m_iBlue);
					}
					else 
					{
						MessageBeep(MB_ICONEXCLAMATION);
					}
				}
			}
			break;
		}

	default:
		return ATMO_FALSE;
	}
	return ATMO_TRUE;
}