Search the Community
Showing results for tags 'Buffer'.
-
I'm trying to make a cel shaded shader and am working on the outline part. Everything seems to work well except for this: http://steamcommunity.com/sharedfiles/filedetails/?id=603858840 It seems to me like the normals past a certain depth are not uniform and I'm not really sure why. Or is this just Nyquist-like effect? If so, what would be the best way to handle this? This is the shader I wrote (there's a simple lua script that binds the diffuse, depth and normal textures): #version 400 uniform sampler2D texture1; //diffuse uniform sampler2DMS texture2; //depth uniform sampler2DMS texture3; //normal uniform vec2 camerarange; uniform bool isbackbuffer; uniform vec2 buffersize; out vec4 fragData0; #define width 2 float DepthToZPosition(in float depth) { return camerarange.x / (camerarange.y - depth * (camerarange.y - camerarange.x)) * camerarange.y; } void main(void) { vec2 texcoord = gl_FragCoord.xy/buffersize + 0.5/(buffersize*0.5); if (isbackbuffer) texcoord.y = 1.0 - texcoord.y; vec4 c = texture(texture1, texcoord); //Line Detection bool edge = false; float depth = DepthToZPosition(texelFetch(texture2,ivec2(texcoord*buffersize),0).x); float depth_temp = 0; vec3 normal = texelFetch(texture3,ivec2(texcoord*buffersize),0).xyz; normal=normal/length(normal); vec3 normal_temp = vec3(0); // Check adjacent pixels for (int x=-1; x<2; x+=2) for (int y=-1; y<2; y+=2) { depth_temp = DepthToZPosition(texelFetch(texture2,ivec2(texcoord*buffersize)+ivec2(x*width,y*width),0).x); normal_temp = texelFetch(texture3,ivec2(texcoord*buffersize)+ivec2(x*width,y*width),0).xyz; normal_temp = normal_temp/length(normal_temp); if ((abs(dot(normal_temp,normal)) < 1) && (abs(depth_temp-depth) > .1)) { edge = true; } } fragData0 = c; if (edge) { fragData0 = vec4(0,0,0,c.a); } }
-
Have anyone code exapmles with buffers using? In wiki it is VERY old
-
I've managed to get a Buffer (and Texture) filled with the current screen. I want to write it to a file, so my game will have a builtin screenshot feature. Leadwerks 2 apparently had a function SaveBuffer which would do exactly what I want, but as far as I can tell it doesn't exist or has been renamed to something else. So, before I try to manually write the bytes to a file, does anyone know if there is a current function for writing a buffer to an image file? (Or maybe there is complete function for taking a screenshot that I don't know about?) EDIT: How do I even get individual values out of a buffer?