shader

qt multiple QGLShaderProgram for one texture

眉间皱痕 提交于 2019-12-12 02:34:48
问题 I use two QGLShaderProgram for processing the texture. ShaderProgram1->bind(); // QGLShaderProgram ShaderProgram2->bind(); glBegin(GL_TRIANGLE_STRIP); ... glEnd(); ShaderProgram1->release(); ShaderProgram2->release(); The texture should be processed with Shaderprogram1 and then ShaderProgram2. But when I call ShaderProgram2->bind() automatically fires ShaderProgram1->release() and only one shader works. How do I bind both shaders? 回答1: You don't. Unless these are separate shaders (and even

Javascript text input editing: How to turn multiple string text shader in one text input into another representation?

大城市里の小女人 提交于 2019-12-12 02:17:23
问题 So I want to have 2 input feilds, one editable. I need some script that would turn such shader text input: #ifdef GL_ES precision highp float; #endif varying vec4 v_color; void main (void) { gl_FragColor = v_color; } into such output: "#ifdef GL_ES\n" "precision highp float;\n" "#endif\n" "\n" "varying vec4 v_color;\n" "\n" "void main (void)\n" "{\n" " gl_FragColor = v_color; \n" "}" (such output can be turned into openGL shader static char* ) So how to create such simple tool with Javascript

Vertex Shader Creating

别等时光非礼了梦想. 提交于 2019-12-12 01:37:07
问题 I am learning D3D and currently i am at shaders. I wrote the code and built it - succeed but when debug i get this error: ERROR Here is the line where debugger breake: dev->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), NULL, &pVS); And here is the whole function: void InitPipeline() { // load and compile the two shaders ID3D10Blob *VS, *PS; D3DX11CompileFromFile("Shaders.shader", 0, 0, "VShader", "vs_4_0", 0, 0, 0, &VS, 0, 0); D3DX11CompileFromFile("Shaders.shader", 0, 0,

GLSL, default value for output color

风格不统一 提交于 2019-12-11 23:50:09
问题 Which is the default value for the output color in GLSL in case you dont set it? #version 330 uniform sampler2DRect colorTex; uniform vec3 backgroundColor; out vec4 outputColor; void main(void) { vec4 frontColor = texture(colorTex, gl_FragCoord.xy); outputColor.rgb = frontColor + backgroundColor * frontColor.a; } Is it (0, 0, 0, 1)? Ps: that code belongs to the old GL, trying to use it with the GL3, I get the following error error C7011: implicit cast from "vec4" to "vec3" I am right to

C++ indicates my highest Shader Model is 3

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 21:21:49
问题 I'm trying to detect what's the highest Shader Model my Graphics Card has in C++ by using if(caps.VertexShaderVersion < D3DVS_VERSION(i, 0)){return false;} where i is the shader model I want to check, but I can only get it up to 3. The problem is I've checked my Graphics Card (Gigabyte GeForce GTX 470) and it has DirectX 11 so shouldn't it have Shader Model 5? Or is there something wrong with the way I'm checking the Shader Model? 回答1: Direct3D 9, which is the API you're using, is not aware

Opengl error C0000 compiling error

杀马特。学长 韩版系。学妹 提交于 2019-12-11 19:56:07
问题 I've a problem with opengl shader compiling. The problem is that when I run the program, I obtain this error: Vertex info 0(1) : error c0000: syntax error, unexpected ' ' at token ' ' the same message is for the fragment object. At the end I obtain a 'program not validated' error. here's my initialization shader code: struct ShadeState { int gl_program_id = 0; // OpenGL program handle int gl_vertex_shader_id = 0; // OpenGL vertex shader handle int gl_fragment_shader_id = 0; // OpenGL fragment

Why my shader doesn't render the subshader with the color?

一世执手 提交于 2019-12-11 19:47:22
问题 I found a shader and it's a Wireframe shader with no diagonals (see ref. here). I'd like to fill is with color so I added a subshader that will render the color (taking from here). Both shaders work great independently, however when I try to combine them the color from the second shader is not rendering. What can the problem be? This is the code I have: Shader "Custom/TransparentSingleColorShader" { Properties{ _Color("Color", Color) = (1.0, 1.0, 1.0, 1.0) [PowerSlider(3.0)] _WireframeVal(

DirectX 11, Combining pixel shaders to prevent bottlenecks

岁酱吖の 提交于 2019-12-11 19:26:45
问题 I'm trying to implement one complex algorithm using GPU. The only problem is HW limitations and maximum available feature level is 9_3. Algorithm is basically "stereo matching"-like algorithm for two images. Because of mentioned limitations all calculations has to be performed in Vertex/Pixel shaders only (there is no computation API available). Vertex shaders are rather useless here so I considered them as pass-through vertex shaders. Let me shortly describe the algorithm: Take two images

Shader Texture Always Facing The Camera

浪子不回头ぞ 提交于 2019-12-11 19:19:10
问题 I have this basic shader, though I ran into some trouble which really bugs me! I'm applying the texture using the fragment shader though however I move or rotate the camera, the texture on the face will always be facing the camera (I've added a GIF image as an example). So as you can see on the image above the texture keeps facing the camera, also if I move away of closer it will keep its scale. I'm trying to achive that I can move around and the texture will keep it's position, rotation and

Shader初级学习(空间)

跟風遠走 提交于 2019-12-11 18:42:49
四种空间 模型空间 世界空间 观察空间 裁剪空间 以下为个人理解,大佬请绕道 模型空间 :建模时在模型空间进行,模型自带的坐标均为模型空间下的表示 观察空间 :以摄像机位置为原点,摄像机局部坐标轴为坐标轴的坐标系 裁剪空间 :一般理解为从Scene中看到的空间 世界空间 :理解为从Game窗口看到的空间 空间变换函数 UnityCG.cginc中一些常用的函数 摄像机方向(视角方向) float3 WorldSpaceViewDir(float4 v) 根据模型空间中的顶点坐标 得到 (世界空间)从这个点到摄像机的观察方向 float3 UnityWorldSpaceViewDir(float4 v) 世界空间中的顶点坐标==》世界空间从这个点到摄像机的观察方向 float3 ObjSpaceViewDir(float4 v) 模型空间中的顶点坐标==》模型空间从这个点到摄像机的观察方向 光源方向 float3 WorldSpaceLightDir(float4 v) 模型空间中的顶点坐标==》世界空间中从这个点到光源的方向 float3 UnityWorldSpaceLightDir(float4 v) 世界空间中的顶点坐标==》世界空间中从这个点到光源的方向 float3 ObjSpaceLightDir(float4 v) 模型空间中的顶点坐标==