shader

Using a Metal shader in SceneKit

守給你的承諾、 提交于 2019-12-06 06:14:37
问题 I'd like to use a Metal shader to apply a toon/cell shading to materials used in the scene. The shader I'm trying to implement is Apple's own AAPLCelShader found in the MetalShaderShowcase. I'm a little new to implementing shaders in SceneKit so I could be doing everything completely wrong. From what I understand in the documentation a Metal or GL shader can be used to modify SceneKit rendering as of iOS 9 and Xcode 7. The documentation suggests that this is done in the same way as GL shaders

How fragment shader determines the number of fragments from vertex shader output?

你说的曾经没有我的故事 提交于 2019-12-06 06:07:22
问题 I'm familiar with vertex and fragment shaders but still confused about how a fragment shader determines the amount of fragments from the output of vertex shader. If I have 3 vertices and I draw a triangle primitive in GLSL, then vertex shader will run three times for every vertex and then fragment shader will run many times (depending upon the number of fragments, once for each fragment). I want to know how fragment shader determines the fragments? Does it use gl_Position? If I don't set gl

Unable to retrieve an error message from glGetShaderInfoLog

孤街浪徒 提交于 2019-12-06 06:02:38
问题 I am attempting to build a simple OpenGL 3.2 program which consists of a single fragment shader, but I do not seem to be able to actually compile the shader. I'm fairly sure that my shader syntax is correct, but even if it's not, I am unable to retrieve an error message using glGetShaderInfoLog . I have developed a short program that shows this in action: GLuint shader = glCreateShader(GL_FRAGMENT_SHADER); const char *shaderData = "#version 120\n" "void main()\n" "{\n" " gl_FragColor = gl

Understanding Shader Programming

人盡茶涼 提交于 2019-12-06 05:54:40
I am trying to understand shader programming, but at this point, documentation wont help me further. 1] Does the data type & size of the buffers have to match? In the DX tutorial 4 from the DX SDK, they have a struct: struct SimpleVertex{ XMFLOAT3 Pos; XMFLOAT4 Color; }; While in their shader file, they define: struct VS_OUTPUT{ float4 Pos : SV_POSITION; float4 Color : COLOR0; }; They define Pos as a vector of 3 in one file, while it is 4 in another. How is this correct? I thought the size of the data have to match. 2] To create another constant buffer, is this the steps I need to do? // Make

How Might I organize vertex data in WebGL for a frame-by-frame (very specific) animated program?

泄露秘密 提交于 2019-12-06 05:50:29
I have been working on an animated graphics project with very specific requirements, and after quite a bit of searching and test coding, I have figured that I could take several approaches, but the Khronos and MDN documentation I have been reading coupled with other posts I have seen here don't answer all of my questions regarding my particular project. In the meantime, I have written short test programs (setting infrastructure for testing). Firstly, I should describe the project: The main object drawn to the screen is a simple quad surrounded by a black outline (LINE_LOOP or LINES will do,

Switch shader program in WebGL

笑着哭i 提交于 2019-12-06 05:17:31
问题 I have an existing WebGL renderer (too much code to be useful to share) which used to be very simple: it only had one vertex shader, one fragment shader, and one shader program with both. It was for rendering quads. I'm trying to extend it to have a second shader program it switches to and from, for rendering point sprites. It has its own vertex attribute array, and a second vertex shader, fragment shader and shader program. I can't seem to switch between the two properly: I keep getting

How to use glslang

我是研究僧i 提交于 2019-12-06 05:15:34
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 .lib's and headers needed to use it. I just cannot find out which ones i need to link. The github page

Opengl Simple Fragment Shader to overlay semi-transparent Triangle Strip over texture

◇◆丶佛笑我妖孽 提交于 2019-12-06 04:48:35
I have a textured triangle strip that forms a quad. when you click on it i want the surrounding areas to get marked with semi-transparent quads so you can still see the textures underneath. i have the quads getting displayed correctly, but they are not transparent at all and completely cover whatever is underneath. i have a very simple fragment shader that i thought would work with glEnable(GL_BLEND) and glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) : #version 130 out vec4 flatColor; void main(void) { flatColor = vec4(0.0,1.0,0.0,0.5); } If i texture the quads with a simple image it works

framebuffer and using shaders in opengl

我与影子孤独终老i 提交于 2019-12-06 03:41:36
问题 I'm quite a bit confused about framebuffers. What I want to do is using a framebuffer with multiple textures attached, fill every texture and then use a shader to combine (blend) all textures to create a new output. Sounds easy? yeah that's what I thought too, but I don't understand it. How can I pass the currently binded texture to a shader? 回答1: What you need is to put the texture in a specific slot, then use a sampler to read from it. In your app: GLuint frameBuffer; glGenFramebuffersEXT(1

Inline webgl shader code in javascript

血红的双手。 提交于 2019-12-06 03:30:26
问题 I'm writing a simple Javascript library that makes use of some WebGL code. I'd like to include the shader sources inline in the .js file, because my alternatives are to include them as script tags in each page, or to have them as separate files which are loaded as AJAX. Neither of these options are particularly modular. However, due to the lack of multi-line strings in javascript, I don't have any good ideas for how to inline the WebGL code. Is there an approach I'm not thinking of? 回答1: Use