Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Do Mai 23, 2024 05:57

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Autor Nachricht
BeitragVerfasst: Mi Nov 21, 2007 00:13 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
What terminology do we use for an effect like we see on the PS3 XMB menu - the whispy, smokey, watery, plasma-ish type effect?

Like this:

Bild

Is it a particle thing? A Perlin noise thing? Something created with the motion blur of a number of bezier curves moving with sine values?

Of course... I am curious and have been trying to emulate it to educate myself... I started with a single 4-control point bezier curve where each point moves up and down on the Y axis tied in to some sine values... looks neat - but nowhere near as neat as that - looks better when I add 4 more bezier curves with different control points... no motion blurring yet, but that might make it look even better - however - the main question is - I'm not even sure I'm using the right kind of algorithims for this. Has anyone got any bright ideas?

I was lucky enough for work to buy me a PS3 to do some investigations on the Cell chip - been there and done a bit of that now with the boring "Get Work Done" type of algorithms - very interesting but I'd always wanted to see if I could do some fancy OpenGL stuff with the ATI thing inside it. Sadly it seems we'll be locked-out from that by Sony for the time-being... but at least, I thought, I should take a look and try to understand what kind of coding is being used to create that funky (but simple) menu effect.

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Nov 21, 2007 17:25 
Offline
DGL Member
Benutzeravatar

Registriert: Di Mai 18, 2004 16:45
Beiträge: 2622
Wohnort: Berlin
Programmiersprache: Go, C/C++
I think, that are some Bezier based Shapes who use a faded Texture.
Create 2-3 Textures where the top is white and the bottom black, add some noise and gauss.
Add this texture on the Shape and change the alpha value of the vertice on the left and right side.
A different alpha value for every Shape let it seem a little bit random.

_________________
"Wer die Freiheit aufgibt um Sicherheit zu gewinnen, der wird am Ende beides verlieren"
Benjamin Franklin

Projekte: https://github.com/tak2004


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Nov 21, 2007 17:47 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
Interesting. I now think I started down a wrong path with Bezier curves being displayed as lines.

I started tinkering and I got to something that looks like the following... the solid colours are just to identify the curves as they bounce up and down... I thought if I did enough of these and then enabled blending that it might start to look like what we see on the PS3 XMB.

Now I no longer think that. I don't think this will provide what I want.

Bild

Bezier patches on the other hand... maybe...

This is where I got to, just in case anyone is interested - should compile easily - just sitting on a TPanel called pOGL... it's a bit 'brute force' I think - not very eloquent.

