SSBM Decomp
Loading...
Searching...
No Matches
lbrefract.c File Reference

Refraction visual effects using GX indirect textures. More...

#include "lbrefract.h"
#include <placeholder.h>
#include "dolphin/gx/GXEnum.h"
#include "lb/lbarchive.h"
#include "lb/types.h"
#include <math.h>
#include <string.h>
#include <dolphin/gx/GXBump.h>
#include <dolphin/gx/GXGeometry.h>
#include <dolphin/gx/GXLighting.h>
#include <dolphin/gx/GXPixel.h>
#include <dolphin/gx/GXTev.h>
#include <dolphin/gx/GXTexture.h>
#include <dolphin/gx/GXTransform.h>
#include <dolphin/os/OSCache.h>
#include <baselib/class.h>
#include <baselib/cobj.h>
#include <baselib/debug.h>
#include <baselib/dobj.h>
#include <baselib/memory.h>
#include <baselib/pobj.h>
#include <baselib/state.h>
#include <MetroTRK/intrinsics.h>

Data Structures

struct  lbRefract_DataLayout
 
struct  lbl_804336D0_t
 

Macros

#define SIGN_BIT   (1 << 31)
 
#define BITWISE(f)   (*(u32*) &f)
 
#define SIGNED_BITWISE(f)   ((s32) BITWISE(f))
 
#define GET_SIGN_BIT(f)   (SIGNED_BITWISE(f) & SIGN_BIT)
 
#define BITWISE_PI_2   0x3FC90FDB
 
#define NAN   MSL_TrigF_80400770[0]
 
#define INF   MSL_TrigF_80400774[0]
 
#define SILVER_RATIO_1_CONJUGATE   lbRefract3_804D7DD4
 
#define BITWISE_INF   0x7F800000 /* = +Infinity */
 
#define BITWISE_0_5   0x3F000000 /* = 0.5f */
 
#define BITWISE_1_0   0x3F800000 /* = 1.0f */
 
#define BITWISE_2_0   0x40000000 /* = 2.0f */
 
#define BITWISE_THRESHOLD_0   0x3F08D5B9 /* = 0.534511148929596f */
 
#define BITWISE_THRESHOLD_1   0x3F521801 /* = 0.8206787705421448f */
 
#define BITWISE_THRESHOLD_2   0x3F9BF7EC /* = 1.218503475189209f */
 
#define BITWISE_THRESHOLD_3   0x3FEF789E /* = 1.870868444442749f */
 

Functions

static void lbRefract_WriteTexCoordIA4 (lbRefract_CallbackData *data, s32 row, u32 col, u32 arg3, u8 arg4, u8 intensity, u8 alpha)
 Write IA4 texture coordinate to refraction buffer.
 
static void fn_80021F70 (lbRefract_CallbackData *data, s32 row, u32 col, s32 r, s32 g, u32 b)
 
static void fn_80021FB4 (lbRefract_CallbackData *data, s32 row, u32 col, u8 arg3, u8 arg4, u8 arg5, u8 arg6)
 
static void fn_80021FF8 (lbRefract_CallbackData *, s32, u32, s32 *, s32 *, s32 *, s32 *)
 
static void fn_8002206C (lbRefract_CallbackData *, s32, u32, s32 *, s32 *, s32 *, s32 *)
 
static void lbRefract_DObjDispReset (HSD_DObj *dobj, Mtx vmtx, Mtx pmtx, u32 rendermode)
 Display DObj then reset TEV/indirect stages for refraction cleanup.
 
static void lbRefract_ReadTexCoordRGBA8 (lbRefract_CallbackData *data, s32 row, u32 col, u32 *out_r, u32 *out_g, u8 *out_b, u8 *out_a)
 Read RGBA8 texture coordinate addresses from refraction buffer.
 
static float lbRefract_80022DF8 (float x)
 
s32 lbRefract_8002219C (lbRefract_CallbackData *data, s32 buffer, s32 format, s32 width, s32 height)
 Initialize refraction callback data for a texture buffer.
 
static void fn_80022650 (void)
 
static void fn_80022940 (void)
 
 STATIC_ASSERT (sizeof(struct lbl_804336D0_t)==0x40)
 
void lbRefract_80021CE8 (void *arg0, s32 arg1)
 
