Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Bigfoot71 committed Sep 16, 2024
1 parent 8e5a889 commit dfa7aa7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/internal/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pfiColorSisdToVec_simd(PFIsimdvf* out, PFcolor in, int vecSize)
}

static inline void
pfiColorUnpackedToVec_simd(PFIsimdvf* out, PFcolor_simd in, int vecSize)
pfiColorUnpackedToVec_simd(PFIsimdvf* out, const PFcolor_simd in, int vecSize)
{
for (int i = 0; i < vecSize; ++i) {
out[i] = pfiSimdMul_F32(
Expand All @@ -200,7 +200,7 @@ pfiColorUnpackedToVec_simd(PFIsimdvf* out, PFcolor_simd in, int vecSize)
}

static inline void
pfiColorUnpackedFromVec_simd(PFcolor_simd out, PFIsimdvf* in, int vecSize)
pfiColorUnpackedFromVec_simd(PFcolor_simd out, const PFIsimdvf* in, int vecSize)
{
out[0] = *(PFIsimdvi*)GC_simd_i32_0;
out[1] = *(PFIsimdvi*)GC_simd_i32_0;
Expand Down
14 changes: 5 additions & 9 deletions src/internal/lighting/lighting.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ PFcolor pfiLightingProcess(const PFIlight* activeLights, const PFImaterial* mate
PFMvec3 negLightDir;
pfmVec3NegR(negLightDir, L);
pfmVec3ReflectR(reflectDir, negLightDir, N);
PFubyte spec = 255*powf(fmaxf(pfmVec3Dot(reflectDir, V), 0.0f), shininess);
PFubyte spec = (PFubyte)(255 * powf(fmaxf(pfmVec3Dot(reflectDir, V), 0.0f), shininess));
# endif

lR = PF_MIN_255(lR + (specular.r*light->specular.r*spec)/(255*255));
Expand Down Expand Up @@ -196,22 +196,18 @@ void pfiSimdLightingProcess(PFcolor_simd fragments, const PFIlight* activeLights

// Specular component
PFsimdv3f specular; {
PFsimdv3f negL;
pfiVec3NegR_simd(negL, L);

# ifndef PF_PHONG_REFLECTION
PFsimdv3f halfWayDir;
pfiVec3AddR_simd(halfWayDir, L, V);
pfiVec3Normalize_simd(halfWayDir, halfWayDir);
PFIsimdvf spec = pfiSimdMax_F32(pfiVec3Dot_simd(N, halfWayDir), pfiSimdSetZero_F32());
# else
PFsimdv3f reflectDir;
pfiVec3ReflectR_simd(reflectDir, negL, N);
PFIsimdvf spec = pfiSimdMax_F32(pfiVec3Dot_simd(V, reflectDir), pfiSimdSetZero_F32());
PFsimdv3f negL, reflect;
pfiVec3NegR_simd(negL, L);
pfiVec3ReflectR_simd(reflect, negL, N);
PFIsimdvf spec = pfiSimdMax_F32(pfiVec3Dot_simd(V, reflect), pfiSimdSetZero_F32());
# endif

spec = pfiSimdPow_F32(spec, material->shininess);

pfiVec3ScaleR_simd(specular, lightSpecular, spec);
pfiVec3Mul_simd(specular, specular, colSpecular);
}
Expand Down

0 comments on commit dfa7aa7

Please sign in to comment.