Code:
  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   OpenGL, Windows, SysUtils, Classes, Controls, Forms, StdCtrls, ComCtrls, ExtCtrls;
  7.  
  8. const
  9.   MaxLevelOfDetail = 100;
  10.   NumberOfControlPoints = 4;
  11.  
  12. type
  13.   TSineIndex = record
  14.     Position : Integer;
  15.     Speed : Integer;
  16.     Travel : GLFloat;
  17.   end;
  18.  
  19.   TPoint = record
  20.     X, Y, Z : GLFloat;
  21.   end;
  22.  
  23.   TfrmMain = class(TForm)
  24.     Timer1 : TTimer;
  25.     pOGL : TPanel;
  26.     procedure FormCreate (Sender : TObject);
  27.     procedure Timer1Timer (Sender : TObject);
  28.     procedure FormKeyDown (Sender: TObject; var Key: Word; Shift: TShiftState);
  29.   private
  30.     function GetPointOnCurve (ControlPoint1, ControlPoint2, ControlPoint3, ControlPoint4 : TPoint; CurvePoint : GLFloat) : TPoint;
  31.     procedure Draw;
  32.     procedure SetupControlPoints;
  33.   public
  34.   end;
  35.  
  36. var
  37.   frmMain : TfrmMain;
  38.   LevelOfDetail : Integer = 50;
  39.   ControlPoints : array[0..4,0..NumberOfControlPoints - 1] of TPoint;
  40.  
  41.   SineTable : array[0..360] of GLFloat;
  42.   SineIndices : array[0..3] of TSineIndex;
  43.  
  44.  
  45. implementation
  46.  
  47.   procedure glBindTexture (Target : GLEnum; Texture : GLUInt); stdcall; external OpenGL32;
  48.   procedure glGenTextures (N : GLSizeI; var Textures : GLUInt); stdcall; external OpenGL32;
  49.  
  50.  
  51. {$R *.DFM}
  52.  
  53.  
  54. procedure SetupPixelFormat ( DC : HDC
  55.                            );
  56. const
  57.    PFD : TPIXELFORMATDESCRIPTOR = (
  58.          nSize : SizeOf (TPIXELFORMATDESCRIPTOR); nVersion : 1;
  59.          dwFlags : PFD_SUPPORT_OPENGL or PFD_DRAW_TO_WINDOW or PFD_DOUBLEBUFFER;
  60.          iPixelType : PFD_TYPE_RGBA;
  61.          cColorBits : 24; cRedBits : 0; cRedShift : 0; cGreenBits : 0; cGreenShift : 0;
  62.          cBlueBits : 0; cBlueShift : 0; cAlphaBits : 0; cAlphaShift : 0; cAccumBits : 0;
  63.          cAccumRedBits : 0; cAccumGreenBits : 0; cAccumBlueBits : 0; cAccumAlphaBits : 0;
  64.          cDepthBits : 16; cStencilBits : 0; cAuxBuffers : 0; iLayerType : PFD_MAIN_PLANE;
  65.          bReserved : 0; dwLayerMask : 0; dwVisibleMask : 0; dwDamageMask : 0);
  66. var
  67.   PixelFormat : Integer;
  68. begin
  69.    PixelFormat := ChoosePixelFormat (DC,@PFD);
  70.    if (PixelFormat = 0) then
  71.    begin
  72.      Exit;
  73.    end;
  74.  
  75.    if (SetPixelFormat (DC,PixelFormat,@PFD) <> True) then
  76.    begin
  77.      Exit;
  78.    end;
  79. end;
  80.  
  81.  
  82. procedure TfrmMain.FormCreate ( Sender : TObject
  83.                               );
  84. const
  85.   DEG2RAD = 3.14159 / 180;
  86. var
  87.   DegInRad : GLFloat;
  88.   DC : HDC;
  89.   RC : HGLRC;
  90.   Loop : Integer;
  91. begin
  92.   Caption := 'DpM: OpenGL Bezier Curve (Level Of Detail: ' + IntToStr (LevelOfDetail) + ')';
  93.   Width := Screen.Width;
  94.   Height := Screen.Height;
  95.  
  96.   DC := GetDC (pOGL.Handle);
  97.   SetupPixelFormat (DC);
  98.   RC := wglCreateContext (DC);
  99.   wglMakeCurrent (DC,RC);
  100.  
  101.   SetUpControlPoints;
  102.  
  103.   glClearColor (0,0,0,1);
  104.   glLineWidth (14);
  105.   glMap1f (GL_MAP1_VERTEX_3,0,1,3,4,@ControlPoints[0]);
  106.   glEnable (GL_MAP1_VERTEX_3);
  107.   glShadeModel (GL_SMOOTH);
  108.  
  109.   for Loop := 0 to 360 do
  110.   begin
  111.     DegInRad := Loop * DEG2RAD;
  112.     SineTable[Loop] := Sin (DegInRad);
  113.   end;
  114.  
  115.   SineIndices[0].Position := 0;
  116.   SineIndices[0].Speed := 1;
  117.   SineIndices[0].Travel := 1.6;
  118.  
  119.   SineIndices[1].Position := 0;
  120.   SineIndices[1].Speed := 1;
  121.   SineIndices[1].Travel := 0.1;
  122.  
  123.   SineIndices[2].Position := 40;
  124.   SineIndices[2].Speed := 2;
  125.   SineIndices[2].Travel := 0.4;
  126.  
  127.   SineIndices[3].Position := 200;
  128.   SineIndices[3].Speed := 1;
  129.   SineIndices[3].Travel := 2.6;
  130. end;
  131.  
  132.  
  133. procedure TfrmMain.Draw;
  134.  
  135.   procedure DisplayBackground;
  136.   begin
  137.     glMatrixMode (GL_PROJECTION);
  138.     glLoadIdentity;
  139.     glOrtho (0,pOGL.Width,0,pOGL.Height,-10,10);
  140.     glMatrixMode (GL_MODELVIEW);
  141.     glLoadIdentity;
  142.  
  143.     glColor3f (1,1,1);
  144.     glBindTexture (GL_TEXTURE_2D,BackgroundTexture);
  145.     glBegin (GL_QUADS);
  146.       glTexCoord2f (0,0);
  147.       glVertex2f (0,0);
  148.       glTexCoord2f (1,0);
  149.       glVertex2f (pOGL.Width,0);
  150.       glTexCoord2f (1,1);
  151.       glVertex2f (pOGL.Width,pOGL.Height);
  152.       glTexCoord2f (0,1);
  153.       glVertex2f (0,pOGL.Height);
  154.     glEnd;
  155.   end;
  156.  
  157.  
  158.   procedure DisplayStreamers;
  159.   var
  160.     ControlPointLoop, Loop : Integer;
  161.   begin
  162.     glMatrixMode (GL_PROJECTION);
  163.     glLoadIdentity;
  164.     gluPerspective (45,pOGL.Width / pOGL.Height,1,100);
  165.     glMatrixMode (GL_MODELVIEW);
  166.  
  167.     glLoadIdentity;
  168.     glTranslatef (0,0,-10);
  169.  
  170.     for ControlPointLoop := 0 to High (ControlPoints) do
  171.     begin
  172.       case ControlPointLoop of
  173.         0 : glColor4f (0,0.5,1,1);
  174.         1 : glColor4f (0,1,0.5,1);
  175.         2 : glColor4f (1,0,0.5,1);
  176.         3 : glColor4f (1,0.5,1,1);
  177.         4 : glColor4f (1,1,0.5,1);
  178.       end;
  179.  
  180.       case ControlPointLoop of
  181.         0 : begin
  182.               ControlPoints[ControlPointLoop][0].Y := SineTable[SineIndices[0].Position] * SineIndices[0].Travel;
  183.               ControlPoints[ControlPointLoop][1].Y := SineTable[SineIndices[1].Position] * SineIndices[1].Travel;
  184.               ControlPoints[ControlPointLoop][2].Y := SineTable[SineIndices[2].Position] * SineIndices[2].Travel;
  185.               ControlPoints[ControlPointLoop][3].Y := 3 + SineTable[SineIndices[3].Position] * SineIndices[3].Travel;
  186.             end;
  187.         1 : begin
  188.               ControlPoints[ControlPointLoop][1].Y := SineTable[SineIndices[0].Position] * SineIndices[0].Travel;
  189.               ControlPoints[ControlPointLoop][3].Y := 3 + SineTable[SineIndices[1].Position] * SineIndices[1].Travel;
  190.               ControlPoints[ControlPointLoop][0].Y := SineTable[SineIndices[2].Position] * SineIndices[2].Travel;
  191.               ControlPoints[ControlPointLoop][2].Y := SineTable[SineIndices[3].Position] * SineIndices[3].Travel;
  192.             end;
  193.         2 : begin
  194.               ControlPoints[ControlPointLoop][3].Y := 3 + SineTable[SineIndices[0].Position] * SineIndices[0].Travel;
  195.               ControlPoints[ControlPointLoop][0].Y := SineTable[SineIndices[1].Position] * SineIndices[1].Travel;
  196.               ControlPoints[ControlPointLoop][2].Y := SineTable[SineIndices[2].Position] * SineIndices[2].Travel;
  197.               ControlPoints[ControlPointLoop][1].Y := SineTable[SineIndices[3].Position] * SineIndices[3].Travel;
  198.             end;
  199.         3 : begin
  200.               ControlPoints[ControlPointLoop][2].Y := SineTable[SineIndices[0].Position] * SineIndices[0].Travel;
  201.               ControlPoints[ControlPointLoop][0].Y := SineTable[SineIndices[1].Position] * SineIndices[1].Travel;
  202.               ControlPoints[ControlPointLoop][3].Y := 3 + SineTable[SineIndices[2].Position] * SineIndices[2].Travel;
  203.               ControlPoints[ControlPointLoop][1].Y := SineTable[SineIndices[3].Position] * SineIndices[3].Travel;
  204.             end;
  205.         4 : begin
  206.               ControlPoints[ControlPointLoop][2].Y := SineTable[SineIndices[0].Position] * SineIndices[0].Travel;
  207.               ControlPoints[ControlPointLoop][1].Y := SineTable[SineIndices[1].Position] * SineIndices[1].Travel;
  208.               ControlPoints[ControlPointLoop][0].Y := SineTable[SineIndices[2].Position] * SineIndices[2].Travel;
  209.               ControlPoints[ControlPointLoop][3].Y := 3 + SineTable[SineIndices[3].Position] * SineIndices[3].Travel;
  210.             end;
  211.       end;
  212.  
  213.       glMap1f (GL_MAP1_VERTEX_3,0,1,3,4,@ControlPoints[ControlPointLoop]);
  214.  
  215.       { Draw the actual segements of the Bezier curve. }
  216.       glBegin (GL_LINE_STRIP);
  217.         for Loop := 0 to LevelOfDetail do
  218.         begin
  219.           { How do I really know what X, Y and Z this is? }
  220.           glEvalCoord1f (Loop / LevelOfDetail);
  221.         end;
  222.       glEnd;
  223.  
  224.       { Reset the Indices into the SineTable each time it is required. }
  225.       for Loop := Low (SineIndices) to High (SineIndices) do
  226.       begin
  227.         Inc (SineIndices[Loop].Position,SineIndices[Loop].Speed);
  228.         if (SineIndices[Loop].Position > High (SineTable)) then
  229.         begin
  230.           SineIndices[Loop].Position := Low (SineTable);
  231.         end;
  232.       end;
  233.     end;
  234.   end;
  235.  
  236. begin
  237.   glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  238.  
  239.   DisplayStreamers;
  240.  
  241.   SwapBuffers (wglGetCurrentDC);
  242. end;
  243.  
  244.  
  245. procedure TfrmMain.Timer1Timer ( Sender : TObject
  246.                                );
  247. begin
  248.   Draw;
  249. end;
  250.  
  251.  
  252. function TfrmMain.GetPointOnCurve ( ControlPoint1, ControlPoint2, ControlPoint3, ControlPoint4 : TPoint;
  253.                                     CurvePoint : GLFloat
  254.                                   ) : TPoint;
  255. var
  256.   V1, V2, V3 : GLFloat;
  257.   Returning : TPoint;
  258. begin
  259.   V1 := 1 - CurvePoint;
  260.   V2 := V1 * V1 * V1;
  261.   V3 := CurvePoint * CurvePoint * CurvePoint;
  262.  
  263.   Returning.X := V2 * ControlPoint1.X + 3 * CurvePoint * V1 * V1 * ControlPoint2.X + 3 * CurvePoint * CurvePoint * V1 * ControlPoint3.X + V3 * ControlPoint4.X;
  264.   Returning.Y := V2 * ControlPoint1.Y + 3 * CurvePoint * V1 * V1 * ControlPoint2.Y + 3 * CurvePoint * CurvePoint * V1 * ControlPoint3.Y + V3 * ControlPoint4.Y;
  265.   Returning.Z := V2 * ControlPoint1.Z + 3 * CurvePoint * V1 * V1 * ControlPoint2.Z + 3 * CurvePoint * CurvePoint * V1 * ControlPoint3.Z + V3 * ControlPoint4.Z;
  266.  
  267.   GetPointOnCurve := Returning;
  268. end;
  269.  
  270.  
  271. procedure TfrmMain.FormKeyDown ( Sender : TObject;
  272.                                  var Key : Word;
  273.                                  Shift : TShiftState
  274.                                );
  275. begin
  276.   if (Key = VK_DOWN) then
  277.   begin
  278.     if (LevelOfDetail > 1) then
  279.     begin
  280.       Dec (LevelOfDetail);
  281.       Caption := 'DpM: OpenGL Bezier Curve (Level Of Detail: ' + IntToStr (LevelOfDetail) + ')';
  282.     end;
  283.   end else
  284.   if (Key = VK_UP) then
  285.   begin
  286.     if (LevelOfDetail < MaxLevelOfDetail) then
  287.     begin
  288.       Inc (LevelOfDetail);
  289.       Caption := 'DpM: OpenGL Bezier Curve (Level Of Detail: ' + IntToStr (LevelOfDetail) + ')';
  290.     end;
  291.   end else
  292.   if (Key = VK_RETURN) then
  293.   begin
  294.   end else
  295.   if (Key = VK_SPACE) then
  296.   begin
  297.   end;
  298. end;
  299.  
  300.  
  301. procedure TfrmMain.SetupControlPoints;
  302. begin
  303.   { Set up the control points for the Bezier curve... }
  304.   ControlPoints[0][0].X := -17;
  305.   ControlPoints[0][0].Y := -2;
  306.   ControlPoints[0][0].Z := 0;
  307.  
  308.   ControlPoints[0][1].X := -2;
  309.   ControlPoints[0][1].Y := 6;
  310.   ControlPoints[0][1].Z := 0;
  311.  
  312.   ControlPoints[0][2].X := 0;
  313.   ControlPoints[0][2].Y := -2;
  314.   ControlPoints[0][2].Z := 0;
  315.  
  316.   ControlPoints[0][3].X := 18;
  317.   ControlPoints[0][3].Y := 4;
  318.   ControlPoints[0][3].Z := 0;
  319.  
  320.   { Set up the control points for the Bezier curve... }
  321.   ControlPoints[1][0].X := -12;
  322.   ControlPoints[1][0].Y := -0;
  323.   ControlPoints[1][0].Z := 0;
  324.  
  325.   ControlPoints[1][1].X := -4;
  326.   ControlPoints[1][1].Y := 6;
  327.   ControlPoints[1][1].Z := 0;
  328.  
  329.   ControlPoints[1][2].X := -2;
  330.   ControlPoints[1][2].Y := -2;
  331.   ControlPoints[1][2].Z := 0;
  332.  
  333.   ControlPoints[1][3].X := 10;
  334.   ControlPoints[1][3].Y := 4;
  335.   ControlPoints[1][3].Z := 0;
  336.  
  337.   { Set up the control points for the Bezier curve... }
  338.   ControlPoints[2][0].X := -14;
  339.   ControlPoints[2][0].Y := 0;
  340.   ControlPoints[2][0].Z := 0;
  341.  
  342.   ControlPoints[2][1].X := 0;
  343.   ControlPoints[2][1].Y := 0;
  344.   ControlPoints[2][1].Z := 0;
  345.  
  346.   ControlPoints[2][2].X := 4;
  347.   ControlPoints[2][2].Y := 0;
  348.   ControlPoints[2][2].Z := 0;
  349.  
  350.   ControlPoints[2][3].X := 11;
  351.   ControlPoints[2][3].Y := 0;
  352.   ControlPoints[2][3].Z := 0;
  353.  
  354.   { Set up the control points for the Bezier curve... }
  355.   ControlPoints[3][0].X := -13;
  356.   ControlPoints[3][0].Y := 0;
  357.   ControlPoints[3][0].Z := 0;
  358.  
  359.   ControlPoints[3][1].X := -8;
  360.   ControlPoints[3][1].Y := 0;
  361.   ControlPoints[3][1].Z := 0;
  362.  
  363.   ControlPoints[3][2].X := 8;
  364.   ControlPoints[3][2].Y := 0;
  365.   ControlPoints[3][2].Z := 0;
  366.  
  367.   ControlPoints[3][3].X := 19;
  368.   ControlPoints[3][3].Y := 0;
  369.   ControlPoints[3][3].Z := 0;
  370.  
  371.   { Set up the control points for the Bezier curve... }
  372.   ControlPoints[4][0].X := -16;
  373.   ControlPoints[4][0].Y := 0;
  374.   ControlPoints[4][0].Z := 0;
  375.  
  376.   ControlPoints[4][1].X := -10;
  377.   ControlPoints[4][1].Y := 0;
  378.   ControlPoints[4][1].Z := 0;
  379.  
  380.   ControlPoints[4][2].X := -2;
  381.   ControlPoints[4][2].Y := 0;
  382.   ControlPoints[4][2].Z := 0;
  383.  
  384.   ControlPoints[4][3].X := 21;
  385.   ControlPoints[4][3].Y := 0;
  386.   ControlPoints[4][3].Z := 0;
  387. end;
  388.  
  389.  
  390. end.

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 3 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 3 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.010s | 14 Queries | GZIP : On ]