New answers tagged

2

Reflection on a rough plane are a bit difficult, as the distance between the point observed & the object reflected into it come into play. That mean you need to render your colors of your reflection, but also its depth, to be able then to compute for each pixel of the plane it's distance to the pixel it reflect. Then you blur it using a ratio computed ...


0

This is caused by the order in which unity normally renders objects. Transparent objects are the glitchy exception to this order, as unity tries to calculate draw only one transparent object per pixel for what it thinks are opaque objects. There are a few approaches to this issue. You could use the Pass solution with Zwrite On and ColorMask 0, but in your ...


0

Apparently all that was going wrong was happening when I declared the Input structure here: struct Input { float2 uv_MainTex; float4 color; }; All that was going wrong was going wrong due to the fact that I forgot to explicitly specify the COLOR semantic on this line: float4 color; With the COLOR semantic specified, the above line of code ...


1

I accidentally stumbled upon a template for the shaders in Monogame installation directory and replaced the shader with this one: #define SV_POSITION POSITION #define VS_SHADERMODEL vs_3_0 #define PS_SHADERMODEL ps_4_0_level_9_1 Texture2D SpriteTexture; sampler2D SpriteTextureSampler = sampler_state { Texture = <SpriteTexture>; }; struct ...


1

Don't use worldspace, use screenspace See 1 See, if you use World Space, what happens when an object gets closer to the camera than your arbitrary sprite distance? Why, it renders in front of the UI. This is bad. Secondly, if you're using GL calls, GL natively works in Screen Space, you actually have to perform counteracting translates in order to ...


0

To fix the aspect ratio (and speed up the shader a bit): void main() { vec2 diff = (v_position + 1.0) * 0.5 - u_mousePosition; diff.x *= u_aspect; // e.g.: (16.0 / 9.0) for 16:9 float distance = dot(diff, diff); // square of distance, saves a square-root if(distance > u_lightRadius_squared)) { discard; } outColor = ...


0

What I've done in the past is to simply not place the decal close to the edge. I know it sounds a bit cheap but its fast simple and can look fine under some circumstances. Just Move the decal in a bit :)


2

I think unity can use stencil buffer though I never used it, if you are not able to do that I'll investigate deeper, One way to achieve that is to cut-out pieces of walls using some lowpoly spheres and stencil buffer, then fill that holes with an "hole" 3d model, so ask an artist to make a hole model wich looks like a cone so it can fir in a variety of holes ...


1

The cheapest (but not necessarily very flexible) solution would be to duplicate the shader code in your C# script. When the player clicks, fire a ray through the mouse position. Capture the RaycastHit struct, and it will give you the world position and texture coordinates of the point directly under the mouse. (If you've displaced your sphere out along the ...


1

The screen coords go from {-1,-1} to {1,1} but you are most likely feeding it {0,0} to {1,1} - hence the fact that only one-quarter of the screen gets rendered. So just to be clear - point {0,0} is not the top-left (or bottom-left, depending on your co-ordinate system) point; it's the center. This also explains the texture coord tranformation that you are ...



Top 50 recent answers are included