d1分辨率和960分辨率_选择2D艺术资产的分辨率

d1分辨率和960分辨率

At game events and online, people often ask me this question: “I’m making a 2D game in Unity for both PC and mobile: what resolution should my assets be?” There is no simple answer to this question that covers all cases. Read this blog post to get a better idea of what’s the best course of action for your project.

在游戏活动和在线活动中,人们经常问我一个问题:“我正在Unity中为PC和移动设备制作2D游戏:我的资产应该是什么分辨率?” 这个问题没有简单的答案可以涵盖所有情况。 阅读此博客文章,以更好地了解什么是您的项目的最佳做法。

In recent years, we’ve been working on a lot of features that help you create 2D games in Unity: Sprite atlassing, 2D physics, a Tilemap feature for rectangular, hexagonal or isometric worlds, the spline-based Sprite Shape, 2D animation, and more.

近年来,我们一直在致力于许多功能,可帮助您在Unity中创建2D游戏 :Sprite地图集,2D物理,用于矩形,六角形或等距世界的Tilemap功能,基于样条线的Sprite Shape2D动画 ,和更多。

Unity doesn’t express the size of an object in pixels and this can confuse artists who are creating assets for 2D games. “How big do they need to be?” As usual in game development, the answer to this question is “it depends”, but let’s go over a few concepts that will make the decision easier.

Unity不以像素表示对象的大小,这可能会使为2D游戏创建资产的美术师感到困惑。 “他们需要多大?” 和游戏开发一样,这个问题的答案是“取决于情况”,但让我们回顾一些使决策更容易的概念。

Note: Pictures in this blog post show the beautiful 2D Forest Pack assets by artist Mikael Gustafsson.

注意:此博客文章中的图片显示了艺术家Mikael Gustafsson制作的精美的2D Forest Pack资产。

If you’re a pixel artist, a word of warning: most of the tips in this post don’t fully apply to your situation. In pixel art graphics you have something that’s extremely low resolution, and you want to blow it up to 2x, 4x, 8x, or maybe even more, its original resolution. It means that one pixel of your original art is now a square of 2×2, 4×4, 8×8 real pixels on the screen.

如果您是像素艺术家,请提个警告:本文中的大多数技巧并不完全适用于您的情况。 在像素艺术图形中,您具有的分辨率非常低,并且您希望将其分辨率提高到其原始分辨率的2倍,4倍,8倍甚至更高。 这意味着您原始艺术作品的一个像素现在是屏幕上2×2、4×4、8×8真实像素的正方形。

So in general in pixel art, you don’t need to bother too much about the screen resolution, but you start from your art and the feel you want to convey (old-school, NES-era, higher-resolution “modern” pixel art, etc.) and you scale it up a few times.

因此,一般而言,在像素艺术中,您无需过多地关注屏幕分辨率,而是从您的艺术和想要传达的感觉开始(老派,NES时代,更高分辨率的“现代”像素艺术等),然后将其放大几次。

Unity now has a Pixel Perfect solution in the form of a package. It comes with a simple component to put on the Camera which will do the hard work for you and make sure the art stays crisp and aligned with the grid of real, small pixels on any screen.

现在,Unity具有打包形式的Pixel Perfect解决方案。 它带有一个放在摄像机上的简单组件,它将为您完成艰苦的工作,并确保艺术作品保持清晰并与任何屏幕上的真实小像素网格对齐。

You can find more info on the Pixel Perfect package at the documentation page of the Pixel Perfect package on GitHub.

您可以在GitHub上Pixel Perfect软件包的文档页面上的Pixel Perfect软件包中找到更多信息。

缩小而不是放大 (Scaling down, not up)

Before we go into any consideration about choosing resolution, it’s worth remembering that when you’re authoring your assets it’s good to go for a higher resolution even if you don’t actually need it for the art that goes into the game. You can always scale down art, but you can’t scale it up without losing quality.

在我们考虑选择分辨率之前,值得记住的是,在创作资产时,最好获得更高的分辨率,即使实际上并不需要游戏中的艺术品。 您始终可以缩小艺术品,但不能在不损失质量的情况下扩大艺术品

