shader

maximum number (256) of shader keywords exceeded unity的报错解决方法

孤街醉人 提交于 2020-02-08 17:32:05
https://bitbucket.org/ArtIsDarkGames/shader-keywords-tool-unity3d/src/master/ https://eternity429.wordpress.com/2017/12/06/unity-shader-variant-system%E6%BD%9B%E8%97%8F%E9%9A%B1%E6%86%82/ 其中, multi_compile 及 shader_feature 都是定義keyword的功能,但其Build情況有所不同。 shader_feature 會根據專案內是否有同時使用到此keyword啟動、非啟動的狀態生成對應Variant,適合無須在Runtime中變動、僅需要在Editor中設定好的功能。 multi_compile 則會無論有無實際啟動keyword與否都會生成Variant。 如果你的keyword功能會在Runtime中動態切換,那麼需使用此項。 ------------------------------------------------------------------------------------------------------------------------- 一般大多數情況都是使用 shader_feature 足矣

【译】Unity3D Shader 新手教程(5/6) —— Bumped Diffuse Shader

浪子不回头ぞ 提交于 2020-02-08 09:38:50
本文为翻译,附上 原文链接 。 转载请注明出处—— polobymulberry-博客园 。 动机 如果你满足以下条件,我建议你阅读这篇教程: 你想学习片段着色器(Fragment Shader)。 你想实现复杂的多通道着色器(multipass),但是对其不是很了解。 你想使用上面提到的两种技术(片段着色器和多Pass)来实现描边效果的Toon shader,你就需要理解这两种技术的概念。 学习资源 Martin Kraus's fantastic Wiki Book GLSL Programming/Unity 引论 在教程的第4部分,我们创建了一个相当好的toon shader,该shader使用了边缘光照(rim lighting)对模型进行描边 — 但是这种方法的问题在于它只能使用在表面光滑的模型上。对于那些平整的,有棱角的表面,我们计算其边缘的法向量时,会发现两个面的边界法向会产生突变(比如正方形的六个面,单个面上的法向都一致,但是两个面之间的法向会发生突变,不像球面上的法向是渐变的),这将产生我们不想要的边界效果。 有一个更好的办法对模型进行描边效果处理 — 先将模型背面稍微扩大一些(边缘延伸一些)然后渲染为全黑,最后正常渲染模型正面即可,这样我们看到的黑色边缘其实是背面呈现的颜色。这就要求在shader中使用两个Pass — 你可能还记得

Vulkan SDK 之 Shaders

北战南征 提交于 2020-02-07 10:28:07
Compiling GLSL Shaders into SPIR-V 1、SPIR-V 是vulkan的底层shader语言。GLSL可以通过相关接口转换为SPIR-V。 Creating Vulkan Shader Modules 来源: https://www.cnblogs.com/khacker/p/12271897.html

shader入门精要读书笔记10 其他相关内容(注意事项等)

心已入冬 提交于 2020-02-07 02:23:45
一、Debug 最讨厌康熙的第8个儿子。 三种Untiy Shader的调试方法: 1.使用假彩色图像 假彩色图像是指用假彩色技术生成的一种图像(照片为真彩色图像),一张假彩色图像可以用来可视化一些数据。 主要思想就是把需要调试的变量映射到[0,1]之间,输出到屏幕上,通过屏幕上的像素颜色判断值是否正确。 可见112页详细介绍。 2.使用 Visual Studio vs中提供了对Unity Shader的调试功能----Graphics Debugger。 通过Graphics Debugger,我们不仅可以查看像素颜色、位置信息,还可以对顶点着色器和片元着色器进行单步调试。 3.帧调试器 Unity官方针对渲染的调试器。 位置:Window–>Frame Debugger 具体介绍可见114页。 二、渲染平台差异 1.坐标差异 OpenGL 与 DirectX 水平相同,竖直方向上相反。 屏幕空间坐标 DX(0,0) 在左上角,OpenGL在左下角。 大多数情况不会有影响,在我们使用渲染到纹理技术时,如果不采取措施,可能导致纹理翻转,但这种情况通常Unity会帮助我们处理。 但如果我们开启了抗锯齿操作时(Edit->Project Setting->Quality->Anti Aliasing),并在此时我们使用到了渲染纹理技术,这时我们得到的屏幕图像并不会被Unity翻转

OpenGL ES for Android 播放视频

