[Overview] integrating shaders into the vision Rendering Engine

Source: Internet
Author: User

This paper in shaderx3 seems to have become the commom sense designed by the 3D Game Engine.

The following is an excerpt Based on the chapter title:

Assigning shaders to Geometry

As mentioned in this Article, the shader of an object is divided into two types. One is the material of a static object, such as fur, concave and convex, and the other is a dynamic environment such as dynamic light and shade, Volume fog, and so on. When performing dynamic shader computing, if the dynamic environment has a volume effect, you need to find a set of rendered objects affected by the dynamic environment.

Rendering order

Base pass is used to render basic texture maps and static illumination. Other dynamic effects or rendering of other shader are called effect pass.

During rendering, the common sense is to first render an opaque object before rendering a transparent object. However, in the case of multi-pass rendering, this method is not so practical. The complexity of the rendering sequence increases dramatically with the case of multi-pass. In order to solve this problem and coordinate technologies such as hook side and volume fog, the following solutions are proposed:

Code
1 Void Renderloop3 ()
2 {
3 Rendereffects (opaque, pre_basepass );
4 Renderbasepass (opaque );
5 Rendereffects (opaque, post_basepass );
6
7 Rendereffects (translucent, pre_basepass );
8 Renderbasepass (translucent );
9 Rendereffects (translucent, post_basepass );
10 }

The rendering of effect pass is divided into pre-base pass and post-base pass. For example, if you want to perform a cartoon rendering on the hook edge, the common practice is to perform normal operations in vs. This step is placed in pre-base. The dynamic rendering light source using the blend method is placed in the Post-base pass. Sometimes there may be multiple pass to be rendered in the same stage. For example, dynamic illumination and volume fog rendering are all carried out in post-base pass, in this case, you can add an sort key to the shader to ensure that the volume fog is always drawn after dynamic illumination.

Shader callback Functions

It is mentioned that the callback function is provided before each frame rendering and before each batch of ry rendering to make the last modification before rendering. This is very similar to the implementation of gamebryo. The design of the gamebryo Render system also provides such a set of callback functions, and the intention is consistent with the viewpoint in this article.

Two examples of using callback functions are given in this article. One is how to use callback functions to calculate the effects of light and shadows on the ry during illumination rendering, and the other is how to render fur, use the distance from the camera to select the shell length of the hair.

Switching overhead for State setup

To reduce the switching of rendering states, the following methods are proposed: Sorting transparent and non-transparent objects; interfaces are provided in the shader object to query the special textures used by the shader, for example, illumination pasters and normal pasters. You can set the desired rendering state for the shader with special textures. Otherwise, no rendering state will be drawn. In addition, you can query the current rendering status before setting the rendering status. If the rendering status is the same as that set, no API call is performed, after all, calling the API to change the rendering status takes a lot of time.

Texture

As mentioned in this articleProgramThe texture generated (the process texture generated by the CPU) and the texture made through art use another technology called texture modifier. Texture modifier is a function that accepts a texture, thenAlgorithmConvert pixels in the texture to the desired effect, such as converting to grayscale images and adding Alpha channels. The texture modifier provides some flexibility for the engine users. You can customize the modifier to modify the texture. In some running cases, this function is very convenient.

 

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.