Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all 6821 articles
Browse latest View live

Where is MonoGame Shared Library?

$
0
0

@geniuszxy wrote:

I'm using VS2017, MonoGame 3.6.
following the tutorial, but there isn't a project called "MonoGame Shared Library".
and there isn't a submenu under the "MonoGame" menu.

Posts: 3

Participants: 3

Read full topic


Sometimes per pixel lighting is better than normal mapping : - D

$
0
0

@DexterZ wrote:

Basic effect per pixel lighting is looking good than a Custom effect normal mapping, well sometimes ^ _^ Y

I'm pretty sure the model is very familiar to XNA users ^_^y

Posts: 1

Participants: 1

Read full topic

Android Activity MD5?

$
0
0

@Alias wrote:

Hello,

When I try to start the game on Android from my Windows Desktop using:

adb shell am start -n " + id .. etc

I've noticed a md5 sum prefix on the activity name (default: Activity1). But because I'm generating the Visual Studio project file - among others - from templates, this md5 sum will change!

Is there any way I can query this md5 sum? Or turn it off?

Thanks!

Posts: 1

Participants: 1

Read full topic

[SOLVED]I have problem with draw primitives

$
0
0

@Grzegorz_Blaszczynsk wrote:

Program dont draw anything.

class Layer
	{
		public int LayerIndex { get; set; }
		public string Name { get; set; }
		public int[,] MapGridsData { get; set; }
		public int SheetID { get; set; }

		private VertexBuffer layerVertexBuffer { set; get; }

		public void InitMesh(GraphicsDevice device, List<GridsSheetContainer> gridTexSheet)
		{
			List<VertexPositionNormalTexture> verticesList = new List<VertexPositionNormalTexture>();

			for (int x=0;x < MapGridsData.GetLength(0); x++)
			{
				for (int y = 0; y < MapGridsData.Length/MapGridsData.GetLength(0); y++)
				{
					if(MapGridsData[x,y] != 0)
					{
							verticesList.Add(new VertexPositionNormalTexture(new Vector3(x*64,0, y * 64),new Vector3(0,1,0),new Vector2(0,0)));
							verticesList.Add(new VertexPositionNormalTexture(new Vector3((x+1) * 64, 0, (y+1) * 64), new Vector3(0, 1, 0), new Vector2(1, 1)));
							verticesList.Add(new VertexPositionNormalTexture(new Vector3((x+1) * 64, 0, y * 64), new Vector3(0, 1,0), new Vector2(1, 0)));

							verticesList.Add(new VertexPositionNormalTexture(new Vector3(x * 64, 0, y * 64), new Vector3(0, 1, 0), new Vector2(0, 0)));
							verticesList.Add(new VertexPositionNormalTexture(new Vector3(x  * 64, 0, (y+1) * 64), new Vector3(0, 1, 0), new Vector2(0, 1)));
							verticesList.Add(new VertexPositionNormalTexture(new Vector3((x+1) * 64, 0, (y+1) * 64), new Vector3(0, 1, 0), new Vector2(1, 1)));
					}
				}
			}
			layerVertexBuffer = new VertexBuffer(device, VertexPositionNormalTexture.VertexDeclaration, verticesList.Count, BufferUsage.WriteOnly);
		}

		public void Draw(GraphicsDevice device, Camera camera,Texture2D tex)
		{

			BasicEffect basicEffect = new BasicEffect(device);
			basicEffect.World = Matrix.CreateTranslation(Vector3.Zero);
			basicEffect.View = camera.View;
			basicEffect.Projection = camera.Projection;
			basicEffect.TextureEnabled = true;
			basicEffect.Texture = tex;
			device.SetVertexBuffer(layerVertexBuffer);

			foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
			{
				pass.Apply();
				device.DrawPrimitives(PrimitiveType.TriangleList, 0, layerVertexBuffer.VertexCount / 3);
			}
		}
	}

Posts: 1

Participants: 1

Read full topic

