fragment-shader

Get accurate integer modulo in WebGL shader

拜拜、爱过 提交于 2020-01-01 10:49:13
问题 I want to get an accurate modulo of x and y in a WebGL fragment shader. x and y are integers. Graphing mod(x,y) , we get the following: The actual code used to generate the red-and-black rectangle is: gl_FragColor = vec4(mod( float(int(v_texCoord[0]*15.))/15., float(int(v_texCoord[1]*15.))/15. ), 0, 0, 1); Where v_texCoord is a vec2 ranging from 0,0 at the top-left to 1,1 at the bottom-right. Precision is set to mediump for both float and int. Reading the chart, we see that although mod(6,6)

GLSL shader for texture cubic projection

拜拜、爱过 提交于 2019-12-24 10:17:59
问题 I am trying to implement a texture cubic projection inside my WebGL shader, like in the picture below: What I tried so far: I am passing the bounding box of my object (the box in the middle of the picture) as follows: uniform vec3 u_bbmin; uniform vec3 u_bbmax; ... so the eight vertexes of my projection box are: vec3 v1 = vec3(u_bbmin.x, u_bbmin.y, u_bbmin.z); vec3 v2 = vec3(u_bbmax.x, u_bbmin.y, u_bbmin.z); vec3 v3 = vec3(u_bbmin.x, u_bbmax.y, u_bbmin.z); ...other combinations vec3 v8 = vec3

glsify - error 'You may need an appropriate loader to handle this file type'?

无人久伴 提交于 2019-12-24 07:29:30
问题 Ok Im following https://tympanus.net/codrops/2019/01/17/interactive-particles-with-three-js/ just trying to get his custom shader to work. I brought in the .frag and .vert files (included in the link) and copied how his setup. When I run I get the error Module parse failed: Unexpected token (3:10) You may need an appropriate loader to handle this file type. Here: const material = new THREE.RawShaderMaterial({ uniforms, vertexShader: glslify(require('./vendor/shaders/particle.vert')), //HERE!!

Apply Projection on half of texture

我的梦境 提交于 2019-12-24 06:16:31
问题 I'm using three glcontrols say GlControl1, GlControl2, GlControl3. And I have two textures stexture1 and stexture2. Where stexture1 is displaying in glcontrol2. And right half portion of stexture2 is displaying on glcontrol1 and left half is dispalying on glcontrol3. Now I want to apply projection on these three glcontrols. Using this link I can apply it successfully on glcontrol2 since it is displaying the texture fully. But when applying on glcontrol1 and glcontrol3 it is not working well.

GLSL: shader linking fail (but no log)

霸气de小男生 提交于 2019-12-24 01:54:16
问题 I'm trying to create a little shader for brightness and contrast of the window (that I've seen here). I can load the file, and compile the shader successfully. But I fail to link it. My problem is that the log has no output, so I can't see what's wrong with it. How can I check the linking problem? Where can I find informations about linking failing, and check why linking can fail (I'm new to shaders). I'm using Ubuntu 12.04. This is the initialization code if (GLEW_ARB_fragment_shader) { // I

GLSL: shader linking fail (but no log)

感情迁移 提交于 2019-12-24 01:54:14
问题 I'm trying to create a little shader for brightness and contrast of the window (that I've seen here). I can load the file, and compile the shader successfully. But I fail to link it. My problem is that the log has no output, so I can't see what's wrong with it. How can I check the linking problem? Where can I find informations about linking failing, and check why linking can fail (I'm new to shaders). I'm using Ubuntu 12.04. This is the initialization code if (GLEW_ARB_fragment_shader) { // I

Change the intensity of an image by comparing intensity of another image - OpenTK

孤街浪徒 提交于 2019-12-23 18:09:40
问题 I have two images. I have to found the points of first image which have intensity greater than 0.8. At the same time I have to found the intensity of second image on same points and need to adjust the light on second image on same points with a threshold/slider value(ranges from 0 to 1). I have done like below. Getting black or dark area on points have intensity greater than 0.8. I'm trying with z value of HSV. But instead of this black area I should be able to adjust the light on image2. How

drawing line using vertex shader & fragment shader in spritkit in swift

夙愿已清 提交于 2019-12-23 01:07:08
问题 I need to draw a line between two spritnodes while hand is pointing from one node to another with rendering or animation. The line drawing is working for me as I follow this link Bobjt's answer, Animate Path Drawing in SpriteKit . I have used concept of fragment shader and vertex shader here.. I have added animatestroke.fsh file and apply the following code .. But the handplayer animation and line drawing speed is mismatching some times. my line rendering i have given increment by

Multiple subroutine types defined in the same fragment shader does not work correctly using GLSL Shaders

最后都变了- 提交于 2019-12-22 17:54:23
问题 I'm working on a program using GLSL shaders. I coded 2 different ways to compute ADS (Ambient + Diffuse + Specular) shading in 2 different methods. To do the job properly I used subroutines to use one or the other method to compute ADS shading. Here's a piece of the fragment shader code : subroutine vec3 LightShadingEffectType(int idx, vec3 normal, vec3 lightDir); subroutine uniform LightShadingEffectType LightShadingEffect; subroutine (LightShadingEffectType) vec3 Basic_ADS_Shading(int idx,

Multiple subroutine types defined in the same fragment shader does not work correctly using GLSL Shaders

亡梦爱人 提交于 2019-12-22 17:54:03
问题 I'm working on a program using GLSL shaders. I coded 2 different ways to compute ADS (Ambient + Diffuse + Specular) shading in 2 different methods. To do the job properly I used subroutines to use one or the other method to compute ADS shading. Here's a piece of the fragment shader code : subroutine vec3 LightShadingEffectType(int idx, vec3 normal, vec3 lightDir); subroutine uniform LightShadingEffectType LightShadingEffect; subroutine (LightShadingEffectType) vec3 Basic_ADS_Shading(int idx,