To help facilitate development on these different devices, XNA 4. These profiles allow developers to target certain hardware devices by supporting a specific set of graphics API designated by the profile they choose. There are two profiles in XNA 4. HiDef is designed for high-powered, top-of-the-line hardware, whereas Reach is designed to support a wider range of hardware devices. The Reach profile offers a limited set of graphic features and is a subset of the HiDef profile.
You can use the HiDef profile to target Xbox hardware as well as Windows-based computers with graphics cards supporting at least DirectX You can identify which profile is supported by your hardware at runtime by using the GraphicsAdapter.
IsProfileSupported method. A chart illustrating more detail on the differences between the Reach and HiDef profiles is shown in Table In previous versions of XNA, the BasicEffect class was a very basic effect, implemented mainly to allow new game developers to build games without in-depth knowledge of complex shader code. The idea was that serious game developers would implement their own shaders and not rely on the BasicEffect class. Much of that thinking had to change with the onset of Windows Phone 7, which does not support custom shaders.
As a result, new configurable effects were added, available on both the Reach and HiDef profiles. These are:. The BasicEffect class has been tweaked to include more pixel and vertex shaders to support more realistic lighting and fog effects.
This effect allows you to use two different textures with independent texture coordinates. The two textures will be blended together for added complexity and detail. This effect uses a reference alpha and an alpha function to implement alpha testing. This can improve performance by updating only those pixels that are drawn in the scene. This effect uses bones and weights to determine the vertex positions. The effect is powerful when used for animation and instancing.
This effect uses textures and a cube map texture to shade objects based on the environment, reflecting the light from objects in the scene. Some of the state properties that were used in previous versions of XNA to modify the way scenes were drawn on the screen and the way the graphics device processes data sent to it by your game have been moved into state object classes.
These classes are:. Controls how color and alpha values are blended. Controls how the depth buffer and the stencil buffer are used. Determines how to convert vector data shapes into raster data pixels. Determines how to sample texture data.
Scalars in XNA 4. This enhancement dramatically improves game performance. Screen orientation is most important on Windows Phone 7 devices, which switch rotation from varieties of landscape to portrait and back when the device rotates. The scalars automatically map your game from one orientation to another, and rotate input such as touch panel input accordingly.
The Microsoft. Right now the only solution I can think of is to divide the level into smaller parts and load the textures on demand, depending on the visible area. But I believe this would slow down the performance big time when navigating in the scene. Any thoughts? There should be some standard approach for level editors on that matter. I'm thinking that if your art direction doesn't really mesh with the tile-based approach, so you will want to start thinking about approach 2.
A few things to think about. It might be a good idea to use with different quality of textures, if you're far away use the 64x64 texture, then when you get closer keep swaping it out to x, x, x, etc Also reconsider using textures of x, since its better to have 4 x textures :.
How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 10 years, 9 months ago. Active 10 years, 9 months ago. Viewed 1k times. Improve this question. Add a comment. Active Oldest Votes. You basically have two options Switch to a tile-based approach. If you're using tiles, that means you can re-use the same texture over and over which saves a lot of memory.
Switch to on-demand as you described. A few things to think about It doesn't necessarily have to be slow, as long as your "active" regions are big enough so that you don't thrash the disk by loading too often you should be fine. The register definition at the end is not required but does enable you to specify which of the samplers the variable will map to. In general, the sampler variables map to the order they are declared.
Explicitly defining which sampler to use enables you more control if you are using multiple textures and want to specify textures to map to specific samplers.
The vertex shader input and output structures need to be updated to include the texture coordinate to use per vertex. The TexCoord field is passed in as part of the vertices that you defined in your quad.
Vertices can contain multiple texture coordinates, and this specifies that this field should be the first one defined in the VertexDeclaration. The vertex shader then needs to copy this value directly to the VertexShaderOutput.
Add the following line to your vertex shader:. The final step is to update the pixel shader to read the final color from the texture sampler and to output the color. Replace your pixel shader with the following:. Use the tex2D intrinsic function to return the color from the texture sampler. The input texture coordinate are interpolated across the face of the triangle using the rules setup in the SamplerState.
Running the sample code now should display a quad with the fractal texture and looks like Figure 8. It is also possible to set this directly in the effect file itself so it does not require code changes within your project.
Be mindful when setting states within the effect file. These changes can affect how other draw calls are rendered, so be watchful of which states you change. To set the sampler state in the effect file, update the file with the following global texture and sampler:.
You have added a new variable to hold the texture to use. The ColorTextureSampler has been updated to specify the sampler settings to use. Because you added the new ColorTexture effect variable, you also need to set this in your game. Instead of setting the texture on the GraphicsDevice, pass which texture to use directly to the effect file. When using sample states directly in the effect file, these settings take affect after you call Apply on the EffectPass that is using them.
Running the sample now should look just like before.
0コメント