Using Monogame without templates and IDE on a macos

$
0
0

@sherjilozair wrote:

Hi,

While I've managed to use Monogame from VSC IDE on macos, I feel like a lot is going on behind the scenes which I don't understand. And to allay this worry a bit, I want to build a game starting from nothing but the bare necessities (i.e., the Monogame dynamic libs), so that I get a better idea about what goes where. Coming from a macos/linux background, I would understand it much more if for instance, I could create all the files in the project directory myself, build it from the command line (calling C# compiler), and then run the game using mono. Is this possible? Any pointers on how I can go about doing this?

Thanks.

Posts: 2

Participants: 2

Read full topic

VR / OpenVR sample code

$
0
0

@YTN wrote:

Does anyone have a working sample using OpenVR and Monogame?

I've been trying to get this working, with no luck so far.

Web searches have not yielded much... almost all samples / demos are using Unity.

TIA.

Posts: 5

Participants: 3

Read full topic

How to combine Deferred Rendering with Forward Rendering for transparent effect?

$
0
0

@Ticoel wrote:

Hello,

I try to create a deferred rendering using MonoGame. This is yet simple but render deferred work. But I do not understand how combine the deferred rendering to forward rendering. How to do ?

Sorry for my practice in English, I am French.

Thank you.

This is my actual method code:

	public void Compute(in GameTime gameTime, in EventHandler<DrawingEventArgs> drawing, in EventHandler<LightingEventArgs> lighting)
	{
		// G-Buffer

		graphicsDevice.DepthStencilState = DepthStencilState.Default;
		graphicsDevice.SetRenderTargets(depthMap, albedoMap, normalMap, worldPositionMap);
		clearGBuffer.CurrentTechnique.Passes[0].Apply();
		drawing?.Invoke(this,  new DrawingEventArgs(in gameTime));
		depthMap = graphicsDevice.GetRenderTargets()[0].RenderTarget as RenderTarget2D;
		albedoMap = graphicsDevice.GetRenderTargets()[1].RenderTarget as RenderTarget2D;
		normalMap = graphicsDevice.GetRenderTargets()[2].RenderTarget as RenderTarget2D;
		worldPositionMap = graphicsDevice.GetRenderTargets()[3].RenderTarget as RenderTarget2D;

		// Ligh and Shadow

		graphicsDevice.SetRenderTargets(lightMap, shadowMap);
		graphicsDevice.Clear(Color.Transparent);
		graphicsDevice.BlendState = BlendState.Additive;
		lighting?.Invoke(this, new LightingEventArgs(in depthMap, in albedoMap, in normalMap, in worldPositionMap, in vertexData, in indexData));
		lightMap = graphicsDevice.GetRenderTargets()[0].RenderTarget as RenderTarget2D;
		shadowMap = graphicsDevice.GetRenderTargets()[1].RenderTarget as RenderTarget2D;
		graphicsDevice.BlendState = BlendState.Opaque;

		// Renderer

		graphicsDevice.SetRenderTargets(renderedImageMap);
		unpack.Parameters["LightMap"].SetValue(lightMap);
		unpack.Parameters["ShadowMap"].SetValue(shadowMap);
		unpack.CurrentTechnique.Passes[0].Apply();
		graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexData, 0, 4, indexData, 0, 2);
		renderedImageMap = graphicsDevice.GetRenderTargets()[0].RenderTarget as RenderTarget2D;
		graphicsDevice.SetRenderTargets(null);

		// Output

		get.Parameters["DRColor"].SetValue(renderedImageMap);
		get.CurrentTechnique.Passes[0].Apply();
		graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexData, 0, 4, indexData, 0, 2);
	}

Posts: 3

Participants: 3

Read full topic

UWP Title Bars and Start Bar Triggers

$
0
0

@Paul_Crawley wrote:

Hi all,

