Beispiel #1
0
        geo FragmentShader(VertexOut vertex, Field <geo> Geo)
        {
            geo
           here       = Geo[Here],
           right      = Geo[RightOne],
           up         = Geo[UpOne],
           left       = Geo[LeftOne],
           down       = Geo[DownOne],
           up_right   = Geo[UpRight],
           up_left    = Geo[UpLeft],
           down_right = Geo[DownRight],
           down_left  = Geo[DownLeft];

            if (!IsValid(here.dir))
            {
                return(here);
            }

            vec2 id_here = here.geo_id;

            if (right.geo_id != id_here ||
                left.geo_id != id_here ||
                up.geo_id != id_here ||
                down.geo_id != id_here ||
                up_right.geo_id != id_here ||
                up_left.geo_id != id_here ||
                down_right.geo_id != id_here ||
                down_left.geo_id != id_here)
            {
                //here.dist = 1;
                return(geo.Nothing);
            }

            return(here);
        }
Beispiel #2
0
        unit FragmentShader(VertexOut vertex, Field <unit> Unit, Field <data> Data, Field <magic> Magic, PlayerTuple Teams)
        {
            data  data_here  = Data[Here];
            unit  unit_here  = Unit[Here];
            magic magic_here = Magic[Here];

            if (Something(data_here))
            {
                if (data_here.action == UnitAction.Spawning)
                {
                    unit barracks = Unit[dir_to_vec(Reverse(data_here.direction))];
                    unit_here.player = barracks.player;
                    unit_here.team   = barracks.team;
                    unit_here.type   = UnitType.Footman;
                    unit_here.anim   = Anim.Stand;
                }

                if (data_here.action == UnitAction.Raising)
                {
                    unit_here.player = magic_here.raising_player;
                    unit_here.team   = GetPlayerVal(Teams, magic_here.raising_player);
                    unit_here.type   = UnitType.Skeleton;
                    unit_here.anim   = Anim.StartRaise;
                }
            }

            return(unit_here);
        }
Beispiel #3
0
        tile FragmentShader(VertexOut vertex, Field <tile> Tiles, Field <data> Select)
        {
            tile here   = Tiles[Here];
            data select = Select[Here];

            tile
                right      = Tiles[RightOne],
                up         = Tiles[UpOne],
                left       = Tiles[LeftOne],
                down       = Tiles[DownOne],
                up_right   = Tiles[UpRight],
                up_left    = Tiles[UpLeft],
                down_right = Tiles[DownRight],
                down_left  = Tiles[DownLeft];

            if (here.type == TileType.Dirt)
            {
                DirtGrassInterface(ref here, ref right, ref up, ref left, ref down, ref up_right, ref up_left, ref down_right, ref down_left);
            }
            else if (here.type == TileType.Grass || here.type == TileType.Trees)
            {
                GrassTreeInterface(ref here, ref right, ref up, ref left, ref down, ref up_right, ref up_left, ref down_right, ref down_left);
            }

            return(here);
        }
Beispiel #4
0
        color FragmentShader(VertexOut vertex, Field <data> CurrentData, Field <unit> CurrentUnit, [Player.Vals] float player)
        {
            color output = color.TransparentBlack;

            data
                data_right = CurrentData[RightOne],
                data_up    = CurrentData[UpOne],
                data_left  = CurrentData[LeftOne],
                data_down  = CurrentData[DownOne],
                data_here  = CurrentData[Here];

            unit
                unit_right = CurrentUnit[RightOne],
                unit_up    = CurrentUnit[UpOne],
                unit_left  = CurrentUnit[LeftOne],
                unit_down  = CurrentUnit[DownOne],
                unit_here  = CurrentUnit[Here];

            output = .5f *
                     .25f * (Presence(player, data_right, unit_right) + Presence(player, data_up, unit_up) + Presence(player, data_left, unit_left) + Presence(player, data_down, unit_down))
                     + .5f *
                     Presence(player, data_here, unit_here);

            return(output);
        }
