Hot answers tagged

26

The physical basis of the colors of an oil slick is iridescence, and also related to Newton's rings. Specifically, the thickness of the oil layer is on the order of the wavelength of light. Since light reflects from both the top and bottom surface of the oil, at any given wavelength, at some angles the two reflections will be out of phase and cancel each ...


8

This all happens on the CPU side, so if caching were a useful feature, then I would speculate that the graphics driver would implement it itself. Adding your own caching layer is unnecessary. My understanding is that whenever you set a parameter, and whenever you call Apply, these calls are passed to DirectX largely as-is, and in turn passed to the user-...


7

I'd approach this using a custom shader on my SpriteRenderers that takes two textures, one for each version you want to transition between. (Even if using this effect to transition between more than two states, I'd still try to structure the game so we only need two for rendering at any one time: the old state and the next state. We'll let that transition ...


5

Per-pixel image processing on the CPU is something where microƶptimization is worth thinking about from the start. You're doing memory allocation and object initialization on a per-pixel basis; this is probably most of your problem. The first thing you should do is figure out how to use only arrays of primitives (byte[] etc.) to perform your computation. ...


5

That is correct: RenderTextures are not necessarily cleared after being released or reacquired. According to the documentation: You can not depend on any particular contents of the RenderTexture you get from GetTemporary function. It might be garbage, or it might be cleared to some color, depending on the platform. If you want the RenderTexture to be ...


4

Kevin gave you a good list of what you really need to do first to improve the performance of the code. However I would just throw out the code and implement the effect on higher level so that Java can utilize native code and GPU. Radial blur Based on the screenshot it looks like the effect you are looking for is radial blur with rotation. These can be ...


4

One interesting thing I found about this topic. From msdn: You can use the Parameters indexed property on Effect to access any effect parameter, but this is slower than using EffectParameters. For this reason, you should create an EffectParameter for each effect parameter that changes frequently. and Creating and assigning a EffectParameter ...


3

The Unity team published a nice slide deck at SIGGRAPH 2011 with a whole palette of special effects that can be achieved with depth. These are low-cost when using deferred rendering, but still available when using forward rendering at the cost of a pass to create the depth texture. Their outline effect is described on slides 46-47, and should be possible to ...


3

To achieve this sort of effect: You need to change your caves "Render Mode" to "Screen space - Camera". You might have did it already as you are using particles but still to ensure you change the canvas "render mode". Now Change "Order in layer" to 0 for particles system. Add a component "Canvas" to the UI which you want to show up on the particles. In ...


2

This is not really dynamically coloring but you can alter the lighting effects to achieve the same thing. The AmbientLightColor effect should work. effect.AmbientLightColor = new Color(r, b, g); Also there is an effect.alpha that you use for transparency iirc which takes a float between 0-1.


2

The idea of blending 4 textures together by using a 5th texture to specify how to blend them together can be easily extended to 8, 12, 16, ... textures. As a quick refresher this is how the default approach works: You have 4 textures for detailing, for example: Rocks Grass Water Concrete And one texture which specifies how to blend these together. In the ...


2

Correct me if I wrong, but it looks like you are trying to mimic the BasicEffect shader code into your own shader file. Microsoft's App Hub provides code for BasicEffect: http://xbox.create.msdn.com/en-US/education/catalog/sample/stock_effects From there you can extract what you need, keep in mind that this will be cumbersome as BasicEffect encapsulates a ...


2

Effect has Techniques that tells you what vertex shader and pixel shader to use In your .fx file you will have 1 vertex shader and 2 pixel shader functions, and two techniques technique Colored { pass Pass0 { VertexShader = compile vs_2_0 VertexShaderFunction(); PixelShader = compile ps_2_0 ColoredPixelShader(); } } ...


2

Shader "SimpleSurf" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } SubShader { Pass { CGPROGRAM #pragma vertex vert_img #pragma fragment frag #include "UnityCG.cginc" uniform sampler2D _MainTex; float4 frag(v2f_img i) : COLOR { return tex2D(_MainTex, ...


2

Typical bloom effects are applied as a post-process to the entire rendered frame. This makes it difficult to bloom only select objects. Even windowing the bloom to a region around the lines risks blooming unrelated content that comes too close. Instead, you can try "pre-blooming" your LineRenderer content - using a wider ribbon and baking a soft surrounding ...


2

I just developed a similiar thing for my project and it works, but it's bad for debugging so I skipped it. What I did was implement this: http://blogs.msdn.com/b/shawnhar/archive/2010/05/07/effect-compilation-and-content-pipeline-automation-in-xna-game-studio-4-0.aspx I have an Engine DLL Library and in it I just created a resource file, called "Effects....


2

This was a pretty simple error made in my initialization code for the two render targets. The render target mainTarget had a height twice the length of the lightsTarget. When the shader was processing them it had to stretch the lightsTarget texture to get it to work.


2

Try creating a 3-4 frame animation of a semi-transparent blue-white dot that moves downward a few pixels before expanding out to a 1-2 pixel radius circle. Then just create random instances of this animation all over the map. Should give the appearance of rain droplets. From there you can adjust it by maybe adding more frames or adjusting the shape when it ...


2

Similar to the answer to the question referenced by Philipp, you might consider using a general system of events and flags for every item: CanEquip, OnEquip/OnDeEquip CanConsume, OnConsume IsQuestItem, OnCompleteQuest etc. This is a much more flexible approach as it allows items to serve multiple purposes as would be the case in, for example, the dry ...


2

Everything is becoming gray because post-processing always draws the whole screen, so the effect gets applied to every pixel. Since the order of the cameras is Camera_All and then Camera_CurrentItem, the post-processing of Camera_CurrentItem gets applied to all the pixels that were drawn earlier by Camera_All. If you exchange the drawing order (by switching ...


1

Probably not the best method, but you could emit particles like a regular gun and draw a curved line between them, give them a certain lifespan and then apply shaders to the lines.


1

After playing with my shader some more I got it working. Indeed you can run multiple effects on the same geometry. It should be similar performance to having all your techniques in the same effect but can be abstracted better.


1

According to its wikipedia page, Nex Machina uses Signed Distance Fields. In the video you linked, the graphics programmer says that their world is actually defined with voxels (and presumably rendered by raymarching it.) Because their world definition is already volumetric, it is easier to spawn particles inside those volumes. If you have conventional 3D ...


1

The direction (d) in which the target ball should move is AB.normalized, where A is the center of the imaginary circle (where cue ball reaches next to target ball) and B is the center of target ball. Obviously d will not be equal to AB.normalized if shot has an angle. i.e. if shot is done in a way that cue ball receives a clockwise rotation, then the target ...


1

First of all if you don't already know the basics of Java, you should learn them first. :) When you have, you will need some kind of graphics library. I know that LWJGL is a good graphics library. LWJGL Link :) According to some people over at stack overflow, Minecraft was made with this. But, as I said it's probably best (if you don't already know ...


1

I would say first, your problem is more one of deciding on an artistic style, and not as much about code. Like with a lot of things artistic, there is no right answers, but there are definitely ideas and approaches. Second, your game is not 2D - it's 2.5D in a pseudo 3D way, just like isometric is 2D, but also 3D'ish. Your characters are not drawn from ...


1

This error can mean: You forgot to install the DirectX SDK. You need to try reinstalling the DirectX SDK. Depending on your other code, you need to install the Debug Runtimes (specifically if you're using CreateWithSwapChain from one of the demos). This could also help get you more information. You'll need to debug more. There's a page of Debugging tips ...


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