fragment-shader

OpenGL ES 2.0 - Multiple Programs or Shaders

佐手、 提交于 2019-12-11 05:57:02
问题 I currently have two programs, one program for solid lines and fills with a vertex-shader-for-solids and a fragment-shader-for-solids and a second program for textures with a vertex-shader-for-textures and a fragment-shader-for-textures. I swap the the two programs in and out using glUseProgram depending on what I am drawing. Is this a good solution? Or should I glAttachShader/glDetachShader from a single program? 回答1: Definitely, you're using the right solution. Binding a different program

how to write a cga shader in glsl?

左心房为你撑大大i 提交于 2019-12-11 05:25:27
问题 How to write a CGA shader that limit the palette to 4 colors and match the original colors with those (cyan, magenta, black, white)?? I'm working on Game Maker Studio Professional, that actually allows the using of shaders writing vertex and fragment code I already asked this question also in the yoyogames community and in the openGl forum someone answered me with this : varying vec2 v_vTexcoord; varying vec4 v_vColour; const mat3 rgb_to_wcm = mat3(1,-1, 0, 1, 0,-1, -1, 1, 1); void main() {

Weird behavior of OpenGL / glGetUniformLocation()

旧巷老猫 提交于 2019-12-11 04:48:47
问题 I just wanna do the basics... give the shaders information from my application. I tried everything and nothing worked because I can never figure out what is new and what is deprecated in OpenGL Vertex Shader: #version 420 core layout(location = 0) in vec2 p_rect; layout(location = 1) in vec2 p_clipRect; out vec2 texturePoint; void main() { gl_Position = vec4( p_rect, 0.0, 1.0 ); texturePoint = p_clipRect; } Fragment Shader: #version 420 core uniform sampler2D p_texture; in vec2 texturePoint;

Can I load a shader into My JavaScript code from an external text file?

佐手、 提交于 2019-12-11 03:26:35
问题 I learn WebGL . I see the tutorial has the code of shaders inside of JavaScript code as a usual string. For example: var VSHADER_SOURCE = 'void main(){\n' + ' gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n' + ' gl_PointSize = 10.0;\n' + '}\n'; I want to place the code of my shaders into the external text files and load them into my JavaScript code when it necessary. How can I do it right? I don't want mix the JavaScript code and shader code in the same source code file. I looked the sample

glClipPlane - Is there an equivalent in webGL?

情到浓时终转凉″ 提交于 2019-12-11 02:16:10
问题 I have a 3D mesh. Is there any possibility to render the sectional view (clipping) like glClipPlane in OpenGL? I am using Three.js r65. The latest shader that I have added is: Fragment Shader: uniform float time; uniform vec2 resolution; varying vec2 vUv; void main( void ) { vec2 position = -1.0 + 2.0 * vUv; float red = abs( sin( position.x * position.y + time / 2.0 ) ); float green = abs( cos( position.x * position.y + time / 3.0 ) ); float blue = abs( cos( position.x * position.y + time / 4

Will the fragment shader automatically clamp the color value to its range?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 20:06:35
问题 Will the fragment shader automatically clamp the color value to its range? Do I need to explicitly clam the value int he shader code? If I do not, and the shader automatically does clampping, does it mean it will save some processing time? 回答1: Yes, they are clamped automatically if the color buffer is in a normalized fixed-point format. Copied from the OpenGL 3.3 spec: Color values written by a fragment shader may be floating-point, signed integer, or unsigned integer. If the color buffer

OpenGL: Circle bevel with fragment shader?

倖福魔咒の 提交于 2019-12-10 18:17:55
问题 I'm trying to make a circular particle that looks like it's got a light shining on the top of it. Here's what I'm trying to get it to look like: And here's what it currently looks like: Not very good. Since I'm using GL_POINTS, I get the gl_PointCoord variable, which should make things easier, except I don't know how to use it properly, which led to this mess: varying lowp vec4 DestinationColor; void main(void) { lowp vec2 circCoord = 2.0 * gl_PointCoord - 1.0; if (dot(circCoord, circCoord) >

Render an SCNGeometry as a wireframe

大憨熊 提交于 2019-12-09 16:30:58
问题 I'm using SceneKit on iOS and I have a geometry I want to render as a wireframe. So basically I want to draw only the lines, so no textures. I figured out that I could use the shaderModifiers property of the used SCNMaterial to accomplish this. Example of a shader modifier: material.shaderModifiers = [ SCNShaderModifierEntryPointFragment: "_output.color.rgb = vec3(1.0) - _output.color.rgb;" ] This example apparently simply inverts the output colors. I know nothing about this 'GLSL' language I

Anti-Aliasing issue with MSAA, drawing CSG with depth and FBO

浪子不回头ぞ 提交于 2019-12-08 19:21:10
问题 I have reimplemented OpenCSG for modern OpenGL version. PixelFormatAttributes: NSOpenGLPFAColorSize , 24 , NSOpenGLPFAAlphaSize , 8 , NSOpenGLPFADepthSize , 32 , NSOpenGLPFAStencilSize , 8 , NSOpenGLPFAAccelerated , NSOpenGLPFADoubleBuffer , NSOpenGLPFASupersample , NSOpenGLPFASampleBuffers, 1 , NSOpenGLPFASamples , 4 , FBO specs: (tried render to FBO with multisample, but lines getting more strong and visible, look on screenshot at bottom) - created texture with power of 2, GL_RGBA (tried GL

Are 1D Textures Supported in WebGL yet?

我的未来我决定 提交于 2019-12-08 15:24:30
问题 I've been trying to find a clear answer, but it seems no one has clearly asked the question. Can I use a 1D sampler and 1D texture in WebGL Chrome, Firefox, Safari, IE, etc? EDIT Understandably 1 is indeed a power of 2 (2^0=1) meaning you could effectively use a 2D sampler and texture using a height of 1 and a width of 256 or 512 etc. to replicate a 1D texture. 1D textures are not moot, they exist because they not only have a purpose, but are intended to translate into optimizations on the