Beispiel #5
0
        void handleBlock(int x, int y, VertexOut v1, VertexOut v2, VertexOut v3)
        {
            VertexOut v;
            float4    resultColor;

            float3 bar = Barycentric(v1.position, v2.position, v3.position, x, y);

            v = Interpolate(v1, v2, v3, bar);

            if (v.position.z < 0.0f || v.position.z > 1.0f || v.position.z > depthbuffer[y * width + x])
            {
                return;
            }


            Color32 outputColor = output[y * width + x];

            float lum = math.max(0.0f, math.dot(v.normal.xyz, new float3(-0.71f, -0.71f, 0)));

            resultColor.x = 0.3f + lum;
            resultColor.y = 0.3f + lum;
            resultColor.z = 0.3f + lum;
            resultColor.w = 0;

            resultColor = math.saturate(resultColor);

            outputColor.r = (byte)Mathf.FloorToInt(resultColor.x * 255);
            outputColor.g = (byte)Mathf.FloorToInt(resultColor.y * 255);
            outputColor.b = (byte)Mathf.FloorToInt(resultColor.z * 255);
            outputColor.a = (byte)Mathf.FloorToInt(resultColor.w * 255);

            output[y * width + x]      = outputColor;
            depthbuffer[y * width + x] = v.position.z;
        }
Beispiel #6
0
        color FragmentShader(VertexOut vertex, Field <building> Buildings, Field <unit> Units, PointSampler Texture, PointSampler Explosion,
                             [Player.Vals] float player,
                             float s)
        {
            color output = color.TransparentBlack;

            building building_here = Buildings[Here];
            unit     unit_here     = Units[Here];

            if (!IsBuilding(unit_here))
            {
                return(output);
            }

            vec2 subcell_pos = get_subcell_pos(vertex, Buildings.Size);

            if (Something(building_here))
            {
                if (building_here.direction >= Dir.StationaryDead)
                {
                    float frame = ExplosionSpriteSheet.ExplosionFrame(s, building_here);
                    if (frame < ExplosionSpriteSheet.AnimLength)
                    {
                        output += ExplosionSprite(building_here, unit_here, subcell_pos, frame, Explosion);
                    }
                }
                else
                {
                    float frame = 0;
                    output += Sprite(player, building_here, unit_here, subcell_pos, frame, Texture);
                }
            }

            return(output);
        }
Beispiel #7
0
        vec4 FragmentShader(VertexOut vertex, Field <vec4> F, PeriodicField <vec4> Noise)
        {
            vec4 f = F[Here];
            vec4 n = Noise[Here];

            return(Noise[Noise[f.xy + n.xy].xy + f.zw]);
        }
Beispiel #8
0
        data FragmentShader(VertexOut vertex, Field <data> Select, Field <data> Data, Field <unit> Units, Field <corpse> Corpses, Field <TeamTuple> AntiMagic,
                            [UnitDistribution.Vals] float distribution, [Team.Vals] float AntiMagicTeam)
        {
            data select = Select[Here];
            data here   = Data[Here];

            TeamTuple antimagic = AntiMagic[Here];

            if (antimagic.TeamOne > _0 && AntiMagicTeam != Team.One)
            {
                return(data.Nothing);
            }
            if (antimagic.TeamTwo > _0 && AntiMagicTeam != Team.Two)
            {
                return(data.Nothing);
            }
            if (antimagic.TeamThree > _0 && AntiMagicTeam != Team.Three)
            {
                return(data.Nothing);
            }
            if (antimagic.TeamFour > _0 && AntiMagicTeam != Team.Four)
            {
                return(data.Nothing);
            }

            if (Something(select) && !Something(here))
            {
                if (UnitDistribution.Contains(distribution, vertex.TexCoords * Select.Size, Corpses))
                {
                    return(select);
                }
            }

            return(data.Nothing);
        }
