C3D: Textures are weirdly colored

Post Reply
The Glitch
Posts: 6
Joined: Thu Jul 11, 2024 8:46 pm

C3D: Textures are weirdly colored

Post by The Glitch » Sat Dec 14, 2024 5:03 am

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


User avatar
fincs
( ͡° ͜ʖ ͡°)
Posts: 104
Joined: Mon Jul 12, 2010 9:45 pm
Location: Seville, Spain
Contact:

Re: C3D: Textures are weirdly colored

Post by fincs » Sat Dec 14, 2024 12:04 pm

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.

Donate to devkitPro - help us stay alive!

The Glitch
Posts: 6
Joined: Thu Jul 11, 2024 8:46 pm

Re: C3D: Textures are weirdly colored

Post by The Glitch » Sat Dec 14, 2024 7:20 pm

It took a little troubleshoot but now it's fixed. Thanks


Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest