shader

OpenGL bool uniform?

风流意气都作罢 提交于 2019-12-06 18:11:13
问题 I'm trying to send a boolean to an OpenGL glsl shader. Currently I have this in the shader: uniform bool foo; And I use this to set it: glUniform1i(glGetUniformLocation(shader, "foo"), true); There doesn't seem to be a glUniform1b , so I'm setting it as an integer. This seems to work fine. Is there any problem with this approach? Is it portable, or could it break on other graphics cards / drivers? I'm using OpenGL 4.3 at the moment. 回答1: § 4.1 Basic Types The OpenGL Shading Language supports

Why do I need to define a precision value in webgl shaders?

我与影子孤独终老i 提交于 2019-12-06 17:39:09
问题 I'm trying to get this tutorial to work but I ran into two issues, one of which is the following. When I run the code as is I get an error in the fragment shader saying: THREE.WebGLShader: gl.getShaderInfoLog() ERROR: 0:2: '' : No precision specified for (float) . So what I did was specifying a precision for every float/vector I define like so varying highp vec3 vNormal . This eliminates the error but I don't get why? I can't find any other example where precision values are added to variable

openGL: lines with shaders

拜拜、爱过 提交于 2019-12-06 17:10:46
问题 How would I create a line (possibly colored) with shaders? I'm using programmable pipeline and I'm a beginner with openGL. I can't find an example on how to draw lines with shaders.. I suppose I have to load a VAO (vertices array object) into the shader, but then what? What functions should I use and how? 回答1: First, set use the shaderprogram. Then draw lines using glDrawArrays (or Elements if your data is indexed) with mode=GL_LINES or one of the other line drawing modes. Here's a code

Get image pixels using mask

*爱你&永不变心* 提交于 2019-12-06 15:25:54
问题 So i have some original image. I need to get and display some part of this image using specific mask. Mask is not a rectangle or a shape. It contains different polygons and shapes. Are there any methods or tutorials how to implement that? Or from where to start to make this? Shall i write some small shader or compare appropriate pixels of the images or something like this? Will be glad for any advises. Thank you 回答1: You can put your image in a UIImageView and add a mask to that image view

Physically Based Shader Development for Unity 2017 Develop Custom Lighting Systems

我们两清 提交于 2019-12-06 14:07:50
Part I: Introduction to Shaders In Unity Chapter 1: How Shader Development Works Chapter 2: Your First Unity Shader Chapter 3: The Graphics Pipeline Chapter 4: Transforming Coordinate Spaces Chapter 5: Your First Unity Lighting Shader Chapter 6: Specular Implementation Chapter 7: Surface Shaders Part II: Physically Based Shading Chapter 8: What Is Physically Based Shading? Chapter 9: Making a Shader Physically Based Chapter 10: Post-Processing Effects Chapter 11: BRDFs Who's Who Chapter 12: Implementing a BRDF Chapter 13: Hooking Into the Standard Shader Chapter 14: Implementing Advanced

Only glsl shader version 120 works on mac OS X

家住魔仙堡 提交于 2019-12-06 12:57:29
问题 I have a problem with the glsl's version on my mac os X 10.9.2. I'm making a program in c++ with OpenGL and SDL2 I can't upgrade from my version 120 to any version higher. How I can upgrade please ? I compile like this : g++ and my flag is : -framework SDL2 -lSDLmain -framework OpenGL -framework SDL2_image -framework cocoa ERROR: 0:3: '' : version '330' is not supported 回答1: On OS/X 10.9 to create an OpenGL 3.3/4.1 context you need to add the following snippet before SDL_CreateWindow . SDL

What vertex shader code should be used for a pixel shader used for simple 2D SpriteBatch drawing in XNA?

落花浮王杯 提交于 2019-12-06 11:06:16
问题 Preface First of all, why is a vertex shader required for a SilverlightEffect (.slfx file) in Silverlight 5? I'm trying to port a simple 2D XNA game to Silverlight 5 RC, and I would like to use a basic pixel shader . This shader works great in XNA for Windows and Xbox, but I can't get it to compile with Silverlight as a SilverlightEffect. The MS blog for the Silverlight Toolkit says that "there is no difference between .slfx and .fx", but apparently this isn't quite true -- or at least

WPF Shader Effect - antialiasing not showing

最后都变了- 提交于 2019-12-06 10:37:27
I am running to a problem where I have a WPF shader effect (modified from Rene Schulte) to simulate Dot Matrix Display (DMD). Everything works great, but all dots are aliased. See attached image. I tried many features within WPF, to bring antialiasing, nothing to do. in constructor (image within a textbox); RenderOptions.SetBitmapScalingMode(MarqueeTB, BitmapScalingMode.HighQuality); RenderOptions.SetEdgeMode(MarqueeTB, EdgeMode.Unspecified); RenderOptions.SetClearTypeHint(MarqueeTB, ClearTypeHint.Enabled); I don't think it is my graphic card or Windows config. I did some testing on two PCs,

How to use a shaderModifier to alter the color of specific triangles in a SCNGeometry

喜夏-厌秋 提交于 2019-12-06 10:20:09
问题 First, before I go on, I have read through: SceneKit painting on texture with texture coordinates which seems to suggest I'm on the right track. I have a complex SCNGeometry representing a hexasphere. It's rendering really well, and with a full 60fps on all of my test devices. At the moment, all of the hexagons are being rendered with a single material, because, as I understand it, every SCNMaterial I add to my geometry adds another draw call, which I can't afford. Ultimately, I want to be

How to use shaders in MonoGame?

懵懂的女人 提交于 2019-12-06 09:27:32
Can someone tell me, how to use shaders in monogame? I have this error: https://gamedev.stackexchange.com/questions/46994/has-anyone-got-the-krypton-lighting-engine-working-in-monogame-for-windows-8 I tried to use 2MGFX, but the tool reports: The effect must contain at least one technique and pass. From what I can see from myshader.fx the file, it does. Here is my shader code: sampler TextureSampler : register(s0); float _valueAlpha = 1; float _valueRGB = 1; float4 main(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0 { // Look up the texture color. float4 tex = tex2D