shader

D3D12遇到的报错记录

纵然是瞬间 提交于 2019-11-26 20:21:09
E_INVALIDARG One or more arguments are invalid. 这个报错是最常见的报错了,一般是调用D3D的函数时的 参数设置不对 ,或者 参数设置无效 ,或者是 当前系统环境不支持你所设置的参数 ,使用Visual studio进行学习开发的话,多注意Output窗口,一般会在报错提示的前后有更详细的提示 Invalid resource barrier type. [ RESOURCE_MANIPULATION ERROR #519: RESOURCE_BARRIER_INVALID_TYPE] 这个报错提示还是很清楚的,我出错的原因是 D3D12_RESOURCE_BARRIER resourceBarrier; resourceBarrier.Transition.pResource = mRenderTargets[mFrameIndex].Get(); resourceBarrier.Transition.StateBefore = D3D12_RESOURCE_STATES::D3D12_RESOURCE_STATE_PRESENT; resourceBarrier.Transition.StateAfter = D3D12_RESOURCE_STATES::D3D12_RESOURCE_STATE_RENDER_TARGET;

Is discard bad for program performance in OpenGL?

元气小坏坏 提交于 2019-11-26 19:44:30
问题 I was reading this article, and the author writes: Here's how to write high-performance applications on every platform in two easy steps: [...] Follow best practices. In the case of Android and OpenGL, this includes things like "batch draw calls", "don't use discard in fragment shaders", and so on. I have never before heard that discard would have a bad impact on performance or such, and have been using it to avoid blending when a detailed alpha hasn't been necessary. Could someone please

Explicit vs Automatic attribute location binding for OpenGL shaders

倾然丶 夕夏残阳落幕 提交于 2019-11-26 19:22:42
When setting up attribute locations for an OpenGL shader program, you are faced with two options: glBindAttribLocation() before linking to explicitly define an attribute location. or glGetAttribLocation() after linking to obtain an automatically assigned attribute location. What is the utility for using one over the other? And which one, if any, is preferred in practice? Kos I know one good reason to prefer explicit location definition. Consider that you hold your geometry data in Vertex Array Objects. For a given object, you create a VAO in such way that the indices correspond to, for example

Unity Shader基础(1):基础

一笑奈何 提交于 2019-11-26 19:12:54
一.Shaderlab语法 1.给Shader起名字 Shader "Custom/MyShader" 这个名称会出现在材质选择使用的下拉列表里 2. Properties (属性) Properties { Name ("display name",ProperType)=DefaultValue //更多属性 } Name:用于Shader中访问的名字 display name:出现在材质面板的名字 ProperType:它的类型 3.SubShader 每一个Unity Shader文件可以包含多个SubShader语义块,但至少要有一个 SubShader { //可选的 [Tags] //可选的 [RenderSetup] Pass{ } //Other Pass } Pass尽量不要太多,太多往往会造成渲染性能的下降 (1)状态设置 下面是常见的状态设置选项 (2).Tags:是一个 键值对 (Key/Value Pair) 用来告诉Unity的渲染引擎:SubShader我希望怎么以及何时渲染这个对象 结构如下: Tags {"TagName1"="Value1" "TagName2"="Value2"} 支持的标签类型如下: (3)Pass语义块 Pass{ [Name] [Tags] [RenderSetup] //Other code } 1.Name

Creating a GLSL Arrays of Uniforms?

*爱你&永不变心* 提交于 2019-11-26 19:05:01
问题 I would like to leave OpenGL's lights and make my own. I would like my shaders to allow for a variable number of lights. Can we declare an array of uniforms in GLSL shaders? If so, how would we set the values of those uniforms? 回答1: Yes this is possible. You declare uniform arrays similar to how you'd do it in C, e.g. uniform float v[10]; Then you can set their values using glUniform{1,2,3,4}{f,i}v GLfloat v[10] = {...}; glUniform1fv(glGetUniformLocation(program, "v"), 10, v); 回答2: Yes it is

Frequency of shader invocations in rendering commands

时光总嘲笑我的痴心妄想 提交于 2019-11-26 16:56:28
问题 Shaders have invocations, which each are (usually) given a unique set of input data, and each (usually) write to their own separate output data. When you issue a rendering command, how many times does each shader get invoked? 回答1: Each shader stage has its own frequency of invocations. I will use the OpenGL terminology, but D3D works the same way (since they're both modelling the same hardware relationships). Vertex Shaders These are the second most complicated. They execute once for every

测试GPU的材质填充率

梦想与她 提交于 2019-11-26 15:12:22
  体渲染最重要的一个优化就是减少GPU的采样工作。测试GPU的材质填充率能够指导我们的工作。要知道为什么GPU在800*600的环境中只能达到12FPS么?这就要看GPU每秒钟采样的次数啦。   我写了一个简单的OSG程序,用来测试采样次数, 点击这里可以下载   程序原理很简单,分几步:创建窗口->生成和设置纹理->载入SHADER->渲染。具体如何做要看程序里面啦,这里就不再贴出来了。   直接说最后的测试的结果了。我的8800GTS(G80)官方资料说材质填充率能够达到24Billion/Sec,官方资料给的核心频率500Mhz,着色器频率1200Mhz,显存800Mhz。我将我的显卡也按照这个数据进行了降频。   测试环境:窗口800*600,3D贴图256*256*256,数据是LUMINACE_ALPHA,每个像素2BYTE。每个像素的Shader采样3D贴图512次。   最后得到测试FPS为11.98帧。算算:800*600*512*11.98=2,944,204,800,因为是3D纹理所以每个采样实际要有8次采样工作,所以最终的材质填充率:23,553,638,400,和24Billion/Sec很接近了。   换用2D贴图可以得到相似的结果,只是FPS会快一倍。原因是三线性采样的工作量是二线性采样的两倍,很显然FPS会提升一倍。   那么怎么去优化呢

How to render Android's YUV-NV21 camera image on the background in libgdx with OpenGLES 2.0 in real-time?

爱⌒轻易说出口 提交于 2019-11-26 10:17:48
问题 Unlike Android, I\'m relatively new to GL/libgdx. The task I need to solve, namely rendering the Android camera\'s YUV-NV21 preview image to the screen background inside libgdx in real time is multi-faceted. Here are the main concerns: Android camera\'s preview image is only guaranteed to be in the YUV-NV21 space (and in the similar YV12 space where U and V channels are not interleaved but grouped). Assuming that most modern devices will provide implicit RGB conversion is VERY wrong, e.g the

What is state-of-the-art for text rendering in OpenGL as of version 4.1? [closed]

≡放荡痞女 提交于 2019-11-26 08:38:45
问题 There are already a number of questions about text rendering in OpenGL, such as: How to do OpenGL live text-rendering for a GUI? But mostly what is discussed is rendering textured quads using the fixed-function pipeline. Surely shaders must make a better way. I\'m not really concerned about internationalization, most of my strings will be plot tick labels (date and time or purely numeric). But the plots will be re-rendered at the screen refresh rate and there could be quite a bit of text (not

Replicating MeshLambertMaterial Using ShaderMaterial ignores textures

时光毁灭记忆、已成空白 提交于 2019-11-26 08:26:35
问题 I noticed that THREE.js uses shaders internally to create core material \"e.g. MeshLambertMaterial\", So I decided to copy the lambert shader from Three.js code into a new shader and build on it. This is the code I got (Copied faithfully from Three.js r66) THREE.MyShader = { uniforms: THREE.UniformsUtils.merge( [ THREE.UniformsLib[ \"common\" ], THREE.UniformsLib[ \"fog\" ], THREE.UniformsLib[ \"lights\" ], THREE.UniformsLib[ \"shadowmap\" ], { \"ambient\" : { type: \"c\", value: new THREE