Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

108 Neutral

About CSharpCoder

  • Rank

Personal Information

  • Role
  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I have written the following pixel shader for point lighting in a 2D platformer. A normal map and a specularity map is generated using Sprite DLight. colorMap is the original sprite, normalMap.rgb is the normal and normalMap.a is the specularity from the specularity map. lightPosition has a z coordinate to position it further away from the scene. Is this correct for 2D specular lighting? float4 PointLightShader(VertexToPixel PSIn) : COLOR0 { float4 colorMap = tex2D(ColorMapSampler, PSIn.TexCoord); clip(colorMap.a - 0.001); float3 pixelPosition = float3(PSIn.WorldPos, 0); float3 lightDirection = lightPosition - pixelPosition; float coneAttenuation = saturate(1.0f - length(lightDirection) / lightDecay); float4 normalColor = tex2D(NormalMapSampler, PSIn.TexCoord); float3 normal = normalColor.rgb; float3 normalTangent = (2.0f * normal) - 1.0f; float3 lightDirNorm = normalize(lightDirection); float3 halfVec = float3(0, 0, 1); float amount = max(dot(normalTangent, lightDirNorm), 0); float3 reflect = normalize(2 * amount * normalTangent - lightDirNorm); float specular = min(pow(saturate(dot(reflect, halfVec)), 10), amount); return (colorMap * coneAttenuation * lightColor * lightStrength) + (colorMap * specular * coneAttenuation * normalColor.a); }
  2. The first one. 1 / 65535 becomes 0.98 for example. I'm using it as a bitfield and I'm using additive blending so it really adds up.
  3. I'm experiencing large floating point precision errors during the conversion between 0-1 floats and 0-65535 integers. I'm using RGBA64 format for a texture. In Shader Model 3.0 is it possible to output int4 or something instead of float4 from pixel shader? This question is a bit similar to this:
  4. InterlockedOr requires shader model 4.0, don't know what you mean by texture UAV. Although I found a perfect solution for my specific case. I can just use additive blending among the shadows being drawn in the same batch because they are all created by different lights, which will create the same result as using bitwise OR 1 + 2 = 1 | 2 = 3, however if the bit is already set 2 + 2 ≠ 2 | 2 = 2 It will still need to sample the shadows from other characters and check if the bit is already set, if that's the case it should return 0 (add 0), otherwise, return light bit for the shadow.
  5. CSharpCoder

    HLSL - Additive blending

    You need to set a BlendState for this, the following code adds the two colors together and calculates alpha as source * 1 + destination * 0, the result will of course be source. BlendState additiveColorBlendState = new BlendState { ColorBlendFunction = BlendFunction.Add, ColorSourceBlend = Blend.One, ColorDestinationBlend = Blend.One, AlphaSourceBlend = Blend.One, AlphaDestinationBlend = Blend.Zero, AlphaBlendFunction = BlendFunction.Add };
  6. I have the following HLSL technique. I want to do additive blending on RGB (color) only, not alpha. The alpha should just override the underlying alpha. This also does additive blending on alpha. How do I modify it to only do additive blending on RGB? technique AdditiveTest { pass Pass1 { AlphaBlendEnable = FALSE; VertexShader = compile vs_3_0 AdditiveVertexShader(); PixelShader = compile ps_3_0 AdditivePixelShader(); SrcBlend = ONE; DestBlend = ONE; } }
  7. I could use additive blending. How do I set blending to additive blending color only (no alpha blending) for a technique in HLSL?
  8. In MonoGame I'm writing a shader for lighting and shadows in a 2D Platformer. A shadow will be drawn for each character for each light that hits said character. Because shadows from different lights can overlap the shadows are drawn to a texture where each pixel is a bitfield where each bit tells you if the pixel was reflected by a given light. In the lighting shader for each light, it only applies light if the bit for that light is not set at the given pixel. In order to not make for example 40 draw calls to draw 40 shadows if 40 lights overlapped a character, I batch shadows together into a VertexBuffer with the data specifying which light created the given shadow. In the shadow shader, it samples the render target I am drawing the shadows to and sets its own bit. My problem is that the changes from the previous shadows in the same batch aren't applied to the render target until after the draw call has completed. This results in the bitfield getting overwritten by shadows from other lights. If I could somehow sample the back buffer this wouldn't be a problem. Is there any way I can fix this without making a draw call for each shadow?
  9. Hello, I am a lone programmer looking for a pixel artist for a 2D action RPG (more like some RPG elements) inspired by games like Dark Souls (but still with original ideas and game mechanics). The game will revolve around an engaging combat-system, environmental story telling, a few characters who in turn has great depth and personality (they will have personal goals that are more important to them than their usefulness to the player). I haven't decided on the rest as I want us to design the game together. In this project, you will play as much a role in decision-making as I will and you will receive 50% of any potential profits. I was thinking of making a Kickstarter, but that depends on your opinion and financial situation. Now, I cannot stress this point enough, we will be partners. I'm not just looking for someone to do what I tell them, I want your opinion ideas and I want to have discussions about the game. All I have right now is the concept and my engine and skill set. The setting, story, and lore of the game are still to be decided as well as a ton more. I do have an idea for a game mechanic, which involves a handful of weapons to change between instantly much like in an FPS you change between weapons with the 0-9 digits on your keyboard. These weapons can be combined to defeat enemies and unlock different parts of the game. But that's just a possible idea, it depends on your opinion. I have made an engine for this game on top of the MonoGame framework using the programming language C# that I have a lot of experience with. I have also created a small example level of what we could make with the engine using art from the game "Chasm". We can easily place tiles and colliders using the tile map editor "Tiled" The Tiled files will be imported to Unity where you can place enemies as well as backgrounds, objects and generally sprites not limited to a tile size (I'm pretty sure Unity also allows import of photoshop files). When saving the scene it will produce a small .level file containing only the data we need from the Unity scene (I have complete control of the content of these files). These files can be placed in the MonoGame folder to allow the game to load them and use them. As for animations, I have made an animation editor for Unity that allows you to select a sprite, a delay until next frame, and colliders for each frame. When saving the scene all animations will be saved to a single .anim file that can be placed in the MonoGame folder to allow the game to read the animations. Don't worry if this all seems overwhelming, I will explain in further detail and guide you through it if you decide to partner up with me. If you want to focus mainly on the pixel art that's fine too. Generally, I understand that you need to eat and since you won't get paid at least until a potential Kickstarter I realize you probably have a job, or school to think of besides this just like me, so I don't expect you to work full time, or even as much as I do. Later on, I can even make tools for you if you have any requests. We will share the animation editor and level editor over Unity collaboration and communicate over Slack unless you have any other preference. Although I do prefer communication in text form since it allows me to express myself concisely, not have to think about my surroundings, think about what I will reply and read previous conversations. Now as promised from the title here is the demonstration of the engine and results of the tools as well as a demonstration of my capabilities. I do not own any of the art and nothing is final in terms of gameplay and the art will not appear in the final product of course. You only have one attack in the demo and I have disabled the stamina system since I'm not sure if we should have that in the game. The enemies are too aggressive since they have no attack cooldown they keep swiping at you (not really an example of the engaging combat-system I was talking about, would be nice with some more moves for both the player and enemies). The cave troll has an exploit where you can just stand inside of it and it can't hit you, this problem which is mainly for large enemies could be solved by extending the attack collider, or adding some kind of AOE attack when the player gets too close like a slam attack. Also, the cave troll has no walking animation. The UI is really barebone and really just placeholder, but it gets the job done. You can open up the menu with "Escape" or "Start" on the controller and set stuff like keybindings and even sound effect and music volume (even though there is no sound or music yet). We are going to need a sound designer in the near future. You can reload the level with the "R" key on the keyboard. You can fall through platforms by jumping while crouching. You can push the explosive crates around and drop them on enemies for massive damage. They also explode when hit with a weapon. The red lines are the colliders, the gray lines are the colliders bounding boxes. I have attached the demo to this post, but the demo can also be downloaded here: The idea was to get this game through Steam Direct and sell it for something like 10$. I will, of course, pay the fee for entry. This isn't a get rich quick scheme, I just want to create a game that I can be proud of and would play myself and it will require the same kind of hard work that I have done to get here in the first place. I will not give up as long as there is hope for the project. If this peaked your interest and/or you have any questions you can contact me on my email: Thank you for reading this
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!