Пример #1
0
/*
 * R_SetSurfaceState_default
 */
static void R_SetSurfaceState_default(const r_bsp_surface_t *surf) {
	r_image_t *image;
	float a;

	if (r_state.blend_enabled) { // alpha blend
		switch (surf->texinfo->flags & (SURF_BLEND_33 | SURF_BLEND_66)) {
		case SURF_BLEND_33:
			a = 0.33;
			break;
		case SURF_BLEND_66:
			a = 0.66;
			break;
		default: // both flags mean use the texture's alpha channel
			a = 1.0;
			break;
		}

		glColor4f(1.0, 1.0, 1.0, a);
	}

	image = surf->texinfo->image;

	if (texunit_diffuse.enabled) // diffuse texture
		R_BindTexture(image->texnum);

	if (texunit_lightmap.enabled) // lightmap texture
		R_BindLightmapTexture(surf->lightmap_texnum);

	if (r_state.lighting_enabled) { // hardware lighting

		if (r_bumpmap->value) { // bump mapping

			if (image->normalmap) {
				R_BindDeluxemapTexture(surf->deluxemap_texnum);
				R_BindNormalmapTexture(image->normalmap->texnum);

				R_EnableBumpmap(&image->material, true);
			} else
				R_EnableBumpmap(NULL, false);
		}

		if (surf->light_frame == r_locals.light_frame) // dynamic light sources
			R_EnableLights(surf->lights);
		else
			R_EnableLights(0);
	}
}
Пример #2
0
void R_SetSurfaceBumpMappingParameters (const mBspSurface_t *surf, const image_t *normalMap, const image_t *specularMap)
{
	if (!r_state.lighting_enabled)
		return;

	if (!r_bumpmap->value)
		return;

	assert(surf);

	if (normalMap && (surf->flags & MSURF_LIGHTMAP)) {
		const image_t *image = surf->texinfo->image;
		R_BindDeluxemapTexture(surf->deluxemap_texnum);
		R_EnableBumpmap(normalMap);
		R_EnableSpecularMap(specularMap, true);
		R_UseMaterial(&image->material);
	} else {
		R_EnableBumpmap(NULL);
		R_EnableSpecularMap(NULL, false);
		R_UseMaterial(NULL);
	}
}