Game Programming 08 OGRE3D Material in Action 2010 년 2 학기 디지털콘텐츠전공.

Slides:



Advertisements
Similar presentations
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
Advertisements

Game Programming 09 OGRE3D Lighting/shadow in Action
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
RealityEngine Graphics Kurt Akeley Silicon Graphics Computer Systems.
CS 4363/6353 BASIC RENDERING. THE GRAPHICS PIPELINE OVERVIEW Vertex Processing Coordinate transformations Compute color for each vertex Clipping and Primitive.
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Real-Time Rendering TEXTURING Lecture 02 Marina Gavrilova.
SE 313 – Computer Graphics Lecture 13: Lighting and Materials Practice Lecturer: Gazihan Alankuş 1.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Real-Time Rendering SPEACIAL EFFECTS Lecture 03 Marina Gavrilova.
IN4151 Introduction 3D graphics 1 Introduction 3D Computer Graphics part 1 Projective display Viewing pipeline Graphics hardware Image-based rendering.
Texture Mapping from Watt, Ch. 8 Jonathan Han. Topics Discussed Texture Map to Models Bump Maps, Light Maps Environment (Reflection) Mapping 3D Textures.
Advanced lighting and rendering Multipass rendering.
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
1 3D –graphics and animation Shading and Surface Characteristics Harri Airaksinen.
02/04/03 Page 1 Rendering Visibility Lighting Texturing.
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
SET09115 Intro Graphics Programming
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
What is ? Open Graphics Library A cross-language, multi-platform API for rendering 2D and 3D computer graphics. The API is used to interact with a Graphics.
GPU Programming Robert Hero Quick Overview (The Old Way) Graphics cards process Triangles Graphics cards process Triangles Quads.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Computer Visualization BIM Curriculum 03. Topics  History  Computer Visualization Methods  Visualization Workflow  Technology Background.
Geometric Objects and Transformations. Coordinate systems rial.html.
Computer Graphics Texture Mapping
Programmable Pipelines. 2 Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
Shading. What is Shading? Assigning of a color to a pixel in the final image. So, everything in shading is about how to select and combine colors to get.
Chris Kerkhoff Matthew Sullivan 10/16/2009.  Shaders are simple programs that describe the traits of either a vertex or a pixel.  Shaders replace a.
09/09/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Event management Lag Group assignment has happened, like it or not.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
3D Graphics for Game Programming Chapter IV Fragment Processing and Output Merging.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
CSE 381 – Advanced Game Programming GLSL Lighting.
Game Programming 06 The Rendering Engine
Programmable Pipelines Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts Director, Arts Technology Center University.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Game Programming 07 OGRE3D Mesh in Action 2010 년 2 학기 디지털콘텐츠전공.
Computer Graphics Blending CO2409 Computer Graphics Week 14.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
ES305 Virtual Tools in Engineering Design Objects & Scripts Prof. Searleman
UV Mapping After a 3D object has been modeled it must be prepared for texturing. 3D surfaces can be “unwrapped” into a 2D representation with. This process.
Graphics Graphics Korea University cgvr.korea.ac.kr Lighting, Fogging, Alpha Blending & Progressive Meshes Byeong-Seon Jeong
Single Pass Point Rendering and Transparent Shading Paper by Yanci Zhang and Renato Pajarola Presentation by Harmen de Weerd and Hedde Bosman.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
Maths & Technologies for Games Graphics Optimisation - Batching CO3303 Week 5.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Chapter 5. Lighting Computer Graphics (spring, 2009) School of Computer Science University of Seoul.
- Introduction - Graphics Pipeline
Week 7 - Monday CS361.
Photorealistic Rendering vs. Interactive 3D Graphics
Programmable Pipelines
Graphics Processing Unit
3D Graphics Rendering PPT By Ricardo Veguilla.
The Graphics Rendering Pipeline
CSE 381 – Advanced Game Programming Terrain
UMBC Graphics for Games
ICG 2018 Fall Homework1 Guidance
Computer Graphics Introduction to Shaders
Texture Mapping 고려대학교 컴퓨터 그래픽스 연구실.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Adding Surface Detail 고려대학교 컴퓨터 그래픽스 연구실.
Presentation transcript:

Game Programming 08 OGRE3D Material in Action 2010 년 2 학기 디지털콘텐츠전공

Rendering in Video Games Depth-Buffered Triangle Rasterization –Virtual Scene –Virtual Camera –Various Light Sources –Visual Properties  Solving the Rendering Equation (Shading Equation)

Rendering in OGRE3D Depth-Buffered Triangle Rasterization –Virtual Scene  createScene() –Virtual Camera  createCamera()/ createViewport() –Various Light Sources  createScene() –Visual Properties  material  Solving the Rendering Equation (OGRE3D engine)

Materials in general The Material controls how objects look in the scene –Basic surface properties such as: reflectance, diffuse color, shininess, etc. –How to use textures What images to be used How many and how to blend them –Special effects such as: Environmental mapping Culling mode filtering

Materials in OGRE SceneManager class manages the list of materials available to the scene To ways of loading a material –Creating and tweaking it by a code MaterialManager –Using a script to be loaded at runtime Material Script

OGRE Material Script: –File name: ‘’*.material ’’ –A text file which describe a material –Easy to define a complex material –Reuse easily for different games How to load –OGRE looks for *.material files in all resource locations. –Call ‘load’ method in order to complete the loading process otherwise, the materials are not available.

Material Script: Format // This is a comment material walls/funkywall1 { // first, preferred technique technique { // first pass pass { ambient diffuse // Texture unit 0 texture_unit { texture wibbly.jpg scroll_anim wave_xform scale sine } // Texture unit 1 (this is a multitexture pass) texture_unit { texture wobbly.png rotate_anim 0.25 colour_op add } // This is a comment material walls/funkywall1 { // first, preferred technique technique { // first pass pass { ambient diffuse // Texture unit 0 texture_unit { texture wibbly.jpg scroll_anim wave_xform scale sine } // Texture unit 1 (this is a multitexture pass) texture_unit { texture wobbly.png rotate_anim 0.25 colour_op add }

Material Script: Name Material name –Should be unique –‘/’ is used for grouping conceptually –‘:’ can be used after the name for inherit from other existing material // This is a comment material walls/funkywall1 { …… } // This is a comment material walls/funkywall1 { …… }

Material Script: Technique Technique –Define how the material looks –Can have multiple techniques used as a fallback or in a different LOD level. –Each Technique is made up of multiple passes // This is a comment material walls/funkywall1 { // first, preferred technique technique { ……… } // second, preferred technique technique { ……… } // This is a comment material walls/funkywall1 { // first, preferred technique technique { ……… } // second, preferred technique technique { ……… }