So I converted a win32 game to a win UWP got everything converted and running correctly except for one very annoying detail. If I roll the mouse up and up and up, it triggers the games title bar, and yep you guessed it if I go down and down up pops the start bar, I've got everything set to full screen as you would with a regular win32 app, so the question;
Is there a way to stop those bars from activating?
additional, my mouse routine uses delta's to place my game cursor really didn't want to re-write those again but I will if I have too.

Thanks peeps

Posts: 1

Participants: 1

Read full topic


[Code] Target synced orbital height camera.

$
0
0

@willmotil wrote:

So i just worked on this for the last i dunno 2 or 3 days and figured id post it as it is a bit different to a simplified orbit camera method.

The below camera code takes a Target Game Objects Matrix... one typically created with the Matrix.CreateWorld method as its target to orbit around.
It takes a distance from the target and a height above the target as well as a angle of rotation.

The target can however be in any orientation and the camera will stay aligned with its forward plane.
Basically if you have a rotated world matrix you can hover over it and move up or down or orbit around its center as if your just orbiting over a flat area that is still.

Basically its a cylindrical style to target camera.

You can alternately do things like flyby's at a specific height over a target that is moving and rotating in 3d space.

        Matrix OrbitAtHeightAroundTargetForward(Matrix target, float ForwardOrbitallRotation, float DistanceFromTarget, float zHeightAboveTarget)
        {
            float flip = -1; // quick fix think my model is upside down
            var targetAxisHeightOffset = target.Forward * zHeightAboveTarget;
            var targetPos = target.Translation; // yes this is intentional, see position.
            Matrix axisTransformation = target * Matrix.CreateFromAxisAngle(target.Forward, ForwardOrbitallRotation);
            // i don't think this can happen anymore now so its probably redundant.
            float proximityToGimblePointRight = Math.Abs(Vector3.Dot(axisTransformation.Right, target.Forward)); 
            var positionalDistanceOffset = Vector3.Lerp(axisTransformation.Right, axisTransformation.Up, proximityToGimblePointRight) * DistanceFromTarget;
            var position = targetPos + positionalDistanceOffset + targetAxisHeightOffset;
            var gimbleSmothingLookAtOffset = Vector3.Zero;
            if (DistanceFromTarget < .5f)
                gimbleSmothingLookAtOffset = (1f * flip * target.Forward + 2f * target.Left + 1f * target.Up) * .1f * (.5f - DistanceFromTarget);
            var toTarget = (targetPos + gimbleSmothingLookAtOffset) - position;
            var lookUp = flip * target.Forward;
            return Matrix.CreateWorld(position, toTarget, lookUp);
        }

I also made this one that just orbits the target it also stays with the target rotation.
It can offset the orbit so it can orbit over it in the full 360, but the height variable doesn't make much sense to use with this so i yanked it out.

        Matrix OrbitAroundTarget(Matrix target, float ForwardOrbitallRotation, float UpAxisRotation, float DistanceFromTarget)
        {
            float flip = -1; // quick fix
            var Target =  target * Matrix.CreateFromAxisAngle(target.Up, UpAxisRotation); // order matters its not commutative.
            var targetPos = Target.Translation; // yes this is intentional, see position.
            Matrix axisTransformation = Target * Matrix.CreateFromAxisAngle(Target.Forward, ForwardOrbitallRotation);
            float proximityToGimblePointRight = Math.Abs(Vector3.Dot(axisTransformation.Right, Target.Forward));
            var positionalDistanceOffset = Vector3.Lerp(axisTransformation.Right, axisTransformation.Up, proximityToGimblePointRight) * DistanceFromTarget;
            var position = targetPos + positionalDistanceOffset;
            var gimbleSmothingLookAtOffset = Vector3.Zero;
            if (DistanceFromTarget < .5f)
                gimbleSmothingLookAtOffset = (1f * flip * Target.Forward + 2f * Target.Left + 1f * Target.Up) * .1f * (.5f - DistanceFromTarget);
            var toTarget = (targetPos + gimbleSmothingLookAtOffset) - position;
            var lookUp = flip * Target.Forward; 
            return Matrix.CreateWorld(position, toTarget, lookUp);
        }