Consider these scenarios: you might need to print some of the art for your game, or you want to increase the size of an element on a screen, or you want to create an “HD version” of your game for 4K monitors later on.

考虑以下情况:您可能需要为游戏打印一些插图,或者想要增加屏幕上元素的大小,或者想要稍后为4K显示器创建游戏的“高清版本”。

For these reasons, as you are working on the art, consider using work files that are twice the resolution that you actually need or more, then scale them down before bringing them into Unity, or use import settings to reduce their size as they are imported into the engine.

出于这些原因,在您从事美术工作时,请考虑使用实际分辨率两倍或更高的工作文件,然后将其缩小后再将它们引入Unity,或者在导入时使用导入设置来减小其大小。进入引擎。

The Import Settings for any image asset allow you to force the maximum resolution to a power of 2.

任何图像资产的导入设置都可以将最大分辨率强制为2的幂。

The Import Settings also allow you to define a Max Size and other compression settings per platform, so, for instance, you can have some assets on a certain resolution on PC and just half of it on mobile devices, where contained disk space is crucial.

导入设置还允许您定义每个平台的最大大小和其他压缩设置,因此,例如,您可以在PC上以某种分辨率拥有一些资产,而在移动设备上却只有一半的资产,其中包含的磁盘空间至关重要。

Tip: Unity offers a way to consolidate several Sprites into one through Sprite Atlases. In addition to being a way to save texture space, atlases also offer one unified way of controlling the Max Size rather than having to set it individually for every single sprite in your project.

提示: Unity提供了一种通过Sprite Atlases将多个Sprite合并为一个的方法。 除了节省纹理空间外,地图集还提供了一种控制“最大大小”的统一方法,而不必为项目中的每个子画面分别设置。

定义平台的分辨率 (Defining the resolution of your platform(s))

When defining asset size, it’s important to consider the platform or the devices that the game is going to be published on. People have very diverse devices and screens and will see your game in a variety of resolutions and aspect ratios.

在定义资产规模时,重要的是要考虑要在其上发布游戏的平台或设备。 人们使用非常多样的设备和屏幕,并且会以各种分辨率和宽高比观看游戏

In general, at the time of writing this post, if you’re publishing for PC you are looking at a vast majority of users with 2 resolutions: mostly “full-HD” (1920×1080 pixels, often called 1080p) and a good deal of 1280×720 (often called 720p). A small percentage of people also have 4K monitors (3840×2160) or Retina monitors on Macs (a modern 15-inch MacBook Pro would have a maximum resolution of 3360 × 2100). That’s a lot of pixels to cover!

通常,在撰写本文时,如果您是为PC发行的,则您会看到绝大多数具有2种分辨率的用户:大多是“全高清”(1920×1080像素,通常称为1080p),并且分辨率为1280×720(通常称为720p)。 一小部分人还拥有Mac上的4K显示器(3840×2160)或Retina显示器(现代15英寸MacBook Pro的最大分辨率为3360×2100)。 这要覆盖很多像素!

For phones, the range is huge. Some old devices can go down to less than 720 pixels vertically, but some modern ones will be up to 4K.

对于手机,范围是巨大的。 一些旧设备在垂直方向上可以降低到720像素以下,但在某些现代设备上则可以达到4K。

Tip: Unity makes some of these stats available in the Operate Dashboard of your Unity ID. Select a project that has Analytics enabled, and you will be able to go under Analytics > Market Insights and see the aggregated stats. Steam also offers a similar service on this page.

提示: Unity在Unity ID 的Operate仪表盘中提供其中一些统计信息。 选择一个启用了Analytics(分析)的项目,您将可以转到Analytics(分析)> Market Insights(市场洞察),然后查看汇总的统计信息。 Steam还在此页面上提供了类似的服务。

With Retina (an Apple trademark) and other modern high-DPI screens, while the actual hardware resolution is very high (e.g. 4K), what they can do is to run at a simulated lower resolution (usually half, say for instance full-HD instead of 4K) but then they render images and text using twice the pixels, so that they appear very crisp.