void lbRefract_800222A4 (void)
 
void lbRefract_8002247C (HSD_CObj *cobj)
 Copy framebuffer to refraction source texture.
 
void lbRefract_80022560 (void)
 Copy framebuffer to refraction source texture.
 
void lbRefract_800225D4 (void)
 Reset TEV and indirect texture stages.
 
s32 lbRefract_PObjLoad (HSD_PObj *pobj, HSD_PObjDesc *desc)
 
void lbRefract_80022998 (HSD_MObj *mobj, u32 rendermode, s32 arg2)
 
void lbRefract_80022BB8 (void)
 Increment refraction effect user count.
 
void lbRefract_80022BD0 (void)
 Decrement refraction effect user count.
 
float atan2f (float y, float x)
 
float acosf (float x)
 
float asinf (float x)
 
float atanf (float x)
 

Variables

HSD_DObjInfo hsdDObj
 
HSD_PObjInfo hsdPObj
 
f32 lbl_803BB0E0 [6]
 
struct lbRefract_DataLayout lbl_803BB0B0
 
static struct lbl_804336D0_t lbl_804336D0
 
static u8lbl_804D63E8
 
float MSL_TrigF_80400770 []
 
float MSL_TrigF_80400774 []
 
static const float atanf_lookup []
 

Detailed Description

Refraction visual effects using GX indirect textures.

Uses reference counting to track active effect users. Supports IA4, IA8, and RGBA8 texture formats.

Macro Definition Documentation

◆ SIGN_BIT

#define SIGN_BIT   (1 << 31)

◆ BITWISE

#define BITWISE (   f)    (*(u32*) &f)

◆ SIGNED_BITWISE

#define SIGNED_BITWISE (   f)    ((s32) BITWISE(f))

◆ GET_SIGN_BIT

#define GET_SIGN_BIT (   f)    (SIGNED_BITWISE(f) & SIGN_BIT)

◆ BITWISE_PI_2

#define BITWISE_PI_2   0x3FC90FDB

◆ NAN

#define NAN   MSL_TrigF_80400770[0]

◆ INF

#define INF   MSL_TrigF_80400774[0]

◆ SILVER_RATIO_1_CONJUGATE

#define SILVER_RATIO_1_CONJUGATE   lbRefract3_804D7DD4

◆ BITWISE_INF

#define BITWISE_INF   0x7F800000 /* = +Infinity */

◆ BITWISE_0_5

#define BITWISE_0_5   0x3F000000 /* = 0.5f */

◆ BITWISE_1_0

#define BITWISE_1_0   0x3F800000 /* = 1.0f */

◆ BITWISE_2_0

#define BITWISE_2_0   0x40000000 /* = 2.0f */

◆ BITWISE_THRESHOLD_0

#define BITWISE_THRESHOLD_0   0x3F08D5B9 /* = 0.534511148929596f */

◆ BITWISE_THRESHOLD_1

#define BITWISE_THRESHOLD_1   0x3F521801 /* = 0.8206787705421448f */

◆ BITWISE_THRESHOLD_2

#define BITWISE_THRESHOLD_2   0x3F9BF7EC /* = 1.218503475189209f */

◆ BITWISE_THRESHOLD_3

#define BITWISE_THRESHOLD_3   0x3FEF789E /* = 1.870868444442749f */

Function Documentation

◆ lbRefract_WriteTexCoordIA4()

static void lbRefract_WriteTexCoordIA4 ( lbRefract_CallbackData data,
s32  row,
u32  col,
u32  arg3,
u8  arg4,
u8  intensity,
u8  alpha 
)
static

Write IA4 texture coordinate to refraction buffer.

◆ fn_80021F70()

static void fn_80021F70 ( lbRefract_CallbackData data,
s32  row,
u32  col,
s32  r,
s32  g,
u32  b 
)
static

◆ fn_80021FB4()

static void fn_80021FB4 ( lbRefract_CallbackData data,
s32  row,
u32  col,
u8  arg3,
u8  arg4,
u8  arg5,
u8  arg6 
)
static

◆ fn_80021FF8()

static void fn_80021FF8 ( lbRefract_CallbackData data,
s32  row,
u32  col,
s32 arg3,
s32 arg4,
s32 arg5,
s32 arg6 
)
static

