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 77 78 79 80 81 82 83 84 85 86 87
|
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "Texture.ih"
#include "Texture2DShared.h"
OSPRAY_BEGIN_ISPC_NAMESPACE
SYCL_EXTERNAL vec4f Texture2D_get(
const uniform Texture *uniform self, const DifferentialGeometry &dg);
SYCL_EXTERNAL vec3f Texture2D_getNormal(
const uniform Texture *uniform self, const DifferentialGeometry &dg);
// XXX won't work with MIPmapping: clean implementation with clamping on integer
// coords needed then
inline vec2f clamp2edge(const uniform Texture2D *uniform self, const vec2f p)
{
const vec2f halfTexel = rcp(make_vec2f(self->size.x, self->size.y)) * 0.5f;
return clamp(p, halfTexel, 1.0f - halfTexel);
}
inline float get1f(const uniform Texture2D *uniform self,
const varying DifferentialGeometry &dg)
{
return get1f(&self->super, dg);
}
inline vec3f get3f(const uniform Texture2D *uniform self,
const varying DifferentialGeometry &dg)
{
return get3f(&self->super, dg);
}
inline vec4f get4f(const uniform Texture2D *uniform self,
const varying DifferentialGeometry &dg)
{
return get4f(&self->super, dg);
}
inline vec3f getNormal(const uniform Texture2D *uniform self,
const varying DifferentialGeometry &dg)
{
return getNormal(&self->super, dg);
}
inline float get1f(const uniform Texture2D *uniform self,
const varying DifferentialGeometry &dg,
const varying float defaultValue)
{
return get1f(&self->super, dg, defaultValue);
}
inline vec3f get3f(const uniform Texture2D *uniform self,
const varying DifferentialGeometry &dg,
const varying vec3f defaultValue)
{
return get3f(&self->super, dg, defaultValue);
}
inline vec4f get4f(const uniform Texture2D *uniform self,
const varying DifferentialGeometry &dg,
const varying vec4f defaultValue)
{
return get4f(&self->super, dg, defaultValue);
}
#if 0 // crashes ISPC!
inline DifferentialGeometry dgFromTexCoord(const varying vec2f &c)
{
DifferentialGeometry dg;
dg.primID = -1;
dg.st = c;
return dg;
}
#else
inline void initDgFromTexCoord(DifferentialGeometry &dg, const varying vec2f &c)
{
dg.primID = -1;
dg.st = c;
dg.pixelFootprint = flt_min;
}
#endif
OSPRAY_END_ISPC_NAMESPACE
|