What's new

Need help with "emulate clear"

Gonetz

Plugin Developer (GlideN64)
I have a question for developers.
I want to implement so called "implement clear" framebuffer feature.
In PJ64 User Manual it is explained as
"This is a framebuffer control. Some games use low level framebuffer clears for special effects.
A classic example is the lens flare from the sun in Zelda."
This explanation gives me no idea how it works. What does it means, "low level framebuffer clears"?
Is it not an ucode command? And how clearing frame buffer can make objects appear?
I've made my own investigation. There is one place in the first dungeon of Zelda OOT, with 2 torches, and when you stand in some place, flame corona appears, but only for one torch (see the picture).
Jobo's plugin works the same with "emulate clear" set off. When I set it on, coronas appeared for both torches.
I have logged this frame, and I found that for second torch, which is without corona, model matrix is zero:

00187698 (c0:da380003, c1:801864b8): uc2:matrix
modelview load
{0.000000,0.000000,0.000000,0.000000}
{0.000000,0.000000,0.000000,0.000000}
{0.000000,0.000000,0.000000,0.000000}
{-208.000000,-841.000000,995.000000,1.000000}

.......

00290e78 (c0:01004008, c1:040156e0): uc2:vertex n: 4, v0: 0, from: 00290df0
v0 - x: -0.982850, y: 4.363775, z: 137.234406, w: 156.501282, u: 64.000000, v: 0.000000
v1 - x: -0.982850, y: 4.363775, z: 137.234406, w: 156.501282, u: 0.000000, v: 0.000000
v2 - x: -0.982850, y: 4.363775, z: 137.234406, w: 156.501282, u: 0.000000, v: 64.000000
v3 - x: -0.982850, y: 4.363775, z: 137.234406, w: 156.501282, u: 64.000000, v: 64.000000

While for the first torch model matrix was

00187680 (c0:da380003, c1:801864f8): uc2:matrix
modelview load
{0.103989,0.000000,0.000000,0.000000}
{0.000000,0.103989,0.000000,0.000000}
{0.000000,0.000000,0.103989,0.000000}
{-281.000000,-810.000000,881.000000,1.000000}

And vertices have correct coordinates.

So, Jabo probably supplies correct model matrix for second torch when "emulate clear" is on, but how he did it?

Second effect, "lens flare from the sun".
The situation is different. All polygons for lens flare are present and on its places, all textures loaded correctly, but it has color combiner PRIM and alpha combiner TEXTURE*PRIM_ALPHA, and PRIM_ALPHA is always 0, so all polygons are invisible. With "emulate clear" on, Jabo's plugin has 1 additional screen-size rectangle, which looks like a fillrect. I don't know what it doing, but lens flare polygons become visible.

Has anybody an idea, how it really works?
 

Rice

Emulator Developer
I wondered what emulate clear was exactly, too. It does stop DK jumping. I guess it is not (or not only) clear the frame buffer and z buffer, but reset RSP matrix stack and some SP/DP registers. I think Smiff or Jabo can answer this question.
 
OP
Gonetz

Gonetz

Plugin Developer (GlideN64)
I guess it is not (or not only) clear the frame buffer and z buffer
I do not see any evidence that "emulate clear" clears frame buffer or z buffer, at least for effects described above. Again, I do not understand, how clearing of frame buffer can make objects appear?

but reset RSP matrix stack and some SP/DP registers
Yes, this is very possible. But, matrix stack must be reset before main processing loop started:
rdp.model_i = 0; // 0 matrices so far in stack
So, if "emulate clear" doing something with matrix stack, it happens during dlist processing. Since there are no such commands were logged, there must be inderect indication that "emulate clear" is used in this frame, something like that zero modelview matrix, or special state of some registers. I still have no idea, where to look at :(

I think Smiff or Jabo can answer this question.
Jabo surely can :) But he will not. I do not remeber that Jabo ever answer such questions.
 

Orkin

d1R3c764 & g1|\|64 m4|<3R
I've wondered the same thing, never took the time to look into it though (barely have time to work on my plugin at all lately).

Let me know if you guys find out anything!
 

Top