Tag Info

New answers tagged

0

The simplest and probably fastest option would be to iterate your mesh and set edges vertices transparency to 0 (or any other desired value). This assumes you v got (fan shaped)adjacency information: foreach(Triangle t in mesh) { for(int i = 0; i < 3; i++) { if(t.Adj[i] == - 1) //on edge { t.Vert[i].a = 0.f; t.Vert[(i ...


0

Found! (Thank you Frame Debugger !) It turns out that Unity renders the Depth Texture in a separate pass before all geometry is rendered. It is hard to find how to include objects in this pass, and how to specify how they are drawn. The documentation is kind of vague, but it tells you that the "RenderType" is important without specifying what it should ...


0

Your problem is where you commented out glBindFramebuffer(GL_FRAMEBUFFER, 0);. You need to bind to a different FBO there, otherwise you lose everything you just rendered when you call glClear a couple lines down. Because of this reading from and writing to the same FBO texture at once cannot work. You'll need a separate FBO and texture to write to.


1

The "tint" color is a color that gets modulated (multiplied) with the texture color. This color is used with sprites for effects like making the player sprite blink red when hit by an enemy. To do so, you could set the tint to red when the player gets hit and leave it red for a couple frames, them restore it to white. Do that repeatedly for a few seconds and ...


2

david van brink answered your question in general. But like he says, OpenGL driver could run stuff on the CPU, and it actually happens a lot. Especially with compatibility contexts, where some weird legacy functions cannot be implemented on the graphic cards. They require software emulation. For example, I've heard before that stippling is executed on the ...


5

Generally, Yes. Java is used to write programs that run on the cpu. Shader languages (cg,hlsl, et al) are used to write programs that run on the gpu. An exception to the rule would be using third party apis which can bridge the gap.


17

That's the gist of it. In principle, the platform could, conceivably, do whatever it wants. One could imagine an advanced operating system doing just-in-time translation of compiled code from, say, x86 to GPU code. Similarly, OpenGL drivers could run whatever it wants on the host CPU. But really, what you just described, is what happens.


0

I Googled extensively yesterday and today screwing around with a similar issue. It turns out that, when using SpriteBatch with a custom effect that samples from textures, you must explicitly asign the textures to a register other than 0. effect.Parameters["WorkingTexture"].SetValue(WorkingTexture); SpriteBatch assigns this texture to register 0 ...


2

The .fxo files are compiled shader files. Think of .obj/.o files for C and C++, but for HLSL. They're the result of running the shader compiler fxc.exe over your shader files. The advantages of .fxo files are three fold. First, the make reverse engineering of your shader code a bit more difficult, which is advantageous for some of the higher-end games with ...


0

For this kind of thing, it depends on what your goals is. If you're looking to ensure that lines are 1 pixel wide, then you could draw the grid using lines instead of textured triangles: However with ensuring that lines are 1 pixel wide, when they're so far away that the individual grid spaces are less than 1px, it will look like a solid: With your ...


0

You can't avoid this problem, you can try super sampling to make it less jarring ... but high frequency + high contrast works very bad in quantisize space. I go around this with a very small bit of blurring on the texture, it's counter intuitive but then you have more chance than a pixel pick a blur value and make the line looks antialiased on the texture, ...


0

The way you draw them, you have big cells that contain 10x10 small cells. Would it be acceptable to draw only the big cells when they're at a certain distance from the camera? That would be one possibility. Another would be to actually draw lines, like in a wireframe mesh. They are always exactly one pixel wide. That's all the ideas i have right now.


1

What makes you think this is the shader code that is slow ? In most machines nowadays, and especially mobile devices, the bottlenecks are not these purely calculation-fed (ALU loaded) shaders, but memory bandwidth. Memory bandwidth is used by framebuffers being fed to shaders as textures, or by the ROPs writing to the render target. Especially bad when ...


5

Sarting with the clouds, a simple method is to draw them as three layers: Layer 1 is the bottom layer, and is drawn first. It just contains the cyan background. Layer 2 is the middle layer, drawn between the other two, and it represents the 3D highlights. The background in this layer would again be transparent (represented by a purple colour in the ...


3

You could achieve this effect using parallax scrolling by making the earth and each shade of green a separate layer. With a parallax effect, no 3D calculations are required, and you get to stay with the pixelated, simple color style you're using. Note that parallax doesn't have to be limited to just horizontal motion. Vertical movement (when the camera ...


0

You can add a depth component to your 2D textures and set the depth value in the pixel shader. There will be some performance loss due to setting the depth in the pixel shader but shouldn't matter for a 2D game on PC. The other way is to use multiple layers of 2D textures for your background.


0

Unity cannot know which triangles are eliminated in the GPU shaders, it counts the number of triangles sent to the GPU, not just the ones that end up drawn. Using the discard keyword forces the shader to run on all pixels, breaking the GPU's hidden surface removal optimization. That is on top of processing all the triangles. If you want to eliminate ...


1

If you use a point sampler for your mask texture, then you can store as many IDs as bits in your texture: for a 32-bit RGBA texture you'd be able to store 128 different IDs. In such a case though, as you have a single bit per ID, there's virtually no blending as you have only 0 or 1. The more bits you devote per ID, the greater the blending granularity, ...


1

It is technically possible with OpenGL ES 2 but almost no device currently support it. You'll have to check GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS on devices. For small "textures" you can use a small array of uniforms. A lot of (old) desktop video cards still in use only supports GL_LUMINANCE32F_ARB and GL_RGBA32F_ARB or don't support any VTF at all. If you ...


0

Officially the uniform keyword indicates it is constant throughout the execution. All uniform variables to a shader must be resolved at compile-time. The HLSL compiler using the legacy Effects profile will generate 3 shaders in this case: A vs_4_0 profile vertex shader using the VS entry-point A ps_4_0 profile pixel shader using the PS entry-point holding ...


0

Disable blending when rendering your depth texture. Or use an actual depth texture as depth buffer in a frame buffer object then use that depth texture in later passes with a sampler.


1

To fix these kinds of issues create a test cubemap clearly marking each face directions and +/- XYZ you can then figure out which one(s) is(are) pointing the wrong way.


9

I tried to implement what teodron suggested: void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; float sepoffset = 0.005*cos(iGlobalTime*3.0); if (uv.y > 0.3 + sepoffset)// is air - no reflection or effect { gl_FragColor = texture2D(texture, vec2(uv.x, -uv.y)); } else { // Compute the mirror effect. ...


0

Depending on the way your matrix type stores its values you may have to transpose the matrix to get the transformation right. You can use the boolean parameter of glUniformMatrix4fv(); to do that. And the way you're applying the transformation in the vertex shader is omitting the translation part. Use it this way: gl_Position = modelToViewWorld * ...



Top 50 recent answers are included