為{幸葍}努か 提交于 2020-02-05 21:18:11
为什么要使用OpenGL ES播放视频 我们都知道Android中有VideoView控件可以直接播放视频,既简单又实用,那么为什么我们还要用OpenGL ES来播放视频呢?那是因为使用OpenGL ES可以做更多的酷炫的动效,比如旋转视频、双指缩放视频、视频的截图、视频的录制、直播、换脸,还有类似“激萌”App里面的特效等这些都是VideoView所无法实现的,而通过OpenGL ES则可以实现这些酷炫的效果,当然这篇文章不会介绍如何这些实现这些效果,如果想了解这些动效请关注我,后面的文章会一一介绍。 开始我们的表演吧,No 图 No Code,先来欣赏下效果图吧: shader 首先我们先创建顶点和片段shader,顶点shader代码如下: attribute vec4 a_Position; attribute vec2 a_TexCoordinate; varying vec2 v_TexCoord; void main() { v_TexCoord = a_TexCoordinate; gl_Position = a_Position; } 片段shader代码如下: #extension GL_OES_EGL_image_external : require precision mediump float; uniform samplerExternalOES u

Issues with Z-axis rotation matrix in glsl shader

怎甘沉沦 提交于 2020-02-04 08:40:07
问题 I've recently began putting together an OpenGL ES 1.1/2.0 2D pipeline from the ground up (iPhone only). This pipeline is intended to be used by engineers with no 3D math experience. Commented out are the X and Y axis rotation matrices that produce the exact results they should . The Z rotation matrix seems to do nothing. VERTEX SHADER //THESE WORK /* highp mat4 rotationMatrix = mat4(1.0, 0.0, 0.0, 0.0, 0.0, cos(angle), -sin(angle), 0.0, 0.0, sin(angle), cos(angle), 0.0, 0.0, 0.0, 0.0, 1.0);

Issues with Z-axis rotation matrix in glsl shader

霸气de小男生 提交于 2020-02-04 08:40:06
问题 I've recently began putting together an OpenGL ES 1.1/2.0 2D pipeline from the ground up (iPhone only). This pipeline is intended to be used by engineers with no 3D math experience. Commented out are the X and Y axis rotation matrices that produce the exact results they should . The Z rotation matrix seems to do nothing. VERTEX SHADER //THESE WORK /* highp mat4 rotationMatrix = mat4(1.0, 0.0, 0.0, 0.0, 0.0, cos(angle), -sin(angle), 0.0, 0.0, sin(angle), cos(angle), 0.0, 0.0, 0.0, 0.0, 1.0);

Which are the right Matrix Values to use in a metal shader passed by a SCNProgram to get a correct chrome like reflection

核能气质少年 提交于 2020-02-04 01:46:09
问题 I am working on an App, that should render a chrome-style reflective sphere-like object inside a skybox (using a six faced cube map). I am doing this in Swift using Scenekit with different approaches. Everything is fine and perfectly reflected (see Figure 1 below) as long as I let Scenekit doing all the work - in other words, using a standard SCNMaterial with metalness 1.0, roughness 0.0 and color UIColor.white (using .physicallyBased as lighting model) attached to the firstMaterial of the

Unity3D优化总结(一)

99封情书 提交于 2020-02-04 00:30:23
容易忽略的美术资源的优化: 优化的美术制作真是一种感觉和经验的积累,能看出制作水平的不是做的效果多么犀利,而是得看制作的效果与对机器的要求等的性价比。 关于合并: 100个三角形的MESH,在渲染时与1500个面数的物体是没太大差别的,最佳的渲染设置应该在每个模型大约1500-4000个三角面。 材质共享: 如果需要通过脚本来访问复用材质属性,改变Renderer.material将会造成一份材质的拷贝。应该使用Renderer.sharedMaterial来保证材质的共享状态。 批处理动态物体需要在每个顶点上进行一定的开销,也有一些约束: 对VB的显存大小也有一定限制,如果着色器使用顶点位置,法线和UV值三种属性,那么只能批处理300顶点以下的物体;如果着色器需要使用顶点位置,法线,UV0,UV1和切向量,那只能批处理180顶点以下的物体了。 拥有lightmap的物体含有额外(隐藏)的材质属性,比如:lightmap的偏移和缩放系数等。所以,拥有lightmap的物体将不会进行批处理(除非他们指向lightmap的同一部分)。 使用不同缩放(scale)的物体将不能批次。分别拥有缩放尺度(1,1,1)和(2,2,2)的两个物体将不会进行批处理。 另外一个值得吸收的经验是非均匀缩放动画在unity中非常的慢,均匀缩放会快很多。 骨骼数量控制:一般来说游戏中的骨骼数量为15-60个

Does the draw order affects objects position in depth? (images included)

折月煮酒 提交于 2020-02-03 05:29:04
问题 I have a few objects on the scene and even if I specify that the object A have y= 10 (the highest object), from the TOP camera I can see the bottom objects through the object A. Here is an image from my scene. And only today I found an interesting property that draw order of models matters, I may be wrong. Here is another image where I change the draw order of "ship1", attention: "ship1" is way bellow my scene, if I do ship1.draw(); first, the ship disappears (correct), but if I do ship1.draw