Beispiel #9
0
        vec4 FragmentShader(VertexOut vertex, Field <unit> Units, Field <data> Data, Field <vec4> PathToOtherTeams, [Player.Vals] float player)
        {
            unit unit_here = Units[Here];
            data data_here = Data[Here];
            vec4 path      = PathToOtherTeams[Here];

            float value = 1;

            if (unit_here.team == Team.One)
            {
                value = path.x;
            }
            else if (unit_here.team == Team.Two)
            {
                value = path.y;
            }
            else if (unit_here.team == Team.Three)
            {
                value = path.z;
            }
            else if (unit_here.team == Team.Four)
            {
                value = path.w;
            }

            if (Something(data_here) && unit_here.player == player &&
                //unit_here.type == UnitType.DragonLord && value < _36) return vec(1,1,1,1);
                unit_here.type == UnitType.DragonLord && value < _46)
            {
                return(vec(1, 1, 1, 1));
            }

            return(vec4.Zero);
        }
Beispiel #10
0
        data FragmentShader(VertexOut vertex, Field <data> Data)
        {
            data data_here = Data[Here];

            float state = select_state(data_here);

            if (state == SelectState.NotSelected_Show2)
            {
                state = SelectState.NotSelected_Show1;
            }
            else if (state == SelectState.NotSelected_Show1)
            {
                state = SelectState.NotSelected_NoShow;
            }
            else if (state == SelectState.Selected_NoShow2)
            {
                state = SelectState.Selected_NoShow1;
            }
            else if (state == SelectState.Selected_NoShow1)
            {
                state = SelectState.Selected_Show;
            }

            set_select_state(ref data_here, state);

            return(data_here);
        }
Beispiel #11
0
        color FragmentShader(VertexOut vertex, Field <geo> Geo, PointSampler Texture)
        {
            color output = color.TransparentBlack;

            geo here = Geo[Here];

            vec2 subcell_pos = get_subcell_pos(vertex, Geo.Size);

            if (here.dir > _0)
            {
                // Draw arrow
                //output += DrawDebugInfoTile(here.dir, 0, subcell_pos, Texture);

                // Draw bad cell info
                //if (here.bad == _true) output.r = 1;

                // Draw guid coloring
                vec2 guid = fmod(here.geo_id * 1293.4184145f, 1.0f);
                output.r   += guid.x;
                output.g   += guid.y;
                output.a    = 1f;
                output.rgb *= output.a;

                // Draw arrow over
                output *= DrawDebugArrow(here.dir, subcell_pos, Texture);
            }

            return(output);
        }
Beispiel #12
0
        color FragmentShader(VertexOut vertex, Field <dirward> Dirward, PointSampler Texture)
        {
            color output = color.TransparentBlack;

            dirward here = Dirward[Here];

            vec2 subcell_pos = get_subcell_pos(vertex, Dirward.Size);

            if (ValidDirward(here))
            {
                // Draw guid coloring
                vec2 guid = fmod(here.geo_id * 1293.4184145f, 1.0f);
                output.r   += guid.x;
                output.g   += guid.y;
                output.a    = 1f;
                output.rgb *= output.a;
            }

            // Draw polarity only
            if (ValidDirward(here))
            {
                return((color)(here.polarity > .5 ? vec(1, 0, 0, 1) : vec(0, 1, 0, 1)));
            }

            return(output);
        }
Beispiel #13
0
        tile FragmentShader(VertexOut vertex, Field <tile> Tiles, Field <data> Select, Field <vec4> Random, [TileType.Vals] float type)
        {
            tile here   = Tiles[Here];
            data select = Select[Here];
            vec4 rndv   = Random[Here];

            float rnd = rndv.x * rndv.x * rndv.x * rndv.x;

            if (Something(select))
            {
                here.type = type;

                if (type == TileType.Grass)
                {
                    here.i = RndFint(rnd, _0, _6); here.j = _31;
                }
                else if (type == TileType.Dirt)
                {
                    here.i = RndFint(rnd, _0, _9); here.j = _30;
                }
                else if (type == TileType.Trees)
                {
                    here.i = _0; here.j = _25;
                }
            }

            return(here);
        }
