Decal的另类用法

article/2025/8/28 23:22:47

Decal在没有办法得到深度之前都是根据地形的高度自己生成三角形来生成的,有了深度之后一切变的很简单,只需要画一个box就可以解决,类似于点光源。

    以前做过的一个项目最后就是把地形的一个sector分成几个decal来画,虽然DP增加了,但是最后GPU反而省了,原因是原始的材质是将5个ue的材质合并blend到一起,texture和ALU实在太多,导致GPR占用非常严重,最后能并行的GPU线程少的可怜,而改为decal画之后,每个ps的texture和ALU大幅下降,GPR也很少,同时并行的GPU线程就很多。这可以理解为原来的做法类似于大卡车严重超载,走的很慢,一小时才走了20公里,而优化的做法可以理解为只拉了一点点货,用了40分钟就跑了5个来回。

    Decal在游戏里用的也很多,但是大多用法都是用在特效上,其实直接将decal刷到mesh或者地形上可以很大程度的提高场景的丰富程度。这样做的好处有2个:

    1.和不同的decal结合可以组合出新的外观表现的模型,比方一个石头上可以投一段文字来模拟石头上刻字的效果,也可以给房子上投一点苔藓来提高房子的表现。。。

    2.有时候在地形上放一大块石头,石头本身和地形的贴图差别太大显得很突兀,这时候就可以通过头一个decal到石头和地形的接缝来完美解决这个问题并且能提高石头的丰富程度。下面的转载内容正好描述了这个详细过程。

    

Why are decals important?

The decal is one of my favorite 3D graphics tools. It serves so many purposes: covering seams, spicing up tiling textures, adding unique details, and allowing dynamic cosmetic environmental changes. Here is a naked 'land chunk' model, with no decals:

Here is the same model again after adding a rock decal and a moss decal:

As you can see, the surface is now more interesting and detailed, and the transition between the ground and the 'land chunk' is less abrupt and unrealistic.

How do decals work?

We've already discussed the user interface for adding decals in parts one andtwo, so now I will talk about how the shading works. We start by placing a couple decals using the decal editor.

As each decal is placed, it creates a small 'base normal' map (the 'normal' of a surface is a vector perpendicular to it) and blurs it slightly to remove any seams. Here is what the base normal map looks like for these decals. The red, green, and blue channels represent the X, Y and Z axes respectively, so the surfaces pointing up (+Y) are green, surfaces facing 'right' (+X) are red, and surfaces facing 'in' (+Z) are blue.

The decals use the alpha channel of their color map to control their transparency. Here is the base normal map color combined with the decal map alpha, so we can see how much of the base mesh shows through.

The base normal map is then combined with the decal normal map to get the final surface normals. This is used to make the lighting respond to the surface details of the decals, such as the roughness of the moss and the smooth roundness of the rocks.

Here is what the direct diffuse lighting looks like on the final normal map. This is easy to calculate because we are using world-space normals -- we just have to calculate the dot product of the light vector and the normal vector in the fragment shader. We don't have to worry at all about tangents and bitangents.

Finally, we modulate the decals by their color channels, and add ambient lighting. The decals blend into the scene very well because they are using the same lighting model as everything else.

In Lugaru I used decals for all sorts of effects, including footprints, wall cracks, blood puddles, and shadows. Can you think of anything special we can use decals for in Overgrowth?


http://chatgpt.dhexx.cn/article/1FpdlLR7.shtml

相关文章

Oracle中declare如何使用

Oracle中declare如何使用 首先我们需要了解declare遵循下面的实现结构 declare --声明 begin --开始 end; --结束 了解之后,我们就可以在这个结构中添加语句实现小功能 例如:输出今天的日期 declare --声明 datevalue varchar2(20);--定义变量 begin --…

DCC - Photoshop - Nvidia NormalMapFilter - 法线生成工具 - 顺便测试 Unity URP 12.1 中的 Decal System

文章目录 NVIDIA Texture Tools Exporter 下载、安装法线生成素材图扣干净无用像素使用 NVIDIA Normal Map Filter 生成贴图配置好 URP Renderer添加好 Decal Render Feature设置好 Decal Render Feature Techniqu: DBuffer配置好 unity shader graph添加 URP Decal Projector …

图形杂记-Decal贴花

ThreeJS WEBGL Decal 贴花 在图形学里主要指将特定图案,以类似粘贴或印刷的方式附着于其他物体上,能创造一种新颖的体验或逼真的效果,比较有趣,游戏中比较出名的有喷射战士splatoon123等。 unity HDRP中默认支持decal&#xff0c…

SQL中的declare用法

 平时写SQL查询、存储过程都是凭着感觉来,没有探究过SQL的具体语法,一直都是按c#那一套往SQL上模仿,前几天项目中碰到一个问题引起了我对declare定义变量的作用域的兴趣。 大家都知道c#中的局部变量,在i…

UE4使用贴花(Decal)

一、创建贴花材质 1:新建一个Material材质,修改Material Domain 为Deferred Decal (延迟贴花),设置Blend Mode 为Translucent(半透明) 2:新建节点 3:给节点赋予材质,根据要求链接透明度和粗糙度 二、使用使用贴花 …

Deferred Decal(延迟贴花)

Decal渲染是一个引擎中重要的一部分,记忆中印象最深刻的就是以前CS中的弹痕与爆炸痕迹了。目前来说,Decal的实现方法也比较多,而且感觉还跟游戏类型有关,比如子弹乱飞的射击类FPS游戏中对贴花系统的要求就比较高,因为本…