◆ fn_8002206C()

static void fn_8002206C ( lbRefract_CallbackData data,
s32  row,
u32  col,
s32 arg3,
s32 arg4,
s32 arg5,
s32 arg6 
)
static

◆ lbRefract_DObjDispReset()

static void lbRefract_DObjDispReset ( HSD_DObj dobj,
Mtx  vmtx,
Mtx  pmtx,
u32  rendermode 
)
static

Display DObj then reset TEV/indirect stages for refraction cleanup.

◆ lbRefract_ReadTexCoordRGBA8()

static void lbRefract_ReadTexCoordRGBA8 ( lbRefract_CallbackData data,
s32  row,
u32  col,
u32 *  out_r,
u32 *  out_g,
u8 out_b,
u8 out_a 
)
static

Read RGBA8 texture coordinate addresses from refraction buffer.

◆ lbRefract_80022DF8()

static float lbRefract_80022DF8 ( float  x)
inlinestatic

◆ lbRefract_8002219C()

s32 lbRefract_8002219C ( lbRefract_CallbackData data,
s32  buffer,
s32  format,
s32  width,
s32  height 
)

Initialize refraction callback data for a texture buffer.

Parameters
dataCallback data to initialize.
bufferBase address of texture buffer.
formatTexture format (3=IA4, 4=IA8, 6=RGBA8).
widthTexture width in pixels.
heightTexture height in pixels.
Returns
0 on success, -1 if format is unsupported.

◆ fn_80022650()

static void fn_80022650 ( void  )
static

◆ fn_80022940()

static void fn_80022940 ( void  )
static

◆ STATIC_ASSERT()

STATIC_ASSERT ( sizeof(struct lbl_804336D0_t = =0x40)

◆ lbRefract_80021CE8()

void lbRefract_80021CE8 ( void *  arg0,
s32  arg1 
)

◆ lbRefract_800222A4()

void lbRefract_800222A4 ( void  )

◆ lbRefract_8002247C()

void lbRefract_8002247C ( HSD_CObj cobj)

Copy framebuffer to refraction source texture.

◆ lbRefract_80022560()

void lbRefract_80022560 ( void  )

Copy framebuffer to refraction source texture.

◆ lbRefract_800225D4()

void lbRefract_800225D4 ( void  )

Reset TEV and indirect texture stages.

◆ lbRefract_PObjLoad()

s32 lbRefract_PObjLoad ( HSD_PObj pobj,
HSD_PObjDesc desc 
)

◆ lbRefract_80022998()

void lbRefract_80022998 ( HSD_MObj mobj,
u32  rendermode,
s32  arg2 
)

◆ lbRefract_80022BB8()

void lbRefract_80022BB8 ( void  )

Increment refraction effect user count.

◆ lbRefract_80022BD0()

void lbRefract_80022BD0 ( void  )

Decrement refraction effect user count.

◆ atan2f()

float atan2f ( float  y,
float  x 
)

◆ acosf()

float acosf ( float  x)

◆ asinf()

float asinf ( float  x)

◆ atanf()

float atanf ( float  x)

Variable Documentation

◆ hsdDObj

HSD_DObjInfo hsdDObj
extern

◆ hsdPObj

HSD_PObjInfo hsdPObj
extern

◆ lbl_803BB0E0

f32 lbl_803BB0E0[6]
extern

◆ lbl_803BB0B0

struct lbRefract_DataLayout lbl_803BB0B0
Initial value:
= {
{ { 0 } },
{ 0 },
{ 0 },
{ 0 },
{ 0 },
{ 0 },
{ 0 },
{ 0 },
"",
"",
"refract_class_library",
"refract_dobj",
"refract_pobj",
}
static void fn_80022650(void)
Definition lbrefract.c:481
static void fn_80022940(void)
Definition lbrefract.c:647

◆ lbl_804336D0

struct lbl_804336D0_t lbl_804336D0
static

◆ lbl_804D63E8

u8* lbl_804D63E8
static

◆ MSL_TrigF_80400770

float MSL_TrigF_80400770[]
extern

◆ MSL_TrigF_80400774

float MSL_TrigF_80400774[]

◆ atanf_lookup

const float atanf_lookup[]
static