Beispiel #14
0
        vec4 FragmentShader(VertexOut vertex, Field <data> Data, Field <unit> Units, [UnitType.Vals] float type)
        {
            data data_here = Data[Here];

            vec4 output = vec4.Zero;

            if (Something(data_here))
            {
                unit unit_here = Units[Here];

                if (unit_here.type == type && !(IsUnit(type) && unit_here.anim == Anim.Die) && !(IsBuilding(type) && !IsCenter((building)(vec4)data_here)))
                {
                    if (unit_here.player == Player.One)
                    {
                        output.x = _1;
                    }
                    if (unit_here.player == Player.Two)
                    {
                        output.y = _1;
                    }
                    if (unit_here.player == Player.Three)
                    {
                        output.z = _1;
                    }
                    if (unit_here.player == Player.Four)
                    {
                        output.w = _1;
                    }
                }
            }

            return(output);
        }
Beispiel #15
0
        float BuildingDirection(VertexOut vertex, Field <vec4> TargetData, building here)
        {
            float dir = Dir.Right;

            vec4 target = TargetData[Here];

            // Unpack packed info
            vec2 CurPos      = vertex.TexCoords * TargetData.Size;
            vec2 Destination = unpack_vec2((vec4)target);

            vec2 diff = Destination - CurPos;
            vec2 mag  = abs(diff);

            if (mag.x > mag.y && diff.x > 0)
            {
                dir = Dir.Right;
            }
            if (mag.x > mag.y && diff.x < 0)
            {
                dir = Dir.Left;
            }
            if (mag.y > mag.x && diff.y > 0)
            {
                dir = Dir.Up;
            }
            if (mag.y > mag.x && diff.y < 0)
            {
                dir = Dir.Down;
            }

            return(dir);
        }
Beispiel #16
0
        vec4 FragmentShader(VertexOut vertex, Field <data> Data, Field <unit> Units, [Player.Vals] float player, bool only_selected)
        {
            data data_here = Data[Here];

            vec4 output = vec4.Zero;

            if (Something(data_here))
            {
                unit unit_here = Units[Here];

                bool valid = (player == Player.None || unit_here.player == player) && (!only_selected || fake_selected(data_here));

                if (IsUnit(unit_here) && valid)
                {
                    output.xyz = pack_coord_3byte(1);
                }

                if (unit_here.type == UnitType.Barracks && IsCenter((building)(vec4)data_here) && valid)
                {
                    output.w = _1;
                }
            }

            return(output);
        }
