English 中文(简体)
HLSL和DX天空箱问题
原标题:HLSL and DX Skybox Issues (creates seams)

I m(re) 学习直接X,并移入HLSL编码。 在使用我的习俗之前,I.fx文件为一场带有曲折的游戏创造了一个天空箱。 一切都做了精彩的工作......绘画和精彩。 然而,现在,我有HLSL安排来管理 there,那里有独特的海.。 案文使我完全站得住脚。

我倾向于认为问题在于特克斯河......,而不是这里的所有文字信息。 我在DX...it的修辞中可能只是说,我还没有在两者之间取得联系。 事先提供帮助的任何进展!

The fx file:

float4x4 World;
float4x4 View;
float4x4 Projection;

float3 CameraPosition;

Texture SkyBoxTexture; 

samplerCUBE SkyBoxSampler = sampler_state 
{ 
   texture = <SkyBoxTexture>; 
   minfilter = ANISOTROPIC; 
   mipfilter = LINEAR; 
   AddressU = Wrap; 
   AddressV = Wrap;
   AddressW = Wrap;
};

struct VertexShaderInput
{
    float4 Position : POSITION0;
};

struct VertexShaderOutput
{
    float4 Position : POSITION0;
    float3 TextureCoordinate : TEXCOORD0;
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;

    float4 worldPosition = mul(input.Position, World);
    float4 viewPosition = mul(worldPosition, View);
    output.Position = mul(viewPosition, Projection);

    float4 VertexPosition = mul(input.Position, World);
    output.TextureCoordinate = VertexPosition - CameraPosition;

    return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
    return texCUBE(SkyBoxSampler, normalize(input.TextureCoordinate));
}

technique Skybox
{
    pass Pass1
    {
        VertexShader = compile vs_2_0 VertexShaderFunction();
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}
最佳回答

为了避免出现海流,你需要把你天空箱引入单一提纲,最好是使用三角地带。 DON 每一面孔都是用单个矩阵或像这样的东西来单独做的原始转变——你们是靠海水。 如果你出于某些无法解释的理由不希望使用单一衍生工具,要求使用空箱部件,那么,你必须保证,所有面孔都使用相同的矩阵(每张电话所用的世界+观点+预测矩阵),并且对玉米vert(即“顶”面孔)也使用完全相同的矢量(方位)。

另一点是,你要么储存天空箱,要么储存天空箱。

  1. cubemap (looks like that s what you re doing) - make just 8 vertices for skybox, draw them as indexed primitive.
  2. Or an unwrapped "atlas" texture that has unused areas filled. with border color.

或者,如果你用斜体重,你可以使用斜体“射线”天线。

问题回答

你们需要把文字坐标与机组国家混为一谈,以清除海姆。 http://www.toymaker.info/Games/html/sky Box.html”rel=“nofollow” 页: 1 陶器是学习直接3D的伟大场所,如果你遇到更多的麻烦,你应检查辅导员。

您不妨仅用一个四级的天空箱。 你们所需要的一切都与世界* 意见*Proj矩阵相反,即(世界* 意见*Proj)^(-1)。

qua应当:(1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1、1。

接着,你对VS的文本坐标进行了计算。

float4 pos = mul(vPos, WorldViewProjMatrixInv);
float3 tex_coord = pos.xyz / pos.w;

最后,你对PS的案文进行了抽样:

float4 color = texCUBE(sampler, tex_coord);

不要担心任何海ms!





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签