shader

applying texture to Cube, different texture on each face of cube

跟風遠走 提交于 2019-12-10 14:48:28
问题 I'm trying to apply different texture on cube with shaders using samplerCube and textureCube. But I'm not able to get texture drawn on faces of cube only single color is appearing. Screenshots of output Below is my shader code: Vertex Shader String strVShader = "attribute vec4 a_position;" + "uniform mat4 u_VPMatrix;" + "attribute vec3 a_normal;" + "varying vec3 v_normal;" + "void main()" + "{" + "gl_Position = u_VPMatrix * a_position;" + "v_normal = a_normal;" + "}"; Fragment Shader String

Qt MDI app with OpenGL: how to grab a valid screenshot?

£可爱£侵袭症+ 提交于 2019-12-10 13:51:07
问题 I have an MDI app written in Qt. Some of the subwindows include QGLWidget s, i.e., OpenGL contexts. The most salient of these use OpenGL vertex and fragment shaders to visualize their data. I need to programmatically capture a screenshot of the application's main window, including of course all the subwindows that happen to be visible. Sounds easy at first ("definitely been asked many times, so let's just google it!"), but after a closer look it seems to be getting a bit tricky... Now here's

Three.js - apply shader to blur a geometry

馋奶兔 提交于 2019-12-10 12:17:45
问题 Been learning ThreeJS over the past day or so however I'm struggling with Shaders. I'm trying to blur a geometry i have. I tried using Depth Of Field with the examples found on the Three.js site but it made my foreground objects slightly blurry too. So I'm hoping to single out one object and just blur that. Now I have a mesh that i created with a LambertMaterial basically like so: var material = new THREE.MeshLambertMaterial({ color: 0x5c5c5c, emissive: 0x000000, shading: THREE.FlatShading,

why the sphere texture map can not actually match

落爺英雄遲暮 提交于 2019-12-10 12:09:22
问题 i have a sphere in my 3d project, and i have an earth texture, i use the algorithm from wiki to calculate the texture coordinate. the code in my effect file look like this: float pi = 3.14159265359f; output.uvCoords.x = 0.5 + atan2(input.normal.z, input.normal.x) / (2 * pi); output.uvCoords.y = 0.5f - asin(input.normal.y) / pi; the result is the picture below: look from left( there is a line, this is my question) look from front 3.look from right 回答1: Not pretend to be a complete answer at

WPF ShaderEffect with PS 3.0 shaders

不羁岁月 提交于 2019-12-10 12:05:48
问题 Where could I find examples of PS 3.0 shaders used as ShaderEffects for WPF 4? I'm looking for tutorials, presentations, any resource on this matter. 回答1: The best information you're going to get is that of the MSDN documentation for the ShaderEffect class in WPF 4.0. Were you looking for anything more specific? 回答2: In fact, there still aren't any resources at all on WPF + PS 3.0 (at least after searching 20 minutes on the web). You'll have to wait or create your own PS 3.0 shaders. 来源:

How to send my model matrix only once per model to shaders

隐身守侯 提交于 2019-12-10 12:04:01
问题 For reference, I'm following this tutorial. Now suppose I have a little application with multiple types of model, if I understand correctly I have to send my MPV matrix from the CPU to the GPU (in other words to my vertex shader) for each model, because each model might have a different model matrix from one to another. Now looking at the tutorial and this post, I understand that the call to send the matrix to my shader ( glUniformMatrix4fv(myMatrixID, 1, GL_FALSE, &myModelMVP[0][0]) ) should

How to use fragment shader to draw sphere ilusion in OpenGL ES?

只谈情不闲聊 提交于 2019-12-10 11:25:52
问题 I am using this simple function to draw quad in 3D space that is facing camera. Now, I want to use fragment shader to draw illusion of a sphere inside. But, the problem is I'm new to OpenGL ES, so I don't know how? void draw_sphere(view_t view) { set_gl_options(COURSE); glPushMatrix(); { glTranslatef(view.plyr_pos.x, view.plyr_pos.y, view.plyr_pos.z - 1.9); #ifdef __APPLE__ #undef glEnableClientState #undef glDisableClientState #undef glVertexPointer #undef glTexCoordPointer #undef

How to use glslang

穿精又带淫゛_ 提交于 2019-12-10 11:11:58
问题 I am trying to use glslang to compile glsl shader code to SPIR-V binaries. The glslang project can be found here: https://github.com/KhronosGroup/glslang It works well via the glslangValidator.exe manually in the command line. But i would like to use the c++ interface. I have build the project as described on the github page, and now I am struggling with how to actually use the interface. I would rather not actually include any projects in my solution (I am using Visual Studio), but link the

How to repeatedly update a uniform data for number of objects inside a single Vulkan render pass and make the update synchronized?

五迷三道 提交于 2019-12-10 10:57:27
问题 I'm trying to port my OpenGL 3D game engine to Vulkan. There are large numbers of 3D objects in the game scene and each has it own attributes (model matrix, lights, etc.) and the objects are completely dynamic, which means some 3D objects may come in and others may be removed during the game play. with OpenGL, I grouped 3D object's attribute into a uniform buffer in shader (code simplified): layout(std140, set = 0, binding = 0) uniform object_attrib { vec3 light_pos; vec3 light_color; mat4

DirectX world view matrix multiplications - GPU or CPU the place

帅比萌擦擦* 提交于 2019-12-10 10:27:34
问题 I am new to directx, but have been surprised that most examples I have seen the world matrix and view matrix are multiplied as part of the vertex shader, rather than being multiplied by the CPU and the result being passed to the shader. For rigid objects this means you multiply the same two matrices once for every single vertex of the object. I know that the GPU can do this in parallel over a number of vertices (don't really have an idea how many), but isn't this really inefficient, or am I