shader

How to get a “Glow” shader effect in OpenGL ES 2.0?

与世无争的帅哥 提交于 2019-11-28 16:33:51
问题 I'm writing a 3D app for iOS. I'm new to OpenGL ES 2.0, so I'm still getting myself around writing basic shaders. I really need to implement a "Glow" effect on some of my models, based on the texturing. Here's a sample: . I'm looking for code examples for OpenGL ES 2.0. Most code I find on the internet is either for desktop OpenGL or D3D. Any ideas? 回答1: First of all there are tons of algorithms and techniques to generate a glow effect. I just want to present one possibility. Create a

What are Vertex and Pixel shaders?

旧街凉风 提交于 2019-11-28 16:16:14
问题 What are Vertex and Pixel shaders? What is the difference between them? Which one is the best? 回答1: A Pixel Shader is a GPU (Graphic Processing Unit) component that can be programmed to operate on a per pixel basis and take care of stuff like lighting and bump mapping. A Vertex Shader is also GPU component and is also programmed using a specific assembly-like language, like pixel shaders, but are oriented to the scene geometry and can do things like adding cartoony silhouette edges to objects

What is the correct file extension for GLSL shaders? [closed]

泄露秘密 提交于 2019-11-28 15:24:15
I'm learning glsl shading and I've come across different file formats. I've seen people giving their vertex and fragment shaders .vert and .frag extensions. But I've also seen .vsh and .fsh extensions, and even both shaders together in a single .glsl file. So I'm wondering if there is a standard file format, or which way is the 'correct' one? There is no standard file extension for GLSL shaders. The most common ones are probably .vert and .frag , as these are the extensions that 3D Labs used in some of their tools. But that's about it for any form of standard extension. There's no official

Curved Frosted Glass Shader?

南笙酒味 提交于 2019-11-28 14:30:37
Well making something transparent isn't that difficult, but i need that transparency to be different based on an object's curve to make it look like it isn't just a flat object. Something like the picture below. The center is more transparent than the sides of the cylinder, it is more black which is the background color. Then there is the bezel which seems to have some sort of specular lighting at the top to make it more shiny, but i'd have no idea how to go about that transparency in that case. Using the normals of the surface relative to the eye position to determine the transparency value?

HLSL: Enforce Constant Register Limit at Compile Time

青春壹個敷衍的年華 提交于 2019-11-28 14:27:41
In HLSL, is there any way to limit the number of constant registers that the compiler uses? Specifically, if I have something like: float4 foobar[300]; In a vs_2_0 vertex shader, the compiler will merrily generate the effect with more than 256 constant registers. But a 2.0 vertex shader is only guaranteed to have access to 256 constant registers, so when I try to use the effect, it fails in an obscure and GPU-dependent way at runtime. I would much rather have it fail at compile time. This problem is especially annoying as the compiler itself allocates constant registers behind the scenes, on

What's the origin of this GLSL rand() one-liner?

旧巷老猫 提交于 2019-11-28 14:23:23
问题 I've seen this pseudo-random number generator for use in shaders referred to here and there around the web: float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } It's variously called "canonical", or "a one-liner I found on the web somewhere". What's the origin of this function? Are the constant values as arbitrary as they seem or is there some art to their selection? Is there any discussion of the merits of this function? EDIT: The oldest reference to this

Which graphics card is used when working with OpenGL shaders over RDP?

孤者浪人 提交于 2019-11-28 12:42:31
问题 I'm taking an introductory OpenGL development course with a Surface Pro, and was hoping to connect to my more powerful desktop for development through the native Windows remote desktop tool. I'm having trouble with the shaders on my first test program, which leads to my question. Will the shader work be done by the graphics card on my Surface (RDP client) or my desktop (RDP host)? 回答1: That depends on your remote system's configuration. Your usual consumer GPU with standard drivers will not

Pixel-perfect shader in Unity ShaderLab

喜欢而已 提交于 2019-11-28 12:03:13
In Unity, when writing shaders, is it possible for the shader itself to "know" what the screen resolution is, and indeed for the shader to control single physical pixels? I'm thinking only of the case of writing shaders for "2D" objects (such as for UI use, or at any event with an ortho camera). (Of course, normally to show a physical-pixel perfect PNG on screen, you merely have a say 400 pixel PNG, and you arrange scaling so that the shader, happens to be drawing to, precisely 400 physical pixels. What I'm wondering about is a shader that just draws, for example a physical-pixel perfect black

360 viewer in unity, texture appears warped in the top and bottom

流过昼夜 提交于 2019-11-28 11:36:42
I am making a 360 viewer in unity, to view a 360 photo I used to have a cubemap attached to a skybox, and it worked great. But the weight of the cubemaps forced me to switch to textures. All of the 360 viewer tutorials say to just put a sphere with a shader on it, and put the camera inside. When I do this, it doesn't work very well, because when I look to the top or bottom, I see the image warped like so: (The chairs are suppossed to look normal) It did not happen when I used a skybox. Does any one know why is this happening? Thank you very much! The shader you choose does not handle

How does vertex shader pass color information to fragment shader?

≡放荡痞女 提交于 2019-11-28 09:01:48
In a simple hello-world OpenGL program, which simply draws a static triangle on the window, when I set the 3 vertex of the triangle to red, green and blue color, the triangle is filled with gradient. But when I use shaders like this: Vertex Shader: attribute vec4 aVertex; attribute vec4 aColor; varying vec4 vColor; void main(void) { gl_Position = gl_ModelViewMatrix * gl_ProjectionMatrix * aVertex; vColor = aColor; } where the attributes aVertex and aColor comes from a vertex buffer, passed through a call of glVertexAttribPointer . Fragment Shader: varying vec4 vColor; void main(void) { gl