-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


.

, 29 2017 . 11:16 +


: , . . , , , .


, , ! :)

: . , .
, !






Level 3.4. .


, CPU . . , , :


  1. , , , ( back , front);
  2. , , , .

, ?
  1. ( ). , , .. ;
  2. , ;
  3. (.. , , ). , ;
  4. .

: , (-, fps ).
:


  • LightSource, , ;
  • IShadowSource, void RebuildShadow(Vector3 lightPosition);
  • ShadowRenderer, .

, , . .

.
.
-, . , z-buffer' ( , z-buffer ).
-, - . , .


, , z-buffer, , , . :


  1. RenderTexture;
  2. , depth-buffer .1, color-buffer ( );
  3. ;
  4. .

.

- . Unity3D Graphics.Blit. , target , .
, :


  1. color buffer, ;
  2. color buffer, ;
  3. Depth+stencil buffer, ( ).

Graphics.Blit color buffer depth buffer . .., , , , .
, , , ( !) .


Unity3D :


Note that if you want to use depth or stencil buffer that is part of the source (Render)texture, you'll have to do equivalent of Blit functionality manually i.e. Graphics.SetRenderTarget with destination color buffer and source depth buffer, setup orthographic projection (GL.LoadOrtho), setup material pass (Material.SetPass) and draw a quad (GL.Begin).

, Blit, :


static void Blit(RenderBuffer colorBuffer, RenderBuffer depthBuffer, Material material) {
    Graphics.SetRenderTarget(colorBuffer, depthBuffer);

    GL.PushMatrix();
    GL.LoadOrtho();

    for (int i = 0, passCount = material.passCount; i < passCount; ++i) {
        material.SetPass(i);

        GL.Begin(GL.QUADS);
        GL.TexCoord(new Vector3(0, 0, 0));
        GL.Vertex3(0, 0, 0);
        GL.TexCoord(new Vector3(0, 1, 0));
        GL.Vertex3(0, 1, 0);
        GL.TexCoord(new Vector3(1, 1, 0));
        GL.Vertex3(1, 1, 0);
        GL.TexCoord(new Vector3(1, 0, 0));
        GL.Vertex3(1, 0, 0);
        GL.End();
    }

    GL.PopMatrix();

    Graphics.SetRenderTarget(null);
}

:


void RenderShadowEffect(RenderTexture source, RenderTexture target, LightSource light) {
    shadowEffect.SetColor("_ShadowColor", light.ShadowColor);
    shadowEffect.SetColor("_LightColor", light.LightColor);
    shadowEffect.SetTexture("_WorldTexture", source);
    shadowEffect.SetTexture("_ShadowedTexture", target);

    Blit(target.colorBuffer, source.depthBuffer, shadowEffect);
}

, ? RenderTexture, ( )?
, frame debug:


-.
. , . : Camera.ctiveTexture .
, , ! ? !
MonoBehaviour.OnRenderImage, MonoBehaviour.OnRenderImage
MonoBehaviour.OnPostRender. : OnRenderImage Apply , , renderTexture. .


, a .

.

.


( 10 15 fps). , , .


: ! , , : , ..

.

, - .
Todo: .


Level 4.1. .


, . (, , 2 ?) , , .
:
MonoBehaviour ScriptableObject. , , ;

.


, , BulletCaster MovableObject. .


.
public class BulletCaster : MonoBehaviour {
    public void CastBullet(Vector2 direction);
}

public class MovingBody : MonoBehaviour {
    public Vector2 Direction {get; set;}
    public bool IsStopped {get; set;}
}


.


(Clock, ShadowManager ..) service locator ( , , ).


, , (, <-> ).


, pool. , , . -, , /.


.

( 10 "" ). : , .
: , , , .
, :


  1. ;
  2. , .

:


, .

, :


  1. , ;
  2. (.. , , ;
  3. , ;
  4. ( ). , ;
  5. - ;
  6. , . , "" .

, , . , , .


TouchManager. . N , ( ). , , . : , .


, , , , .
. , .


Todo: , .


Level 4.2. .


, . , :


  1. ?
  2. ?
  3. ?
  4. (//)?

. ? :


  1. . ;
  2. . ;
  3. . . , . ..;
  4. . , , ;
  5. . , , .;
  6. . , , ;
  7. . , , ;
  8. . , , , ;
  9. . , , , ;
  10. .


.


. low-poly , :


  1. ;
  2. (), .

, , , . , . . :


  1. . . . ? ;
  2. . . , ;
  3. . , "", "". .

, :


  1. , ;
  2. ;
  3. ;
  4. ;
  5. ;
  6. .

    , .

, , .


, , . , . , .


Todo: .


Level 5.1. .


, . , , , . . . , . : . , . . .

, - . :


  • ", , ! !"
    :
  • ", ! , !"

. . , , , .


, ?


  1. , ;
  2. , , .

! ! , ? , , .


, . :


  1. , , ;
  2. . , , . N ( N ) . ;
  3. . , . PolygonCollider2D.


, .


:


  1. (, ..) , , . "Piece";
  2. Piece;
  3. "" ;
  4. Piece . Piece (, ):
    4.1. ;
    4.2. ;
    4.3. ;
    4.4. ;
    4.5. , ;
    4.5. , , . . .
  5. Piece, ;
  6. , .

, 8 . "" , .
, , .





.


, , , .

: . - . .

, . , / . rigidBody . isBullet, . FloorHider, z , ( .)


:


  1. "" . . , . ;
  2. ;
  3. . , ?
  4. - , , ;
  5. , !




!


, , . , , .


Todo: .


Level 5.2.1. .


, " ", npc. . .

, . : , . . :


.


, :





.
, . overdraw' . , , .
, ( ) . . : , , , . , ? :)


, .
. , . :


  1. N {-0.5, -0.5, 0.5, 0.5};
  2. Y [-tiles, tiles] X [-tiles, tiles], X = 0, Y = 0:
    2.1. X, Y ( tiles = 1 9 );
  3. ( ) ;
  4. ;
  5. , {-0.5, -0.5, 0.5, 0.5}.

, , ( ). , .
, , , . , , ( tiles).
, -, . , , - .

?



, :

.


ScriptableObject, "recalculate tiles".


- float' . .. , , . :)

!


Todo: .


Level 5.2.2. .


, . - , . , , "" .


"", :


, 512 . , 512 . :

.
, , .


, :
center radius. , .


  1. AABB , AABB ( 0 rows 1 - ).
    var rectSize = size / (float)rows;
    int minX = Mathf.FloorToInt((center.x - radius) / rectSize);
    int minY = Mathf.FloorToInt((center.y - radius) / rectSize);
    int maxX = Mathf.CeilToInt((center.x + radius) / rectSize);
    int maxY = Mathf.CeilToInt((center.y + radius) / rectSize);
  2. min max;
  3. , ;
  4. :
    int innerX = ((x + rows) % rows + rows) % rows;
    int innerY = ((y + rows) % rows + rows) % rows;
  5. ;
  6. , ( ).

, , :

.


, . :





, , . , , , {0, 0} {1, 1}, .


, :


  1. , ;
  2. ;
  3. .

:
:

Points = 500, Relax = 5


, .
:

Points = 500, Relax = 0


: , , , :

Triangles, Points = 500, Relax = 0


. , , , : , . - "", , :

.


, . , : -:

.


: , . . , "" .


Todo: .


.


, . , . , ( ), .


, :


  1. . ( ) , ;
  2. : , , . , . :)
  3. Unity3D , . frame debug, , Unity3D ( msaa).

, , .


, feedback'a!

Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/326840/


: [1] []
 

:
: 

: ( )

:

  URL