Beispiel #17
0
        color FragmentShader(VertexOut vertex, Field <vec4> Path, float blend)
        {
            vec4 dist = Path[Here];

            vec4 enemy_dist = vec(
                min(dist.y, dist.z, dist.w),
                min(dist.x, dist.z, dist.w),
                min(dist.x, dist.y, dist.w),
                min(dist.x, dist.y, dist.z));

            color clr    = color.TransparentBlack;
            float _blend = 1;

            //if (dist.x < TerritoryCutoff && dist.x < enemy_dist.x) { clr = Team1; _blend = max(.3f, min(1, (TerritoryCutoff - dist.x) / _3)); }
            //if (dist.y < TerritoryCutoff && dist.y < enemy_dist.y) { clr = Team2; _blend = max(.3f, min(1, (TerritoryCutoff - dist.y) / _3)); }
            //if (dist.z < TerritoryCutoff && dist.z < enemy_dist.z) { clr = Team3; _blend = max(.3f, min(1, (TerritoryCutoff - dist.z) / _3)); }
            //if (dist.w < TerritoryCutoff && dist.w < enemy_dist.w) { clr = Team4; _blend = max(.3f, min(1, (TerritoryCutoff - dist.w) / _3)); }

#if DEBUG
            if (dist.x < TerritoryCutoff && dist.x < enemy_dist.x)
            {
                clr = TerritoryColor.Get(Player.One + ((int)dist.x / 100));
            }
            if (dist.y < TerritoryCutoff && dist.y < enemy_dist.y)
            {
                clr = TerritoryColor.Get(Player.Two + ((int)dist.x / 100));
            }
            if (dist.z < TerritoryCutoff && dist.z < enemy_dist.z)
            {
                clr = TerritoryColor.Get(Player.Three + ((int)dist.x / 100));
            }
            if (dist.w < TerritoryCutoff && dist.w < enemy_dist.w)
            {
                clr = TerritoryColor.Get(Player.Four + ((int)dist.x / 100));
            }
#else
            if (dist.x < TerritoryCutoff && dist.x < enemy_dist.x)
            {
                clr = TerritoryColor.Player1();
            }
            if (dist.y < TerritoryCutoff && dist.y < enemy_dist.y)
            {
                clr = TerritoryColor.Player2();
            }
            if (dist.z < TerritoryCutoff && dist.z < enemy_dist.z)
            {
                clr = TerritoryColor.Player3();
            }
            if (dist.w < TerritoryCutoff && dist.w < enemy_dist.w)
            {
                clr = TerritoryColor.Player4();
            }
#endif
            clr     *= _blend;
            clr.a   *= blend;
            clr.rgb *= clr.a;

            return(clr);
        }
Beispiel #18
0
        protected vec2 get_subcell_pos(VertexOut vertex, vec2 grid_size, vec2 grid_shift)
        {
            vec2  coords = vertex.TexCoords * grid_size + grid_shift + lookup_shift;
            float i      = floor(coords.x);
            float j      = floor(coords.y);

            return(coords - vec(i, j));
        }
Beispiel #19
0
        color FragmentShader(VertexOut vertex, Field<cell> Current)
        {
            color output = color.TransparentBlack;

            cell here  = Current[Here];

            return here.state == State.Alive ? rgba(1,1,1,1) : rgba(0,0,0,1);
        }
Beispiel #20
0
        dirward FragmentShader(VertexOut vertex, Field <dirward> Dirward)
        {
            dirward dirward_here = Dirward[Here];

            dirward_here.importance = _0;

            return(dirward_here);
        }
Beispiel #21
0
        geo FragmentShader(VertexOut vertex, Field <geo> Geo)
        {
            geo geo_here = Geo[Here];

            geo_here.geo_id = ReducedGeoId(geo_pos_id(geo_here));
            geo_here.dist   = _0;

            return(geo_here);
        }