Posts: 1

Participants: 1

Read full topic

How to incorporate an algorithm into a geometry shader.

$
0
0

@Optmisitic_Peach wrote:

I'm trying to use a geometry shader to emulate water, but the programmable pipeline is ordered like so:

Which means that the geometry stage comes after the vertex stage. I wanted to ask, if I use the vertex stage to do the transformations, and use the geometry stage to do the normal calculations, where do I do the lighting?
PS. I will try to set the geometry shader using the underlying SharpDX.Direct3D11.Device to set the geometry shader and the variables.

Thanks!

Posts: 3

Participants: 2

Read full topic

I just slaved over my game's prologue. I want your feedback. :)

$
0
0

@Watercolor_Games wrote:

We just spent the last day redoing the prologue for The Peacenet using new Peace Engine features such as the multicolored terminal and better audio and cutscene system. I like how it turned out, but I'd like to hear your opinions. Are there any things I could improve? Anything that needs changing? Let me know! :slight_smile:

Funny thing is, at the end of the video, the abrupt ending is caused by the fact that Peace Engine actually crashed because the Peacenet Backend Protocol is multithreaded and two threads tried to touch the same thing on the server-side which causes problems. Pretty much an instant death sentence in C#. But that's what you get for doing Minecraft-like blended multiplayer where the singleplayer component is just a multiplayer server without an authentication layer and with additional singleplayer only features. We'll be redoing the protocol in the May 2018 Week 3 release though. :stuck_out_tongue:

Posts: 2

Participants: 2

Read full topic

Normal map lighting shader only gets brighter at 0,0

$
0
0

@thera wrote:

I'm trying to adapt this tutorial into a small test project. :LWJGL ShaderLesson6

The mouse position is suppose to be the source of light. It only seems to illuminate when I move the cursor closer to 0,0 though. See the gif below for an example.

And this is the shader:

#if OPENGL
    #define SV_POSITION POSITION
    #define VS_SHADERMODEL vs_3_0
    #define PS_SHADERMODEL ps_3_0
#else
    #define VS_SHADERMODEL vs_4_0_level_9_1
    #define PS_SHADERMODEL ps_4_0_level_9_1
#endif

matrix WorldViewProjection;
Texture2D SpriteTexture;
Texture2D NormalTexture;

sampler2D SpriteSampler = sampler_state
{
    Texture = <SpriteTexture>;
};
sampler2D NormalSampler = sampler_state
{
    Texture = <NormalTexture>;
};

float2 Resolution;
float3 LightPos;
float4 LightColor;
float4 AmbientColor;
float3 Falloff;



struct VertexShaderOutput
{
    float4 Position : SV_POSITION;
    float4 color : COLOR0;
    float2 texCoord : TEXCOORD0;
};



float4 MainPS(VertexShaderOutput input) : COLOR0
{

    float4 DiffuseColor = tex2D(SpriteSampler, input.texCoord);
    float3 NormalMap = tex2D(NormalSampler, input.texCoord).rgb;
    float3 LightDir = float3(LightPos.xy - (input.texCoord.xy / Resolution.xy), LightPos.z);
    LightDir.x *= Resolution.x / Resolution.y;

    float D = length(LightDir);
    float3 N = normalize(NormalMap * 2.0 - 1.0);
    float3 L = normalize(LightDir);

    float3 Diffuse = (LightColor.rgb * LightColor.a) * max(dot(N, L), 0.0);
    float3 Ambient = AmbientColor.rgb * AmbientColor.a;
    float Attenuation = 1.0 / (Falloff.x + (Falloff.y*D) + (Falloff.z*D*D) );

    float3 Intensity = Ambient * Diffuse * Attenuation;
    float3 FinalColor = DiffuseColor.rgb * Intensity;

    

    return input.color * float4(FinalColor, DiffuseColor.a);

}

