Tag Info

New answers tagged

2

Simple lens shader that uses object's normals to distort the background. Render texture without this object, use it as "ScreenMapSampler" and then render all scene including this object in final frame. Not best implementation, but it works. struct PS_OUTPUT{float4 Color : COLOR0;}; struct VS_Lens { float4 Position: POSITION; float4 ...


0

This question already has been answered. See the second link here: http://stackoverflow.com/questions/12794428/calculating-world-space-coordinates-in-the-pixel-shader


0

Okay so, finally achieved my goal. view = Matrix.CreateScale(new Vector3(1, 0.75f, 1)) * Matrix.CreateTranslation(-playerpos.X, -playerpos.Y, 1); world = Matrix.Invert(view); projection = Matrix.CreateOrthographicOffCenter(0, view.Width, view.Height, 0, -1, 1); Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0); projection = halfPixelOffset ...


4

For best performance you should avoid changing uniforms as well as shaders by using vertex attributes. Ideally pack all your 2D object textures into 1 single large texture (called an atlas) so you can render all your 2D objects in one call using a single vertex buffer. In your large texture you also put a 4x4 white area and map the texture coordinates of ...


0

nailed it, for those having the same trouble, you should add two lines in the processor: EffectContent effectSource = new EffectContent(); effectSource.EffectCode = input.SourceCode; //Add these two lines: effectSource.Identity = new ContentIdentity(); effectSource.Identity.SourceFilename = input.name; //End of correction EffectProcessor processor = new ...


0

If the source image is bi-level (1-bit black/white), a direct mapping of greyscale to gradient will not suffice. A possible solution to the problem is to compute a distance field (preferably as an offline task), where each texel encodes the distance to the nearest white texel. You can then use that distance to sample the gradient map. The images below show ...


0

Your problem is the difference between XMMatrixLookToLH and XMMatrixLookAtLH. The DirectX TK SimpleSample is using XMMatrixLookAtLH which is computing: XMVECTOR Eye = XMVectorSet(0.0f, 3.0f, -6.0f, 0.0f); XMVECTOR At = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f); XMVECTOR Up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f); XMMATRIX g_View = XMMatrixLookAtLH(Eye, At, Up); ...


2

Rather than using a geometry shader as mentioned in another answer, I managed to implement the lines very cleanly in the fragment shader, by passing the spherical coordinates before the deformation from the tessellation shader to the fragment shader. There I could then use uniforms that describe the number of level curves to calculate position and line width ...


0

Write your own botnet. I faced the same problem of not being able to test if shaders even compiled and linked on GLSL implementations and it drove me to a crude solution. I made small tools that ran in the background on a machine, waiting for JSON bundles with shaders sources to compile and link together using a windowless OpenGL context, returning the ...


1

You can use a geometry shader to generate those lines. There are a few tutorials/examples on how to generate sprites with geometry shaders, you can base yourself off of these to create thick lines with triangle strips from line strips. http://www.geeks3d.com/20140815/particle-billboarding-with-the-geometry-shader-glsl/


0

The problem is probably: precision lowp float; Which causes u_time to be 8bit unsigned fixed points with a range of only 0 to 1 or -2 to 2. setting it to mediump would probably fix the scrolling issue but would still degrade performance greatly. uniform mediump vec2 u_time; uniform lowp vec4 u_color; It's better to calculate UV coordinates in the ...


4

Khronos provides a reference GLSL compiler. It is capable of validating GLSL up to version 3.50 (full support) and up to 4.50 (partial support). It also handles ESSL (OpenGL ES's GLSL). The tool verifies that the shader conforms to the GLSL specification. This does not necessarily guarantee that it works with all drivers but it does guarantee that the ...


1

You could use compressed textures to store your 1bpp image, they can all store 1bpp images without loss as each tiles can have 2 colors (and in-betweens). PVRTC supports a 2bpp format, PVRTC is only supported on PowerVR devices. ETC1 and S3TC (DXT1) are 4bpp which comes back to the same size as 4x4 in RGBA4444 format but you don't need to combine and then ...


1

Because the plane in front is alpha-blended over the entire screen, after all the alpha leaves behind it have been drawn as objects they are depth-sorted by Unity to render properly with alpha-blending. In your test without the front plane the cost of blending is minimal as all of the leaves use the same shader and texture which are in the cache and only ...


1

The reason is due to a bug in the driver (or an overlooked gotcha in the GLSL language?). Your vertex shader uses some of the struct members, your fragment shader uses a different set of the struct members, and the drivers ends up creating 2 different types by independently eliminating the unused uniforms from the struct type in both shaders which cause them ...


6

I'll try to answer to the best of my knowledge, with little knowledge about the specific case of UE4, but rather on the general technique. Graph based materials are as much programming as writing the code yourself. It just doesn't feel like it for people with no background on code, making it seemingly easier. So, when a designer links a "Add" node, he is ...


1

World position is vertex position multiplied by world matrix, not view matrix. So it should be like this in the vertex shader: output.WorldPos = mul(input.Pos,World); Unless you want View position to work with. I haven't checked the code for bugs if you want to use that.


9

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


5

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


5

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



Top 50 recent answers are included