Spherical environment ing for highlights

Source: Internet
Author: User
Tags mul

When looking at the wow model some time ago, there was a strange rendering status switch in the render flag, and this status was not mentioned in wowdev.

Pass. useenvmap = (texunitlookup [Tex [J]. texunit] =-1) & (RF. Flags & 0x10 )! = 0) & RF. Blend> 2; // & RF. Blend <5; // use environmental reflection effects? <Br/>

After tracking, we found that several models will switch to this "spheremap" only when a certain type of texture is used. The file name is usually like armorreflect4.blp.

At that time, I only knew that it was used for highlights, but I didn't take a closer look at the implementation.

Later, I accidentally discovered in the project that I also used this technology to know that apart from {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
Track ('ctl00 _ mtcs_main_ctl00 | ctl00_mtcs_main_ctl05 ', this );
}
}
}
}
}
} "Href =" http://msdn.microsoft.com/en-us/library/ee415223 (vs.85). aspx "> outside of cubic environment mapping, There Is {
Function onclick ()
{
Function onclick () {function onclick () {track ('ctl00 _ mtcs_main_ctl00 | ctl00_mtcs_main_ctl03 ', this );}}}}
}
} "Href =" http://msdn.microsoft.com/en-us/library/ee422438 (vs.85). aspx "> spherical environment mapping.

According to the dx sdk, the UV coordinates are calculated as follows:

Where NX and NY are the XY components of the camera's space vertex normal. the original wow model was not successfully tested, so the texture was treated as a normal texture. No wonder the dragon teeth and claws shown in the figure do not look as sharp as the wowmodelviewer @_@. it seems that I have not changed the normal to the camera space.

I tried a teapot in rendermonkey. The result is correct:

Float4x4 matviewprojection; <br/> float4x4 matview; </P> <p> struct vs_input <br/>{< br/> float4 position: position0; <br/> float3 normal: normal; <br/> float2 texcoord: texcoord0; <br/>}; </P> <p> struct vs_output <br/>{< br/> float4 position: position0; <br/> float2 texcoord: texcoord0; <br/> float2 sphereuv: texcoord1; <br/>}; </P> <p> vs_output vs_main (vs_input input) <br/>{< br/> vs_output output; </P> <p> output. position = MUL (input. position, matviewprojection); <br/> output. texcoord = input. texcoord; <br/> float3 viewnormal = MUL (input. normal, matview); <br/> output. sphereuv = viewnormal. XY * 0.5 + 0.5; </P> <p> return (output); <br/>}

Sampler2d basemap; <br/> sampler2d spheremap; </P> <p> struct ps_input <br/>{< br/> float2 texcoord: texcoord0; <br/> float2 shpereuv: texcoord1; <br/>}; </P> <p> float4 ps_main (ps_input input): color0 <br/>{< br/> float4 diffuse = tex2d (basemap, input. texcoord); <br/> float4 envmap = tex2d (spheremap, input. shpereuv); </P> <p> return diffuse + envmap; <br/>}

:

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.