technique SpriteDrawing
{
    pass P0
    {
        PixelShader = compile PS_SHADERMODEL MainPS();
    }
};

And in game1:

 > protected override void LoadContent()
>         {
>             // Create a new SpriteBatch, which can be used to draw textures.
>             spriteBatch = new SpriteBatch(GraphicsDevice);
>             normalMap = Content.Load<Texture2D>("normalMap2");
>             textureMap = Content.Load<Texture2D>("textureMap2");
>             normalEffect = Content.Load<Effect>("normalEffect3");
>             lightColor = new Vector4(0.8f, 1f, 1f, 0);

>             AmbientColor = new Vector4(0.6f, 0.6f, 1f, 0.2f);
>             Falloff = new Vector3(.4f, 3f, 20f);
>             lightColor = new Vector4(1f, 1f, 1f, 1f);
>         }

> protected override void Update(GameTime gameTime)
>         {
>             if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
>                 Exit();

>             mouseState = Mouse.GetState();

>             float x = mouseState.X / (float)graphics.PreferredBackBufferWidth;
>             float y = mouseState.Y / (float)graphics.PreferredBackBufferHeight;

>             light = new Vector3(x, y, 0.075f);

>             base.Update(gameTime);
> }

>  protected override void Draw(GameTime gameTime)
>         {

>             GraphicsDevice.Clear(Color.Transparent);

>             spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.Opaque, null, null, null, normalEffect, null);

>             SetShaderValues();

>             spriteBatch.Draw(textureMap, Vector2.Zero, Color.White);

>             spriteBatch.End();


>             base.Draw(gameTime);
>         }

>         public void SetShaderValues()
>         {
>             Vector2 res = new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
>             normalEffect.Parameters["Resolution"].SetValue(res);
>             normalEffect.Parameters["LightPos"].SetValue(light);
>             normalEffect.Parameters["NormalTexture"].SetValue(normalMap);
>             normalEffect.Parameters["LightColor"].SetValue(lightColor);
>             normalEffect.Parameters["AmbientColor"].SetValue(AmbientColor);
>             normalEffect.Parameters["Falloff"].SetValue(Falloff);
>             normalEffect.Parameters["SpriteTexture"].SetValue(textureMap);
>             normalEffect.CurrentTechnique.Passes[0].Apply();
>         }

A push in the right direction would be appreciated!

Posts: 4

Participants: 3

Read full topic

Read text files

$
0
0

@bunnyboonet wrote:

Hi,
I'm trying to read text files by

var filePath = Path.Combine(Content.RootDirectory, "score.txt");
using (var stream = TitleContainer.OpenStream(filePath))
{
text = File.ReadAllText(filePath);
}

In the content pipeline i set build action to 'Copy'. When run the code it says Could not find a part of the path "/Content/score.txt".

thanks
lasa

Posts: 4

Participants: 3

Read full topic

[General Cleanup] Where to place collision code

$
0
0

@Oyyou wrote:

Hello, I'm trying to make my code as clean as possible, but I'm having a bit of an issue trying to decide where I want my collision detection code. At the moment I have my code in a "PostUpdate" method in the main class:

  foreach (var leftSprite in _sprites)
  {

    foreach (var rightSprite in _sprites)
    {

      // Don't do anything if they're the same sprite!
      if (leftSprite == rightSprite)
        continue;

      // Don't do anything if they're not colliding
      if (!leftSprite.Rectangle.Intersects(rightSprite.Rectangle))
        continue;

      if (leftSprite is Bullet)
      {
        if (leftSprite.Parent == rightSprite)
          continue;

        if (leftSprite.Parent is Player && rightSprite is Enemy)
        {
          leftSprite.IsRemoved = true;

          var enemy = rightSprite as Enemy;

          enemy.Health--;

          if (enemy.Health <= 0)
            enemy.IsRemoved = true;
        }

        if (leftSprite.Parent is Enemy && rightSprite is Player)
        {
          leftSprite.IsRemoved = true;

          var player = rightSprite as Player;

          player.Health--;

          if (player.Health <= 0)
            player.IsRemoved = true;
        }
      }

      if (leftSprite is Player && rightSprite is Enemy)
      {
        var player = leftSprite as Player;
        var enemy = rightSprite as Enemy;

        player.Health--;

        if (player.Health <= 0)
          player.IsRemoved = true;

        enemy.Health--;

        if (enemy.Health <= 0)
          enemy.IsRemoved = true;
      }

      if (leftSprite is Enemy && rightSprite is Player)
      {
        var player = rightSprite as Player;
        var enemy = leftSprite as Enemy;

        player.Health--;

        if (player.Health <= 0)
          player.IsRemoved = true;

        enemy.Health--;

        if (enemy.Health <= 0)
          enemy.IsRemoved = true;
      }
    }
  }

