shader

Volumetric Fog Shader - Camera Issue

流过昼夜 提交于 2019-12-11 06:03:59
问题 I am trying to build an infinite fog shader. This fog is applied on a 3D plane. For the moment I have a Z-Depth Fog. And I encounter some issues. As you can see in the screenshot, there are two views. The green color is my 3D plane. The problem is in the red line. It seems that the this line depends of my camera which is not good because when I rotate my camera the line is affected by my camera position and rotation. I don't know where does it comes from and how to have my fog limit not based

how to convert shadershop formula into glsl

不想你离开。 提交于 2019-12-11 05:57:19
问题 I have been learning some basic of shaders recently and I came up with a great visual tools : shadershop But I am having trouble to convert the formula I created in this site into glsl. A simple example, I created a formula in this site: And I am able to convert this in glsl: And then I moved on, I created a two dimension formula on shadershop : But this I just have no clue how to convert this formula into glsl just like I did before. Any advice will be appreciated, thanks :) UPDATE I tried

Mapping texture on 3DS VAO turns out mirrored

徘徊边缘 提交于 2019-12-11 05:50:06
问题 I implemented a 3ds modelloader following this tutorial. Currently my program uses VAOs do display things. This worked so far for simple cubes and tiles. Textures were displaying correctly. However, when I load the 3DS model into a VAO its a different sotry. The model looks correct concerning the vertices, but the texture is mirrored along the Y axis for some reason. This is how i read the UV: case 0x4140: qty = reader.ReadUInt16(); // 2 bytes UV[] texcoords = new UV[qty]; for (i = 0; i < qty

Performance of GLSL geometry shaders unexpectedly slow

假装没事ソ 提交于 2019-12-11 05:38:39
问题 I'm trying to learn how to program GLSL Geometry shaders. My test project works like this: I have N VBO's which are modeling "blades of grass". Without the shader, each blade of grass is just basically a line strip with 20 segments. I was able to get this animating more or less smoothly with almost N=10k blades so that's 200,000 lines. The shader takes each line segment and blows it out to a cylinder of the same length centered on that line segment, so the blades of grass are now tubes with

OpenGL uniform nof found if uniform block gets too big

徘徊边缘 提交于 2019-12-11 05:34:26
问题 I´m trying to implement a Uniform Block. This is how the block looks like in my fragment shader: struct Light { uint LightType; vec3 Direction; float SpotBlur; vec3 AmbientColor; float LinearAttenuation; vec3 DiffuseColor; float QuadraticAttenuation; vec3 SpecularColor; float CubicAttenuation; vec3 Position; float SpotCutoff; }; layout(std140) uniform LightBlock { Light values; } lights[32]; As you can see, I defined an array of the Light struct with a fixed size of 32. I can upload the data

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() {

Arc subdivision algorithm

我是研究僧i 提交于 2019-12-11 05:16:36
问题 I'm looking to sample from a texture along a circular arc in a fragment shader. That kind of rules out recursive methods such as this. I have come up with a few different ways to accomplish this: Two that seem the most reasonable are (Given start position p , center c , radius r = length(c-p) , angle (arc extent) theta in radians and N positions): 1) Rotate the vector p-c about c by theta/N , N times: This requires the construction of a rotation matrix which will be repeatedly used: cost is

Three.js shader pointLight to global position

此生再无相见时 提交于 2019-12-11 05:09:45
问题 All hello, I'm doing a fog shader and trying to add light sources. Recently I asked how to correctly determine the position of the light source, the question was solved, but another problem turned out, for the fog I use the position of the modelMatrix vec3 fogVPosition = (modelMatrix * vec4( position, 1.0 )).xyz To calculate the intensity of light, I use the calculation of the distance from the light source to the point of fog. float diffuseCoefficient = max( 1.0 - (distance(pointLights[i]

WebGL translation after rotation of the camera (as an FPS)

若如初见. 提交于 2019-12-11 04:59:17
问题 I've already done some projects with c++ and OpenGL, now I'm creating a simple project with html5 and WebGL. The problem is, after I rotate the camera, the movement is always along the default axes and not along the rotated ones. For example: I move forward -> no problem, I rotate the camera by 90 degrees right -> no problem, now I aspect that, if I go forward, the camera goes right on the world axes (so in front of the camera, as an FPS game) but the camera goes always towards the starting z

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;