`
sjkgxf7191
  • 浏览: 257824 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Away3D(九):Lighting & shading

阅读更多

Away3D中的光照可以分为三个基本要素:

  • the light source(s) defining the properties of the light(s)
  • light source(s) 定义了光照的属性
  • shaders providing algorithms that determine how a light source interacts with a material
  • shaders 提供一些决定光源如何同材质交互的算法
  • a material type combining different shaders along with base colours or bitmaps
  • 一种组合 了不同 shaders 和 colors 或者 bitmaps 的 material type

 

第一个同PV3D不同之处是我们可以指定超过一个光源 。这样会加大CPU的负担,但同时也可以制造出更加真实的场景渲染。

 

三种主要的 light sources:

  • AmbientLight3D which has no position and provides a uniform ambient light to all objects
  • AmbientLight3D 环境光源 )没有空间坐标,他为所有的 object 提供了一种统一的环境光照
  • DirectionalLight3D which provides light from a specified position but with a strength that does not diminish with distance
  • DirectionalLight3D 定向光源 ),有一个空间坐标,有一个不会减弱的光照强度
  • PointLight3D providing light from a specified position that weakens in intensity with distance
  • PointLight3D 点光源 ),有一个空间坐标,光照强度会随着距离的增加而减弱

以下几种 shaders:

  • AmbientShader which provides ambient shading to a triangle face
  • AmbientShader 为一个三角面提供环境阴影
  • DiffusePhongShader which, depending on the angle between the light source and a triangle face, produces a diffuse shading pattern
  • DiffusePhongShader 根据光源和三角面之间所成的角度,产生一个散射阴影
  • SpecularPhongShader which produces specular shading on triangles to imitate a surface that is reflecting light, depending on the observer’s position and the light position
  • SpecularPhongShader 根据观察者和光源的位置,为三角面产生一个模拟的反射光源的效果
  • EnviroShader allowing for environment mapping, producing a reflection from a surrounding environment on an object, independent of a light source. Requires bitmap data for the environment
  • EnviroShader 根据光源位置和环境贴图,给 object 添加一个环境贴图反射的映射
  • DiffuseDot3Shader to increase scene reality by adding more small scale structure through the use of normal mapping to an object. Requires bitmap data for the normal map
  • DiffuseDot3Shader 通过增加更多的 structure 来增加场景的真实感

以上shaders,除了 EnviroShader ,其余的 light source 都是DirectionalLight3D

 

我们可以选择使用CompositeMaterials ,这种材质包含了一些不同的 shaders 和基于这些 shaders 的materials。

 

material列表如下:

PhongBitmapMaterial used to create ambient, diffuse and specular lighting on a texture-mapped material

Base material : BitmapMaterial

Shaders : AmbientShader , DiffusePhongShader and SpecularPhongShader

 

PhongMovieMaterial used to create ambient, diffuse and specular lighting on a material based on another Flash movie

Base material : MovieMaterial

Shaders : AmbientShader , DiffusePhongShader and SpecularPhongShader

 

PhongColorMaterial used to create ambient, diffuse and specular lighting on a simple coloured material

Base material : ColorMaterial

Shaders : AmbientShader , DiffusePhongShader and SpecularPhongShader

 

EnviroBitmapMaterial used to create environmental lighting on a texture-mapped material

Base material : BitmapMaterial

Shaders : EnviroShader

 

Dot3BitmapMaterial used to create ambient and normal-mapped lighting on a texture-mapped material

Base material : BitmapMaterial

Shaders : AmbientShader and DiffuseDot3Shader ,

 

Dot3MovieMaterial used to create ambient and normal-mapped lighting on a material based on another Flash movie

Base material : MovieMaterial

Shaders : AmbientShader and DiffuseDot3Shader

 

以上这些 materials 都是很耗性能的 ,如果你想使用简单点的 shade ,你可以选择CenterLightingMaterial  这种材质的效果就相同于PV3D里的 flat-shaded materials ,Away3D里有两种选择

  • ShadingColorMaterial for simple flat shading of a ColorMaterial
  • WhiteShadingBitmapMaterial for simple flat shading of a BitmapMaterial , but assuming that the light source is always white (independent of colour given to light source).

 

  // create a new directional white light source with specific ambient, diffuse and specular parameters
  var light:DirectionalLight3D = new DirectionalLight3D({color:0xFFFFFF, ambient:0.25, diffuse:0.75, specular:0.9});
  light.x = 100;
  light.z = 500;
  light.y = 500;
  scene.addChild(light);

  // Create an object container to group the objects on the scene
  group = new ObjectContainer3D();
  scene.addChild(group);
   
  // Create a new sphere object using a very shiny phong-shaded bitmap material representing the earth
  var earthMaterial:PhongBitmapMaterial = new PhongBitmapMaterial(Cast.bitmap(earthBitmap));
  earthMaterial.shininess = 100;
  sphere = new Sphere({material:earthMaterial, radius:50, segmentsW:10, segmentsH:10});
  sphere.x = ORBITAL_RADIUS;
  sphere.ownCanvas = true;
  group.addChild(sphere);

  // Create a new cube object using a tiled, phong-shaded bitmap material
  var tiledAway3DMaterial:PhongBitmapMaterial = new PhongBitmapMaterial(Cast.bitmap(away3DBitmap), {repeat:true, scaleX:.5, scaleY:.5});
  cube = new Cube({material:tiledAway3DMaterial, width:75, height:75, depth:75});
  cube.z = -ORBITAL_RADIUS;
  cube.ownCanvas = true;
  group.addChild(cube);
 
  // Create a cylinder mapping the earth data again
  cylinder = new Cylinder({material:earthMaterial, radius:25, height:100, segmentsW:16});
  cylinder.x = -ORBITAL_RADIUS;
  cylinder.ownCanvas = true;
  group.addChild(cylinder);
 
  // Create a torus object and use a checkered, flat-shaded (from white light) bitmap material
  var checkerBitmapMaterial:WhiteShadingBitmapMaterial = new WhiteShadingBitmapMaterial(Cast.bitmap(checkerBitmap));
  torus = new Torus({material:checkerBitmapMaterial, radius:40, tube:10, segmentsT:8, segmentsR:16});
  torus.z = ORBITAL_RADIUS;
  torus.ownCanvas = true;
  group.addChild(torus);
 
  // Create a new cube object using a smoothed, precise, phong-shaded, mat (not shiny) bitmap material
  var away3DMaterial:PhongBitmapMaterial = new PhongBitmapMaterial(Cast.bitmap(away3DBitmap), {smooth:true, precision:2});
  away3DMaterial.shininess = 0;
  centerCube = new Cube({material:away3DMaterial, width:75, height:75, depth:75});
  centerCube.ownCanvas = true;
  group.addChild(centerCube);

  // add mouse listeners to all the 3D objects
  sphere.addOnMouseDown(onMouseDownOnObject);
  cube.addOnMouseDown(onMouseDownOnObject);
  cylinder.addOnMouseDown(onMouseDownOnObject);
  torus.addOnMouseDown(onMouseDownOnObject);
  centerCube.addOnMouseDown(onMouseDownOnObject);

 

sphere.ownCanvas = true;

这句话很重要,没有这句话,当 objects 被别的 objects 遮挡了 ,他们可能不会被正确渲染

 

 

 

0
0
分享到:
评论

相关推荐

    The Graphics Pipeline and OpenGL II: Lighting and Shading, Fragment Processing

    图形管线与OpenGL II:光照与着色,片段处理 图形管线是计算机图形学中渲染图像的关键步骤,它将三维场景转换成二维图像。在图形管线的多个阶段中,光照与着色是实现图像真实感最重要的环节之一。...

    Lighting.Shading.pdf

    2. **Phong Shading**:不仅在顶点处计算颜色,还会在多边形内部的每个像素点上计算光照,这种方法可以产生更细腻的高光效果。 3. **纹理映射**:使用预先定义的图像来模拟物体表面的细节,增加图像的真实感。 ####...

    away3D 4.6.0 src

    3. **材质和着色器系统**:Away3D 4.6.0可能改进了材质和自定义着色器的处理方式,使开发者能创建更多样化的3D物体表面效果。源码中会包含关于如何编写和应用GLSL(OpenGL Shading Language)着色器的示例。 4. **...

    pbrt-skin-bssrdf:Donner & Jensen 的“A Spectral BSSRDF for Shading Human Skin”在 PBRT 中的实现

    它提供了详细的理论与实践相结合的光线交互模型,为创建逼真的3D图像提供了解决方案。在PBRT中,Donner & Jensen的“一种用于人皮肤着色的频谱BSSRDF”是一种关键的技术,用于模拟人类皮肤的复杂光学特性。本文将...

    Flat Kit Toon Shading and Water 2.1.3.unitypackage

    Flat Kit Toon Shading and Water 2.1.3 最新版本

    让不懂编程的人爱上Unity3d游戏开发017-你人生的第一款游戏08-获取更多Unity学习资源1

    Unity Certified 3D Artist认证适合对美术设计感兴趣的人员,Unity Certified Programmer则针对编程人员,Unity Certified Expert分为Gameplay Programmer、Technical Artist: Rigging & Animation以及Technical ...

    Unity3D教程:着色器1

    Unity3D 是一款广泛应用于游戏开发、虚拟现实和增强现实领域的3D引擎,它提供了丰富的功能,其中着色器(Shader)是实现复杂视觉效果的关键工具。本教程将介绍Unity3D中的着色器基础,重点讲解散射、凹凸和高光等...

    OpenGL-4-Shading-Language-Cookbook-Third-Edition:OpenGL 4 Shading Language Cookbook-第三版,由Packt发行

    示例代码 大卫·沃尔夫(David Wolff)出版并由Packt Publishing发行的的示例代码。 要求 要编译这些示例,您将需要以下内容: 0.9.6或更高版本。 请注意,0.9.6之前的版本可能无法正常使用,因为从度数转换为弧度...

    flat_shading.cpp

    图形学实验:flat shading C++源码(用opengl实现) 给定物体的动态序列(见附件),请利用局部光照模型将其渲染。要求: (1)给场景增加一个平坦的地面模型,增加纹理到地面上更好; (2)在适当位置设置两个光源; ...

    celshading_cel_C++_SHADER_

    Cel Shading,又称为卡通渲染或细胞着色,是一种在3D图形中模拟2D卡通风格的技术。它通过减少光照和阴影的连续性,使物体表面呈现出明显的边缘轮廓和单一的区域颜色,从而创造出类似漫画或动画的视觉效果。在游戏...

    Deferred Shading延迟光照

    延迟光照(Deferred Shading)是一种在3D图形渲染中广泛使用的高级光照技术,它与传统的立即模式光照(Forward Shading)方法有所不同。延迟光照的主要目标是优化处理大量光源时的性能,尤其在复杂的场景中,当物体...

    Shawn的Deferred Shading ppt 翻译

    延迟着色(Deferred Shading)是一种在3D图形渲染领域广泛应用的技术,特别是在现代游戏和高级图形应用程序中。这种技术由Shawn Hargreaves等人提出并广泛推广,它改变了传统即时着色(Forward Shading)的方式,...

    shape from shading matlb实现

    "Shape from Shading"(SFS)是一种计算机视觉技术,用于通过分析图像的像素颜色变化来重建三维物体的形状。在MATLAB环境中实现这一技术,我们可以利用其强大的图像处理和数学计算功能。以下是对"shape from shading...

    OpenGL.Shading.Language.rar_3D shading_OpenGL 3d_opengl API_open

    OpenGL is the leading cross-platform 3D-graphics API, and the OpenGL Shading Language allows developers to take total control over the most important stages of the graphics-processing pipeline.

    暗电流和lenshading

    在IT行业中,尤其是在计算机视觉和图像处理领域,暗电流(Dark Current)和镜头遮光(Lens Shading),是两个非常重要的概念。它们直接影响到相机模组的成像质量和图像处理的效果。OpenCV是一个广泛使用的开源计算机...

    Adaptive lens shading correction.pdf

    apple公司的lens shading专利,用于iphone手机上使用。

    基于ECharts GL的3D图表展示设计与实现

    xAxis3D: {type: 'category', data: ['Category 1', 'Category 2', ...]}, yAxis3D: {type: 'value'}, zAxis3D: {type: 'value'}, series: [{ type: 'bar3D', data: [[1, 2, 3], [2, 3, 4], ...], shading: '...

    OpenGL Shading Language (3rd Edition)

    OpenGL® Shading Language is the experienced application programmer's guide to writing shaders. Part reference, part tutorial, this book thoroughly explains the shift from fixed-functionality graphics...

    3D数学基础:图形与游戏开发

    8. **光照和着色(Lighting and Shading)**:3D物体的外观受光照影响,包括光源类型(点光源、平行光等)、光照模型(Lambert、Phong等)以及阴影的计算。着色模型则决定了颜色如何随角度变化。 9. **纹理贴图...

Global site tag (gtag.js) - Google Analytics