Homebrew Homebrew Development

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,509
Country
United States
The GPU supports procedural textures, which includes a color LUT, but it's not completely documented and I don't know of anyone who has successfully achieved it. I will be toying with it this week though for usage in ScummVM.

Some data on it:
https://www.3dbrew.org/wiki/GPU/Procedural_Texture_Generation
https://www.3dbrew.org/wiki/GPU/Internal_Registers#GPUREG_PROCTEX_LUT

From what I understand, there is no actual texture/image data you can associated with it to abuse its color LUT capability. I hope I'm wrong though, so if you do find a way that allows you to use an indexed texture and draw it through that, it would be very much appreciated to fill us in.

There is, an alternative that StapleButter devised many months ago, but it's still being tinkered with. It abuses bumpmapping to use reflective color LUTs to mimic a kind of indexed texture, using the GPU_L8 format, with up to 255 usable colors out of 256. The remaining one is an invalid entry because the calculation done with this one entry (0x80) produces a zero-length normal, resulting in black texels. This is a problem because this invalid entry is still drawn, when it would likely be applicable as the transparency index, hence why it would be nice if there was some special way to crop it out with color/texture combiners (which is why I asked earlier). There is the GPU_LA8 format which includes its own alpha component per texel, but that is double the texture space needed. The problem with using bumpmapping? Greater load on the GPU than a regular texture (about 100% more, I think), because of having to calculate the normals based on the texture data.
 
  • Like
Reactions: Coto

TheCruel

Developer
Banned
Joined
Dec 6, 2013
Messages
1,350
Trophies
2
XP
3,131
Country
United States
From what I understand, there is no actual texture/image data you can associated with it to abuse its color LUT capability. I hope I'm wrong though, so if you do find a way that allows you to use an indexed texture and draw it through that, it would be very much appreciated to fill us in.

There is, an alternative that StapleButter devised many months ago, but it's still being tinkered with. It abuses bumpmapping to use reflective color LUTs to mimic a kind of indexed texture, using the GPU_L8 format, with up to 255 usable colors out of 256. The remaining one is an invalid entry because the calculation done with this one entry (0x80) produces a zero-length normal, resulting in black texels. This is a problem because this invalid entry is still drawn, when it would likely be applicable as the transparency index, hence why it would be nice if there was some special way to crop it out with color/texture combiners (which is why I asked earlier). There is the GPU_LA8 format which includes its own alpha component per texel, but that is double the texture space needed. The problem with using bumpmapping? Greater load on the GPU than a regular texture (about 100% more, I think), because of having to calculate the normals based on the texture data.
Sounds useful. Where in blargSNES source is this?
 

ksanislo

Well-Known Member
Member
Joined
Feb 23, 2016
Messages
386
Trophies
0
Location
Seattle, WA
XP
512
Country
United States
For developing homebrew, yes, but basically something to load the code over the network like one can do with Netloader/3dslink. Network printfs sound neat, but loading code without yanking my sdcard out constantly is more interesting to me XD

My current project might be more what you're after, but you'll need to install some type of web server on your build machine, pretty much anything that can serve up the .cia file will work (apache/nginx/IIS, doesn't matter as long as its HTTP/1.1), make a QR code URL pointing to wherever your file can be downloaded, and use QRWebLoader to install in one shot. If you use the (Y) button to install via AutoLoader, you'll get an extra icon which will automatically re-pull the last used URL and launch after installing. (Also, this can be utilized by any other home-brew CIA to self-upgrade via the internet in general. I'll make a library for that at some point.)
 
Last edited by ksanislo,

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,509
Country
United States
Alright, after doing various tests, I can conclude that GPU_LA8 works for mimicking an indexed texture with a transparency entry. The purpose of the alpha component is meant to cull out the invalid entry at 0x80 of the indexed part (setting the alpha to 0, all else set to 0xFF). It also requires that you set up the alpha test. The downside is that it's not 8-bit, but 16-bit (8 bits for palette index, 8-bits for alpha).

Now, I'm trying to see if there's a way using texture combiners to do the same thing with just one 8-bit set, but this time, pointing to the same texture data with TEXTURE0 as GPU_L8 and TEXTURE1 as GPU_A8, but having to deal with the invalid entry at 0x80 complicates things. If it were at 0x00, then this would be a cinch, because I could just add 0xFE as a constant in the combiner, then cull with an alpha test, set at greater than 0xFE (because there would only be 2 values afterwards, 0xFE and 0xFF, the latter is because any value greater than 0xFF becomes 0xFF, or so I think).

So, what I need is to find a way using texture combiners to make all sources values except 0x80 result in any value that would be greater than what would result from the source value of 0x80, and in such a way that I can simply add a constant value that would cause 0x80 to finalize as less than 0xFF, and any other value to be equal to 0xFF.

Any ideas?
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,035
Country
United States
Alright, after doing various tests, I can conclude that GPU_LA8 works for mimicking an indexed texture with a transparency entry. The purpose of the alpha component is meant to cull out the invalid entry at 0x80 of the indexed part (setting the alpha to 0, all else set to 0xFF). It also requires that you set up the alpha test. The downside is that it's not 8-bit, but 16-bit (8 bits for palette index, 8-bits for alpha).

Now, I'm trying to see if there's a way using texture combiners to do the same thing with just one 8-bit set, but this time, pointing to the same texture data with TEXTURE0 as GPU_L8 and TEXTURE1 as GPU_A8, but having to deal with the invalid entry at 0x80 complicates things. If it were at 0x00, then this would be a cinch, because I could just add 0xFE as a constant in the combiner, then cull with an alpha test, set at greater than 0xFE (because there would only be 2 values afterwards, 0xFE and 0xFF, the latter is because any value greater than 0xFF becomes 0xFF, or so I think).

So, what I need is to find a way using texture combiners to make all sources values except 0x80 result in any value that would be greater than what would result from the source value of 0x80, and in such a way that I can simply add a constant value that would cause 0x80 to finalize as less than 0xFF, and any other value to be equal to 0xFF.

Any ideas?
What if you invert the alpha - 0 as solid and 0xff as transparent? And change the alpha to one minus src alpha with the combiner? Maybe? Something with alpha and transparent reversed seems like it would be possible. Maybe even eight 8 bit textures.
 

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,509
Country
United States
What if you invert the alpha - 0 as solid and 0xff as transparent? And change the alpha to one minus src alpha with the combiner? Maybe? Something with alpha and transparent reversed seems like it would be possible. Maybe even eight 8 bit textures.

How do you mean? Get 0x80 to become 0xFF? But how would I get all other values to not be 0xFF?
 

elhobbs

Well-Known Member
Member
Joined
Jul 28, 2008
Messages
1,044
Trophies
1
XP
3,035
Country
United States
How do you mean? Get 0x80 to become 0xFF? But how would I get all other values to not be 0xFF?
I think I may have misunderstood. I was thinking entry 255 had a solid black pixel. I was thinking you could use one minus source alpha to switch it to transparent. But I see that isn't your goal.
 

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,509
Country
United States
I think I got it. Turns out, it was a LOT simpler than I thought it would be. How? Ignored texture combiners for this, and just use alpha test & alphablending, by culling out 0x80 in the test, and then forcing all alpha to one in the blend.


C3D_AlphaTest(true, GPU_NOTEQUAL, 0x80);
C3D_AlphaBlend(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_ONE, GPU_ZERO, GPU_ONE, GPU_ZERO);

How this will turn out with other effects though, I don't know, but right now, I'm happy. Now all I need is a way to keep entry 0x01-0x7F.
 
Last edited by DiscostewSM,

DiscostewSM

Well-Known Member
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,509
Country
United States
Might have a solution to my latest problem with keeping 0x01-0x7F. I'd do the following texture combiner sequence

SUB(CONST[0.5], TEX[src])
ADD(PREV[src], PREV[src])
MODULATE(PREV[src], PREV[1-src])

Assuming with each stage it saturates between 0.0 and 1.0, this would cause entry 0x00 and 0x80-0xFF to result in a value of 0, with 0x01-0x7F to range between 0.0 (exclusive) and 0.25 (inclusive). Also assuming that when the alpha test is done, the reference value is converted into a float and then compared, as entries like 0x01 and 0x7F with these texture combiner stages results in extremely small values. So, after this, I'd set the alpha test to be "greater than 0", and then I'd force all passing tests to be fully solid. Guess it's time to test.
 
  • Like
Reactions: daxtsu

xem

Well-Known Member
Member
Joined
Nov 22, 2014
Messages
142
Trophies
0
Age
36
Location
Valbonne
XP
333
Country
France
Hi, sorry for the incomplete tutorial. I started it when ctrulib came out, and I hoped to see ctrulib enhanced and documented over time so I could continue to learn 3DS HB development and describe it on my wiki. Sadly, it didn't really happen and it's still too complicated for me to understand the important details. Though, it's a wiki, and everyone interested in 3DS dev and having some knowledge is welcome to contribute to it :)
 

YugamiSekai

Mr. Picross
Member
Joined
Dec 24, 2014
Messages
2,015
Trophies
1
Age
22
XP
2,386
Country
United States
Hi, sorry for the incomplete tutorial. I started it when ctrulib came out, and I hoped to see ctrulib enhanced and documented over time so I could continue to learn 3DS HB development and describe it on my wiki. Sadly, it didn't really happen and it's still too complicated for me to understand the important details. Though, it's a wiki, and everyone interested in 3DS dev and having some knowledge is welcome to contribute to it :)
I'll start contributing once I finish learning the necessary parts of C and libraries.
 

goodbytes

Well-Known Member
Newcomer
Joined
Sep 15, 2014
Messages
51
Trophies
0
Age
37
XP
168
Country
Am I looking in the wrong places or is there not much Homebrew stuff for 3DS?

I could only see SNES emulator worth using really.
 

Slashcash

Well-Known Member
Member
Joined
Oct 15, 2015
Messages
338
Trophies
0
XP
611
Country
Italy
Am I looking in the wrong places or is there not much Homebrew stuff for 3DS?

I could only see SNES emulator worth using really.

What are you looking for really? Speaking of emulation we have a full range of emulated devices (nes, snes, gb, gba, dos, sega consoles + a couple of others with oscillating results)

There are ways to customize your home menu by changing themes, tools to mess with savefiles, a lot of ways to play "backup" games, a good replica of the official Nintendo Pokemon Bank, an experimental rpg maker game engine... and a lot of other things. There is a lack of good homebrew games but that's to be expected. We can't launch missiles to space yet.
 

goodbytes

Well-Known Member
Newcomer
Joined
Sep 15, 2014
Messages
51
Trophies
0
Age
37
XP
168
Country
What are you looking for really? Speaking of emulation we have a full range of emulated devices (nes, snes, gb, gba, dos, sega consoles + a couple of others with oscillating results)

There are ways to customize your home menu by changing themes, tools to mess with savefiles, a lot of ways to play "backup" games, a good replica of the official Nintendo Pokemon Bank, an experimental rpg maker game engine... and a lot of other things. There is a lack of good homebrew games but that's to be expected. We can't launch missiles to space yet.

Cool thanks, maybe i'll take another look at it, Sega emulator would be awesome.
 

Ryuzaki_MrL

Green Thunder
Member
Joined
Jun 23, 2015
Messages
781
Trophies
0
Age
26
XP
2,047
Country
Brazil
I really don't like to start new threads just for asking something, so I'm going to ask here.

We can access every title savedata, extdata and exeFS(kinda?) from within a homebrew. Can we also access other title's romFS? I found an example on ctrulib, but it's used to read files from within a homebrew's own romFS.
 

Slashcash

Well-Known Member
Member
Joined
Oct 15, 2015
Messages
338
Trophies
0
XP
611
Country
Italy
I really don't like to start new threads just for asking something, so I'm going to ask here.

We can access every title savedata, extdata and exeFS(kinda?) from within a homebrew. Can we also access other title's romFS? I found an example on ctrulib, but it's used to read files from within a homebrew's own romFS.

From a quick glance on 3dbrew and ctrulib's source it doesn't seem to be possible. But i'm probably missing something as this seems really strange.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    SylverReZ @ SylverReZ: @Psionic Roshambo, https://youtu.be/9FcXxqthgUM?feature=shared&t=169