The general gist is I loop around all my sprites twice. If they collide, then do something depending on the types of the sprites.

I have a feeling I'm going about it completely wrong.

Could I get some advice on how I could clean this up?

Cheers!

Posts: 1

Participants: 1

Read full topic

New to shaders....

$
0
0

@EnemyArea wrote:

Hello,

I had a question. Which shader model should be currently used?
There are vs_4_0_level_9_0 and vs_4_0_level_9_1 ...
But most of the tutorials I found related to vs_1_1 or vs_3
I also read that there is a new syntax or new commands (a main method?) Is there somewhere a good DX9 to DX11 migration guide? (Or a good starter guide? Nothing good has been found on google yet :()

Posts: 1

Participants: 1

Read full topic


How to support as many joysticks as possible?

$
0
0

@Jesuszilla wrote:

Hello! I’m currently developing a fighting game using MonoGame as the base for my engine.

My question is simple: how can I support as many different types of joysticks as possible? Arcade sticks in particular have numerous amounts of boards you can use to create your stick, including the PS360+, which I use.

However, I notice I have to plug it in as 360 mode to get it to recognize. I also have an 8bitdo that I also have to plug in as XInput mode in order for it to recognize.

Is there some other library or class I should/can be using in order to have support for more devices, including Bluetooth controllers such as 8bitdo and PS4? I intend to support Windows 10, Linux, and macOS.

Posts: 4

Participants: 2

Read full topic

[Tool] I tried to develop an editor for MonoGame!

$
0
0

@ClEngine wrote:

I am very excited because I started to develop an editor for MonoGame that will have exciting features like code editor, resource manager, UI editor, map editor, particle editor and a full editor help documentation. .

I am also particularly grateful to the author of MonoGame.Extended, my editor uses his map and particle library.



The editor is still in production. The script was created using Lua. I hope everyone can support

Because I am a new user, I can only pass some pictures

Posts: 1

Participants: 1

Read full topic

Maze Frenzy - free mobile action puzzler built with MonoGame

$
0
0

@kylechu wrote:

After a lot of false starts and ideas that didn't pan out, I've finally released my first game built with MonoGame to the Play and App store! It's an endless runner in a maze that combines fast-paced swiping action with maze-solving puzzle elements.

Android Download

iOS Download

Gameplay Clip


Screenshots:


MonoGame and C# have been a joy to work with and I'm really happy with how everything turned out. Please let me know what you think of the game, or if you have any questions about its development!

Posts: 3

Participants: 3

Read full topic

Background image size

$
0
0

@bunnyboonet wrote:

Hi, I created background image using export to screens for android in AI. But i have no idea how to use this in monogame android project. I set a background image, but not fit to whole screen. I use landscape orientation.
Anyone know how to do this? thanks.

Posts: 1

Participants: 1

Read full topic

Android games made with monogame ?

$
0
0

@AgravKire wrote:

I'd like to learn monogame, I know there are really awesome games made with it. But i wonder why I cannot google any android games made with monogame... only found like 1 github repo for android game called The Witness.

Posts: 2

Participants: 2

Read full topic

Viewing all 6821 articles
Browse latest View live