コード例 #1
0
ファイル: outline.cpp プロジェクト: xpansive/cpumarch
vec3 calculate_color(const distance& dist, const vec3& p, const vec3& ray, const int userdata)
{
	vec3 normal = get_normal(dist.field, p);

	const float eta = 0.3;
	const float sqf = (1 - eta) / (1 + eta);
	const float f = sqf * sqf;
	const float fresnel_power = 5;
	const float ratio = f + (1 - f) * pow(1 - dot(ray, normal), fresnel_power);

	vec3 diffuse = get_color(dist.object_id, p);
	if (dist.object_id == 2 && userdata < 3) {
		vec3 reflect_ray = glm::reflect(ray, normal);
		diffuse = mix(diffuse, raymarch(p + reflect_ray * 0.01f, reflect_ray, userdata + 1), ratio);
	}
	vec3 color(0.1);
	for (vec3 light : get_lights()) {
		const vec3 light_dir = normalize(p - light);
		const float light_dist = glm::distance(p, light);
		color += max(dot(normal, light_dir), 0.0f) * diffuse;
		const vec3 half = normalize(light_dir + ray);
		color += pow(max(dot(normal, half), 0.0f), 64.0f);
		color *= softshadow(p, -light_dir, 0.1, light_dist, 64) * 0.7 + 0.3;
	}
	//color *= mix(vec3(1), get_background_color(), 0.5 + 0.5 * dot(normal, vec3(0, -1, 0)));
	//color = pow(color, vec3(0.45f));
	color = clamp(color, 0.0f, 1.0f);
	return color;
}
コード例 #2
0
ファイル: final.c プロジェクト: carmi/comp356
int main(int argc, char **argv) {

    // Initialize the drawing window.
    glutInitWindowSize(DEFAULT_WIN_WIDTH, DEFAULT_WIN_HEIGHT);
    glutInitWindowPosition(0, 0);
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);

    // Create the main window.
    glutCreateWindow("Ray tracer");
    glutReshapeFunc(handle_resize);
    glutDisplayFunc(handle_display);

    // Application initialization.
    surfaces = get_surfaces();
    set_view_data(&eye, &look_at, &up_dir);
    set_view_plane(&view_plane_dist, &view_plane_width, &view_plane_height);
    lights = get_lights();
    compute_eye_frame_basis();

    // Enter the main event loop.
    atexit(handle_exit);
    glutMainLoop();

    return EXIT_SUCCESS;
}
コード例 #3
0
ファイル: volumetric.c プロジェクト: danielmarg/blender-main
/* single scattering only for now */
void vol_get_scattering(ShadeInput *shi, float scatter_col[3], const float co[3], const float view[3])
{
	ListBase *lights;
	GroupObject *go;
	LampRen *lar;

	zero_v3(scatter_col);

	lights = get_lights(shi);
	for (go = lights->first; go; go = go->next) {
		float lacol[3] = {0.f, 0.f, 0.f};
		lar = go->lampren;
		
		if (lar) {
			vol_shade_one_lamp(shi, co, view, lar, lacol);
			add_v3_v3(scatter_col, lacol);
		}
	}
}
コード例 #4
0
ファイル: main.cpp プロジェクト: qristofer/ggj
int main(int argc, char**argv)
{


	vec3 a = {0,0,1},b={0,1,0},c;
	c = vcross(b,a);
	printf( "C = %f, %f, %f\n\n",c.x,c.y,c.z);

	const char*out_file,*in_file;

	//open up enter root element
	if ( argc < 3 )
		return printf( " Sorry, too few args.\n" ),-1;
    in_file = argv[1];
	out_file = argv[2];
    TiXmlDocument doc(in_file);
    if(!doc.LoadFile())//doc.Error()==1)
        return printf("ERR: %s\n",  doc.ErrorDesc()), -1;
	TiXmlElement*root=doc.RootElement();
	if(!root)
		return printf("Root not found\n"),-1;

	//MATERIAL NAMES 
	//get_material_names(root);

	//READ LIGHTS
	get_lights(root);

	//READ GEO (polys)
	get_geometry(root);

	//Convert to poly / vertex format
	dae_geo_to_polys_and_verts( dae_geo_objects[0] );
	
	//... nau... do lighting calculations (simple at first
	render_vertex_colors();
	
	convert();
	write(out_file);
	
//	render();
    return 0;
}
コード例 #5
0
ファイル: volumetric.c プロジェクト: OldBrunet/BGERTPS
/* single scattering only for now */
void vol_get_scattering(ShadeInput *shi, float *scatter_col, float *co)
{
	ListBase *lights;
	GroupObject *go;
	LampRen *lar;
	
	scatter_col[0] = scatter_col[1] = scatter_col[2] = 0.f;
	
	lights= get_lights(shi);
	for(go=lights->first; go; go= go->next)
	{
		float lacol[3] = {0.f, 0.f, 0.f};
		lar= go->lampren;
		
		if (lar) {
			vol_shade_one_lamp(shi, co, lar, lacol);
			add_v3_v3(scatter_col, lacol);
		}
	}
}