使用Retina(Apple商标)和其他现代高DPI屏幕时,尽管实际的硬件分辨率非常高(例如4K),但是他们可以做的是以模拟的较低分辨率(通常为一半,例如全高清)运行而不是4K),但随后它们使用两倍像素来渲染图像和文本,因此看起来非常清晰。

Note: DPI (dots-per-inch) or PPI (points-per-inch, or pixels-per-inch) are different names used interchangeably by different manufacturers, but at the end of the day, they mean the same thing: how many pixels are squeezed in a linear inch on screen. Traditionally, screens were 72 DPI. Today high-DPI screens are usually 144 DPI, but you can find phones that boast up to 400 DPI or more since they are packing a lot of pixels on relatively small screens. Some examples here.

注意: DPI(每英寸点数)或PPI(每英寸点数或每英寸像素数)是不同制造商可互换使用的不同名称,但归根结底,它们的含义相同:屏幕上的线性英寸会压缩许多像素。 传统上,屏幕为72 DPI。 如今,高DPI屏幕通常为144 DPI,但是您可以找到拥有400 DPI甚至更高的电话,因为它们在相对较小的屏幕上封装了很多像素。 这里有一些例子。

For these screens, you have two options. One is to aim at offering an experience that uses the 4K resolution in full. The downside is that producing 4K-compatible assets takes a lot of extra work. In this case, make sure to highlight it in your marketing materials!! (“A Beautiful 4K Experience”… etc.). Owners of consoles like PS4 Pro and Xbox One X, which are compatible with 4K, will love the fact that your game is using the hardware to its full power.

对于这些屏幕,您有两个选择。 一个目的是提供一种完全使用4K分辨率的体验。 缺点是生产兼容4K的资产需要大量额外工作。 在这种情况下,请确保在您的营销材料中突出显示它! (“美好的4K体验”…等)。 与4K兼容的PS4 Pro和Xbox One X等游戏机的拥有者会喜欢您的游戏充分利用硬件的事实。

Or, you can “just” architect your game to cover full-HD. In this second case, users with higher DPI monitors won’t benefit from the increased resolution of their screens but they will just see the game in full-HD. That’s not ideal, but it might be OK if you are also trying to keep build size under control.

或者,您可以“只是”设计您的游戏以涵盖全高清。 在第二种情况下,具有更高DPI显示器的用户不会从屏幕分辨率的提高中受益,而只会看到全高清游戏。 这不是理想的,但是如果您还试图控制构建大小,那可能没问题。

So the bottom line is: you need to choose a maximum resolution you are aiming for (based on the current market shares, see above), and set that as your target for the whole project. Everyone in the team will then be able to make decisions knowing that.

因此,底线是:您需要选择目标最大分辨率(基于当前市场份额,请参见上文),并将其设置为整个项目的目标。 这样,团队中的每个人都可以知道这一点来做出决定。

Unity场景中的测量 (Measurements in a Unity scene)

As we mentioned before, Unity measures distances and sizes in something that is simply called a unit, not in pixels. In general, it’s good practice to match 1 Unity unit to 1 meter. For instance, the average humanoid model between 1.7 and 1.8 units in this scenario. This isn’t mandatory, but it will ensure that games with physics (both 3D and 2D) behave correctly, because physics in Unity are tuned to use 1 unit for a meter. Same goes for 3D lighting, where light parameters are meant to stay true to reality.

如前所述,Unity以简单称为单位而不是像素的方式测量距离和大小。 通常,将1个Unity单位与1米相匹配是一个好习惯 例如,在这种情况下,平均人形模型在1.7和1.8单位之间。 这不是强制性的,但可以确保具有物理(3D和2D)游戏的行为正确,因为Unity中的物理已调整为每米使用1个单位。 3D照明也是如此,在这种情况下,灯光参数应保持真实。

In 2D this scale is less important, but it’s still good practice to respect it if you’re using physics in your project. If you’re using a Tilemap, it might be nice to keep a scale of 1 tile = 1 unit, just for the sake of simplicity.

