glsl

Geometry shader producing gaps between lines

荒凉一梦 提交于 2019-12-12 17:49:45
问题 I wrote a geometry shader to compute the intersection contour of a mesh and a plane, but at the intersection points there are sometimes 1 pixel wide gaps between two lines. The shader first computes the signed distances of the triangle vertices to the plane. It then checks if two distances have a different sign to determine if there is an intersection with an edge. If so, it emits a vertex at the intersection, which is computed as the weighted average between the edge points. #version 330

Can glsl be used instead of webgl?

杀马特。学长 韩版系。学妹 提交于 2019-12-12 17:27:50
问题 This may be a bit of a naive question so please go easy on me. But I was looking at shaders at shadertoy.com and I'm amazed at how small the glsl code is for the 3d scenes. Digging deeper I noticed how most of the shaders use a technique called ray marching. This technique makes it possible to avoid using vertices/triangles altogether and just employ the pixel shader and some math to create some pretty complex scenes. So I was wondering why is it that 3d scenes often use triangle meshes with

How to create and use very large palette textures for use in opengl?

被刻印的时光 ゝ 提交于 2019-12-12 17:25:42
问题 Details: I have a glsl fragment shader with a uniform texture, "u_MapTexture" with several thousand colors on it (max of about 10k-15k unique rgb values). I also have a uniform palette texture ("u_paletteTexture") that is 16384 × 1 that I want to use to index the colors on u_MapTexture to. My problem is that no matter what I try mathematically, I can't seem to properly index the colors from the first texture to the palette texture using the RGB values of the passed color. Amy thoughts or

GLSL How to retrieve vertex position after a shader process it?

谁说胖子不能爱 提交于 2019-12-12 16:45:01
问题 I wrote a program that simulates soft bodies using springs. It looks nice but the problem is it consumes a lot of CPU time. So I can not run it on my laptop or any not high end PC. I thought It would be a good idea to write a vertex shader and move the logic to the GPU. I've read some tutorials and made a toon shader so I thought (wrong) I was ready to go. The big problem I have is that I need to know the old position of a vertex to calculate the new one. I don't know how could I retrieve a

Reading OpenGL Shader Language from .glsl File

爱⌒轻易说出口 提交于 2019-12-12 15:23:11
问题 I am trying to read shader strings from a file; however, I faced with a problem at glShaderSource() function line. As you know, glShaderSource() takes const char** , and I have to declare char * for reading from the file. So, I am using casting to convert types. If I use const_cast<const char **> , the shape appears; however, it has wrong color (It should be orange not white). If I use reinterpret_cast<const char**> , I get a Access violation reading location 0x73726576 error in running time.

Getting rendered Screen as (feedback-) Texture (Shadtertoy)

*爱你&永不变心* 提交于 2019-12-12 14:22:44
问题 Is it possible to access a rendered image (GLSL) in the next frame with shader toy? 回答1: Now they have implemented rendering to buffers, so you can render to buffer. Actually, you can use up to four buffers, if you need. Also, watch useful demo. 回答2: No. There is no access to previously rendered frames. 来源: https://stackoverflow.com/questions/33634861/getting-rendered-screen-as-feedback-texture-shadtertoy

GLSL Atmospheric Scattering Not Scaling With Transformations

余生长醉 提交于 2019-12-12 13:52:31
问题 I am trying to implement atmospheric scatting in GLSL version 4.10. I am adapting the shaders from the this Shadertoy shader https://www.shadertoy.com/view/lslXDr. The atmosphere in my program is created from a scaled version of the planet sphere. I have the actual scattering equations working, but the inner radius of the atmosphere does not line up with the outer radius of the sphere for most camera positions. I know this is from the radius of the atmosphere being bigger than the planet

In a fragment shader, why can't I use a flat input integer to index a uniform array of sampler2D?

↘锁芯ラ 提交于 2019-12-12 11:01:30
问题 new to shaders here, and a bit puzzled. I want to specify textures to be used when I render an array of sprites. So I put a texture index in their vertex data, and pass it as a flat value from my vertex shader to my fragment shader, but can't use it to index an array of samplers as expected because compiler sees it as "non-constant". Instead I have to resort to the disgusting code below. Can anyone explain what is going on here? const int numTextures = 2; uniform sampler2D textures

OpenGL: Gamma corrected image doesn't appear linear

孤街浪徒 提交于 2019-12-12 09:39:05
问题 I'm using OpenGL for rendering, and when I write linear values to the default framebuffer (without any gamma correction) they appear linear on my monitor. This goes against everything I thought I knew about gamma correction (as explained here: http://gamedevelopment.tutsplus.com/articles/gamma-correction-and-why-it-matters--gamedev-14466 ). Without gamma correction, I would expect to see mid-range colors darkened non-linearly by my monitor. But here is what I actually see; first with no gamma

WebGL and HTML shader-type

吃可爱长大的小学妹 提交于 2019-12-12 09:30:37
问题 I declare my GLSL ES shader program within a HTML file, using this code: <script id="shader-fs" type="x-shader/x-fragment">..shader-code..</script> as seen in the learning WebGL examples. Everything works fine, but I dont understand why I should use the type attribute of the script tag. I want to know where the "x-shader/x-fragment" value is specified. Who does that.. the W3C, the Khronos Group or the browser developers? Can anybody help me? Tahnk you. 回答1: There is no official organization