New answers tagged

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" {} } ...


0

First make sure that your matrices are column-major. Second this call: glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0 ); Should look like this: glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 3, (void*)0 ); Because you want to move vertex attrib pointer by 3 floats (I ...


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


0

To create this effect convert the pixel to greyscale: float grayscale = dot(color.rgb, float3(0.3, 0.59, 0.11)); Then return red above the threshold and return black below it (while preserving the alpha). See what threshold value works for you.


0

Simplest possible way is obviously the following: create mesh with enough vertices that describes water surface configure your shader to move the vertices in a circle


0

Depends on which level of detail you wanna achieve. Height Maps could be a solution, try to avoid as much work on the CPU as possible in every case. You can combine also some techniques as tesselation. There are plenty sites on the web for inspiration, you know where to search :)


0

extern float perm[512]; Note that uniforms allocated in vectors, not in single floats.This array of 512 floats actually takes 512 vectors, (2048 floats) You could try to pack this data in vec4 first, you will fit in 128 vectors then.


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

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


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


0

i forget it. it's a too hard in 2D game. i need to restrict some of features in varierty perspective.


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.


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


-2

after setting glDepthRange(n, f); Full formula: finalDepth = (gl_Position.z/gl_Position.w)*(f-n)*0.5+(f+n)*0.5 Bonus: Every other answer out there about depth buffer always assumes the use of projection matrix, this matrix is a waste of space, time and precision, of the 16 floats that it has only 2 are really needed, the "field of view" and the "...


0

After all of your transformations are applied (rotations, perspective transformations, etc.), all of the coordinates are divided by w (the fourth value in the gl_Position vector) to determine Normalized Device Coordinates, NDC. In other words NDC = (x/w, y/w, z/w) The x, y, and z coordinates in NDC space are in the range [-1..1] if they are in the clip ...


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.


0

If I remember correctly, z (as well as x and y) will be divided by w. Then, everything outside of -1..1 will be culled. And then, resulting value will be mapped to 0..1 (or to whatever range you selected with glDepthRange()). In case of default range, full formula would be depth = z / w / 2 + 0.5.


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


0

Well, it is not recommended to use in DirectX 12. Dynamic shader linkers are proven to be useless since a long time in game development, because the performance of your shader code base becomes less predictable, so it is not safe to use this feature in your app.


0

No alpha map is needed in Unity Standard Shader. Change alpha value in color swatch.


0

You were adding Assets.GameArt.shadowTexture as Texture2D to your graphicdevice but there are no any texture associated in your HLSL file. You need add Texture2D to your pixel shader file and use your sampler to sample your texture2D. I suggest to render it without spritebatch and go one level lower and create your own quad with vertices, then render it with ...


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



Top 50 recent answers are included