3D Programming: Skyboxes

Source: Internet
Author: User

Skyboxes

A common application of a texture cube is to map the texture cube around camera to a skybox,box or a sphere, and to create a visual view of the scene environment. Listing 8.1 lists a skybox effect code.

List 8.1 skybox.fx

/************* Resources *************/cbuffer Cbufferperobject {float4x4 worldviewprojection:worldviewprojectio N < string uiwidget= "None";
>;
    } texturecube skyboxtexture < string uiname = "Skybox texture";
String resourcetype = "3D";

>;

Samplerstate Trilinearsampler {Filter = min_mag_mip_linear;};

Rasterizerstate disableculling {cullmode = NONE;

/************* Data Structures *************/struct Vs_input {float4;};
    struct Vs_output {float4 position:sv_position;
FLOAT3 Texturecoordinate:texcoord;

};
    
    /************* Vertex Shader *************/vs_output vertex_shader (vs_input in) {vs_output out = (vs_output) 0; Out. Position = Mul (in.
    Objectposition, worldviewprojection); Out. Texturecoordinate = in.
    
    Objectposition;
return out; }/************* Pixel Shader *************/float4 pixel_shader (vs_output in): Sv_target {return skyboxtexture.sa Mple (TrilinearsamplEr, in.
Texturecoordinate); }/************* Techniques *************/technique10 Main10 {pass P0 {SetVertexShader (
        Vs_4_0, Vertex_shader ()));
        Setgeometryshader (NULL);
            
        SetPixelShader (Compileshader (Ps_4_0, Pixel_shader ()));
    Setrasterizerstate (disableculling);

 }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.