New answers tagged

2

Changing shader properties for each camera You can accomplish this with a script on the camera. In my example I change the color but you can extend this idea to any property in the shader. [ExecuteInEditMode] public class CameraMaterialChanger : MonoBehaviour { public Color myColor; // color you want the camera to render it as public Material ...


0

I am pretty sure the attribute should bind to the current buffer so there is no reason to be redoing this business with the attributes every frame unless you rebuild the buffer every time.... So you should probably do it one way or the other - either leave it be or rebuild the whole thing every frame.


0

Try rendering the stars at full resolution, and building a mipmap. A mipmap is a "pyramid" of images, each at a different scale. At the "top" of the (upside down) pyramid is the original image. The next level is the same image at half-scale. And so on. GPU can produce mipmaps (opengl, directx I'd imagine too), though such a map is prolly too large to do it ...


3

One obvious error in your current implementation is that you should combine nodes based on their total area, and not total radius. Otherwise you're overstating the visual effect by a squared factor - remember the area formula, pi*r^2. But you'll still run into other artifacts. An obvious one is that when you are zooming or refining your detail, there will ...


5

I don't think this is going to be quite as easy as you'd like, that said you should be able to copy/paste the code below to get something going. There might be a better way to approach this, but as I see it you'll need 2 render passes. The first to render the scene to a low resolution to introduce pixelation, and a second to resample the low resolution ...


0

How many times are you calling render from the Tile class? Because every time you do it adds 5 new enemys. If you are calling that render method a lot then I would suggest moving the for loop to the constructor.


1

OK, assuming that render() gets called once per frame you are telling your game to create 5 new enemies every frame in the tile class. This would lead to creating hundreds of enemies per second. I think you only want to use that for loop once when initialising the game. That way you will only make 5 (until you decide to make more). look in the ...


4

I believe that might be related to "shadow acne." Try lowering the bias of your directional lights. http://answers.unity3d.com/questions/925812/unity-5-real-time-lights-cast-shadows-with-gaps-li.html


1

EDIT: @Bálint made a great point about my answer. This works best for 2D rendering frameworks (SDL, XNA, etc) and less so with working directly with things like DirectX/OpenGL, which require a much closer coupling of the WHAT, WHERE, and HOW that I list below. Here is the paradigm I follow with how I organize my classes and what responsibilities each has: ...


1

For no apparent reason, you are filling your loaded image with a solid white color using SDL_FillRect. Also, you seem to clear the renderer without rerendering the texture. You need to SDL_RenderCopy the texture again after clearing the renderer.


0

The LibGDX Animation class is primarily a container of keyframes (Texture or TextureRegion instances) with some extra logic to pick the correct keyframe given a time and a play mode (normal, loop, ping-pong, etc...) The important part is that the timer that is used to get a keyframe is not built in to the Animation instance and so there should be a separate ...


2

The idea is simple. You need to have a way to define an object on the screen. It should contain the information for the rendering (like textures, effects, etc.) and for the game logic (velocity, acceleration, etc.). The main game logic shouldn't touch the rendering parts and vice-versa. There are variables, which needs to be used by both systems (like the ...


1

If you're going to use two images anyways, why don't you simply just have one image without an outline and one with an outline and just swap between them? As for other methods of drawing an outline, it can be done using multiple methods. If you're going to draw an outline on simple textures (let's say a square) use a ShapeRenderer (docs & tutorial) and ...


0

It turns out, it was because of a previous SpriteBatch call causing the GraphicsDevice settings to be changed. Putting this code in before my model drawing code executed fixed it, and now it draws correctly. GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;


2

You are loading part.png and creating the surface for each tail part in a loop. That's incredibly slow. Instead you should load it once, at the program initialization and just use it in drawing. You should get rid of these in drawPart(): auto surface = IMG_Load("part.png"); texture = SDL_CreateTextureFromSurface(renderer, surface); SDL_FreeSurface(surface);



Top 50 recent answers are included