1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#include "common/FeatureFlagsEnum.h"
#include "math/random.ih"
#include "math/sampling.ih"
#include "render/ScreenSample.ih"
#include "render/materials/OBJ.ih"
#include "render/util.ih"
#include "texture/TextureParam.ih"
// AO Renderer
#include "surfaces.ih"
// c++ shared
#include "render/materials/OBJShared.h"
OSPRAY_BEGIN_ISPC_NAMESPACE
inline vec4f getSurfaceColor(
const DifferentialGeometry &dg, const uniform FeatureFlagsHandler &ffh)
{
const OBJ *mat = (const OBJ *)dg.material;
vec3f surfaceColor = make_vec3f(1.f);
float opacity = 1.f;
const uniform FeatureFlags ff = getFeatureFlags(ffh);
const uniform bool fft = ff.other & FFO_TEXTURE_IN_MATERIAL;
foreach_unique (m in mat) {
if (m != NULL && m->super.type == MATERIAL_TYPE_OBJ) {
surfaceColor = m->Kd;
if (valid(m->KdMap) && fft) {
vec4f Kd_from_map = get4f(m->KdMap, dg);
surfaceColor = surfaceColor * make_vec3f(Kd_from_map);
opacity *= Kd_from_map.w;
}
opacity *= m->d * (fft ? get1f(m->dMap, dg, 1.f) : 1.f);
}
}
return make_vec4f(surfaceColor * make_vec3f(dg.color), opacity * dg.color.w);
}
SYCL_EXTERNAL SSI AORenderer_computeShading(const AORenderer *uniform self,
const World *uniform world,
const DifferentialGeometry &dg,
ScreenSample &sample,
const uniform FeatureFlagsHandler &ffh)
{
SSI retval;
const vec4f surfaceColor = getSurfaceColor(dg, ffh);
const vec3f color = make_vec3f(surfaceColor);
const float opacity = surfaceColor.w;
const float eyeLightIntensity = absf(dot(dg.Ns, sample.ray.dir)) * opacity;
float intensity = eyeLightIntensity;
if (self->aoSamples > 0 && self->aoIntensity > 0.01f) {
const float ao = computeAO(&self->super,
world,
dg,
self->aoSamples,
self->aoRadius,
sample.sampleID,
ffh);
intensity *= (1.0f - self->aoIntensity) + (ao * self->aoIntensity);
}
retval.shadedColor = make_vec4f(color * intensity, opacity);
retval.albedo = color;
return retval;
}
OSPRAY_END_ISPC_NAMESPACE
|