FAQ Database Discussion Community


Overlaying a transparent color over a Texture with GLSL

glsl,lwjgl,slick2d,vertex-shader,blending
I have an image that I am loading using the Slick library, and the image renders fine without my shader active. When I use my shader to overlay a transparent color over the image the entire image is replaced by the transparent color. without the shader With the shader Vertex...

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

webgl,shader,fragment-shader,vertex-shader
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...

GLSL shading: The entire screen is colored instead of just a quad

c++,opengl,glsl,fragment-shader,vertex-shader
The shaders I've done shades the entire screen in red instead of shading only the quad I'm drawing. The way I've done things in my code is described here. #version 140 core // vertex shader in vec3 position; out vec3 color; void main(void) { gl_Position = vec4(position,1.0); color = vec3(1.0,0.0,0.0);...

OpenGl basic Vertex Shader

opengl-es,vertex-shader
I am new in shader concepts and I am trying to implement a sprite of 8x8 in OpenGL ES. I want to move the texture in the vertex shader but I cant figure out how to this, my code may be wrong, feel free to correct me If I change...

Threejs: PointCloudMaterial size compared to ShaderMaterial gl_PointSize with size attenuation

three.js,webgl,vertex-shader
I am curious to know what the relationship is between gl_PointSize and the size property within PointCloudMaterial. When I create a PointCloud with PointCloudMaterial and set the size property to 1, the size of the particles are far larger than when creating a PointCloud with a ShaderMaterial and setting the...

GLSL offsetting multitexture

opengl,glsl,shader,vertex-shader
How can I do something like this in GLSL shaders? vec2 attribute texture_sky; vec2 attribute texture_floor; if(texture_sky) gl_position = position+Xoffset; else gl_position = position; I want to move one texture over the other. Is it possible to do with the vertex shaders?...

How to draw a star in iOS OpenGL ES 2.0

ios,opengl-es-2.0,vertex-shader
This question has been asked before but the quite a few years ago in my searches. The answer was always to use texture mapping but what I really want to do is represent the star as a single vertex - you may think I'm copping out with a simplistic method...

GLSL can't compile a shader without interpolation (flat)

c++,glsl,fragment-shader,vertex-shader
I'm drawing a complete object with mutiple meshes from a single vertex/index buffer, and they have different textures. Thus, I thought of passing ID of texture along with the vertices from vertex shader to fragments in the fragment shader. The problem is disabling the interpolation. I'm using GLSL ver 3.3...

Why is a simple shader slower than the standard pipeline?

opengl,glsl,fragment-shader,vertex-shader
I want to write a very simple shader which is equivalent to (or faster) than the standard pipeline. However, even the simplest shader possible: Vertex Shader void main(void) { gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = ftransform(); } Fragment Shader uniform sampler2D Texture0; void main(void) { gl_FragColor = texture2D(Texture0, gl_TexCoord[0].xy); } Cuts...

What happens if Vertex Attributes not match Vertex Shader Input

opengl,attributes,glsl,vertex-shader,pixel-shader
As I know, if the vertex buffer has an attribute that shader does not use, there will be no problem. What happens if the vertex buffer does not have an attribute that the vertex shader uses for OpenGL? I know for DirectX11, nothing will draw if the attribute needed in...

WebGL heightmap using vertex shader, using 32 bits instead of 8 bits

opengl-es,webgl,vertex-shader,heightmap
I'm using the following vertex shader (courtesy http://stemkoski.github.io/Three.js/Shader-Heightmap-Textures.html) to generate terrain from a grayscale height map: uniform sampler2D bumpTexture; uniform float bumpScale; varying float vAmount; varying vec2 vUV; void main() { vUV = uv; vec4 bumpData = texture2D( bumpTexture, uv ); vAmount = bumpData.r; // assuming map is grayscale it...

Retrieve Vertices Data in THREE.js

three.js,textures,webgl,shader,vertex-shader
I'm creating a mesh with a custom shader. Within the vertex shader I'm modifying the original position of the geometry vertices. Then I need to access to this new vertices position from outside the shader, how can I accomplish this?

Implementing Normal Mapping using OpenGL/GLSL

opengl,glsl,fragment-shader,vertex-shader
I'm learning GLSL and trying to implement some lighting and mapping tricks. I'm working with ShaderDesigner tool. After coding normal mapping I recognized that my model illumination looks not real. Here is my code and some pictures. If it possible tell me what is my problem. Vertex Shader #define MAX_LIGHTS...

Primitive assembly performance

opengl,opengl-es,vertex-shader,vertex-buffer,index-buffer
I am currently experimenting with some terrain/height-map rendering. Each tile of that terrain is rendered with a VBO and IBO. For being able to draw subtiles easily, I ordered the indices using Morton coding and at this point some questions about primitive assembly came to my mind. Primitive assembly happens...

Colored Vignette Shader (the outer part) - LIBGDX

opengl-es,libgdx,opengl-es-2.0,shader,vertex-shader
I've seen lots of tutorials on vignette shaders just like these but none of them say how to change the color of the vignette, they only talk about applying sepia or grey shaders to the whole composite image. For example the video above gives the below code for the vignette...

Implementing a 32-bit heightmap vertex shader in threejs

opengl-es,webgl,vertex-shader,heightmap
I am attempting to repurpose the heightmap shader example found here into one that will work with 32-bits of precision instead of 8. The work-in-progress code is on github: https://github.com/bgourlie/three_heightmap The height map is being generated in .NET. The heights are within 0f...200f and converted into a 32-bit color value...

Check vertex visibility in OpenGL ES 2.0

c++11,matrix,opengl-es-2.0,vertex-shader,frustum
How can I check if vertex is visible in the most simple way? If my vertex shader looks like: void main(void) { vec4 glPosition = vec4(VTPosition.x * VTAspectRatio, VTPosition.y, VTPosition.z, 1.0); gl_Position = VTProjection * VTModelview * glPosition; } Can I check visibility on CPU the same way ? Vector4...

How vertex and fragment shaders communicate in OpenGL?

opengl,graphics,glsl,fragment-shader,vertex-shader
I really do not understand how fragment shader works. I know that vertex shader runs once per vertices fragment shader runs once per fragment Since fragment shader does not work per vertex but per fragment how can it send data to the fragment shader? The amount of vertices and amount...

three.js webgl custom shader sharing texture with new offset

three.js,webgl,shader,vertex-shader
I am splitting a texture 1024 x 1024 over 32x32 tiles * 32, Im not sure if its possible to share the texture with an offset or would i need to create a new texture for each tile with the offset.. to create the offset i am using a uniform...

Should Meshes with and without Skeleton use different Shaders?

c++,opengl,glsl,shader,vertex-shader
Should Meshes with and without Skeleton use different Shaders? Background: Right now my shader is constructed to handle meshes with skeletons. Each vertex takes 3 bone IDs, with respective bone weight. This works well for models with skeletons that I wish to animate, but I feel that it is a...