Tag Info

New answers tagged

7

This is based on my speculation and skimming through Celestia's source code. Celestia allows you to fly around a planet and zoom out to see the whole galaxy. I browsed its source code and found it used an octree, a structure to recursively divide space into 8 octants. The renderer would render the environment by traversing the octree, and don't traverse ...


12

There's a number of pieces to this puzzle, each of which will provide a deep and interesting rabbit hole of exploration. Some of them are: Level of Detail -- automatically (or "manually") choosing detailed or simplified models, or even sprites or just dots, or for objects as they are further away. Culling -- choosing to only draw what's needed. This might ...


2

Anything that is either hierarchical and/or sparse should help you out here. There's a lot of empty space, so not having to use storage to represent empty space is a must. A typical hierarchical approach would be something like an Oct tree which recursively subdivides space into 8 smaller cubes, and you can store objects in the smallest cube that they can ...


2

When you resize your game resolution you need to update every single rectangle in your game (every button, etc) and multiply it by a proper scale, so that the "hitboxes" would work, which would be a lot of work. So, a smarter way of achieving the same result is simply by multiplying your mouse position by a Vector2 scale = new Vector2(originalWidth / width, ...


1

I use MRT rendering for this; I render everything into both a diffuse map and a glow map. I then blur the glow map into a bloom-like effect, and add it back on top of the diffuse map as a post-processing effect. This way I can make objects that glow (by drawing their diffuse color into both the diffuse and the glow map), objects that don't glow (by ...


2

Usually bloom is done with HDR rendering where you use a floating point (usually 16 bits per channel) texture for rendering to. Things that are brighter than 1.0 get bloom applied. Things that are 1.0 or less don't get any bloom. You render everything to the same texture, and remove anything that's not bright enough to bloom when you start processing the ...


2

Firstly, texture filtering and anti aliasing are two different ways of improving image quality. You can apply them both independently. Anti aliasing is primarily done to smooth the joins where two separate triangles overlap. Depending on how it's done it can also benefit texturing quality indirectly too. Texture filtering is done to improve the image ...


2

Viewports and Clipping (Direct3D 9) is a good overview that, while specific to D3D9, is relevant to all APIs. The viewport defines an additional transformation that occurs before rasterization: Direct3D uses the viewport location and dimensions to scale the vertices to fit a rendered scene into the appropriate location on the target surface. Internally, ...


0

I tested your script and was able to dynamically adjust the colors of the line renderer. Perhaps you didn't pass your linerenderer component into your script in the editor on the attached object? Alternatively, you could add to your script: void Start() { lineRenderer = gameObject.GetComponent<LineRenderer>(); } Aside from that your code seems ...


2

The discard statement comes in handy. You didn't say too much about your decision path, so I'll offer an example using a simple texture lookup: void main() { gl_FragColor = texture2D(u_texture, v_uv) * u_color; if (gl_FragColor.a <= 0.0) discard; } (That's from some sample code I wrote before I learned about alpha blending.)


7

Yes, you can discard in the fragment shader to avoid writing the pixel. Here's a random example I dug up from Google. Note that this may not actually stop the fragment shader from processing (as the GPU tends to process fragments in blocks; only discarding from all fragments in a block will abandon the processing). But the fragment won't be written to the ...


1

I have a couple of suggestions Avoid Allocations and Copies A lot of your code has unnecessary allocations and copies. Instead of filling a vector with push_back, try pre-allocating the vector and setting the data there. You have a fixed maximum number of intersection points, so pre-allocate a vector of that size. Do a Simple Broadphase Before you do ...


0

A UI button by default contains one image and one label inside it, but you can change that. You can remove the label from within the button, and instead add several items, making the button a container of several other elements, hence creating whatever layout you want. It might be easier if you created a panel, put in it all the info you wanted, and then ...


0

You can use an anti aliasing algorithm to fix it. One simple way to do AA is to take multiple samples per destination pixel when you down sample. Here's a link to one such method, called 4-rook ssaa! http://blog.demofox.org/2015/04/23/4-rook-antialiasing-rgss/


0

Would you mind sharing your implementation with other interested programmers? I think there are a couple of people interested in a working implementation to play around with, so am I. I know I am "abusing" the answer function, but I do not have enough reputation to comment, sorry.


-1

you can "lock" the axis for a rigidbody so it cannot move/rotate/whatever around/along specific axis. Check the inspector options for the rigidbody component. http://docs.unity3d.com/Manual/class-Rigidbody.html



Top 50 recent answers are included