summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-07-04 15:11:40 +0000
committerrodri <rgl@antares-labs.eu>2024-07-04 15:11:40 +0000
commit27724b010694549f17cad50158cf73ca035e9cad (patch)
tree25c4811b96e519cb6f9d96ff98de89fd5db92ad6
parentecdeed125c0fe00b6a90f85db44ad37f0913e992 (diff)
download3dee-27724b010694549f17cad50158cf73ca035e9cad.tar.gz
3dee-27724b010694549f17cad50158cf73ca035e9cad.tar.bz2
3dee-27724b010694549f17cad50158cf73ca035e9cad.zip
med,vis: fix normal map sampling.
recent changes in libgraphics assume every texture resides in an sRGB color space, which is not the case for material resources like normals.
-rw-r--r--med.c5
-rw-r--r--vis.c5
2 files changed, 6 insertions, 4 deletions
diff --git a/med.c b/med.c
index 9ab0ff5..3bdeff7 100644
--- a/med.c
+++ b/med.c
@@ -283,9 +283,9 @@ gouraudshader(FSparams *sp)
{
Color tc, c;
- if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0){
+ if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
tc = texture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
- }else if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
+ else if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
tc = texture(sp->su->entity->mdl->tex, sp->v.uv, tsampler);
else
tc = Pt3(1,1,1,1);
@@ -358,6 +358,7 @@ phongshader(FSparams *sp)
else{
/* TODO implement this on the VS instead and apply Gram-Schmidt here */
n = texture(sp->v.mtl->normalmap, sp->v.uv, neartexsampler);
+ n = linear2srgb(n); /* TODO not all textures require color space conversion */
n = normvec3(subpt3(mulpt3(n, 2), Vec3(1,1,1)));
TBN.p = Pt3(0,0,0,1);
diff --git a/vis.c b/vis.c
index ce45b0c..1cf67a2 100644
--- a/vis.c
+++ b/vis.c
@@ -161,9 +161,9 @@ gouraudshader(FSparams *sp)
{
Color tc, c;
- if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0){
+ if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
tc = texture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
- }else if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
+ else if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
tc = texture(sp->su->entity->mdl->tex, sp->v.uv, tsampler);
else
tc = Pt3(1,1,1,1);
@@ -240,6 +240,7 @@ phongshader(FSparams *sp)
else{
/* TODO implement this on the VS instead and apply Gram-Schmidt here */
n = texture(sp->v.mtl->normalmap, sp->v.uv, neartexsampler);
+ n = linear2srgb(n); /* TODO not all textures require color space conversion */
n = normvec3(subpt3(mulpt3(n, 2), Vec3(1,1,1)));
TBN.p = Pt3(0,0,0,1);