Sep 09, 2017 The other 'like' is the quality of the tessellation. Displacement just looks the most natural and controlled. I just need to adjust my heightmap in order to ensure that the shaping is correct. It is also a fast shader, this allows us to turn on many features practically. Also it lies in between CTS and RTP in terms to control of features. See how to create a natural shader to render ground/terrain surfaces. This clip takes a look at diffuse color properties, displacement and bump channels. Whether you're new to Luxology's popular 3D computer graphics application or are a seasoned digital artist merely on the lookout for new tips and tricks, you're sure to be well served by this free video modo tutorial from the folks at CG Cookie.
![]()
To create a new Material, use Assets->Create->Material from the main menu or the Project View A view that shows the contents of your Assets folder (Project tab) See in context menu. By default, new materials are assigned the Standard Shader, with all map properties empty, like this: Once the Material has been created, you can apply it to an object and tweak all of its properties in the Inspector A Unity window that displays information about the currently selected GameObject, Asset or Project Settings, alowing you to inspect and edit the values. To apply it to an object, just drag it from the Project View to any object in the Scene A Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. See in or Hierarchy.
Setting Material Properties You can select which Shader you want any particular Material to use. Simply expand the Shader A small script that contains the mathematical calculations and algorithms for calculating the Color of each pixel rendered, based on the lighting input and the Material configuration.
See in drop-down in the Inspector, and choose your new Shader. The Shader you choose will dictate the available properties to change. The properties can be colors, sliders, textures, numbers, or vectors. If you have applied the Material to an active object in the Scene, you will see your property changes applied to the object in real-time. There are two ways to apply a Texture An image used when rendering a GameObject, Sprite, or UI element.
You control the weather, landscape, rivers, lakes and oceans, suns, moons and stars. With Terragen 3-4 you have complete control over the shader networks used for terrains, textures, micropolygon displacements, clouds and object distributions. You can reorganise the planetary shading pipeline to suit your goals.
Textures are often applied to the surface of a mesh to give it visual detail. See in to a property. • Drag it from the Project View on top of the Texture square • Click the Select button, and choose the texture from the drop-down list that appears Built-in Shaders In addition to the A built-in shader for rendering real-world objects such as stone, wood, glass, plastic and metal.
Supports a wide range of shader types and combinations. See in, there are a number of other categories of built-in shaders for specialised purposes: • FX: Lighting and glass effects.
• GUI and UI (User Interface) Allows a user to interact with your application. See in: For user interface graphics. • Mobile: Simplified high-performance shader for mobile devices. • Nature: For trees and terrain The landscape in your scene.
A Terrain GameObject adds a large flat plane to your scene and you can use the Terrain’s Inspector window to create a detailed landscape. • Particles: Particle system A component that simulates fluid entities such as liquids, clouds and flames by generating and animating large numbers of small 2D images in the scene. See in effects. • Skybox A special type of Material used to represent skies.
Tutorial 9: Terrain Blending This DirectX 11 terrain tutorial will cover how to blend textures on terrain using alpha maps to create a smooth transition between different textures.The code in this tutorial is based on the color mapping tutorial. To blend textures on terrain we use the same principles as were discussed in the DirectX alpha mapping tutorial.We take two color textures and blend them together on a pixel by pixel basis using the alpha map texture as the blending value.Now to do this on a large terrain requires quite a few different alpha maps to achieve different texture transitions.It will also require a number of different textures to create the look we are going for.A combination of two textures and a alpha map will be referred to as a material. For each material we will want to just set the two textures and alpha map once and then draw all the terrain associated with this material.To do this we will need to break the terrain into vertex buffers based on materials.The combination of the material and its vertex/index buffer will be called a material group.You have seen this same kind of thing in the quad tree tutorial where we broke the terrain into buffers for each node, this is the same thing except for materials. To setup a material based rendering system for terrain we will first need a text file containing all the textures and alpha maps that will be used for the terrain.This file will also contain the list of materials which is just a combination of those same textures and alpha maps.Here is the example one we use for this tutorial: As you can see it starts with a texture count and then lists all the textures and alpha maps that should be loaded and used in the terrain rendering.The second portion is where the materials are defined.It starts with a material count and then lists each material defined by indexes.The first index is the first texture. For example if the index is 1 then it is referring to the texture02.dds file.The second index is the texture to blend with, it works the same way except that if it is defined as -1 then it means this material does not blendand is just the texture by itself.The third index is the alpha map. For example if the third index is 3 then it refers to the alpha01.dds alpha map. The last three numbers are a red, green, blue index.They are used together to define a color that represents this particular material.So for example the first material is 0, 255, 0 which means the material is defined by green.Now what we do is use a bitmap with each of the colors as an index and location where the material should be rendered on the terrain.For this tutorial we will use the following bitmap as our material map: Now you can that the green is the lower right section in the material map.So every quad in the terrain in that lower right section would use the first material.You can also see the top left section is mostly white, which means that material 4 which is defined by 255, 255, 255 would be used to render to those parts ofthe terrain.There are also thin lines along the borders which are usually a alpha map between the two textures so they transition by blending between the two materialsof the two regions. The main reason for using this is because it gives you or the artist 100% control of how the terrain will look.Most procedural methods usually use some kind of slope and height equation which works well for uninhabited areas that have general terrain.But anything that is inhabited or has unique features to it will require a way to define those features.Using a material map is one of the easier ways to do so. Also note that most programmers will build a separate terrain creation tool which does this inside the tool and then exports everything as modelsso the vertex buffers are already prepared in advance and easy to load into the engine.I am doing it inside the engine for this tutorial so you can see how it works without the need to explain a terrain generation tool also.And like usual this tutorial is not optimized so it is easier to read and understand how it works and then you can optimize it later for your own needs. We will start the code section of the tutorial by looking at the changes to the HLSL shader files. Terrain.vs The terrain vertex shader remains the same as it was in the color mapping tutorial. Terrain.ps We have three textures for the terrain pixel shader.The first two are the two color textures that will be blended together.The third texture is the alpha map which will be used to determine how the two color textures are blended together. There is a new buffer to hold the boolean value indicating if the textures should be blended together or if only one should be rendered with no blending. If the boolean value indicates to blend then we first sample the two color textures and the alpha map.After that we blend the two color textures together based on the alpha value in the alpha map.This type of blending was covered in the DirectX blending tutorials. If the boolean value indicates that we should not blend then we just sample the first color texture and use that as the texture color value. We then combine the light color and the blended texture value. Terrainshaderclass.h A new buffer has been added to hold the boolean value indicating if the terrain textures should be blended or not for each polygon. The Render function has been removed and the RenderShader function was made public.Also the SetShaderParameters private function has been divided into two public functions. This was done so the terrain could be efficiently rendered by only setting certain variables once while being able to change the textures often. This is the new texture information buffer. Terrainshaderclass.cpp Initialize the texture information buffer to null in the class constructor. A new buffer description variable is added for the texture information buffer. The new texture information buffer description is setup here. Once the description is setup the texture information buffer is then created. The texture information buffer is released here in the ShutdownShader function. The setting of textures has been removed from the SetShaderParameters function. SetShaderTextures is a new function which is used for setting textures in the shader.It was separated from the SetShaderParameters function so the setting of textures could happen more often. The primary texture is set in the pixel shader first. If this material group uses blending then set the second color texture and the alpha map in the shader so blending can occur. Now set the boolean value in the shader letting it know to blend or not. Terrainclass.h The height map type has been modified and has a red, green, and blue index.The indices are used to indicate which material is used for each polygon in the terrain.The red, green, and blue index will match up to the colors in the material map. This is the new structure for the material groups.The material group is made up of indexes to the two textures and the alpha map for that group.It also has red, green, and blue indexes to match up to the material map.It has a vertex and index buffer to hold the polygon data from the terrain in each group instead of just one large single buffer.It also has a temporary vertex and index array used for building the vertex and index buffers. There are new functions for loading and unloading the material groups. There are new variables for the texture array and material group arrays. Terrainclass.cpp Initialize the texture array and material group array to null in the class constructor. The material groups array is initialized instead of the single vertex and index buffer.Each material group will have its own vertex and index array with its own set of textures. When the shutdown occurs the material groups array is also released now. The LoadMaterialFile function reads in the text file containing the information about the textures and the material groups the terrain uses.All of the textures used by the terrain are first loaded into the texture array.Their position in that array is also their index for the material group to access them by.After that the material group is created and the indexes for it are read in from the material file.Once the indexes are loaded the material map is read in and then the vertex and index buffers for each material group is createdbased on the information from the indexes and the material map. LoadMaterialMap is the new function which loads the material map bitmap into the height map array.It takes the colors from the material map and stores them as indexes in the rIndex, gIndex, and bIndex components of the height map array.This way each polygon in the height map can be associated with a material. The LoadMaterialBuffers function does the work of associating a material with its specific terrain vertices and then placing each vertice in the correct array inside the material groups array.It starts by first creating a temporary vertex and index array for each material group.Then it goes through the height map and stores the vertices for that material group in the correct temporary vertex and index array.After the entire height map has its vertices in the right material groups the vertex and index buffer for each material group is createdand the temporary vertex and index arrays are released. The ReleaseMaterials function cleans up the material groups array and the texture array during shutdown. Render draws the terrain using the material groups array as the vertex and index buffer source.It goes through each material group, sets its textures, and then draws the terrain vertex data that is associated with those textures.When it is done with one group in the changes the textures to the next group and then draws that groups vertices.This is continued until all material groups have been rendered. Applicationclass.h The ApplicationClass header has not changed for this tutorial. Applicationclass.cpp ![]() The terrain now takes as input a file name of the textures and material indexes (legend.txt) and a bitmap representing the material map (materialmap01.bmp). The terrain Render function now takes as input the TerrainShaderClass object and does all the rendering work inside the TerrainClass. ![]() Summary The terrain now smoothly blends textures using alpha maps where transitions are required.The color map is also combined to help hide repetition and give the terrain an added touch of color. To Do Exercises 1. Recompile and run the program. You will see blended textures on the terrain. Press escape to quit. 2. In the pixel shader comment out the last line of the color map addition so you can clearly see the blending of the textures on the terrain. 3. Modify the material map bitmap using the same colors to place materials elsewhere on the terrain. 4. Create your own material and material group and add it to the terrain. Source Code Visual Studio 2010 Project: tertut09.zip Source Only: tersrc09.zip Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |