Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Spherical Coordinates and Normal Mapping on Nintendo Systems.

Author
Message
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 6th Jun 2013 06:34
Seems like you could save memory by reading in Vertex data this way

Read X
Read Y
start with a Theta like 0 to convert to Z values with

H1=1-(2/3)/KAPPA
H2=(sqrt(2))
K2=ABS(KAPPA-2/3)
KAPPA=sqrt(2)-1/3*4

(H2 (-) ((1.0-t)*0 + K2*t) + tevbias) * tevscale
(H1 (+) ((1.0-t)*0 + TEV1*t) + tevbias) * tevscale

Then Offset Z with another TEV stage in the Same time it would take to load all three values from memory

or

With Theta and Phi Starting at say 0

and

You could procedurally generate coordinate without baking to memory

Reading from an Array or using the relation

http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/NURBS/RB-conics.html

q=cos(x)
z=cos(x)
z=sqrt(1-x^2)-sqrt(1-y^2)
q=sqrt(1-x^2)-sqrt(1-y^2)

=cos(u)^2-cos(v)^2

z=sqrt(1-x^2)-sqrt(1-y^2)

z^2=Hyperbola-sincombo=(y^2-x^2)-sin(u+v)

Basically to Convert to X Y Z in 2 to 3 TEV cycles( 3 for Y,Z 2 for Z) into XYZ so it can Procedurally create shapes with spherical coordinates or if this is too hard/cumbersome fall back on Array lookups for X and Y. So the method would read in x=sincos(Theta,Phi)
y=sinsin(Theta,Phi) then use 3 TEVS to model verticies iterating along the XZ or YZ axis. This should take the same time as reading in three vectors as well.

So why do developers choose baking?

XXX
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 6th Jun 2013 07:00
Then there's normal mapping reading from spherical coordinates

Read in Rratio 1 Image Search (Smaller File Size)
Calculate Sinratio 1 Array Search SIN(THETA)/SIN(PHI)*Rratio 256MB=
Calculate Stheta 1 Array Search 16 MB
Calculate Sphi 1 Array Search 1MB
Calculate Dot Product 1 Array Search using trig identity 512MB=
sin(AngT1)sin(AngP1)*cos(AngT2-AngP2)+sin(AngT1)sin(AngP1)
Calculate Dot Product 1 Array Search using trig identity
sin(AngT1)sin(AngP1)*cos(AngT2-AngP2)+sin(AngT1)sin(AngP1)
Calculate ANS 1 Array Search 1MB

Once you've calculated it this way you just apply it as a texture from which you can add other effects on top.

It allows speed as with only 6 Array searches and how it convienietly searches Rratio from a file it makes normal mapping faster given you have the Binormals,Tangents and Normals. (which can be gotten from the normals)

XXX
_Pauli_
AGK Developer
16
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 6th Jun 2013 10:07 Edited at: 6th Jun 2013 10:08
Don't ask me why but you sound like this guy! Posting magical formulas all over the place...
Maybe you should ask a Nintendo engineer?

Somehow came to that thread because of some slightly unrelated search, just posting here for the funny concurrency

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Jun 2013 23:58
Quote: "So why do developers choose baking?"

Reduce computational overhead?

Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 7th Jun 2013 03:37
Turns out the Sin(2u)-Sin(2v) that you get is the equation to find the coordinate of the chord between the two angles so you just calculate the distance between the two points in the y so its just the sin(4u-2v).

So the three TEVS is TEVscale=4
c=1/2
a=0
b=v
d=u
Scale=4
tev=4(u-1/2v)
and The same two TEVS to calculate a circle.

XXX
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 7th Jun 2013 03:40
AT 4GB/s from RAM it takes the same amount of time to allocate dyanmically from RAM 3 times as it does to start with a value preloaded and procedurally generate from there with the GPU so I don't understand what you're saying about computation overhead?

XXX
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Jun 2013 13:48
Programmer X, why are you converting from spherical coordinates?

Anyway, to answer your question:

Quote: "So why do developers choose baking?"


Baking means you're calculating all of the light data before you even use the model in the game. This gives you a texture like the following: http://2.bp.blogspot.com/_W5dgtEXHWak/S1lweqBYfHI/AAAAAAAAACo/B_PjdXPufTU/s400/baking_map.jpg

If your textures are baked, you don't need to calculate the lights during runtime on the GPU again for every frame. It saves you a lot of processing power.

@all

You may have noticed he's been talking a lot about "TEV". This is Nintendo's version of a shading technique used on the GameCube and on the Wii. It's much closer to the actual hardware, and is considered to be just as powerful as shading model 2.0. However, it lacks the flexibility of shading model 2.0.

I couldn't find a lot of information about it. This article from 2002 explains it in detail:

http://www.gamasutra.com/view/feature/131354/shader_integration_merging_.php?page=1

And I was able to dig up an example of what a TEV shader could look like.

http://forums.dolphin-emu.org/Thread-pixel-shader-for-tev-stages


TheComet


Yesterday is History, Tomorrow is a Mystery, but Today is a Gift. That is why it is called "present".
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 7th Jun 2013 23:35
Looks like I was mistaken first you find with 1 TEV

ANS=(U-V)sin(V)

U and V in Radians

