fog-of-war | Unity3D游戏高性能战争迷雾系统 | Plugin library
kandi X-RAY | fog-of-war Summary
kandi X-RAY | fog-of-war Summary
Unity3D游戏高性能战争迷雾系统
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of fog-of-war
fog-of-war Key Features
fog-of-war Examples and Code Snippets
Community Discussions
Trending Discussions on fog-of-war
QUESTION
I'm trying to implement line-of-sight visibility / fog-of-war for my 2D top-down game, and found this article which has a simple and efficient algorithm which involves shooting rays at the edges of rectangles to calculate a list of triangles to brighten.
However, my game uses tiles, so it would be very inefficient to run this against the 150x150 (22,500) tiles surrounding the players every frame. Rather, it would be better to instead convert the tile-map to a list of rectangles and then run the line-of-sight algorithm against that. For example, if this were my tile-map (where 1 is a solid tile and 0 is a free tile):
...ANSWER
Answered 2021-Apr-09 at 20:44There is naive way, for example, start top left in a width-first filling process, that would give you similar results to what you're looking for.
Here's what the width-first algo might look like:
Results in:
QUESTION
I’m working on a Metal, MTKView
based app that takes advantage of the A11 TBDR architecture to do deferred shading in a single render pass. I used Apple’s Deferred Lighting sample code as reference, and it works great.
I’d like to try changing the geometry buffer pass to be GPU-driven, using the Indirect Command Buffer feature of Metal 2 on A11 hardware.
I’ve been using Apple’s Encoding Indirect Command Buffers on the GPU sample code as my main point of reference for this. I’m able to run this sample on my iPhone XR (although, probably off-topic, the scrolling is not smooth, it judders).
I’m running into difficulties however with my own code, when I try to move my geometry buffer pass into an indirect command buffer. When I set supportIndirectCommandBuffers
to true
on the MTLRenderPipelineDescriptor
of the Geometry Buffer pipeline, device.makeRenderPipelineState
fails with the error
AGXMetalA12 Code=3 "Fragment shader cannot be used with indirect command buffers"
I’ve not been able to find any information in the documentation on this error. I’m wondering, are there certain kinds of fragment operation that are not allowed in indirect pipelines, or some kind of limit to GPU-driven drawing that I've overlooked (the number of color attachments perhaps)?
SharedTypes.hHeader shared by Metal and Swift
...ANSWER
Answered 2019-Apr-02 at 14:56Looking through the code and through Metal documentation and Metal Shading Language specification, I think I know why you get this error.
If you look through render_command
interface that is present in metal_command_buffer
header in Metal, you'll find that to pass parameters to indirect render commands, you only have these functions: set_vertex_buffer
and set_fragment_buffer
, there is no set_vertex_texture
or set_vertex_sampler
like you have in MTLRenderCommandEncoder
.
But, since your pipeline uses shader that in turn uses textures as arguments and you indicate by using supportIndirectCommandBuffers
that you would like to use this pipeline in indirect commands, Metal has no choice but to fail pipeline creation.
Instead if you want to pass textures or samplers to indirect render commands, you should use argument buffers, that you will pass to the shader that issues indirect render commands, which in turn will bind them using set_vertex_buffer
and set_fragment_buffer
for each render_command
.
Specification: Metal Shading Language Specification (Section 5.16)
QUESTION
I am currently developing a complex MATLAB application. I am trying to save figures (created within its UI) by using the getframe
function. This works fine, and saves the figure as intended. However, the UI 'blanks' after every use. The window remains but becomes a uniform white rectangle. Mousing over features in the UI makes them appear again (like a fog-of-war). Adding a refresh
statement did not help.
Why does this happen? How do i make it stop?
Irritatingly this doesn't happen in 2018a, but the code is in 2014b, which is problematic (something I discovered after being pleased at my cool fix :( ).
Unfortunately posting code is not feasible because I do not have permission to share it.
...ANSWER
Answered 2018-Sep-20 at 10:41OK after much research I've been unable to find a direct solution. But I have implemented an indirect solution.
QUESTION
Unity beginner here!
So I'm trying to get some static-fog-of-war/line-of-sight for my game.
Currently I have 2 cameras:
- The first one renders the scene.
- The second one has black background and a white polygon which represents the line of sight.
The 1st camera renders first, so far everything works. (layers are set properly so that the second camera has only the line of sight polygon)
Then I wan't to do some post processing on the second camera by setting all white pixels of that camera to transparent but this is where I'm lost.
Using that code to apply the shader:
...ANSWER
Answered 2017-Jun-07 at 15:45You should use a shader for this instead. OnRenderImage
requires piping the data back to the CPU and processing it linearly there (slow!!!1) rather than in parallel on the GPU.
This will take a little bit of research to do properly, but the concept is pretty straight forward. You need to use the stencil mask to get the desired effect. The "white polygon" you have writes data (literally setting a bit to 1 instead of 0) to the stencil mask and then the rest of the scene gets rendered, but only where the stencil mask is a 1.
Basically think of the line of sight polygon as telling the camera where it's allowed to draw other things. Which is what a mask is. The stencil mask is just a specific grouping of bits that are available during rendering that aren't data that gets drawn to the screen, but rather persist across rendering passes. So:
Pass 1: draw the LOS object to the mask buffer.
Pass 2: render the scene only where the buffer has been modified.
I wrote up an outline shader that uses the stencil mask, which you could use as an example and get started. Mind, that shader was writen to apply only to a single object (and "creates" new geometry), but the same process should still work for doing what you're attempting (I just haven't tried to do it myself).
Looks like this thread has a (partial) shader that has the effect you're looking for.
I created two shaders of the standard affair and modified as follows: Hidden Shader: Just under the auto generated shader line "LOD 200", add:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fog-of-war
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page