【游戏开发小技】Unity中实现Dota里的角色技能地面贴花效果(URP | ShaderGraph | Decal)

本文最终效果 文章目录 一、前言二、环境准备1、URP环境准备2、技能范围图案 二、方案一:写Shader实现1、Shader脚本:UrpDecal.shader2、材质球3、创建Cube4、地面场景5、添加Renderer Feature: Decal6、移动DecalCube,与地面交叉7、运行效果…

UE5实现贴地面效果(RT+Decal)

文章目录 1.实现目标2.实现过程2.1 实现原理2.1.1 Render Target2.1.2 Polygon2.2 具体过程3.参考资料1.实现目标 在之前的文章中基于CesiumForUnreal实现了对地形3DTileset的贴地面绘制效果,在这里基于UE自带的RT和Decal实现更加通用的贴地面效果。依旧是加载在线的Cesium W…

Unity Shader-Decal贴花(SelfDecal,Alpha Blend,Mesh Decal,Projector,Deferred Decal)

前言 最近通关了《What Remains of Edith Finch》(艾迪芬奇的记忆),总体来说应该算是一个剧情解密向的游戏,故事表现手法十分出色。 游戏主要是叙述一个神秘的家族遭遇了一系列类似《死神来了》的故事,家族的人离奇死…

Unity Decal 贴花效果测试

贴花效果,就和名字的直接意思类似,把一张图贴到另一个物体上显示,经常被用于表现一些重复出现的图案,比如弹孔,涂鸦,污渍等。效果图: 常规贴花实现 Unity官方提供了一个工程,这个…

UE4 Decal 贴花不在静态光照下绘制

Decal顶点没有烘焙的光照数据,因此无法在含前向管线的阴影下绘制。特效贴花为unlit自发光材质,阴影下表现影响不大。而场景Decal需要计算光照。 1. Decal实现原理 MobileDecalRendering.cpp 通过矩阵变换 得到FrustumComponentToClip,传入…

游戏中的Decal(贴花)

在游戏中,decal是一种非常常见的效果,常用来实现弹孔,血迹,涂鸦等效果。最近研究了下Decal在游戏引擎中的实现方式,大致总结了一下:1.基于面片实现:直接用一个Quat的mesh,加上一张贴图&#xff…

UE4 Decal实现简介

Decal 是游戏中常见的一个东西,经常被用在 显示弹痕,地面叠加花纹等。 Decal 绘制流程 Decal可以认为是,将一个面的画面沿Decal的Box的X轴方向投影到物体表面。 Decal的绘制实际只有一个Box绘制。 RHICmdList.DrawIndexedPrimitive(GetUn…

跳出for循环

跳出for循环有三种方式&#xff1a; 1&#xff1a;continue&#xff1b;跳出当次循环&#xff0c;可继续进行下一个循环&#xff1b; function ceshi(){for(var i 0 ; i < 6 ; i){if(i 3){continue;}console.log(,i);} }ceshi(); 效果图&#xff1a; 2&#xff1a;brea…

跳出forEach循环

我们平时用到的循环有很多种。for, map, while, forEach, for...of, for...in等等&#xff0c;每种循环都有在某一次循环语句中跳出本次循环的方法&#xff0c;但是除了forEach。 有小伙伴说不用不就好了。其实这些循环里边&#xff0c;当属for的效率最高&#xff0c;for...in最…

Java 8 跳出foreach循环,跳出本次循环,继续执行,之前的for each循环如何跳出本次循环,跳出循环,跳出多层for循环。

在Java8之前&#xff0c;最开始使用for i 循环&#xff0c;很老旧&#xff0c; 后来有了高级的for each 循环&#xff0c;然后这个跳出本次循环和跳出所有的for循环&#xff0c;都简单&#xff0c;稍微没见过的就是跳出多层for循环。 然后就是Java8出的foreach循环&#xff0…

js中的for循环如何跳出,js中for循环的两种语法

js几种for循环的几种用法 谷歌人工智能写作项目&#xff1a;小发猫 js&#xff0c;for循环是怎么运行的&#xff1f; typescript有哪些变化。 最普遍的介绍&#xff1a;for循环是JavaScript中最常用的循环&#xff0c;标准for循环代码格式为&#xff1a;for(定义变量初始值;…

if/while/do-while/for循环以及跳出循环break/return/continue

流程控制对任何一门编程语言都是至关重要的&#xff0c;它为我们提供了控制程序步骤的基本手段。常见对主要分为&#xff0c;条件语句、循环语句、跳转语句。 1、if语句 if 语句是一种判断语句。 语法&#xff1a; if(条件){条件成立时执行的代码 } if...else 语句当条件成…

Python中跳出循环的两种方法

我们经常遇到循环在进行到某一个特定的值时&#xff0c;需要跳出循环&#xff0c;或跳过这个值&#xff0c;python中早已为我们准备了这样的参数:break,continue 比如下面的for循环&#xff1a; for i in range(1,10):print(循环了,i,次) 结果显而易见如图&#xff1a; 当我…

js foreach与for循环之return跳出循环

因为自己比较大只&#xff0c;容易忘记&#xff0c;仅此用来记录一下~ 各种循环中使用return或者退出循环的机制。 1、forEach 使用 return 可以退出循环吗&#xff1f;下面代码打印啥&#xff1f; const list [1, 2, 3, 4, 5]list.forEach(e > {if (e 3) {return}consol…