在2D模式下,此比例尺不太重要,但是如果您在项目中使用物理,则尊重它仍然是一种好的做法。 如果您使用的是Tilemap ,只是为了简单起见,最好将比例尺保持为1 tile = 1 unit。

Now that we have gone over units, let’s move on to the camera. Unity’s 2D cameras (Orthographic) have a parameter called Size, which – when doubled – is telling you how many units this camera is framing on the vertical axis.

现在我们已经讨论了单位,让我们继续摄影 。 Unity的2D摄像机(正交)具有一个名为“大小”的参数,当该参数加倍时,它会告诉您该摄像机在垂直轴上取景的帧数。

The Size parameter in the Inspector of an Orthographic camera

正交相机检查器中的“大小”参数

With a size of 5, we have a viewport that measures 10 Unity units on the vertical. The horizontal axis will just be a consequence of this since we don’t know what aspect ratio the user’s screen will have. But it’s easy to calculate: on your average PC or Android phone, with an aspect ratio of 16:9, you can just do:

大小为5,我们有一个视口,在垂直方向上可以测量10个Unity单位。 由于我们不知道用户屏幕的宽高比,因此水平轴将只是此结果。 但这很容易计算:在普通PC或Android手机上,纵横比为16:9时,您可以执行以下操作:

10 (Vertical Size) x 16 / 9 = 17.7 (Horizontal Size)

10 (垂直尺寸)x 16/9 = 17.7 (水平尺寸)

So we know that with these settings, we’re framing an area of roughly 17.7 by 10 units. On Macs (which are generally 16:10) it will be 16 by 10 (so less visibility on the horizontal). On a 16:9 phone held vertically (so it becomes 9:16), the same camera will show only an area of 5.6 by 10 units.

因此,我们知道通过这些设置,我们可以将10个单位构成大约17.7的区域。 在Mac上(通常为16:10),它将为16 x 10 (因此水平方向的可见性较小)。 在垂直持下的16:9手机上(它变成9:16),同一相机将仅显示5.6 x 10单位的区域。

Note: We won’t go over how to cope with aspect ratios in this blog post because if you’re aiming to make a game for different aspect ratios, not only you need to think of the graphics, but in general you need to make a lot of gameplay tweaks to make sure the game doesn’t play differently on devices with different ratios. For instance, any game that scrolls horizontally will benefit from a slender horizontal aspect ratio because the player can see more of the coming hazards. Sometimes making a game that works fine on wildly different aspect ratios is impossible, and people use frames or black bars to fill the negative space that they can’t fill with gameplay.

注意:在本博客文章中,我们将不介绍如何处理宽高比 ,因为如果您要针对不同的宽高比制作游戏,则不仅需要考虑图形,而且通常需要制作图形。为了确保游戏在具有不同比例的设备上不会出现差异,我们进行了大量的游戏调整。 例如,任何水平滚动的游戏都将受益于细长的水平纵横比,因为玩家可以看到更多即将到来的危险。 有时,不可能制作出可以在纵横比非常不同的情况下正常运行的游戏,并且人们使用框架或黑条来填充游戏无法填充的负空间。

输入单位像素 (Enter Pixels per Unit)

When importing graphics as Sprites, Unity displays a parameter called Pixels per Unit (PPU). Now that we know all about units, this should be very clear. It’s expressing how many pixels from your Sprite fit into a unit in the Unity scene when the GameObject is scaled 1,1,1.

将图形导入为Sprites时,Unity将显示一个称为“每像素像素数(PPU)”的参数。 既然我们已经知道所有单位,那么这应该很清楚。 它表示当GameObject缩放为1,1,1时,您的Sprite中有多少像素适合Unity场景中的一个单元。

Say for instance I have the Sprite of a rock that’s 218 by 175 pixels, and I set the Pixels per Unit to be 100, once I drag that Sprite in the scene my GameObject by default will be 2.18 by 1.75 units, occupying roughly one-fifth of the 10 units on the vertical axis.

