Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 775 776 [777] 778 779 ... 795

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 817922 times)

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11640 on: March 17, 2020, 03:48:20 am »

The reason Unity works like that is so you can mix sound effects.

Say you have a character talking, while some music is playing on a radio, and there's a door that opens. That's three things. So you have a positional AudioSource on each one, and you have single AudioListener at the player's location. The AudioListener is the playback channel.

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #11641 on: March 18, 2020, 01:28:25 pm »

Unfortunately, I wasn't able to get very far with that model. I download the model as Collada (.dae) but when I import into Blender 2.78, it's just a few polygons out in space and a bunch of empties.

My only thought is that something is wrong with Sketchup's Collada export function, or there's some data the model maker used that can't be converted, like a bezier surface or something. I tried to open the model in Sketchup to see what the problem is, but the registration form is locked up and won't let me progress in either Firefox or Chrome. Sorry I couldn't help more :-\

Although if you do end up with the overlapping vertices problem on an otherwise-fine model, that's an easy fix. Just enter edit mode (tab,) then hit space and type "remove doubles." Any vertices within a certain distance of each other will be welded together. If the model is split up into multiple models, you can select all the pieces by pressing 'A' and then 'CTRL+J' to join the pieces into one model, where you can then join the vertices.
Thanks for the attempt, I really appreciate the help. :) Well now that I've had my sanity checked it's time to find an alternative.

That's OK! You've helped a lot, this gives me grounds to find an alternate model

I haven't had problems with overlapping vertices but I have imported models that just have loads of verts just floating off in space like a constellation which is really odd. On a few of the a/c some of the models were partly disassembled, like... Like a lego set that's 1 or 2 steps from being finished. The Chinook I had for example, the entire thing was all together except for the landing wheel assembly, which was detached and floating off to the side. In that case I just deleted it but I was surprised, why wouldn't the person who uploaded it just deliver the whole model properly assembled? Is "some assembly required" some kind of best practice?
Logged

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11642 on: March 18, 2020, 02:31:23 pm »

I think it must be that either Sketchup is broken, or in some way incompatible with Blender. From what I understand it's more of an archviz program than a full modelling and animation setup, so the program might be using some conventions that can't be easily translated into a more general model format. I'm just talking out of my ass though, I have no clue.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

mko

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11643 on: March 18, 2020, 04:05:49 pm »

tld;dr make fun of my code, please

Has anybody here has ever tried generating terrain in Unity (given that is a DF forum I think that there is chance that somebody tried playing with it)?

I tried making one myself, and to my surprise my own simple and dumb algorithm produced something usable.

But making 160 000 Quads to display heightmap is certainly a bad idea. Sadly I am unsure what is the sane way of doing this. Also, has someone got an idea what is the best way to take heightmap and use it to deform plane/mesh/quads into 3D terrain? I will start Googling soon but maybe someone can point me to what I should Google.

Spoiler (click to show/hide)

code of my unity script is at https://gist.github.com/matkoniecz/f895ee1bdb35608998f20194e1ff01fe
Logged

WealthyRadish

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11644 on: March 18, 2020, 06:10:08 pm »

I know nothing about Unity, but I would imagine the most basic implementation would be to use the generated 2D array to either create the mesh or write it to a texture and translate the vertexes in the shader (you would do that anyway if you want a 2D representation of it). The easiest base mesh at any rate would be a triangle strip in a grid. Horrible texture stretching when the slope is extreme is on some level unavoidable, but there must be like 20 years of hacks out there to mitigate it.
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11645 on: March 18, 2020, 06:12:50 pm »

Well, can't you just make a grid of verts, and assign the z coordinate of each to the corresponding height? Then just add triangles inside each unit square of the grid like

Code: [Select]
*-*-*-*-*-*-*-*...
|/|/|/|/|/|/|/|...
*-*-*-*-*-*-*-*...
|/|/|/|/|/|/|/|...
*-*-*-*-*-*-*-*...
.
.
.

You shouldn't use quads for each unit square since four vertices are not guaranteed to be in the same plane, and I'm not entirely certain what happens when you try to draw quads that don't each fit in one plane.

edit: ninja'd somewhat
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

mko

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11646 on: March 18, 2020, 06:44:21 pm »

Yes, I know that it will involve deforming meshes - but I am curious what is the proper way to do this in Unity.

I already discovered that I was creating cube The Wrong Way (TM) and that is why my collider checks were malfuctioning. So I am curious whatever anyone has any example of code deforming meshes in Unity.
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11647 on: March 19, 2020, 03:14:29 am »

Quads will be drawn as two triangles anyway, so it's perfectly harmless if they're not coplanar.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11648 on: March 19, 2020, 05:52:20 am »

Well I did muck around with generating terrain in Unity.

Mind you this may be doing it the hard way, I didn't have a lot of reference when going into this:

Spoiler (click to show/hide)

You'll need to cut a lot of that out, since it was specific to my project but that's the general way to make a sheet of mesh. Adapted from OpenGL originally.

The basic idea is that the "triangles" array will always be the same for the same sized piece of mesh, so you could split that bit out of there, and store the triangle-list for using separately with multiple pieces of the same-sized mesh, for example for dynamically loading in pieces of terrain mesh as the player moves around, and generate the vertex array separately when needed.

you need to fill in the vertexes array with your actual vertexes. You can play around with what happens if you change the values in the vertex array during run-time.
« Last Edit: March 19, 2020, 06:00:16 am by Reelya »
Logged

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11649 on: March 19, 2020, 08:41:33 pm »

What is the absolute simplest, most concise and to-the-point, "you are literally a baby and I have to start with the alphabet" HLSL tutorial out there? Whenever I try things like "HLSL guide" or "shader programming" I get links to textbooks, pre-made shaders for other peoples' projects, or reference documentation. I know what some of the key words mean but taken together any given shader just looks like gibberish to me

Adding to my woes is probably the weirdest issue I've ever encountered. Monogame's content pipeline tool """"helpfully"""" keys out pink, as in (255, 0, 255) which would be great if I wasn't already trying to use that as my palette index color. It's easy enough to change, but still.

And here I was thinking I had a lot more freedom and control than Unity afforded me. Do I have to go down to x86 or something?
« Last Edit: March 19, 2020, 09:44:23 pm by itisnotlogical »
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11650 on: March 19, 2020, 11:20:31 pm »

I don't know of any HLSL shader tutorials since I've never used it directly, but I'm really surprised that it's difficult to find one that goes through something simple like a per-vertex lit and texture mapped render pipeline.

What are you trying to do with Monogame that you couldn't do with Unity and are now struggling with?  For shaders specifically I assumed that Unity would have a shader designing tool so you wouldn't even need to write any HLSL, but I've never used it.
Logged
Through pain, I find wisdom.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11651 on: March 20, 2020, 12:44:17 am »

To be honest, I was just saying that for comic effect. My main reason for using MonoGame is that it doesn't have a splash screen, and a secondary reason is that it's easier to create authentic-looking pixel graphics. I was just slightly annoyed that the old "pink = transparency" thing still exists.

Unity does have a visual shader editor, but last I remembered you had to use either the Lightweight or High-Definition Render Pipeline--and there was no way to switch once a project's been created.

Monogame has its strengths and weaknesses. If I were making a 3D game I would definitely rather use Unity, but there are certain things where MonoGame offers a lot more control at the expense of convenience. For example I can rebind controls in-game, a feature that isn't possible out of the box in Unity. MG being free as in free beer endears it to me as well.

To answer your question though, what I was trying to do was make a color replacement shader; i.e. any pink pixels are rendered as a unit's or player's team color. Once I realized what the pipeline tool was doing I got it working.



I suddenly got a lot of insight into how batching and draw calls work. My replacement shader worked fine when I only had one replacement color, but it didn't work when I had multiple "to" colors; the units on different sides would be rendered as the same color. Since I was using MonoGame's built-in sprite sorting, it was rendering everything in the same batch and not updating the shader information per-sprite.

I could render in immediate mode and do my own sprite sorting, but that would mean I don't get any benefits from batching. A better solution would be to create different batches for spites without a shader effect and sprites that do use one... But that means that sprites in the two different layers can't be sorted between each other, unless I add extra steps for compositing the two after they've been drawn. I'm already part of the way there by rendering to an internal render target and scaling it to match the window.

My creative energy was gone, but now that I've started learning things again I feel a lot better.
« Last Edit: March 20, 2020, 06:03:41 pm by itisnotlogical »
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

mko

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11652 on: March 20, 2020, 09:13:37 pm »

Thank you Reelya! Would be OK to use this code in my project (AKA, do you agree to license it under MIT/CC0 or some other permissible licence)?

With slight modifications I got it to display area, thank you - and now I want to use this modified version.
Well I did muck around with generating terrain in Unity.

Mind you this may be doing it the hard way, I didn't have a lot of reference when going into this:

Spoiler (click to show/hide)

You'll need to cut a lot of that out, since it was specific to my project but that's the general way to make a sheet of mesh. Adapted from OpenGL originally.

The basic idea is that the "triangles" array will always be the same for the same sized piece of mesh, so you could split that bit out of there, and store the triangle-list for using separately with multiple pieces of the same-sized mesh, for example for dynamically loading in pieces of terrain mesh as the player moves around, and generate the vertex array separately when needed.

you need to fill in the vertexes array with your actual vertexes. You can play around with what happens if you change the values in the vertex array during run-time.
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11653 on: March 20, 2020, 09:17:43 pm »

Does anyone know of any good resources for studying for USACO? I've moved up to Gold league at the moment but am finding the contest problems much harder than Silver level. Thank youuuu
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

mko

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11654 on: March 20, 2020, 09:28:10 pm »

Does anyone know of any good resources for studying for USACO? I've moved up to Gold league at the moment but am finding the contest problems much harder than Silver level. Thank youuuu
Following is based on my experience with Polish Computer Science Olympiad, may not be applicable here.

Is there somewhere overview of tasks and solutions from old contests? Polish one published very thorough analysis, going over multiple solutions from brute-force to optimal ones. If there is no official one - unofficial ones may be also very helpful.

"Introduction to Algorithms" by Thomas H. Cormen was kind of overkill, but used especially by winners.

Also, see http://usaco.org/index.php?page=resources on their own site (I see Cormen there).
« Last Edit: March 20, 2020, 09:30:08 pm by mko »
Logged
Pages: 1 ... 775 776 [777] 778 779 ... 795