shader

Unity人物残影实现

房东的猫 提交于 2019-12-03 15:36:42
一.最近学习unity看到一个关于人物残影的实现过程,在这里记一下,大概原理就是 通过获取人物的SkinnedMeshRenderer组件,然后将其中重要的材质和Mesh赋值给新创建的Gameobject物体上,然后设置淡出效果,按生存周期销毁gameobject就好了; 详细的看代码吧; 为人物添加脚本:(脚本中设有注释就不多说了) <span style="font-size:18px;">using UnityEngine; using System.Collections; using System.Collections.Generic; public class DestroyShadow : MonoBehaviour { public float interval = 0.1f; //残影的时间间隔; public float lifeCycle = 2f; //残影的生存周期 float lastCombineTime = 0.0f; //上次组合时间; MeshFilter[] meshFilters = null; SkinnedMeshRenderer[] skinnedMeshRenderers = null; List<GameObject> objs = new List<GameObject>(); // Use this for

General purpose compute with Vertex/Pixel shaders (Open GL / DirectX)

混江龙づ霸主 提交于 2019-12-03 15:22:18
I have a question regarding compute shaders. are compute shaders available in DX 9? would it be still possible to use a compute shader with a DX9 driver if there is no compute shader fragment on the GPU? ( SGX 545 does not have it, but SGX 6X generation is going to have it), as far as what IMG says. I would like to know If i can do some simple general purpose programming on SGXs GPUs with DirectX9 or OpenGL drivers. Also, is there anyway I can use OpenGL vertex shaders for GPGPU programming? Here is what I am thinking: I will load my Matrices/ data into the vertex buffer, and bind them to the

【Unity】Unity 5 Statistics 窗口

家住魔仙堡 提交于 2019-12-03 15:04:53
Unity5的 Statistics上的统计信息和Unity4 有一些区别, Statistics窗口,全称叫做 Rendering Statistics Window ,即渲染统计窗口(或渲染数据统计窗口),窗口中罗列出关于渲染、声音、网络状况等多种统计信息 ,下面详细的解释一下这些项的意义。 FPS FPS(Time per frame andFPS) :frames per seconds表示引擎处理和渲染一个游戏帧所花费的时间,该数字主要受到场景中渲染物体数量和 GPU性能的影响,FPS数值越高,游戏场景的动画显示会更加平滑和流畅。一般来说,超过30FPS的画面人眼不会感觉到卡,由于视觉残留的特性,光在视网膜上停止总用后人眼还会保持1/24秒左右的时间,因此游戏画面每秒帧数至少要保证在30以上。 另外,Unity中的FPS数值仅包括此游戏Scene里更新和渲染的帧,编辑器中绘制的Scene和其它监视窗口的进程不包括在内。 CPU CPU: 获取到当前占用CPU进行计算的时间绝对值,或时间点,如果Unity主进程处于挂断或休眠状态时,CPU time将会保持不变。 Render thread Render thread: GPU渲染线程处理图像所花费的时间,具体数值由GPU性能来决定 Batches Batches: 即Batched Draw Calls

Fast Gaussian blur at pause [closed]

﹥>﹥吖頭↗ 提交于 2019-12-03 14:16:41
Closed. This question is off-topic. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it's on-topic for Stack Overflow. In cocos2d-x I need to implement fast gaussian blur and here is how it should looks like( I just found some game on the App Store with already done such blur, in unity): So, it's nice fadeIn - fadeOut blur when user pauses the game. GPUImage already has a fast blur I need, but I can't find solution for cocos2d-x. v1 code when it was (GPUImage v1) Objective C v2 code when is now Swift(GPUImage v2) Swift GPUImage-x C++

Unity2017 中新加入的 CustomRenderTexture类用户手册翻译

冷暖自知 提交于 2019-12-03 13:59:30
由于最近研究一些使用熔岩等粘稠流体模拟技术,需要计算生成一张中间纹理,并用相应的shader实时更新中间纹理中的信息,以实现流体模拟。使用GLSL可以实现,在UnityShader中的实现需要依赖Unity2017新加入的CustomRenderTexture类,来自定义中间纹理,保存需要的信息。这样使用UnityShader同样可以方便的将一些中间信息保存到纹理中,实现更加丰富的模拟效果。 下面现根据官方手册介绍一下新CustomRenderTexture类。边看便翻译的,水平有限,各位凑合着看 https://docs.unity3d.com/2017.2/Documentation/Manual/CustomRenderTextures.html 一、CustomRenderTexture类 CustomRenderTexture是继承自Unity之前版本中的RenderTexture类。RenderTexture的使用需要结合相机,将这个相机所看到的图像渲染到RenderTarget中,这个RenderTarget就是一张RenderTexture类的纹理,这一技术常用语模拟镜面效果(具体应用参考《UnityShader入门精要》一书)。CustomRenderTexture类是对RenderTexture类的一个扩充。我们可以使用Shader来实时地更新纹理

opengl读取灰度图生成三维地形并添加光照

戏子无情 提交于 2019-12-03 13:34:29
转自: https://www.cnblogs.com/gucheng/p/10152889.html 准备第三方库 glew、freeglut、glm、opencv 准备一张灰度图 最终效果 代码如下 代码包括主程序源文件mainApp.cpp、顶点着色器shader.vs、片元着色器shader.fs mainApp.cpp #include <stdio.h> #include <string.h> #include <iostream> #include <fstream> #include <sstream> #include <GL/glew.h> #include <GL/freeglut.h> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> using namespace std; using namespace cv; using namespace glm; //shader文件 const char* vsShaderName = "shader.vs";/

Compute sum of array values in parallel with metal swift

非 Y 不嫁゛ 提交于 2019-12-03 13:05:50
问题 I am trying to compute sum of large array in parallel with metal swift. Is there a god way to do it? My plane was that I divide my array to sub arrays, compute sum of one sub arrays in parallel and then when parallel computation is finished compute sum of sub sums. for example if I have array = [a0,....an] I divide array in sub arrays : array_1 = [a_0,...a_i], array_2 = [a_i+1,...a_2i], .... array_n/i = [a_n-1, ... a_n] sums for this arrays is computed in parallel and I get sum_1, sum_2, sum

Gaussian Blur - standard deviation, radius and kernel size

折月煮酒 提交于 2019-12-03 12:32:31
问题 I've implemented a gaussian blur fragment shader in GLSL. I understand the main concepts behind all of it: convolution, separation of x and y using linearity, multiple passes to increase radius... I still have a few questions though: What's the relationship between sigma and radius? I've read that sigma is equivalent to radius, I don't see how sigma is expressed in pixels. Or is "radius" just a name for sigma, not related to pixels? How do I choose sigma? Considering I use multiple passes to

Shader to bevel the edges of a cube?

╄→гoц情女王★ 提交于 2019-12-03 12:13:07
问题 This question relates to using shaders (probably in the Unity3D milieu, but Metal or OpenGL is fine), to achieve rounded edges on a mesh-minimal cube. I wish to use only 12-triangle minimalist mesh cubes, and then via the shader, Achieve the edges (/corners) of each block being slightly bevelled. In fact, can this be done with a shader ? Thanks, shader gurus! 回答1: I recently finished creating such shader. The only way it can work is by providing 4 normal vectors instead of one for each vertex

What does glUseProgram(0) do?

北城以北 提交于 2019-12-03 12:08:08
问题 The OpenGL docs for glUseProgram claim that calling it with an argument of zero will cause the results of shader execution to be undefined . However, after a little searching I've seen a couple examples of people using glUseProgram to uninstall the current shader program. Is this behavior reliable? If not, then what exactly does glUseProgram(0) do? 回答1: glUseProgram means that the given program object is the current program that will be used for things that use programs ( glUniform ,