paysages : Added shortcut in global renderer for surface lighting.
git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@504 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
parent
a191849cee
commit
0d3906a93e
5 changed files with 17 additions and 19 deletions
|
@ -129,16 +129,11 @@ Color atmosphereGetPreview(Renderer* renderer, double x, double y, double headin
|
|||
if (_checkHit(eye, direction, &hit, &normal))
|
||||
{
|
||||
Color color;
|
||||
LightStatus* light;
|
||||
|
||||
normal = m4Transform(rotation, normal);
|
||||
hit = m4Transform(rotation, hit);
|
||||
|
||||
light = lightingCreateStatus(renderer->lighting, hit, eye);
|
||||
renderer->atmosphere->getLightingStatus(renderer, light, normal, 1);
|
||||
color = lightingApplyStatus(light, normal, &MOUNT_MATERIAL);
|
||||
lightingDeleteStatus(light);
|
||||
|
||||
color = renderer->applyLightingToSurface(renderer, hit, normal, &MOUNT_MATERIAL);
|
||||
return renderer->atmosphere->applyAerialPerspective(renderer, hit, color);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -74,6 +74,15 @@ static Color _applyClouds(Renderer* renderer, Color base, Vector3 start, Vector3
|
|||
return base;
|
||||
}
|
||||
|
||||
Color _applyLightingToSurface(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial* material)
|
||||
{
|
||||
LightStatus* light = lightingCreateStatus(renderer->lighting, location, renderer->camera_location);
|
||||
renderer->atmosphere->getLightingStatus(renderer, light, normal, 0);
|
||||
Color result = lightingApplyStatus(light, normal, material);
|
||||
lightingDeleteStatus(light);
|
||||
return result;
|
||||
}
|
||||
|
||||
Renderer* rendererCreate()
|
||||
{
|
||||
Renderer* result = malloc(sizeof(Renderer));
|
||||
|
@ -103,6 +112,8 @@ Renderer* rendererCreate()
|
|||
result->applyTextures = _applyTextures;
|
||||
result->applyClouds = _applyClouds;
|
||||
|
||||
result->applyLightingToSurface = _applyLightingToSurface;
|
||||
|
||||
result->lighting = lightingManagerCreate();
|
||||
|
||||
result->atmosphere = AtmosphereRendererClass.create();
|
||||
|
|
|
@ -31,6 +31,9 @@ struct Renderer
|
|||
void (*pushTriangle)(Renderer* renderer, Vector3 v1, Vector3 v2, Vector3 v3, f_RenderFragmentCallback callback, void* callback_data);
|
||||
void (*pushQuad)(Renderer* renderer, Vector3 v1, Vector3 v2, Vector3 v3, Vector3 v4, f_RenderFragmentCallback callback, void* callback_data);
|
||||
|
||||
/* Shortcuts */
|
||||
Color (*applyLightingToSurface)(Renderer* renderer, Vector3 location, Vector3 normal, SurfaceMaterial* material);
|
||||
|
||||
/* Scenery related */
|
||||
RayCastingResult (*rayWalking)(Renderer* renderer, Vector3 location, Vector3 direction, int terrain, int water, int sky, int clouds);
|
||||
HeightInfo (*getWaterHeightInfo)(Renderer* renderer);
|
||||
|
|
|
@ -268,13 +268,7 @@ double texturesGetLayerCoverage(TextureLayerDefinition* definition, Renderer* re
|
|||
|
||||
static inline Color _getLayerColor(Renderer* renderer, TextureResult texture)
|
||||
{
|
||||
LightStatus* light;
|
||||
Color result;
|
||||
light = lightingCreateStatus(renderer->lighting, texture.location, renderer->camera_location);
|
||||
renderer->atmosphere->getLightingStatus(renderer, light, texture.normal, 1);
|
||||
result = lightingApplyStatus(light, texture.normal, &texture.definition->material);
|
||||
lightingDeleteStatus(light);
|
||||
return result;
|
||||
return renderer->applyLightingToSurface(renderer, texture.location, texture.normal, &texture.definition->material);
|
||||
}
|
||||
|
||||
Color texturesGetLayerColor(TextureLayerDefinition* definition, Renderer* renderer, Vector3 location, double detail)
|
||||
|
|
|
@ -310,7 +310,6 @@ WaterResult waterGetColorDetail(WaterDefinition* definition, Renderer* renderer,
|
|||
RayCastingResult refracted;
|
||||
Vector3 normal;
|
||||
Color color;
|
||||
LightStatus* light;
|
||||
SurfaceMaterial material;
|
||||
double detail, depth;
|
||||
|
||||
|
@ -351,11 +350,7 @@ WaterResult waterGetColorDetail(WaterDefinition* definition, Renderer* renderer,
|
|||
|
||||
_applyFoam(definition, location, normal, detail, &material);
|
||||
|
||||
light = lightingCreateStatus(renderer->lighting, location, renderer->camera_location);
|
||||
renderer->atmosphere->getLightingStatus(renderer, light, normal, 0);
|
||||
color = lightingApplyStatus(light, normal, &material);
|
||||
lightingDeleteStatus(light);
|
||||
|
||||
color = renderer->applyLightingToSurface(renderer, location, normal, &material);
|
||||
color = renderer->atmosphere->applyAerialPerspective(renderer, location, color);
|
||||
color = renderer->applyClouds(renderer, color, renderer->camera_location, location);
|
||||
|
||||
|
|
Loading…
Reference in a new issue