Beispiel #22
0

        
Beispiel #23
0
        geo FragmentShader(VertexOut vertex, Field <geo> Geo, Field <geo> OuterGeo)
        {
            geo
                geo_here       = Geo[Here],
                geo_right      = Geo[RightOne],
                geo_up         = Geo[UpOne],
                geo_left       = Geo[LeftOne],
                geo_down       = Geo[DownOne],
                geo_up_right   = Geo[UpRight],
                geo_up_left    = Geo[UpLeft],
                geo_down_right = Geo[DownRight],
                geo_down_left  = Geo[DownLeft];

            geo
                outer_geo_here = OuterGeo[Here];

            if (IsValid(geo_here.dir))
            {
                return(geo_here);
            }

            outer_geo_here.dist = _255; // Start off as maximum possible 1-byte distance, since we will be taking the min of surrounding distances (and adding _1)
            if (outer_geo_here.dist > geo_right.dist && IsValid(geo_right.dir))
            {
                InheritsFrom(ref outer_geo_here, geo_right);
            }
            else if (outer_geo_here.dist > geo_up.dist && IsValid(geo_up.dir))
            {
                InheritsFrom(ref outer_geo_here, geo_up);
            }
            else if (outer_geo_here.dist > geo_left.dist && IsValid(geo_left.dir))
            {
                InheritsFrom(ref outer_geo_here, geo_left);
            }
            else if (outer_geo_here.dist > geo_down.dist && IsValid(geo_down.dir))
            {
                InheritsFrom(ref outer_geo_here, geo_down);
            }
            else if (outer_geo_here.dist > geo_up_right.dist && IsValid(geo_up_right.dir))
            {
                InheritsFrom(ref outer_geo_here, geo_up_right);
            }
            else if (outer_geo_here.dist > geo_up_left.dist && IsValid(geo_up_left.dir))
            {
                InheritsFrom(ref outer_geo_here, geo_up_left);
            }
            else if (outer_geo_here.dist > geo_down_right.dist && IsValid(geo_down_right.dir))
            {
                InheritsFrom(ref outer_geo_here, geo_down_right);
            }
            else if (outer_geo_here.dist > geo_down_left.dist && IsValid(geo_down_left.dir))
            {
                InheritsFrom(ref outer_geo_here, geo_down_left);
            }

            return(outer_geo_here);
        }
Beispiel #24
0
        color FragmentShader(VertexOut vertex, TextureSampler <Clamp, Linear> Texture)
        {
            color output;

            output      = Texture[vertex.TexCoords];
            output     *= vertex.Color;
            output.rgb *= vertex.Color.a;

            return(output);
        }
Beispiel #25
0
    static VertexOut Interpolate(VertexOut v1, VertexOut v2, VertexOut v3, float3 barycentric)
    {
        VertexOut output = new VertexOut();

        output.position  = InterpolatedFromBarycentric(v1.position, v2.position, v3.position, barycentric);
        output.normal    = InterpolatedFromBarycentric(v1.normal, v2.normal, v3.normal, barycentric);
        output.texcoord0 = InterpolatedFromBarycentric(v1.texcoord0, v2.texcoord0, v3.texcoord0, barycentric);

        return(output);
    }
Beispiel #26
0
        color FragmentShader(VertexOut vertex, Field <TeamTuple> AntiMagic, [Team.Vals] float casting_team)
        {
            color output = color.TransparentBlack;

            TeamTuple here = AntiMagic[Here];

            float max_val = max(here.TeamOne, here.TeamTwo, here.TeamThree, here.TeamFour);

            return(max_val > _0 ? Active : color.TransparentBlack);
        }
Beispiel #27
0
        color FragmentShader(VertexOut vertex, TextureSampler <Clamp, Point> Texture, color clr)
        {
            color output;

            output      = Texture[vertex.TexCoords];
            output     *= vertex.Color * clr;
            output.rgb *= vertex.Color.a;

            return(output);
        }
Beispiel #28
0
        vec4 FragmentShader(VertexOut vertex, Field <vec4> PreviousLevel)
        {
            vec2
           TL = unpack_vec2(PreviousLevel[Here]),
           TR = unpack_vec2(PreviousLevel[RightOne]),
           BL = unpack_vec2(PreviousLevel[UpOne]),
           BR = unpack_vec2(PreviousLevel[UpRight]);

            return(pack_vec2(min(TL, TR, BL, BR)));
        }
Beispiel #29
0
        color FragmentShader(VertexOut vertex, PointSampler Texture)
        {
            color output;

            output      = Texture[vertex.TexCoords];
            output     *= vertex.Color;
            output.rgb *= vertex.Color.a;

            return(output);
        }
