shader

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

Optimizing performance of a heavy fragment shader

青春壹個敷衍的年華 提交于 2019-12-12 14:06:16
问题 I need help optimizing the following set of shaders: Vertex: precision mediump float; uniform vec2 rubyTextureSize; attribute vec4 vPosition; attribute vec2 a_TexCoordinate; varying vec2 tc; void main() { gl_Position = vPosition; tc = a_TexCoordinate; } Fragment: precision mediump float; /* Uniforms - rubyTexture: texture sampler - rubyTextureSize: size of the texture before rendering */ uniform sampler2D rubyTexture; uniform vec2 rubyTextureSize; uniform vec2 rubyTextureFract; /* Varying

Unity3D - Shader for sprite clipping

旧时模样 提交于 2019-12-12 12:01:30
问题 I am trying to create a shader that can be used to clip 2D sprites in a game, I found this shader in another question Shader "Sprites/ClipArea" { Properties { _MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {} _Length ("Length", Range(0.0, 1.0)) = 1.0 _Width ("Width", Range(0.0, 1.0)) = 0.5 } 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

OpenGL ES: flat shading without duplicating vertices?

大城市里の小女人 提交于 2019-12-12 10:37:58
问题 Is there a way in OpenGL ES to do flat shading without repeating each vertex for every triangle? In regular OpenGL this is done with glShadeModel but in ES I write the shaders so its not that simple. GLSL 1.3 or 1.4 (not sure) introduces the keyword flat which seem to enable this but unfortunately ES 2.0 doesn't have this yet. Yet another way to do this uses dFdx , dFdy functions which, alas, are also missing in ES. 回答1: No, flat-shading is not a feature of OpenGL ES 2.0, sorry. 来源: https:/

Threejs DataTexture Not Updating

天涯浪子 提交于 2019-12-12 10:16:30
问题 UPDATE: Issue was that texData object was recreated each time and thus reference for DataTexture was lost. Solution by WestLangley was to overwrite the data in texData instead of recreating texData object. I have a simple threejs scene with a DataTexture in a ShaderMaterial . The data array passed to it once during initialization is updated on mouse events. However the DataTexture does not seem to update. Did i assign uniforms or texture data wrongly? Or using the needsUpdate flags wrongly?

Unity 3d Sprite Shader (How do I limit Max Brightness to 1 with Multiple Lights Hitting)

送分小仙女□ 提交于 2019-12-12 10:09:23
问题 I am creating a videogame in Unity. Every sprite is rendered with a Sprite Renderer with a Material that has the CornucopiaShader.shader. The problem I have is I want to limit the max brightness (or color) of the sprite to just be a normal image of the sprite regardless of the power of how many point lights are hitting it, the intensity of the lights, and also the ambient light in the unity scene. When the intensity of the lights hitting the sprite is below that max brightness level I want it

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

Calculating screen texture coordinates in CG/HLSL

纵然是瞬间 提交于 2019-12-12 09:13:24
问题 In OpenGL , sometimes when doing multi-pass rendering and post-processing I need to apply texels to the primitive's assembly fragments which are part of full screen texture composition.That is usually the case when the current pass comes from FBO texture to which the screen quad had been rendered during previous pass.To achieve this I calculate objects UV coordinates in SCREEN SPACE .In GLSL I calculate it like this: vec2 texelSize = 1.0 / vec2(textureSize(TEXTURE, 0)); vec2 screenTexCoords =

Passing data through tessellation shaders to the fragment shader

眉间皱痕 提交于 2019-12-12 07:37:03
问题 I'm a bit confused about how the shader pipeline works with regards to passing data through each stage. What I'm trying to do is pass color data that is loaded in the vertex stage using glVertexAttrib4fv() through the tessellation control shader, and then the tessellation evaluation shader, so that it can be used in the fragment shader. I'm not sure if I've made some sort of conceptual mistake (quite possible, since I'm still trying to get my head around this over fixed functions), but either

Can't get ids assigned to an attribute in OpenGL

旧时模样 提交于 2019-12-12 06:47:28
问题 I am trying to have OpenGL automatically assign an ID to a glsl-attribute, but it is failing. My main program: #include <iostream> #include <GL/glew.h> #include <GL/glfw3.h> #include "test.h" #include "shader_utils.h" static void error_callback(int error, const char* description) { std::cout << description << std::endl; } static void key_callback(GLFWwindow* window, int a, int b) { if (a == GLFW_KEY_ESCAPE && b == GLFW_PRESS) { glfwSetWindowShouldClose(window, GL_TRUE); } } void test() { std: