Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Recoil

Pages: 1 [2] 3 4 ... 6
16
DotNet / Re: [Solved-ish] Layer lighting help
« on: June 17, 2019, 02:11:24 pm »
On both of the previous examples I am drawing both the .png and triangle fan onto the black overlay with BlendMode.Add, and then displaying the black overlay with BlendMode.Multiply.

The .png image is just a Gaussian blurred white circle made in Photoshop with transparent background, but it also works if the background is black with the same effect

The center point of the triangle fan is white, and the outer points of the 360 degree fan are black.  I have yet to even try to get shaders working on this thing, I am completely lost in that regard.

17
DotNet / Re: [Solved] Layer lighting help
« on: June 16, 2019, 03:32:16 pm »
Can someone  help me understand what may be going wrong with this?

The first image attached (Test4) is using a Gaussian blurred white circle created in Photoshop.  This is a really nice lighting effect.

The second image (Test5) is drawing a radial gradient with a 45 point triangle fan in code for the lights.  My issue with this one is the veining effect when the edges of lights intersect - the edge should not be darker than the area it is going into.

I'm hoping to add more dynamic lighting for my engine without using images.  To be able to set size, intensity, color, etc for each light source independently from the rest.  I'm not entirely sure what would cause the effect I am getting in the second method to display the way it does.

18
DotNet / Re: Layer lighting help
« on: June 15, 2019, 04:37:37 am »
Just in case anyone else finds this in the searches...

Solution here

So I was making a new Render Texture every draw frame just in case the window was resized.  I moved my new call when I initialize everything at program startup.  I set a boolean (RedrawNightTexture) to get checked in my drawing loop each iteration.  I set the boolean to true if the form was Maximized/Minimized/Resized/SizeChanged events...not sure if I need all those.

When I set the boolean to True on RedrawNightTexture, I dispose of the old RenderTexture before calling a new one.  No clue if this is even needed, but why not.  My memory leak stopped, and my FPS gets up to ~160 at normal size, and ~110 when it is maximized.  So I believe my problem, and the problems of fixing those problems, have all been resolved.

A side note - I had to change the size of the RenderTexture  tor the main forms GameScreen picturebox that my game is being drawn to, instead of the RenderWindow.  For some reason without that I was only able to get the texture drawn to the proper size when I would drag-resize the form down from a larger size.  Not sure if that info is even needed, but it may help someone else  ;)

19
DotNet / Re: Layer lighting help
« on: June 14, 2019, 10:51:29 pm »
So I have some success fixing this.  I am having to call RenderTexture.Display(), which fixed the inversion issue (for some reason).  However, I could not draw the Render Texture directly to the Render Window, so I had to create a new Sprite and draw the RenderTexture.Texture to that, then draw the Sprite to the Render Window.

I know, complicated, but halfway working...

That is until I started noticing my FPS dropped from ~120 to ~16.  Then things became very sluggish after a few minutes, and I noticed my game was increasing 1mb of memory every few seconds.

So, here is my current process on the light code (pseudo code):

Draw a new RenderTexture.
Clear the RenderTexture.
Loop through each tile for a light source.
When it finds one it creates a new Sprite of the light image.
Draws the RenderTexture.Draw(Sprite, New RenderStates(BlendMode.Add))
Disposes of that Sprite before continuing on to the next light source.

RenderTexture.Display()
Create new Sprite of Overlay.Texture
Sprite.Draw(RenderWindow, New RenderStates(BlendMode.Multiply))
RenderTexture.Dispose
Sprite.Dispose
 

Even removing the lights altogether and just drawing the render texture over the screen drops the FPS and causes the memory leaks.  Bypassing the light code jumps my FPS back up to 120 and there is no leak in memory.  This is the first time I have run into memory leak issues so I am lost on how to track them down since I am disposing of everything after it is used.

20
DotNet / Re: Layer lighting help
« on: June 14, 2019, 04:03:38 pm »
Thanks for your help Laurent.  No joke, when I initially tried messing with the lighting I attempted to do just that: clear a Render Texture with black -> draw light spots to the Render Texture -> draw the Render Texture to the game screen with multiply blend.  Previously I had issues with the whole screen just being black, so I settled on drawing the way I was with Alpha/Add.

But I tried it again, and it worked!  Well, to an extent.  Drawing the previous way the lights show where they are supposed to, and stay where they are supposed to.  Drawing the new way achieves the visual results I was wanting (thanks) but now the lights are off for some reason, and when I move the player down the lights move down, but not going left to right.

It's been a minute since I have worked on the engine, so it gives me something to tinker with for now.  I really appreciate the help though!

21
DotNet / [Re-Solved] Layer lighting help
« on: June 13, 2019, 10:09:47 pm »
I'm revisiting my lighting code for my engine so it has a much better working effect.  All of the examples I have come across say to use a lightmap over the screen and set the blend mode to multiply.  I have tried using different "lightmaps" to see if mixing with the blending options helps but so far none of them seem to work correctly.  To save time I will omit the testing results that I have got using each one.

I had some initial success drawing a black png image over the whole screen and setting the blend mode to alpha, then for each light instance drawing a smaller blurred light image with transparent background, and the blend mode set to add on top of the black layer.  However, that isn't really providing the type of lighting effect I see done with other engines, so it's back to the drawing board and here to see if someone can help me with the logic behind my code.

This is the order I am drawing my layers to the render window:
Lower tiles
Player
NPC's
Upper tiles
Night layer (alpha blend)
Light layer (add blend)
UI

I am attaching the current light image I am using as well as the result using approx. 86% opacity.  When I set the opacity to 100% the black is fully black, and the lights are blurred fully white and I am unable to see underneath.  My goal is to be able to increase the black to 100% to hide objects outside of the light sources, while being able to see the characters and map under the lights.

If it will help I can add the list of results I have gotten using different lighting images and blending modes.

22
DotNet / Re: [VB.NET] Mouse events for custom drawn gfx controls.
« on: June 10, 2016, 10:48:26 pm »
When I do the steps in the order on my previous post, RaiseEvent is not even needed.  I am just passing the command through to the method of the button's instance.  This is how I have been doing it.  This is just very tedious to setup each control in this manner.

However, this is also where I have been having issues with the events not firing correctly, and when the mouse leaves a control to quickly it will remain highlighted.  So then I have to setup a bunch of additional checks to toggle the boolean values for all the controls mouse methods.

For clarification: TGUI for C#

While I had a lot of issues trying to use TGUI, his library has the functionality that I am referring to.  When you create an instance of a control, there is not sending pointers through to them, they just work.  No tedious setup required.

I have tried porting his project to VB to make better sense of it, but I cannot inherit in a class twice like is done in C#.  It has been a couple months since I have tried, so I cannot remember all the reasons that I had issues porting that library.  That being said, there are several things being done that I have never run across reading C# code, and will also not convert properly.

So that is where I am at in a nutshell.  This project has had a lot of thought into how it is "supposed" to work, but due to my lack of development experience, I have been lost on making it work properly.  The whole point of this thread wasn't to get code to fix it, but to get some ideas if what I am looking up have the ability to provide the correct functionality.  I'm just lost on what is the "correct" way  ;)

Edit: I messaged the dev for TGUI and got a different perspective on how I can go about achieving what I have been attempting to do with my current setup.  Hopefully once I get this thing somewhat working, I can post it so it may help others who want to use it.

23
DotNet / Re: [VB.NET] Mouse events for custom drawn gfx controls.
« on: June 10, 2016, 10:18:22 pm »
I'm either really confused, or already doing that I believe:

    Private Sub _mRenderWindow_MouseMoved(sender As Object, e As MouseMoveEventArgs) Handles _mRenderWindow.MouseMoved

        If TestButton.ButtonControlBounds.Contains(e.X, e.Y) Then

            TestButton.ButtonMouseMove(sender, e)

        End If

    End Sub
 

That will already call to set the boolean value here in the actual control:
    Public Sub ButtonMouseMove(sender As Object, e As MouseMoveEventArgs)
       
        If Not Visible And Not Enabled Then Exit Sub

        If MouseDown = False Then

            MouseHover = True

        Else

            MouseHover = False

        End If

    End Sub
 

Then when it draws the button, if True, will draw the highlight as well.

Is this what you are talking about?

24
Audio / Re: Capturing audio from headphones
« on: June 10, 2016, 08:07:49 pm »
As an aside, technically, you can use headphones as a microphone.

I bet I am the only one who is going to be plugging in their headphones into the mic jack and trying to talk into the ear pieces  :o

LOL

25
DotNet / Re: [VB.NET] Mouse events for custom drawn gfx controls.
« on: June 10, 2016, 07:26:35 pm »
Thanks Laurent, that does clarify things quite a bit.  I did not think I needed to "AddHandler" in the class itself.  So I removed that from my Sub New() in my button class.

