Hot answers tagged

3

You dont need a shader for this. Setting the Order in Layer of the Back sprite render toa higher value that the Order in Layer of the Fron sprite renderer makes sure that Back renders in front of Front in 2d space, regardless of the position in 3d space.


2

Preprocessor macros don't work on pragmas, because they are parsed before any preprocessing happens. What you can do instead is to make two identical subshaders, the top one without noforwardadd and the bottom one with. If you assign different LOD thresholds to those subshaders, you can then choose between them by making mobile builds use a lower LOD value: ...


2

You can not Sample a texture in vertex shader with regular sampling. You should use SampleLevel and sample a specific mip level of the texture with it. This is because you don't have screen space derivatives (ddx and ddy) in the vertex shader. In the pixel shader those are used to determine the mip level. You can also use texture.Load.


2

It turns out that this is due to optimisation of the .fx compiler. When only one sampler is actually used (regardless of the number of samplers being declared) the effect is compiled to be optimized to only read from the first register. So: With this declaration: sampler ScreenTextureSampler: register (s0) // This is the texture that SpriteBatch will try ...


1

What I ultimately decided to do was to use a single material with all of the texture compiled together, and add a shader. The effect is as follows: The shader code is below. I added a texture of some pre-generated noise to let it work. Shader "Custom/Position Blur" { Properties{ _MainTex("Main", 2D) = "white"{} _BumpMap("Bumpmap", 2D) ...


1

You could interpolate and make the grid smaller. Basically the idea would be to take those large squares and make them smaller so that the edges are not so obvious. I posted the algorithm here with an example and some pretty pictures: Creating colour spectrum by light flux values Essentially, you would have to take your generated map data array -- and ...


1

That error means that you're trying to use (directly or indirectly) a fragment shader that has too many uniform variables. Specifically, your hardware or GL implementation has a upper limit of about 3.5k bytes of uniform storage per shader (3584 bytes is room for 896 4-byte floats or 224 4-component float vectors). Look through your shaders for one that ...


1

When the distance to the camera is really small, you can end up dealing with very small numbers which create floating point rounding errors in your calculations. If you change o.uv = mul(UNITY_MATRIX_MVP, input.pos); to o.uv = mul(UNITY_MATRIX_MV, input.pos); then the projection portion of the matrix will no longer be included in your calculations (...


1

This is an issue with any non 1x1 filter(such as a Gaussian one). If you don't want to clip, you can not apply the filter on the edge, or apply only part of it(and it will be darker probably). Another option, if the background outside the image, is known to be a specific color or transparency, is when you apply the filter, apply that color as part of the ...


1

How is your surf defined? In addition to lighting shader, you must modify it for material properties. Here's a modified example that uses red color instead of texture from http://docs.unity3d.com/Manual/SL-SurfaceShaderLightingExamples.html Shader "Custom/CustomLight" { Properties { _MainTex ("Texture", 2D) = "white" {} } ...


1

2D Water Reflection can achieve results like that. I did it first for a friend who wanted exactly the same effect that you described and that is looking like Kingdom. I did not used GrabPass but a specific render texture instead. The result is then applied on a screen aligned quad, flipped, Y clipped and distorded. I do not know which one is performing ...



Only top voted, non community-wiki answers of a minimum length are eligible