Tag Info

New answers tagged

0

I don't know of any plug and play solutions for it, but here is an algorithm that works in the pixel shader with just a texture as extra assets. The asset required is a small texture with a single row of some number of tiles, where the left most is the darkest and the right most the lightest. What happens then is (per frame): Take the buffer you want to ...


4

You can reduce the instruction count by using vector operations: e.g. instead of edr = bool4((w1.x < w2.x) && ir_lv1.x, (w1.y < w2.y) && ir_lv1.y, (w1.z < w2.z) && ir_lv1.z, (w1.w < w2.w) && ir_lv1.w); you can write edr = (w1 < w2) && ir_lv1; Operators in HLSL ...


4

I got this working. It does not use the hqx filter, it uses the xBR filter (which I prefer). For me, this is not a problem. If you require the hqx filter then you'll want to convert the .cg files into their appropriate XNA equivalent. For completeness and searching reasons, I will be editing the question to be more concise and then posting all the relevant ...


2

Bloom effect filters are usually circularly symmetric or isotropic. You can't achieve your goal by solely modifying the radial shape of the filter, since it won't break the symmetry. However, to implement the desired effect, you can use e. g. the stencil buffer to mask out the region you want to remain dark. Alternatively you can create a texture of the ...


1

Here's how I've approached this situation in Unity in the past: I create a custom shield shader that accepts some number of vector parameters (typically 3 or 4), each representing a recent hit. The xyz components are the position of the hit in local coordinates, and the w component is the intensity. Within the fragment shader, I compute the object-space ...


0

For the sad weary soul a decade from now who stumbles upon this question wishing for it to be answered: void main(void){ vec3 p1 = mix(tcPosition[0], tcPosition[3], gl_TessCoord.x);//may have to rearrange these numbers depending on your implementation vec3 p2 = mix(tcPosition[1], tcPosition[2], gl_TessCoord.x); vec3 pos = normalize(mix(p1, p2, ...


0

I figured it out. Hopefully this can help someone else. private short[] indexData = new short[] { 0, 1, 2, 2, 3, 0 }; private VertexPositionTexture[] CreateTriangles(Vector2 location, int width, int height) { /* this is what the index data tells us * * 2 ________________ 3 * |\ ...


0

In the code here : new VertexPositionTexture(new Vector3(1f, -1f, 0f), new Vector2(1, 1)), new VertexPositionTexture(new Vector3(-1f, -1f, 0), new Vector2(0, 1)), new VertexPositionTexture(new Vector3(-1f, 1f, 0), new Vector2(0, 0)), ...


8

You already know what you have to do, I'll just summarize it. There are three ways to solve your problem: Go ahead and make a conditional like you're saying, either by sampling the texture or by creating a separate uniform for this purpose. As you probably know, adding branching on a shader is almost never a good idea, and much less so in the fragment ...


0

If you could generate a texture which is about the normal on the surface of the object you want to show the shield. There is no need for shaders. First, you need to prepare a cellular texture like the reaction in the picture, which should be transparent. Then, about the reaction when hit by the beam. Then, you need to prepare a(maybe several) dome for ...


1

You can't rewrite that loop so that it can't be unrolled. GPUs do not in general support a varying number of attributes to be passed between stages. You can, however, eliminate the loop entirely. Just pass vPosWS to the fragment shader, and do the loop there. Then the unrolling will actually be helpful. Bonus: You don't waste an absurd amount of bandwidth ...


0

Unroll. The instruction cost is minimal - just a subtraction! You can try and put "[unroll]" (without quotes) just above the "for" line, or just unroll manually, but, really, unroll. You won't even have the comparison instruction for the for loop check.


1

I'm a newb to DirectX myself, but from what I've read, in HLSL, this: Texture textures[3]; Will actually be compiled like this: Texture textures0; Texture textures1; Texture textures2; So indexing into the array won't work.


2

One way of doing this is to when you are loading the model and creating the vertex layout. you could calculate a second set of normals. which would be the flat normals. Do so by taking the connecting triangles. and then put it into all the vertices. if there is more than one connecting pollygon, you could insert some indexing to make it easier to handle ...


3

You need two different models, because flat-shaded and smooth-shaded models normals are different. One of the ways is to generate 2 separate models and replace them with one another on demand. Another way is to make a single model prepared for flat shaded render (all vertices unique) and replace only normals when switching to flat/smooth shading. For ...


0

I don't really understand what is it that you're trying to do, but as far as I know, no, you can't do that. Oversimplifying, each window draws to a different texture, and the Desktop Window Manager (DWM) composes all of those textures into one big full screen texture, which is what you see. Generally, the DWM composition pipeline is a core part of Windows, ...


2

if you are trying to make a screensaver for example, they most usually go with screen capturing one time, then create a fullscreen borderless window and draw over the picture they took. Some games where you "destroy your desktop" with a hammer and it breaks in glass fashion, or other effects, also works like that. Some virus/jokes, also do that. If you want ...


1

It's a simple interpolation. Let's assume that your heights span -1 to 1, 0 is water surface and you have 3 colours: dark green, light green and white. A way to do what you want is to have the following color_from_height function in the pixel or fragment shader (depending on how efficient you want to be). In my shader below I visualize the gradient, but the ...


1

Typically, the MVP matrix (along with any other matrices you might be using) are specified using uniforms, for example: #version 330 in vec3 iPosition; // input from vertex attribute out vec3 vPosition; // output to fragment shader // other inputs/outputs for colors, texture coordinates, etc. as needed uniform mat4 uMVP; void main() { vPosition = ...



Top 50 recent answers are included