举例来说,假设我的岩石的Sprite尺寸为218 x 175像素,并且将“像素单位”设置为100,一旦我将Sprite拖动到场景中,默认情况下,我的GameObject将为2.18 x 1.75单位,大约占一个垂直轴上10个单位的五分之一。

With these settings, we can fit more than five rocks on the vertical of the viewport

通过这些设置,我们可以在视口的垂直方向上容纳五个以上的岩石

So let’s take a full-HD screen as our test resolution. The vertical is 1080 pixels, and the rock is less than a fifth of the screen (you can see how the faded rocks fit more than 5 times in the image above), it means we are using 175 pixels of source graphics to render more than 200 pixels. Which means that we are going to have a slightly blurry rock.

因此,让我们以全高清屏幕作为我们的测试分辨率。 垂直为1080像素,并且岩石不到屏幕的五分之一(您可以在上面的图片中看到褪色的岩石如何适合5倍以上),这意味着我们使用175像素的源图形来渲染200像素。 这意味着我们将拥有一块稍微模糊的岩石。

To fix this, we have several solutions: we can scale down the rock to about half the size, make the camera frame bigger to 10.8 (which produces a zoom out), or we can change the PPU value of the Sprite to 108 (which has the same effect of making the rock smaller on screen). In all three cases, if we want the rock to be crisp, it will have to be smaller.

要解决此问题,我们有几种解决方案:我们可以将岩石缩小到大约一半大小, 将摄像机框架放大到10.8(产生缩小),或者可以将Sprite 的PPU值更改为108(即具有使岩石在屏幕上变小的相同效果)。 在这三种情况下,如果我们希望岩石变脆,则必须变小。

Where are that camera size and the PPU value coming from? Easy! For the camera size, if we import our graphics at 100 PPU, then we would need a 10.8 camera because 10.8×100 equals 1080. This allows us to cover the whole height of the screen. Conversely, to calculate a correct PPU where the camera size stays on 5, if we hope to cover a full-HD screen with 10 Unity units vertically, then we have 1080/10 = 108. This is the number of pixels that we should be cramming in one unit if we don’t change the camera size.

相机尺寸和PPU值从哪里来? 简单! 对于摄像头尺寸,如果我们以100 PPU导入图形,则将需要10.8摄像头,因为10.8×100等于1080。这使我们可以覆盖整个屏幕高度。 相反,要计算正确的PPU(摄像机尺寸保持在5),如果我们希望垂直覆盖10个Unity单位的全高清屏幕,则我们有1080/10 =108。这是我们应该如果不更改相机尺寸,则只能装在一个单元中。

制定规则,打破常规 (Make the rule, break the rule)

Keep in mind that as you’re working on your game, it’s dangerous to mix these workflows as you go: you might end in a position where some graphics used in the wrong scene have a  resolution that’s too low and you didn’t even notice. It’s good to establish guidelines: one PPU for most of the asset in your project, and a typical camera size.

请记住,在进行游戏时,将这些工作流程混合在一起是很危险的:您可能会以错误场景中使用的某些图形的分辨率过低甚至没有注意到的位置结束。 建立指导原则是一件好事:为项目中的大多数资产配备一个PPU,并为典型的摄像机尺寸。

Then you can break the rules later. Maybe you have a cutscene where the camera zooms in and out, changing the size temporarily. Or maybe your background elements are so big that you can’t afford to keep the same PPU because you would end up with enormous textures. In that case, it’s OK to reduce the PPU for those elements and import smaller sprites, but still cover a big area of the screen with them.

然后, 您可以稍后违反规则 。 也许您有一个过场动画,相机在其中放大和缩小,暂时改变尺寸。 也许您的背景元素太大,以至于您承受不起拥有相同PPU的负担,因为最终会产生大量纹理。 在这种情况下,可以减少这些元素的PPU并导入较小的Sprite,但是仍然可以使用它们覆盖屏幕的较大区域。

预览游戏 (Previewing your game)

As you are working in Unity, you might be wondering what’s the resolution that you are seeing through the Game View and whether that’s an accurate preview of your art on the target platform.

在Unity中工作时,您可能想知道通过“游戏视图”看到的分辨率是多少,以及这是否是目标平台上艺术品的准确预览。

Most of the options you will need are in the drop-down menu at the top and the slider next to it.

您将需要的大多数选项都在顶部的下拉菜单中,并在其旁边的滑块中。

Notice how with Low Res Aspect Ratios on, Scale is on 2 by default. This is because pixels need to be duplicated to simulate low-DPI on a high-DPI screen.

请注意,启用“低分辨率长宽比”后,默认情况下“缩放”为2。 这是因为需要复制像素才能在高DPI屏幕上模拟低DPI。

Aspect ratios just force a specific ratio between horizontal and vertical, but they will make use of the current resolution of your Game View viewport, which in turn depends on your screen. So they’re good for setting up UI and objects on a screen, but not really for testing art.

宽高比只会强制确定水平与垂直之间的特定比例,但它们将利用您的“游戏视图”视口的当前分辨率,而该分辨率又取决于您的屏幕。 因此,它们非常适合在屏幕上设置UI和对象,但不适用于测试艺术作品。

While you’re on an aspect ratio, the checkbox Low Resolution Aspect Ratios will be active if you are on a high-DPI screen. If you check it, it will simulate a standard DPI screen resolution.

使用长宽比时,如果您在高DPI屏幕上,则“ 低分辨率长宽比 ”复选框将处于活动状态。 如果选中它,它将模拟标准的DPI屏幕分辨率。

Fixed resolutions, on the other hand, force Unity to render a window of that exact size. At that point, you might need to expand your Game View or maximize it to visualize the whole preview. In this context, the Scale slider can make high resolutions fit into your Game View window, but if you’re going below 1x scale, then you aren’t actually seeing that resolution, but a resampling of it.

另一方面, 固定分辨率会迫使Unity渲染该大小的窗口。 届时,您可能需要扩展游戏视图或将其最大化以可视化整个预览。 在这种情况下,“比例”滑块可以使高分辨率适合您的“游戏视图”窗口,但是如果您要低于1倍比例,那么您实际上并没有看到该分辨率,而是对其进行了重新采样。

Check this video for a practical example of sizes on a Retina screen:

查看此视频,以获取Retina屏幕上尺寸的实际示例:

Video showcasing different uses of the Game View

视频展示了游戏视图的不同用法

And don’t forget that you can add your own fixed resolutions and aspect ratios to the drop-down:

并且不要忘记,您可以在下拉列表中添加自己的固定分辨率和宽高比:

Tip: Don’t forget that you shouldn’t base your judgment on the editor only. Every now and then, make a build of the game (or just of the art!) and take a look at it on your target device or screen.

提示:不要忘记,您不应仅基于编辑器来做出判断。 时不时地制作游戏(或仅仅是艺术作品!),然后在目标设备或屏幕上进行查看。

最后的笔记 (Some final notes)

As you can see, the resolution of your art, the camera size, and the screen you want to go for are all connected and there’s not one pixel size or PPU that fits all cases. Study your target platforms, decide on a resolution, and inform the whole team by making guidelines. Then produce higher-res art anyway, it might be useful later! Finally, resize it to the resolution you need and import it in Unity.

如您所见,艺术品的分辨率,相机尺寸和您要使用的屏幕都已连接,并且没有一个像素尺寸或PPU适合所有情况。 研究您的目标平台,确定解决方案,并通过制定准则来告知整个团队。 然后无论如何都要制作更高质量的艺术品,以后可能会有用! 最后,将其调整为所需的分辨率,然后将其导入Unity。

And one final suggestion. Even if previously I used the terms “slightly blurry” as if it was the end of the world and something we absolutely MUST FIX, this is not a hard rule. It might be that in your game some objects – sometimes – are under resolution. Especially if there are a lot of minute details on screen, maybe transparencies overlapping, with some fog, rain, or post-processing on top. Play the game at its normal speed. Do you actually notice the fact that they are being re-sampled?

