Texture coordinate processing

Source: Internet
Author: User
Tags reflection
Texture coordinate processing

Overview:

For some special texture applications, it is necessary to deal with texture coordinates, including texture coordinate auto-generation and texture coordinate transformation.

Source of texture coordinates: from FVF and from Direct3D

Determines whether the texture coordinate transformation is enabled before the texture coordinates reach the raster processor.

first, the texture coordinates are automatically generated

Texture coordinates can be automatically generated through the Direct3D rendering engine for special visuals such as environment mapping. The automatic generation of texture coordinates is done in the Direct3D coordinate transformation and illumination pipeline, and the execution speed is faster.

The Direct3D system can use transformed spatial vertex position coordinates and normal information to generate texture coordinates.

The automatic generation of texture coordinates is mainly used to produce some special effects.

The D3dtss_texcoordindex texture stage state controls how the Direct3D system automatically generates texture coordinates. Coordinate generation Flags:

D3dtss_tci_passthru using the texture coordinates in vertex information

D3dtss_tci_cameraspacenormal the texture coordinate output of the texture layer with the normal vector of the vertex in the observing coordinate system

d3dtss_tci_cameraspaceposition Vertex coordinates in the observing coordinate system as the texture coordinate output of the texture layer

D3dtss_tci_reflectionvector as the texture coordinate output of the texture layer with the reflection vector of the vertex in the observing coordinate system, the reflection vectors are computed by vertex coordinates and normal vectors.

D3dtss_tci_spheremap the texture coordinates of the output spherical reflection

Pd3ddevice->settexturestagestate (0,d3dtss_texturecoordindex, d3dtss_tci_cameraspacenormal);

The texture stage state d3dtss_texturetransformflags is used to control the output generated by the texture coordinates.

Pd3ddevice->settexturestagestate (0,d3dtss_texturetransformflags, D3dttff_count2);

second, texture coordinate transformation

Direct3D provides the ability to coordinate transformations of the generated texture coordinates. You can specify a 4*4 texture coordinate transformation matrix, multiply it with the generated texture coordinates, and then output the transformed texture coordinates to the Direct3D rendering pipeline.

The following code pans the original texture coordinates (1.0,1.0,0.0)

D3DXMATRIX Mat;

D3DXMatrixIdentity (&mat);

mat.41 = 1.0f;

mat.42 = 1.0f;

mat.43 = 0.0f;

Pd3ddevice->settransform (D3DTEXTURE0, Mat);

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.