Tag Info

New answers tagged

0

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)), ...


7

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 = ...


1

You don't specify what rendering method you want to use. Standard rasterisation of a 3D mesh? Or do you have a volume representation of the model and your renderer uses that directly? If you render a volume, check this: http://http.developer.nvidia.com/GPUGems/gpugems_ch39.html especially 39.2. The effect in the picture you provide is mainly subsurface ...


2

Yes. There an article about this by Chris­t­ian Schüler: http://www.thetenthplanet.de/archives/1180 It's a followup to a book article (ShaderX 5) which did exactly what you need. I've used it myself. Here is the part that you need: (p : world-space position, N : world-space normal) mat3 cotangent_frame( vec3 N, vec3 p, vec2 uv ) { // get edge vectors ...


0

That is explained here by Shawn Hargreaves, the Xna lead coder http://blogs.msdn.com/b/shawnhar/archive/2010/04/05/spritebatch-and-custom-shaders-in-xna-game-studio-4-0.aspx


2

I don't think any of the other answers here will achieve the effect in Pokémon X/Y. I can't know exactly how it's done, but I figured out a way which seems like pretty much what they do in the game. In Pokémon X/Y, outlines are drawn both around the silhouette edges and on other non-silhouette edges (like where Raichu's ears meet his head in the following ...


0

In the SpriteEffect source, the world matrix is actually float4x4 MatrixTransform



Top 50 recent answers are included