So you would do (u (+) ((1.0-TEV2)*u + v*TEV1)

XXX
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 7th Jun 2013 23:44
Yes and you can also bake your models where you calculate all the points the model is at.

XXX
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 8th Jun 2013 00:00
"Programmer X, why are you converting from spherical coordinates?"

It makes the curves more complex from less input.

Also c0 = color[1] this the wii is slow compared to TEV because it's memory speed is only 4GB/s. Reading lots of Booleans from Ram should be fast but not chars and ints.

XXX
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 8th Jun 2013 00:36
rastemp = colors_0.rgba;
c0 = color[1], c1 = color[2], c2 = color[3]
in float4 rawpos : VPOS,
in float4 colors_0 : COLOR0,
in float4 colors_1 : COLOR1,

I'm not sure how this is instanciating C++ but even at....

Char percision reading in 16 8bit(4* (4char arrays)) values is slower than reading from an array 6 times with 8 bit (1 byte) values like in the normal map example. There is a catch though Normal mapping that way is based on 6bit unsigned angles with quadrants for boolean array reads and signs so its only comparable to 7 bit percision regular floats for array size restraints.

XXX
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 8th Jun 2013 01:14
Your talking a load of rubbish.


Yesterday is History, Tomorrow is a Mystery, but Today is a Gift. That is why it is called "present".
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 8th Jun 2013 02:53 Edited at: 8th Jun 2013 02:54
Nevermind...

Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 8th Jun 2013 03:41
Your talking a load of rubbish.

How is it rubbish?

XXX
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Jun 2013 06:19
Quote: "AT 4GB/s from RAM it takes the same amount of time to allocate dyanmically from RAM 3 times as it does to start with a value preloaded and procedurally generate from there with the GPU so I don't understand what you're saying about computation overhead?"


You said Nintendo, and with my mind on the retro competition all week, I was thinking NES. Which I wasn't sure why someone would even want to calculate spherical coords on an NES, but as you can probably see now where my mind was.

Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 8th Jun 2013 08:05
I keep messin up those coords but here's what you're supposed to do

1/2*sin(2*Theta)*LastX

Evaluate Sin(2T) for theta
Evaluate scale=0.5 of LastX*TEV

Which means you take the sin(2t) and multiply it by the last X you got with scale 1/2

sin(u)-(sin(-v))

sin(u+v)

sin(2v)*Last X

sin(Theta-Phi)*Last X

Sin(Theta)cos(Phi)=1/2*(sin(Theta+Phi)+sin(Theta-Phi))=

1/2*sin(2*Theta)*LastX

Because

sin(x)-(sin(-y))=sin(x-(-y))*LastX
u=Theta
v=Phi
x=u-v
y=u+v

XXX
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 8th Jun 2013 08:07
The last x input is what i mean for the bezier curve

XXX
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 10th Jun 2013 08:45
Unfortunately i don't think that was right either but this may be closer but it is wrong

sin(u)cos(v)=0.5*((0.5(sin(3v)-((2(Y)sin(V))-sin(v)))*(cos(u

))



sin(v)^2*sin(u)

1-sin(v)

-sin^2






Looks like I went wrong

applying sin(u)cos(v)=1/2sin(u+v)+1/2sin(u-v)

with x=u+v and y=u-v

that should allow me to solve for a chord of circle at angle so it becomes

sin(u)*cos(v)

2*sin(u+v-(u-v)/2)= 2*sin(2v)/2)=2sin(v)
should be the chord then times the cos(?) of some angle should get me the value in the x direction from there apply trig identities so its just the sin(ku) or sin(kv) which you can look up and the cos(u) depending on how you solve for Y=sin(x)sin(y). cos(u) finds you Z sin(u)sin(v) finds you Y. then you can take your last TEVS to find sin(u)cos(v)

XXX
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 10th Jun 2013 18:43 Edited at: 10th Jun 2013 18:48
Text formatting of maths is horrific, you should find a way to display it more nicely.

This site is great.

[img]http://latex.codecogs.com/png.latex?cos(2x)%20\equiv%201-%202sin^{2}(x)[/img]

But apparently image embedding doesn't work...


They see me coding, they hating. http://indi-indicium.blogspot.co.uk/
The Zoq2
16
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 10th Jun 2013 18:48
That looks realy usefull, thanks for sharing!
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 10th Jun 2013 22:08


If that's too hard I guess you could just search sin(u)sin(v) calculating sin(u) and sin(v) then going sin(u+270%%360) and use sin(u) as the Z cosine there then do the same with sin(v) and calulate the next u and v to use in sin()sin() sin()cos() cos() That would be 4 TEV cycles for the sines leaving lots of TEVs for additional bezier operations

I also think i figured out where i went wrong you have to add 2*sin(V) for to the chord and take the Sin(?) not the cosine.

XXX
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 12th Jun 2013 01:10
Normal Maps may be too slower than the following method. That method has 4TEVs and 3Bytes for the RGB Normal Map and 3bytes to read in the position of the light in 3d space. If you make the wii read 6bits in 4GB for the Theta and Phi, Rratio and sinratio it's may be faster otherwise it looks like this might be slightly faster.
http://beyond3d.com/showthread.php?t=54480

I'd really have to do a speed test.

XXX
Programmer X
18
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 19th Jun 2013 01:49
http://www.handwritten.net/mv/papers/shao96curve_fitting_with_bezier_cubics.pdf
http://www.codeproject.com/Articles/63170/Least-Squares-Regression-for-Quadratic-Curve-Fitti

More for curve fitting 3d Models to piecewise bezier curves that should load faster than from Memory

XXX

Login to post a reply

Server time is: 2026-07-10 22:44:54
Your offset time is: 2026-07-10 22:44:54