Page 1 of 1
C3D: Textures are weirdly colored
Posted: Sat Dec 14, 2024 5:03 am
by The Glitch
I've been working on a C3D demo and I've managed to get textures to work but they are off colored.
I would attach pictures but the site won't let me copy paste.
The code is on the "textures" branch of https://github.com/kijetesantakalu042/C3D-Template
Re: C3D: Textures are weirdly colored
Posted: Sat Dec 14, 2024 12:04 pm
by fincs
You need two texenv stages to blend the texture color with the fragment lighting color, like this:
Code: Select all
environment = C3D_GetTexEnv(0);
C3D_TexEnvSrc(environment, C3D_Both, GPU_FRAGMENT_PRIMARY_COLOR, GPU_FRAGMENT_SECONDARY_COLOR, 0);
C3D_TexEnvFunc(environment, C3D_Both, GPU_ADD);
environment = C3D_GetTexEnv(1);
C3D_TexEnvSrc(environment, C3D_Both, GPU_PREVIOUS, GPU_TEXTURE0, 0);
C3D_TexEnvFunc(environment, C3D_Both, GPU_MODULATE);
In effect, these texenv settings calculate (fragPrimaryColor + fragSecondaryColor) * texture0Color.
Re: C3D: Textures are weirdly colored
Posted: Sat Dec 14, 2024 7:20 pm
by The Glitch
It took a little troubleshoot but now it's fixed. Thanks