Beispiel #30
0
        BuildingDist FragmentShader(VertexOut vertex, Field <BuildingDist> Path, Field <data> Data, Field <unit> Unit)
        {
            BuildingDist output = BuildingDist.Nothing;

            data data_here = Data[Here];
            unit unit_here = Unit[Here];

            if (Something(data_here) && (IsBuilding(unit_here) || unit_here.type == UnitType.DragonLord || unit_here.type == UnitType.Necromancer))
            {
                float type = unit_here.type;
                if (type == UnitType.DragonLord)
                {
                    type = UnitType.DragonLordIcon;
                }
                if (type == UnitType.Necromancer)
                {
                    type = UnitType.NecromancerIcon;
                }

                set_type(ref output, type);
                set_player(ref output, unit_here.player);
                output.diff = CenterOffset;
                output.dist = _0;
            }
            else
            {
                BuildingDist
                    right = Path[RightOne],
                    up    = Path[UpOne],
                    left  = Path[LeftOne],
                    down  = Path[DownOne];

                float min_dist = _255;
                if (left.dist < min_dist)
                {
                    output.player_and_type = left.player_and_type; min_dist = left.dist;  output.diff = left.diff - vec(_1, _0);
                }
                if (down.dist < min_dist)
                {
                    output.player_and_type = down.player_and_type; min_dist = down.dist;  output.diff = down.diff - vec(_0, _1);
                }
                if (right.dist < min_dist)
                {
                    output.player_and_type = right.player_and_type; min_dist = right.dist; output.diff = right.diff + vec(_1, _0);
                }
                if (up.dist < min_dist)
                {
                    output.player_and_type = up.player_and_type; min_dist = up.dist;    output.diff = up.diff + vec(_0, _1);
                }

                output.dist = min_dist + _1;
            }

            return(output);
        }
Beispiel #31
0
        building FragmentShader(VertexOut vertex, Field <unit> Unit, Field <building> Building)
        {
            building building_here = Building[Here];
            unit     unit_here     = Unit[Here];

            if (Something(building_here) && IsBuilding(unit_here) && IsCenter(building_here))
            {
                if (building_here.direction >= Dir.StationaryDead)
                {
                    building_here.direction += _1;
                    return(building_here);
                }

                building
                    right      = Building[RightOne],
                    up         = Building[UpOne],
                    left       = Building[LeftOne],
                    down       = Building[DownOne],
                    up_right   = Building[UpRight],
                    up_left    = Building[UpLeft],
                    down_right = Building[DownRight],
                    down_left  = Building[DownLeft];

                // If any part of the building is dying, then the center (and consequently the whole building) should be marked as dead.
                if (right.direction == Dir.StationaryDying ||
                    up.direction == Dir.StationaryDying ||
                    left.direction == Dir.StationaryDying ||
                    down.direction == Dir.StationaryDying ||
                    up_right.direction == Dir.StationaryDying ||
                    up_left.direction == Dir.StationaryDying ||
                    down_right.direction == Dir.StationaryDying ||
                    down_left.direction == Dir.StationaryDying)
                {
                    building_here.direction = Dir.StationaryDead;
                }

                // Select this center if any part of the building is selected
                if (!selected(building_here))
                {
                    bool is_selected =
                        selected(right) ||
                        selected(up) ||
                        selected(left) ||
                        selected(down) ||
                        selected(up_right) ||
                        selected(up_left) ||
                        selected(down_right) ||
                        selected(down_left);

                    set_selected(ref building_here, is_selected);
                }
            }

            return(building_here);
        }
Beispiel #32
0
        cell FragmentShader(VertexOut vertex, Field<cell> Current)
        {
            cell here = Current[Here];

            float neighbors = 
                Current[RightOne].state + Current[UpOne] .state + Current[LeftOne]  .state + Current[DownOne] .state +
                Current[UpRight] .state + Current[UpLeft].state + Current[DownRight].state + Current[DownLeft].state;

            if (neighbors < _2 || neighbors > _3)
                here.state = State.Dead;

            if (neighbors == _3)
                here.state = State.Alive;

            return here;
        }