Material Script: Pass Single Pass –One single rendering with a given setup –A pass has global attributes such as ambient, diffuse, etc. –A pass can have a texture unit or multiple texture units Multiple Passes (1~16 passes) –Rendering can be done multiple times with different setup –The final rendering result will be obtained by compositing every results from the passes. material walls/funkywall1 { technique { // first pass pass { …… } material walls/funkywall1 { technique { // first pass pass { …… }

Material Script: Pass Global attributes –Ambient color Format: ambient ( [ ]| vertexcolour) Example: ambient Default: ambient –Diffuse color Format: diffuse ( [ ]| vertexcolour) Example: diffuse Default: diffuse –Specular color Format: specular ( [ ]| vertexcolour) Example: specular Shininess: any value between 0~128 (the bigger, the sharper) Default: specular

Material Script: Pass Global attributes –scene_blend How to blend the pass with the existing scene content Flexible version: –Format: scene_blend –Meaning: (pass_result * sourceFactor) + (scene_pixel * destFactor) –Factors: one | zero | src_color | one_minus_src_colour | dest_colour | one_minus_dest_colour | dest_alpha | one_minus_dest_alpha | src_alpha | one_minus_src_alpha –Example: scene_blend one one_minus_dest_alpha Simpler version –Format2: scene_blend –Meaning: »add: 'scene_blend one one‘ (explosions, flares, lights, ghosts) »modulate: 'scene_blend dest_colour zero‘ (darkening, smoked glass) »colour_blend: 'scene_blend src_colour one_minus_src_colour' »alpha_blend: 'scene_blend src_alpha one_minus_src_alpha‘ –Example: scene_blend add –scene_blend_op Specify the operation in scene blending Format: scene_blend_op Meaning: (pass_result * sourceFactor) +(-) (scene_pixel * destFactor) Default: scene_blend_op add

Material Script: Pass Global attributes –Lighting on/off Format: lighting If off, all objects will be fully lit. Default: lighting on –Shading Format: shading Default: shading gouraud –Polygon mode Format: polygon_mode Default: polygon_mode solid

Material Script: Pass Global attributes –Depth check Format: depth_check Default: depth_check on –Depth write Format: depth_write Default: depth_write on –Depth function Determine how to check the depth Format: depth_func –always_fail : Never writes a pixel to the render target –always_pass : Always writes a pixel to the render target –less : Write if (new_Z < existing_Z) –less_equal : Write if (new_Z <= existing_Z) –equal : Write if (new_Z == existing_Z) –not_equal : Write if (new_Z != existing_Z) –greater_equal : Write if (new_Z >= existing_Z) –greater :Write if (new_Z >existing_Z) Default: depth_func less_equal

Material Script: texture_unit Texture –Set name of the texture image Format: texture [ ] [unlimited | numMipMaps] [alpha] [ ] [gamma] Example: texture funkywall.jpg Animated texture –Set the images to be used in animated texture Format1 (short): anim_texture Example: anim_texture flame.jpg Meaning: load 3 frames (frame_0.jpg, frame_1.jpg, frame_2.jpg) for 1.5 sec. Format2 (long): anim_texture... Example: anim_texture flamestart.jpg flamemore.png flameagain.jpg 1.5

Material Script: texture_unit Texture coordinate set –Sets which texture coordinate set is to be used Format: tex_coord_set Example: tex_coord_set 2 Texture address mode –Defines what happens when uv values exceed 1.0 Simple Format: tex_address_mode Extended Format: tex_address_mode Mode: Texture border color –Set the border color when thexture address mode is border Format: tex_border_colour [ ] Example: tex_border_colour

Material Script: texture_unit Color operation –Determines how the color of this texture layer is combined with the one below it –Format: colour_op –Operation types: replace : Replace all color with texture with no adjustment add : Add color components together. modulate : Multiply colour components together alpha_blend : Blend based on texture alpha –Default: colour_op modulate

Material Script: texture_unit Texture Transformation –Scroll Sets a fixed scroll offset for the texture. Format: scroll –Scrolling animation Sets up an animated scroll for the texture layer Format: scroll_anim –Rotate Format: rotate –Rotating animation Format: rotate_anim –Scale Format: scale

Material Script: texture_unit Advanced Texture Transformation –Animation using wave function Format: wave_xform Example: wave_xform scale_x sine xform_types: –scroll_x : Animate the x scroll value –scroll_y : Animate the y scroll value –rotate : Animate the rotate value –scale_x : Animate the x scale value –scale_y : Animate the y scale value wave_types: –sine »A typical sine wave which smoothly loops between min and max values –triangle »An angled wave which increases & decreases at constant speed, changing instantly at the extremes –square »Max for half the wavelength, min for the rest with instant transition between –sawtooth »Gradual steady increase from min to max over the period with an instant return to min at the end. –inverse_sawtooth »Gradual steady decrease from max to min over the period, with an instant return to max at the end. Base: The base value, the minimum if amplitude > 0, the maximum if amplitude < 0

Material Script: other functions There are other advanced shader-based functions in Material script –Vertex/geometry/fragment programs –CG programs –HLSL programs –GLSL programs

Reference for the materials

Manual Creation Using MaterialManager Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create ( "Test/ColourTest", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME ); material->getTechnique(0)->getPass(0)->setDiffuse(Ogre::ColourValue(1.0,0.0,0.0)); Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create ( "Test/ColourTest", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME ); material->getTechnique(0)->getPass(0)->setDiffuse(Ogre::ColourValue(1.0,0.0,0.0));

Material basic attributes ambient reflectance = ColourValue::White (full) diffuse reflectance = ColourValue::White (full) specular reflectance = ColourValue::Black (none) emmissive = ColourValue::Black (none) shininess = 0 (not shiny) No texture layers (& hence no textures) SourceBlendFactor = SBF_ONE, DestBlendFactor = SBF_ZERO (opaque) Depth buffer checking = on Depth buffer writing = on Depth buffer comparison function = CMPF_LESS_EQUAL Culling mode = CULL_CLOCKWISE Ambient lighting in scene = ColourValue(0.5, 0.5, 0.5) (mid-grey) Dynamic lighting = enabled Gourad shading mode Solid polygon mode Bilinear texture filtering