citro3d
Loading...
Searching...
No Matches
proctex.h
1#pragma once
2#include "types.h"
3
4typedef struct
5{
6 u32 color[256];
7 u32 diff[256];
9
10typedef struct
11{
12 union
13 {
14 u32 proctex0;
15 struct
16 {
17 u32 uClamp : 3;
18 u32 vClamp : 3;
19 u32 rgbFunc : 4;
20 u32 alphaFunc : 4;
21 bool alphaSeparate : 1;
22 bool enableNoise : 1;
23 u32 uShift : 2;
24 u32 vShift : 2;
25 u32 lodBiasLow : 8;
26 };
27 };
28 union
29 {
30 u32 proctex1;
31 struct
32 {
33 u16 uNoiseAmpl;
34 u16 uNoisePhase;
35 };
36 };
37 union
38 {
39 u32 proctex2;
40 struct
41 {
42 u16 vNoiseAmpl;
43 u16 vNoisePhase;
44 };
45 };
46 union
47 {
48 u32 proctex3;
49 struct
50 {
51 u16 uNoiseFreq;
52 u16 vNoiseFreq;
53 };
54 };
55 union
56 {
57 u32 proctex4;
58 struct
59 {
60 u32 minFilter : 3;
61 u32 unknown1 : 8;
62 u32 width : 8;
63 u32 lodBiasHigh : 8;
64 };
65 };
66 union
67 {
68 u32 proctex5;
69 struct
70 {
71 u32 offset : 8;
72 u32 unknown2 : 24;
73 };
74 };
76
77enum
78{
79 C3D_ProcTex_U = BIT(0),
80 C3D_ProcTex_V = BIT(1),
81 C3D_ProcTex_UV = C3D_ProcTex_U | C3D_ProcTex_V,
82};
83
84void C3D_ProcTexInit(C3D_ProcTex* pt, int offset, int length);
85void C3D_ProcTexNoiseCoefs(C3D_ProcTex* pt, int mode, float amplitude, float frequency, float phase);
86void C3D_ProcTexLodBias(C3D_ProcTex* pt, float bias);
87void C3D_ProcTexBind(int texCoordId, C3D_ProcTex* pt);
88
89// GPU_LUT_NOISE, GPU_LUT_RGBMAP, GPU_LUT_ALPHAMAP
90typedef u32 C3D_ProcTexLut[128];
91void C3D_ProcTexLutBind(GPU_PROCTEX_LUTID id, C3D_ProcTexLut* lut);
92void ProcTexLut_FromArray(C3D_ProcTexLut* lut, const float in[129]);
93
94void C3D_ProcTexColorLutBind(C3D_ProcTexColorLut* lut);
95void ProcTexColorLut_Write(C3D_ProcTexColorLut* out, const u32* in, int offset, int length);
96
97static inline void C3D_ProcTexClamp(C3D_ProcTex* pt, GPU_PROCTEX_CLAMP u, GPU_PROCTEX_CLAMP v)
98{
99 pt->uClamp = u;
100 pt->vClamp = v;
101}
102
103static inline void C3D_ProcTexCombiner(C3D_ProcTex* pt, bool separate, GPU_PROCTEX_MAPFUNC rgb, GPU_PROCTEX_MAPFUNC alpha)
104{
105 pt->alphaSeparate = separate;
106 pt->rgbFunc = rgb;
107 if (separate)
108 pt->alphaFunc = alpha;
109}
110
111static inline void C3D_ProcTexNoiseEnable(C3D_ProcTex* pt, bool enable)
112{
113 pt->enableNoise = enable;
114}
115
116static inline void C3D_ProcTexShift(C3D_ProcTex* pt, GPU_PROCTEX_SHIFT u, GPU_PROCTEX_SHIFT v)
117{
118 pt->uShift = u;
119 pt->vShift = v;
120}
121
122static inline void C3D_ProcTexFilter(C3D_ProcTex* pt, GPU_PROCTEX_FILTER min)
123{
124 pt->minFilter = min;
125}
GPU_PROCTEX_FILTER
GPU_PROCTEX_SHIFT
GPU_PROCTEX_LUTID
GPU_PROCTEX_CLAMP
GPU_PROCTEX_MAPFUNC
Definition proctex.h:5
Definition proctex.h:11
#define BIT(n)
uint16_t u16
uint32_t u32