shader

OpenGL ES 2.0 Multiple shader programs - texture rendering not working anymore

风流意气都作罢 提交于 2019-12-22 09:58:09
问题 My app draws a mixture of point sprites and standard quad textures. Until recently, I was using a single shader program for this - however a branch in the fragment shader (to decide whether to use point sprite coords/colors) was seriously throttling the performance of my rendering. My fragment shader originally looked like this: precision highp float; uniform sampler2D u_textureSprite; uniform bool u_isSprite; varying vec4 v_color; varying vec2 v_textureCoord; void main() { vec4 textureColor

Transparent shader allows the objects below to show on top

ⅰ亾dé卋堺 提交于 2019-12-22 09:40:03
问题 In my scene, the smileys(Quad with png image) are placed at Y:0 and the dots(Quad with tiling 3X3) are placed at Y: -0.25. The shader I need to use for the smileys is Transparent-Diffuse as I am using a circle png image. But the dots I use below are showing up above the smiley. Using any other shader like Diffuse solves the issue but the smiley becomes a square. Screenshot: If you need any more clarifications please dont hesitate to ask. Edit: I have attached the shader details of both the

Passing custom type (struct) uniform from Qt to GLSL using QGLShaderProgram

坚强是说给别人听的谎言 提交于 2019-12-22 08:59:51
问题 I defined a struct for light parameters which contains two vectors. The struct is defined in both C++ and GLSL in an analogous way (note: QVector3D encapsulates 3 float s, not double s): C++ host program: struct LightParameters { QVector3D pos; QVector3D intensity; }; Fragment Shader: struct LightParameters { vec3 pos; vec3 intensity; }; In the fragment shader, I also define the following uniforms. The numbers of lights is limited to 8, so the uniform array has a constant size (but only

How do i display 2 or more objects in openGL (model - view - projection matrices and shaders)

爷,独闯天下 提交于 2019-12-22 05:09:30
问题 It's all ok when i want to draw one object, for example a cube. I create vertices for cube, i create the buffer, i create the MVP matrix and send it to shader and it works nice. But, what to do when i want to draw 2 or more objects , for example both cube and a triangle? I believe that View and Projection matrices should be same both for triangle and cube, i only need different Model matrix, right? So that means that i will have two MVPs? //Example (using GLM): glm::mat4 MVPC = Projection *

Why am I getting a blank screen when using shader?

折月煮酒 提交于 2019-12-22 01:30:53
问题 I'm using this tutorial to create and draw an outline for my game Sprite s. However, all I get is a blank red screen. I'm very new to Shader s so I'm not sure if I'm missing something very trivial. My vertex and fragment shaders were copy-pasted from the above tutorial. (Commenting on the tutorial doesn't seem to work so I was unable to seek help there.) My code: float x = 0, y = 0, height = 256, width = 256, angle = 0, outlineSize = 1f; @Override public void create() { batch = new

Possible Retina issue with OpenGL ES on iPhone?

耗尽温柔 提交于 2019-12-21 21:28:54
问题 This is probably linked to another unsolved mystery of mine. I'm drawing Orthographic 2d on iPhone, using real device and simulator. I'm trying to color my pixels a given color depending on how far they are from arbitrary point in pixelspace of 'A', which I pass in (hard code). I'm doing everything in Retina 960x640 resolution. I calculate distance from A to gl_FragCoord , and I color based on leaping between 2 colors with the 'max' being 300px distance. When on simulator (with retina display

Threejs Custom Shader - Screen Tearing

让人想犯罪 __ 提交于 2019-12-21 21:25:33
问题 So to implement a tilemap using Threejs and Brandon Jone's tilemap method (found here) I am using a THREE.Plane geometry for each layer, and painting the face with the following custom shaders: Vertex Shader: var tilemapVS = [ "varying vec2 pixelCoord;", "varying vec2 texCoord;", "uniform vec2 mapSize;", "uniform vec2 inverseTileTextureSize;", "uniform float inverseTileSize;", "void main(void) {", " pixelCoord = (uv * mapSize);", " texCoord = pixelCoord * inverseTileTextureSize *

Image2D in compute shader

孤街浪徒 提交于 2019-12-21 21:19:15
问题 I want to use image2D as 2D storage for vertices which will be modified by compute shader but things doesnt work. Create textures: glGenTextures(1, &HeightMap); glBindTexture(GL_TEXTURE_2D, HeightMap); glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA32F, 513, 513, 0,GL_RGBA32F, GL_UNSIGNED_BYTE, 0); Use and dispatch compute shader: glUseProgram(ComputeProgram); glActiveTexture(GL_TEXTURE0); glBindImageTexture(0, HeightMap, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F); glDispatchCompute(1, 1, 1 );

changing the intensity of lighten/darken on bitmaps using PorterDuffXfermode in the Android Paint class

主宰稳场 提交于 2019-12-21 20:34:12
问题 Ok my orignal question has changed. How do i change the intensity of how something like this is effected? DayToNight.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); in my dream world it would have worked like this DayToNight.setXfermode(new PorterDuffXfermode(Mode.DST_IN(10))); the 10 being a level of intensity. An example would be if I had a flickering candle, when the candle burns bright I want the bitmaps I am drawing to the screen to retain their origanol color and brightness, when it

Synchronisation in OpenGL [closed]

戏子无情 提交于 2019-12-21 19:54:11
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 7 days ago . I have just spent around five hours studying parts of the OpenGL 4.5 specification found here (or a slightly earlier version of it): https://www.khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf Unfortunately, I seem to be getting mixed messages. In section 5.3.1 “Determining