shader

Passing an array of vec2 to shader in THREE.js

时光总嘲笑我的痴心妄想 提交于 2019-12-05 21:54:23
I've been searching the web for a while now and did not find the correct answer yet. I found the list of uniform types THREE.js uses, and I think the following code should be correct. At the last line I define an uniform array of Vector2. uniforms: { "center": { type: "v2", value: new THREE.Vector2( 0.5, 0.5 ) }, "aspectRatio": { type: "f", value: null }, "radius": { type: "f", value: 0.1 }, "pointList": { type: "v2v", value: [] }, }, In my js script I pass this array as follows. This should work too, I guess: // Add effects effect = new THREE.ShaderPass( THREE.MetaBalls2D ); effect

How to make a shader fade to a color?

ε祈祈猫儿з 提交于 2019-12-05 21:46:11
This is the current shader I am using. It fades the object by slowly reducing the opacity. I want to fade to purple. How can this be done? shader.frag: uniform sampler2D texture; uniform float opacity; void main() { vec4 pixel = texture2D(texture, gl_TexCoord[0].xy); gl_FragColor = pixel * vec4(1.0, 1.0, 1.0, opacity); } shader.vert: void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; gl_FrontColor = gl_Color; } application of shader in main function: sf::Shader shader; if (!shader.loadFromFile("shader.vert", "shader

OpenGL - Texture mapping in vertex or fragment shader?

时间秒杀一切 提交于 2019-12-05 21:40:56
Is there texture of an object/triangles mapped in the fragment shader or the vertex shader? Whether if it is on the vertex or fragment shader, if you are programming shaders it's something that you have to code yourself right? Without shader you just assinged the tex coords and opengl mapps it without you knowing, but with shaders you have to do it yourself, right? fen Usually the texturing happens in the fragment shader. This is the place where triangle's fragments gain a color. Usually in the vertex shader you calculate texture coords (or simply pass them through from vertex attribs without

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

别来无恙 提交于 2019-12-05 21:19:18
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 = texture2D(u_textureSprite, u_isSprite ? gl_PointCoord : v_textureCoord); if (u_isSprite) { gl

Metal shader in SceneKit to outline an object

≯℡__Kan透↙ 提交于 2019-12-05 21:17:38
I'm playing around and trying to implement Metal shader in SceneKit that will outline an object. The idea is to draw an outline (or silhouette) similar to this image found in this blogpost (the blogpost doesn't contain any code): I'm new to SceneKit and Metal shaders so I'm able just to draw some geometry and write simple vertex or fragment shader. I'm curious how can I achieve this kind of effect? Is it done in multiple passes? Cheers! The basic idea here is to clone the "selected" node and its geometry, then use a custom vertex and fragment shader to "push" the geometry out along the vertex

DirectX world view matrix multiplications - GPU or CPU the place

醉酒当歌 提交于 2019-12-05 19:58:54
I am new to directx, but have been surprised that most examples I have seen the world matrix and view matrix are multiplied as part of the vertex shader, rather than being multiplied by the CPU and the result being passed to the shader. For rigid objects this means you multiply the same two matrices once for every single vertex of the object. I know that the GPU can do this in parallel over a number of vertices (don't really have an idea how many), but isn't this really inefficient, or am I just missing something? I am still new and clueless. In general, you want to do it on the CPU. However,

fastbuild联编ue4 shader的使用

巧了我就是萌 提交于 2019-12-05 19:32:48
1. 更新\Engine\Binaries\ThirdParty\FastBuild,进入Engine\Binaries\ThirdParty\FASTBuild目录 有一个setting.bat文件 setx FASTBUILD_BROKERAGE_PATH "\\DESKTOP-5UA8611\FASTBuild" reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v FASTBuildWorker /t REG_SZ /d %~dp0FBuildWorker.exe /freg add HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v FASTBuildWorker /d %~dp0FBuildWorker.exe 第一句是远程存放每个client配置文件的路径,配到环境变量里面去。第二句表示设置开机启动,但我自己机器上并不好使。 运行该bat文件 重新启动机器 注意 如果安装某数字杀毒软件或者某讯管家 会拦截掉 甚至开机启动项注册不进去 那么就要修改注册表,将FBuildWorker.exe手动添加到开机启动的注册表里 win10系统在:“计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft

Add alpha to shader in Unity3D

两盒软妹~` 提交于 2019-12-05 19:05:19
I don't have any idea about shader programming but right now I need to add alpha to the shader that I want to use. Actually I want to fade in and fade out my sprite but it's not in the shader that I use. Shader : Shader "Sprites/ClipArea2Sides" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {} _Length ("Length", Range(0.0, 1.0)) = 1.0 _Width ("Width", Range(0.0, 1.0)) = 1.0 } SubShader { LOD 200 Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" } Pass { Cull Off Lighting Off ZWrite Off Offset -1, -1 Fog { Mode Off } ColorMask RGB Blend

Hello Triangle_练习二:创建相同的两个三角形,但对它们的数据使用不同的VAO和VBO

混江龙づ霸主 提交于 2019-12-05 17:45:29
2019/11/26 1 #include <glad/glad.h> 2 #include <GLFW/glfw3.h> 3 4 #include <iostream> 5 6 void framebuffer_size_callback(GLFWwindow* window, int width, int height); 7 void processInput(GLFWwindow *window); 8 9 // settings 10 const unsigned int SCR_WIDTH = 800; 11 const unsigned int SCR_HEIGHT = 600; 12 13 const char *vertexShaderSource = "#version 330 core\n" 14 "layout (location = 0) in vec3 aPos;\n" 15 "void main()\n" 16 "{\n" 17 " gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n" 18 "}\0"; 19 const char *fragmentShaderSource = "#version 330 core\n" 20 "out vec4 FragColor;\n" 21 "void main

Hello Triangle_练习一:添加更多顶点到数据中,使用glDrawArrays,尝试绘制两个彼此相连的三角形

那年仲夏 提交于 2019-12-05 17:44:19
2019/11/26 1 #include <glad/glad.h> 2 #include <GLFW/glfw3.h> 3 4 #include <iostream> 5 6 void framebuffer_size_callback(GLFWwindow* window, int width, int height); 7 void processInput(GLFWwindow *window); 8 9 // settings 10 const unsigned int SCR_WIDTH = 800; 11 const unsigned int SCR_HEIGHT = 600; 12 13 const char *vertexShaderSource = "#version 330 core\n" 14 "layout (location = 0) in vec3 aPos;\n" 15 "void main()\n" 16 "{\n" 17 " gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);\n" 18 "}\0"; 19 const char *fragmentShaderSource = "#version 330 core\n" 20 "out vec4 FragColor;\n" 21 "void main