What you should do is write a HandleMouseMove function, which will be called by the GUI (or parent control, or whatever). This function will change the internal state of the button, and finally raise the MouseMove event for anyone interested in it.

Are you referring to writing a function in the button's class itself, or in the GUI?  If it is in the GUI I believe that was what I am doing now, checking the mouse position in the RenderWindow.MouseMove event then changing the state of the button that way.

26
DotNet / Re: [VB.NET] Mouse events for custom drawn gfx controls.
« on: June 10, 2016, 06:16:55 pm »
Here is the general idea of how my button class is setup with the handlers:
Public Class MyButton

    Public Event MouseMove(sender As Object, e As MouseMoveEventArgs)

    Public MouseHover As Boolean

    Public MouseDown As Boolean


    Public Sub New()

        AddHandler MouseMove, AddressOf ButtonMouseMove

    End Sub


    Public Sub ButtonMouseMove(sender As Object, e As MouseMoveEventArgs) Handles Me.MouseMove

        RaiseEvent MouseMove(sender, e)

        If Not Visible And Not Enabled Then Exit Sub

        If MouseDown = False Then

            MouseHover = True

        Else

            MouseHover = False

        End If

    End Sub


    Public Sub DrawButton(ByVal target As RenderWindow)

        ' Draw base button image here...

        Dim _rectHighlight As New RectangleShape

        If MouseHover = True Then

            ' Set the hover image

        ElseIf MouseDown = True Then

            ' Set the down image

        End If

        target.Draw(_rectHighlight)

    End Sub
 

Currently the way I have to handle this:

RenderWindow mouse move event: Check if the location of the mouse is in the bounds of the button, then set the Button.MouseHover = True

Something tells me my logic for this is wrong.  One button instance doesn't take that much code.  However, going this way and I want to use a scrollbar, I have to send the mouse location through to that control which is then checking the location of the mouse in relation to it's controls and if it is on one of it's buttons then turn on/off the highlight image there.

The more complex the control, the more checks I have to go through, and the more tedious it is to setup.  I believe this is why it keeps "missing" the mouse leave events, which cause the button to stay highlighted.


27
DotNet / Re: [VB.NET] Mouse events for custom drawn gfx controls.
« on: June 10, 2016, 04:48:08 pm »
Ok, I see. And where exactly is your problem in implementing this stuff for your controls?

I have tried implementing event handlers and they would never work.  I have never worked with callback functions, but tried to implement those for this purpose, and they would not work either.

So first, I want to make sure one of those is the appropriate method I must do to make this work, and I am not blindly looking over the "proper" way to implement this functionality.  I have had this issue for about a month now, and am afraid I am going to waste more time when it will not work at all the ways I have been trying.

Once I am certain I am trying to go about this the proper way I can reevaluate what I am currently trying to do and see how it is wrong.

28
DotNet / Re: [VB.NET] Mouse events for custom drawn gfx controls.
« on: June 10, 2016, 04:10:40 pm »
Thanks.  I guess I am explaining the problem right in my mind, or I am probably using the wrong terminology LOL!

Here are a few articles that explain what I am talking about, with examples in C++/C#/VB:
MSDN: Implement Callback Functions
MSDN: EventHandler Delegate

To be honest, I am not even sure those are what I am looking for because I have not been able to get them to work for this purpose.

When I make a new instance of my control in code I want to figure out how to have it perform like a traditional control - mouse hover or mouse clicked automatically works on the control, so it will change it's image.

Other controls that use a button, such as the scrollbar, will be able to click and fire the event to move the thumb button.

When I move the mouse over the render window, and I hover over a button, it will change a boolean MouseIsOver so when an application call the buttons draw method of the control it displays the proper image.

Because this is a predominant C++ forum I have not uploaded a test project with my control library project because I did not believe it would be of any use because it is in VB.  If it will help I will upload it.


Note: I am working on a few beginner tutorials in VB.NET to post at a programming forum so new programmers will get to know more about SFML and how to use it.

29
SFML projects / Re: Rage - a coop dungeon crawler
« on: June 10, 2016, 03:46:30 am »
This looks like it would be fun.  I like how the progress looks so far ;)

30
SFML projects / Re: Screenshot Thread
« on: June 10, 2016, 03:43:40 am »
That looks great!  ;D

Pages: 1 [2] 3 4 ... 6
anything