最后一个建议。 即使以前我曾经使用“稍微模糊”一词,好像这是世界的尽头,也是我们绝对必须解决的问题,但这并不是一个硬性规定 。 可能是游戏中的某些物体(有时)处于分辨率之下。 尤其是如果屏幕上有很多详细信息,则可能是透明胶片重叠,上面有一些雾,雨或后期处理。 以正常速度玩游戏。 您实际上注意到它们正在重新采样的事实吗?

If you honestly can’t tell the difference, then maybe the extra work, disk space, and processing needed to render a higher resolution sprite aren’t worth it. Remember: good games make big compromises!

如果老实说不出区别,那么渲染更高分辨率的精灵所需的额外工作,磁盘空间和处理可能不值得 。 记住:好的游戏会做出重大的妥协!

#Unity2DC挑战 (#Unity2DChallenge)

Do you have some amazing 2D art in the works? Are you curious about our new 2D tools? Make something great with our new 2D animation tools, Tilemaps, SpriteShape, Pixel Perfect package or SVG importer, and join Unity 2D Challenge! I’m one of the judges and can’t wait to see all your brilliant ideas.

您的作品中有一些令人惊叹的2D艺术吗? 您是否对我们的新2D工具感到好奇? 使用我们的新2D动画工具,Tilemaps,SpriteShape,Pixel Perfect软件包或SVG导入器,制作出很棒的东西,并加入Unity 2D Challenge ! 我是评委之一,迫不及待想看到您所有的出色创意。

翻译自: https://blogs.unity3d.com/2018/11/19/choosing-the-resolution-of-your-2d-art-assets/

d1分辨率和960分辨率

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下是一个16位分辨率的AD2S1210的Verilog驱动代码: ```verilog module ad2s1210_driver ( input clk, input rst, input [15:0] data_in, output [15:0] data_out, output cs, output sclk, output rd ); reg [15:0] shift_reg; reg [3:0] state; wire [15:0] rom_data; wire [1:0] rom_address; wire rom_rd; assign cs = (state == 4); assign sclk = (state == 1) || (state == 3); assign rd = (state == 2); ad2s1210_rom rom ( .clk(clk), .address(rom_address), .data(rom_data), .rd(rom_rd) ); always @(posedge clk) begin if (rst) begin shift_reg <= 16'h0; state <= 4'd0; end else begin case (state) 4'd0: begin shift_reg <= {shift_reg[14:0], data_in[15]}; state <= 4'd1; end 4'd1: begin shift_reg <= {shift_reg[14:0], data_in[15]}; state <= 4'd2; end 4'd2: begin shift_reg <= {shift_reg[14:0], rom_data[15]}; state <= 4'd3; end 4'd3: begin shift_reg <= {shift_reg[14:0], rom_data[15]}; state <= 4'd0; end 4'd4: begin shift_reg <= {shift_reg[14:0], 1'b0}; state <= 4'd5; end 4'd5: begin shift_reg <= {shift_reg[14:0], 1'b0}; state <= 4'd0; end default: begin shift_reg <= {shift_reg[14:0], 1'b0}; state <= 4'd0; end endcase end end assign rom_address = shift_reg[9:8]; assign data_out = shift_reg; endmodule module ad2s1210_rom ( input clk, input [1:0] address, output [15:0] data, output rd ); reg [15:0] rom[4]; initial begin // 初始化ROM数据 rom[0] = 16'h0000; rom[1] = 16'hFFFF; rom[2] = 16'h5555; rom[3] = 16'hAAAA; end always @(posedge clk) begin case (address) 2'b00: begin data <= rom[0]; end 2'b01: begin data <= rom[1]; end 2'b10: begin data <= rom[2]; end 2'b11: begin data <= rom[3]; end endcase rd <= 1'b1; end endmodule ``` 这个驱动与之前的驱动类似,只是将数据位宽扩展到了16位,并相应地修改了状态机和ROM数据的位宽。控制模块的状态机有5个状态,分别是:等待数据输入、传输数据到芯片、从芯片中读取数据、传输数据到输出端口和空闲状态。ROM模块包含了4个16位的数据,其中的数据可以根据需要进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值