Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added texture support to basic renderer #415

Merged
merged 2 commits into from
Jun 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions plugins/engines/ospray/ispc/render/BasicRenderer.ispc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ inline vec3f BasicRenderer_shadeRay(const uniform BasicRenderer* uniform self,
DifferentialGeometry dg;
postIntersect(self->abstract.super.model, dg, ray,
DG_NS | DG_NG | DG_NORMALIZE | DG_FACEFORWARD |
DG_MATERIALID | DG_COLOR);
DG_MATERIALID | DG_COLOR | DG_TEXCOORD);

uniform Material* material = dg.material;
uniform ExtendedOBJMaterial* objMaterial =
Expand All @@ -67,12 +67,18 @@ inline vec3f BasicRenderer_shadeRay(const uniform BasicRenderer* uniform self,
if (!objMaterial)
Kd = make_vec3f(dg.color);
else
foreach_unique(mat in objMaterial) Kd = mat->Kd * make_vec3f(dg.color);
foreach_unique(mat in objMaterial)
{
Kd = mat->Kd * make_vec3f(dg.color);
if (valid(mat->map_Kd))
{
const vec4f diffuseColorFromMap = get4f(mat->map_Kd, dg.st);
Kd = make_vec3f(dg.color * diffuseColorFromMap);
}
}

// Head-light shading
const vec3f intersection = dg.P + dg.epsilon * dg.Ns;
const vec3f headLight = normalize(ray.org - intersection);
color = Kd * max(0.f, dot(headLight, dg.Ns));
color = Kd * max(0.f, dot(neg(ray.dir), dg.Ns));
sample.alpha = 1.f;

// Z-Depth
Expand Down