CityEngine制作玻璃材质反光效果

来源:互联网 发布:淘宝固定背景代码 编辑:程序博客网 时间:2024/04/29 14:15
 

当我们走在城市的大街上,经常会看到很多栋写字楼,其外墙大多都是玻璃材质的,使得建筑更有质感。在本文中,我们利用CityEngine实现玻璃材质反光效果。首先,需要确定做什么样的效果?一是玻璃效果(即透明),二是反光。

CityEngine中提供了“Material”设置,即材质。其属性包括如下,本文用到了红框内的属性。

编写规则如下:

version"2012.1"

#属性参数定义

attrFloor=10

attrFloor_Height=3

attrGroundfloor_Height=4

attrHighBuilding_Color="#6892d7"

#变量定义

Building_Height=Floor*Floor_Height

constTile_Width=1.8

constFloorTop_Hight=0.1

constFrame_Width=0.08

@StartRule

#生成建筑结构

Lot-->

   extrude(Building_Height)

   HighBuilding

   

#切分出第一层和上面楼层

HighBuilding-->

   split(y){Groundfloor_Height:FloorVolume|{~Floor_Height:FloorVolume}*}    

#拆分出每个楼层的地面和侧面

FloorVolume-->

   comp(f) {top :offset(-0.1,inside)FloorTop|side:FloorSides}

#楼层地面填充颜色

FloorTop --> color(0.5,0.5,0.5)

#侧面生成玻璃窗户

FloorSides -->

   split(x) {~Tile_Width : FloorTile }*

FloorTile -->

   offset(-Frame_Width/2)

   comp(f) {border :color(0.2,0.2,0.2)Frame. |inside :Glass}

   

#制作玻璃反光效果

Glass -->

   color(HighBuilding_Color)

   set(material.opacity, 0.4)

   #镜面反射

   set(material.specular.r,0.6)

   set(material.specular.g,0.6)

   set(material.specular.b,0.6)      

   set(material.shininess,50)

   #反射率

   set(material.reflectivity, 0.2)

生成效果图:

练习数据:下载

更多关于材质的属性设置,可以在CityEngine帮助中搜索“material”关键字来查看。

原创粉丝点击