shader

Why does glValidateProgram fail when no VAO is bound?

我只是一个虾纸丫 提交于 2019-12-05 09:37:12
I have a problem validating my shader program in LWJGL/OpenGL 3. I read the documentation, but I can't seem to find a reason why a VAO is needed when calling glValidateProgram. int program = glCreateProgram(); int vertexShader = glCreateShader(...); int fragmentShader = glCreateShader(...); // ... vertex and fragment shader loading, compiling, errorchecking ... glAttachShader(program, vertexShader); glAttachShader(program, fragmentShader); glBindAttribLocation(program, 0, "position"); glBindAttribLocation(program, 1, "color"); glLinkProgram(program); glDetachShader(program, shader);

webgl: share texture with other program/shader

浪尽此生 提交于 2019-12-05 08:53:20
问题 i have two shaders that use different vertexarrays and different uniform values but they use the same texture (spritesheet/atlas). is it possible for them to share the same texture (without causing the texture to be sent to the gpu twice)? background: My game has some serious performance issues on my laptop and they seem to be gpu related. My current implementation uses two canvases, one for my background and one for my foreground. they then get composed for the final image (draw onto 3rd

Glitchy Facial Morph Target Animation in OpenGL (C++)

百般思念 提交于 2019-12-05 08:22:15
I've been trying to implement Morph Target animation in OpenGL with Facial Blendshapes but following this tutorial. The vertex shader for the animation looks something like this: #version 400 core in vec3 vNeutral; in vec3 vSmile_L; in vec3 nNeutral; in vec3 nSmile_L; in vec3 vSmile_R; in vec3 nSmile_R; uniform float left; uniform float right; uniform float top; uniform float bottom; uniform float near; uniform float far; uniform vec3 cameraPosition; uniform vec3 lookAtPosition; uniform vec3 upVector; uniform vec4 lightPosition; out vec3 lPos; out vec3 vPos; out vec3 vNorm; uniform vec3 pos;

Shader's function parameters performance

只谈情不闲聊 提交于 2019-12-05 08:09:11
I'm trying to understand how passing parameters is implemented in shader languages. I've read several articles and documentation, but still I have some doubts. In particular I'm trying to understand the differences with a C++ function call, with a particular emphasis on performances. There are slightly differences between HSLS,Cg and GLSL but I guess the underline implementation is quite similar. What I've understood so far: Unless otherwise specified a function parameter is always passed by value (is this true even for matrix?) Passing by value in this context hasn't the same implications as

Full setup of Transform Feedback(openGL)

随声附和 提交于 2019-12-05 07:59:10
GLSL 1.50, openGL 3.3. I've been lately trying to get my tranform feedback working but without success. I still receive error after glBeginTranformFeedback() and as I haven't found any full working code I have stacked up my knowledge with some code that I found and documentation, it should be working well by now but I am missing something. So if anybody got full code (initializing of buffers, setting up, updating, rendering, reading back) it would definitelly help and if you don't but know what's going on you could take look at my code. I excluded some benchmarking, handling of windows and it

How do i display 2 or more objects in openGL (model - view - projection matrices and shaders)

泪湿孤枕 提交于 2019-12-05 07:03:48
It's all ok when i want to draw one object, for example a cube. I create vertices for cube, i create the buffer, i create the MVP matrix and send it to shader and it works nice. But, what to do when i want to draw 2 or more objects , for example both cube and a triangle? I believe that View and Projection matrices should be same both for triangle and cube, i only need different Model matrix, right? So that means that i will have two MVPs? //Example (using GLM): glm::mat4 MVPC = Projection * View * ModelCube; glm::mat4 MVPT = Projection * View * ModelTriangle; So what do i do with those two now

Directx 11, send multiple textures to shader

守給你的承諾、 提交于 2019-12-05 06:42:47
using this code I can send one texture to the shader: devcon->PSSetShaderResources(0, 1, &pTexture); Of course i made the pTexture by: D3DX11CreateShaderResourceViewFromFile Shader: Texture2D Texture; return color * Texture.Sample(ss, texcoord); I'm currently only sending one texture to the shader, but I would like to send multiple textures, how is this possible? Thank You. By using Texture Arrays . When you fill out your D3D11_TEXTURE2D_DESC look at the ArraySize member. This desc struct is the one that gets passed to ID3D11Device::CreateTexture2D . Then in your shader you use a 3rd texcoord

How can I tint a sprite to white in XNA?

泪湿孤枕 提交于 2019-12-05 06:10:57
I don't think this is possible just using the color setting in SpriteBatch, so I'm trying to work out a simple shader that would take every pixel and make it white, while respecting the alpha value of the pixel. The answer Joel Martinez gave looks right, but how do I incorporate that when I draw the sprite with SpriteBatch? I think this is what you're looking for sampler2D baseMap; struct PS_INPUT { float2 Texcoord : TEXCOORD0; }; float4 ps_main( PS_INPUT Input ) : COLOR0 { float4 color = tex2D( baseMap, Input.Texcoord ); return float4(1.0f, 1.0f, 1.0f, color.w); } It's very simple, it just

THREE.js repeat wrapping texture in shader

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 02:20:42
问题 I want to repeat wrapping texture in THREE.js shader. The original texture image is: I want it to repeat 4x4 times which will looks like: But with the following code, it turns out to be: Vertex shader: varying vec2 vUv; uniform float textRepeat; void main() { // passing texture to fragment shader vUv = uv * textRepeat; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } Fragment shader: varying vec2 vUv; uniform sampler2D texture; void main() { // add origianl texture gl

pixijs shader 实现图片波浪效果

岁酱吖の 提交于 2019-12-05 01:53:42
const app = new PIXI.Application({ transparent: true }); document.body.appendChild(app.view); // Create background image const background = PIXI.Sprite.from('/moban/bg_grass.jpg'); background.width = app.screen.width; background.height = app.screen.height; app.stage.addChild(background); // Stop application wait for load to finish app.stop(); app.loader.add('shader', '/moban/shader.frag') .load(onLoaded); let filter; // Handle the load completed function onLoaded(loader, res) { // Create the new filter, arguments: (vertexShader, framentSource) filter = new PIXI.Filter(null, res.shader.data, {